This commit is contained in:
Phillip Thelen 2018-11-07 15:17:25 +01:00
parent d10bedd990
commit d298c62fc1
13 changed files with 276 additions and 188 deletions

View file

@ -63,6 +63,7 @@ GEM
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3)
fastlane-plugin-increment_version_code (0.4.3)
fastlane-plugin-versioning_android (0.1.0)
gh_inspector (1.1.3)
google-api-client (0.23.9)
addressable (~> 2.5, >= 2.5.1)
@ -145,6 +146,7 @@ PLATFORMS
DEPENDENCIES
fastlane
fastlane-plugin-increment_version_code
fastlane-plugin-versioning_android
BUNDLED WITH
1.16.4

View file

@ -91,7 +91,7 @@ dependencies {
implementation 'io.reactivex.rxjava2:rxjava:2.2.2'
//Analytics
implementation 'com.amplitude:android-sdk:2.18.1'
implementation 'com.instabug.library:instabug:8.0.3'
implementation 'com.instabug.library:instabug:8.0.11'
// Fresco Image Management Library
implementation('com.facebook.fresco:fresco:1.11.0') {
exclude module: 'bolts-android'
@ -145,7 +145,7 @@ android {
buildConfigField "String", "STORE", "\"google\""
multiDexEnabled true
versionCode 2016
versionCode 2021
versionName "1.6"
}

View file

@ -1,11 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="@color/brand_300" >
</solid>
<corners
android:radius="8dp" >
</corners>
</shape>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape android:shape="rectangle">
<solid
android:color="@color/brand_500" >
</solid>
<corners
android:radius="8dp">
</corners>
</shape>
</item>
<item android:state_focused="true" >
<shape android:shape="rectangle">
<solid
android:color="@color/brand_400">
</solid>
<corners
android:radius="8dp">
</corners>
</shape>
</item>
<item android:state_enabled="false">
<shape android:shape="rectangle">
<solid
android:color="@color/gray_200">
</solid>
<corners
android:radius="8dp">
</corners>
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid
android:color="@color/brand_300">
</solid>
<corners
android:radius="8dp">
</corners>
</shape>
</item>
</selector>

View file

@ -2,162 +2,165 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
xmlns:tools="http://schemas.android.com/tools">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="98dp"
android:scaleType="center"
android:src="@drawable/hello_sign"
android:layout_marginTop="@dimen/spacing_large"
android:layout_marginBottom="@dimen/spacing_large"/>
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/spacing_large"
android:background="@color/white"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/brand_200"
android:text="@string/usernamePromptTitle"
android:gravity="center"
android:textSize="16sp"
android:textStyle="bold"
android:layout_marginBottom="@dimen/spacing_large"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/gray_100"
android:text="@string/usernamePromptBody"
android:gravity="center"
android:textSize="14sp"
android:layout_marginBottom="@dimen/spacing_medium"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/gray_100"
android:text="@string/usernamePromptWiki"
android:gravity="center"
android:textSize="14sp"
android:layout_marginBottom="@dimen/spacing_large"/>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="2"
android:background="@drawable/rounded_border">
<TableRow>
<TextView
android:layout_height="42dp"
android:text="@string/display_name"
android:paddingLeft="@dimen/spacing_medium"
android:paddingRight="@dimen/spacing_medium"
android:layout_marginLeft="1dp"
android:background="@color/gray_700"
android:gravity="center_vertical"
/>
<View android:background="@color/gray_600"
android:layout_height="42dp"
android:layout_width="1dp" />
<EditText android:id="@+id/display_name_edit_text"
android:background="@color/transparent"
android:layout_height="42dp"
android:layout_marginLeft="@dimen/spacing_large"
android:layout_marginRight="@dimen/spacing_large"
android:lines="1"/>
</TableRow>
<TableRow>
<View android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/gray_600" android:layout_span="3" />
</TableRow>
<TableRow>
<TextView android:text="@string/username"
android:background="@color/gray_700"
android:layout_height="41dp"
android:paddingLeft="@dimen/spacing_medium"
android:paddingRight="@dimen/spacing_medium"
android:layout_marginLeft="1dp"
android:gravity="center_vertical"/>
<View android:background="@color/gray_600"
android:layout_width="1dp"
android:layout_height="42dp"/>
<LinearLayout
android:layout_marginLeft="@dimen/spacing_large"
android:layout_marginRight="@dimen/spacing_large">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@"
android:gravity="center_vertical"
android:textColor="@color/gray_400"/>
<EditText android:id="@+id/username_edit_text"
android:background="@color/transparent"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="42dp"
android:layout_marginLeft="@dimen/spacing_small"
android:lines="1"/>
</LinearLayout>
</TableRow>
</TableLayout>
<TextView
android:id="@+id/issues_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_medium"
android:textColor="@color/red_50"
android:textSize="12sp"
android:gravity="center"
android:visibility="gone"
tools:visibility="visible"
tools:text="Issues go here"/>
<Button
android:id="@+id/confirm_username_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/purchase_button_background"
android:textColor="@color/white"
android:text="@string/confirm_username"
android:layout_marginTop="@dimen/spacing_large"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/verification_pet"
android:gravity="center"
android:layout_marginTop="@dimen/spacing_large"
android:layout_marginBottom="@dimen/spacing_medium"
android:layout_marginLeft="@dimen/spacing_large"
android:layout_marginRight="@dimen/spacing_large"
android:textSize="12sp"
android:textColor="@color/gray_200"/>
<ImageView
android:layout_width="121dp"
android:layout_height="31dp"
android:layout_gravity="center_horizontal"
android:src="@drawable/veteranpets2018_promo"/>
android:layout_width="match_parent"
android:layout_height="98dp"
android:scaleType="center"
android:src="@drawable/hello_sign"
android:layout_marginTop="@dimen/spacing_large"
android:layout_marginBottom="@dimen/spacing_large"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/spacing_large"
android:background="@color/white"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/brand_200"
android:text="@string/usernamePromptTitle"
android:gravity="center"
android:textSize="16sp"
android:textStyle="bold"
android:layout_marginBottom="@dimen/spacing_large"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/gray_100"
android:text="@string/usernamePromptBody"
android:gravity="center"
android:textSize="14sp"
android:layout_marginBottom="@dimen/spacing_medium"/>
<TextView
android:id="@+id/wiki_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/gray_100"
android:text="@string/usernamePromptWiki"
android:gravity="center"
android:textSize="14sp"
android:layout_marginBottom="@dimen/spacing_large"/>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="2"
android:background="@drawable/rounded_border">
<TableRow>
<TextView
android:layout_height="42dp"
android:text="@string/display_name"
android:paddingLeft="@dimen/spacing_medium"
android:paddingRight="@dimen/spacing_medium"
android:layout_marginLeft="1dp"
android:background="@color/gray_700"
android:gravity="center_vertical"
/>
<View android:background="@color/gray_600"
android:layout_height="42dp"
android:layout_width="1dp" />
<EditText android:id="@+id/display_name_edit_text"
android:background="@color/transparent"
android:layout_height="42dp"
android:layout_marginLeft="@dimen/spacing_large"
android:layout_marginRight="@dimen/spacing_large"
android:lines="1"/>
</TableRow>
<TableRow>
<View android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/gray_600" android:layout_span="3" />
</TableRow>
<TableRow>
<TextView android:text="@string/username"
android:background="@color/gray_700"
android:layout_height="41dp"
android:paddingLeft="@dimen/spacing_medium"
android:paddingRight="@dimen/spacing_medium"
android:layout_marginLeft="1dp"
android:gravity="center_vertical"/>
<View android:background="@color/gray_600"
android:layout_width="1dp"
android:layout_height="42dp"/>
<LinearLayout
android:layout_marginLeft="@dimen/spacing_large"
android:layout_marginRight="@dimen/spacing_large">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@"
android:gravity="center_vertical"
android:textColor="@color/gray_400"/>
<EditText android:id="@+id/username_edit_text"
android:background="@color/transparent"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="42dp"
android:layout_marginLeft="@dimen/spacing_small"
android:lines="1"/>
</LinearLayout>
</TableRow>
</TableLayout>
<TextView
android:id="@+id/issues_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_medium"
android:textColor="@color/red_50"
android:textSize="12sp"
android:gravity="center"
android:visibility="gone"
tools:visibility="visible"
tools:text="Issues go here"/>
<Button
android:id="@+id/confirm_username_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/purchase_button_background"
android:textColor="@color/white"
android:text="@string/confirm_username"
android:layout_marginTop="@dimen/spacing_large"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/verification_pet"
android:gravity="center"
android:layout_marginTop="@dimen/spacing_large"
android:layout_marginBottom="@dimen/spacing_medium"
android:layout_marginLeft="@dimen/spacing_large"
android:layout_marginRight="@dimen/spacing_large"
android:textSize="12sp"
android:textColor="@color/gray_200"/>
<ImageView
android:layout_width="121dp"
android:layout_height="31dp"
android:layout_gravity="center_horizontal"
android:src="@drawable/veteranpets2018_promo"/>
</LinearLayout>
<TextView
android:id="@+id/footer_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/spacing_large"
android:text="@string/usernamePromptDisclaimer"
android:gravity="center"
android:textSize="12sp"
android:textColor="@color/gray_300"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/spacing_large"
android:text="@string/usernamePromptDisclaimer"
android:gravity="center"
android:textSize="12sp"
android:textColor="@color/gray_300"/>
</LinearLayout>
</ScrollView>
</ScrollView>
<FrameLayout
android:id="@+id/snackbar_view"
android:layout_width="match_parent"

View file

@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/light_gray_bg"
android:background="@color/setup_background"
android:gravity="center_horizontal">
<Button

View file

@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/light_gray_bg"
android:background="@color/setup_background"
android:gravity="center_horizontal">
<ImageView

View file

@ -4,14 +4,14 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
android:fillViewport="true"
android:background="@color/setup_background">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/light_gray_bg"
android:paddingLeft="@dimen/spacing_medium"
android:paddingRight="@dimen/spacing_medium"
android:paddingLeft="@dimen/spacing_large"
android:paddingRight="@dimen/spacing_large"
android:paddingTop="32dp"
android:paddingBottom="16dp">
@ -45,8 +45,9 @@
android:paddingLeft="@dimen/spacing_medium"
android:paddingRight="@dimen/spacing_medium"
android:layout_marginLeft="1dp"
android:background="@color/gray_700"
android:background="@color/setup_label_background"
android:gravity="center_vertical"
android:textSize="14sp"
/>
<View android:background="@color/gray_600"
android:layout_height="42dp"
@ -56,6 +57,7 @@
android:layout_height="42dp"
android:layout_marginLeft="@dimen/spacing_large"
android:layout_marginRight="@dimen/spacing_large"
android:textSize="14sp"
android:lines="1"/>
</TableRow>
<TableRow>
@ -65,12 +67,13 @@
</TableRow>
<TableRow>
<TextView android:text="@string/username"
android:background="@color/gray_700"
android:background="@color/setup_label_background"
android:layout_height="41dp"
android:paddingLeft="@dimen/spacing_medium"
android:paddingRight="@dimen/spacing_medium"
android:layout_marginLeft="1dp"
android:gravity="center_vertical"/>
android:gravity="center_vertical"
android:textSize="14sp"/>
<View android:background="@color/gray_600"
android:layout_width="1dp"
android:layout_height="42dp"/>
@ -82,14 +85,16 @@
android:layout_height="match_parent"
android:text="@"
android:gravity="center_vertical"
android:textColor="@color/gray_400"/>
android:textColor="@color/gray_400"
android:textSize="14sp"/>
<EditText android:id="@+id/username_edit_text"
android:background="@color/transparent"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="42dp"
android:layout_marginLeft="@dimen/spacing_small"
android:lines="1"/>
android:lines="1"
android:textSize="14sp"/>
</LinearLayout>
</TableRow>
</TableLayout>

View file

@ -17,7 +17,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dip"
style="?android:attr/listSeparatorTextViewStyle"
style="@style/Body1"
android:textAllCaps="true"
android:textSize="12sp"
android:background="@color/transparent"
android:textColor="@color/gray_300"
android:paddingLeft="32dip"

View file

@ -16,7 +16,7 @@
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginBottom="6dip"
android:layout_marginLeft="15dip"
android:layout_marginLeft="16dip"
android:layout_marginRight="6dip"
android:layout_marginTop="6dip"
android:layout_weight="1" >

View file

@ -161,4 +161,6 @@
<color name="ic_launcher_background">#331960</color>
<color name="scrollbarThumb">@color/gray_500</color>
<color name="black">#000</color>
<color name="setup_background">#efeff4</color>
<color name="setup_label_background">#fafaff</color>
</resources>

View file

@ -6,6 +6,7 @@ import android.os.Bundle
import androidx.core.content.ContextCompat
import android.text.Editable
import android.text.TextWatcher
import android.text.method.LinkMovementMethod
import android.view.View
import android.view.ViewGroup
import android.widget.Button
@ -16,12 +17,15 @@ import com.habitrpg.android.habitica.components.AppComponent
import com.habitrpg.android.habitica.data.UserRepository
import com.habitrpg.android.habitica.extensions.runDelayed
import com.habitrpg.android.habitica.helpers.RxErrorHandler
import com.habitrpg.android.habitica.models.responses.VerifyUsernameResponse
import com.habitrpg.android.habitica.ui.helpers.bindView
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar
import io.reactivex.BackpressureStrategy
import io.reactivex.Completable
import io.reactivex.Flowable
import io.reactivex.Single
import io.reactivex.functions.BiFunction
import io.reactivex.functions.Consumer
import io.reactivex.subjects.PublishSubject
import java.util.concurrent.TimeUnit
@ -36,8 +40,11 @@ class VerifyUsernameActivity: BaseActivity() {
private val confirmUsernameButton: Button by bindView(R.id.confirm_username_button)
private val issuesTextView: TextView by bindView(R.id.issues_text_view)
private val snackbarView: ViewGroup by bindView(R.id.snackbar_view)
private val wikiTextView: TextView by bindView(R.id.wiki_text_view)
private val footerTextView: TextView by bindView(R.id.footer_text_view)
private val verificationEvents = PublishSubject.create<String>()
private val displayNameVerificationEvents = PublishSubject.create<String>()
private val usernameVerificationEvents = PublishSubject.create<String>()
private val checkmarkIcon: Drawable by lazy {
BitmapDrawable(resources, HabiticaIconsHelper.imageOfCheckmark(ContextCompat.getColor(this, R.color.green_50), 1f))
@ -57,13 +64,23 @@ class VerifyUsernameActivity: BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
compositeSubscription.add(userRepository.getUser().firstElement().subscribe {
displayNameEditText.setText(it.profile?.name)
usernameEditText.setText(it.authentication?.localAuthentication?.username)
})
wikiTextView.movementMethod = LinkMovementMethod.getInstance()
footerTextView.movementMethod = LinkMovementMethod.getInstance()
confirmUsernameButton.setOnClickListener { confirmNames() }
displayNameEditText.addTextChangedListener(object: TextWatcher {
override fun afterTextChanged(p0: Editable?) {
}
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
}
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
displayNameVerificationEvents.onNext(p0.toString())
}
})
usernameEditText.addTextChangedListener(object: TextWatcher {
override fun afterTextChanged(p0: Editable?) {
}
@ -72,14 +89,27 @@ class VerifyUsernameActivity: BaseActivity() {
}
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
verificationEvents.onNext(p0.toString())
usernameVerificationEvents.onNext(p0.toString())
}
})
compositeSubscription.add(verificationEvents.toFlowable(BackpressureStrategy.DROP)
compositeSubscription.add(Flowable.combineLatest(
displayNameVerificationEvents.toFlowable(BackpressureStrategy.DROP)
.map { it.length in 1..30 }
.doOnNext {
if (it) {
displayNameEditText.setCompoundDrawablesWithIntrinsicBounds(null, null, checkmarkIcon, null)
issuesTextView.visibility = View.GONE
} else {
displayNameEditText.setCompoundDrawablesWithIntrinsicBounds(null, null, alertIcon, null)
issuesTextView.visibility = View.VISIBLE
issuesTextView.text = getString(R.string.display_name_length_error)
}
},
usernameVerificationEvents.toFlowable(BackpressureStrategy.DROP)
.throttleLast(1, TimeUnit.SECONDS)
.flatMap { userRepository.verifyUsername(usernameEditText.text.toString()) }
.subscribe {
.doOnNext {
if (it.isUsable) {
usernameEditText.setCompoundDrawablesWithIntrinsicBounds(null, null, checkmarkIcon, null)
issuesTextView.visibility = View.GONE
@ -88,16 +118,25 @@ class VerifyUsernameActivity: BaseActivity() {
issuesTextView.visibility = View.VISIBLE
issuesTextView.text = it.issues.joinToString("\n")
}
confirmUsernameButton.isEnabled = it.isUsable
})
}, BiFunction<Boolean, VerifyUsernameResponse, Boolean> { displayNameUsable, usernameUsable -> displayNameUsable && usernameUsable.isUsable})
.subscribe(Consumer {
confirmUsernameButton.isEnabled = it
}, RxErrorHandler.handleEmptyError()))
compositeSubscription.add(userRepository.getUser().firstElement().subscribe {
displayNameEditText.setText(it.profile?.name)
displayNameVerificationEvents.onNext(it.profile?.name ?: "")
usernameEditText.setText(it.authentication?.localAuthentication?.username)
usernameVerificationEvents.onNext(it.username ?: "")
})
}
private fun confirmNames() {
confirmUsernameButton.isEnabled = false
confirmUsernameButton.isClickable = false
compositeSubscription.add(userRepository.updateUser(null, "profile.name", displayNameEditText.text.toString())
.flatMap { userRepository.updateLoginName(usernameEditText.text.toString()).toFlowable() }
.doOnComplete { showConfirmationAndFinish() }
.doOnEach { confirmUsernameButton.isEnabled = true }
.doOnEach { confirmUsernameButton.isClickable = true }
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError()))
}

View file

@ -26,7 +26,7 @@ object MarkdownParser {
private val processor = AndDown()
private val regex = Pattern.compile("@(?:\\w+)")
private val regex = Pattern.compile("(?!\\b)@[\\w-]+")
private val colorSpan = ForegroundColorSpan(Color.parseColor("#6133b4"))
/**

View file

@ -2,4 +2,4 @@
#
# Ensure this file is checked in to source control!
gem 'fastlane-plugin-increment_version_code'
gem 'fastlane-plugin-versioning_android'