Implement new welcome screen
1
.gitignore
vendored
|
|
@ -62,3 +62,4 @@ captures
|
|||
/Habitica/prod
|
||||
/Habitica/release
|
||||
/fastlane/secret-key.json
|
||||
/fastlane/report.xml
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.habitrpg.android.habitica"
|
||||
android:versionCode="1999"
|
||||
android:versionName="1.6"
|
||||
android:screenOrientation="portrait"
|
||||
android:installLocation="auto" >
|
||||
|
||||
|
|
@ -66,7 +64,7 @@
|
|||
</activity>
|
||||
<activity
|
||||
android:name=".ui.activities.SetupActivity"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize"
|
||||
android:screenOrientation="portrait">
|
||||
</activity>
|
||||
<activity
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ buildscript {
|
|||
}
|
||||
dependencies {
|
||||
classpath 'io.fabric.tools:gradle:1.25.4'
|
||||
classpath('com.noveogroup.android:check:1.2.3') {
|
||||
classpath('com.noveogroup.android:check:1.2.5') {
|
||||
exclude module: 'checkstyle'
|
||||
exclude module: 'pmd-java'
|
||||
}
|
||||
|
|
@ -128,17 +128,20 @@ dependencies {
|
|||
implementation 'com.nex3z:flow-layout:1.2.2'
|
||||
}
|
||||
|
||||
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
buildToolsVersion '28.0.3'
|
||||
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 15
|
||||
applicationId "com.habitrpg.android.habitica"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
buildConfigField "String", "STORE", "\"google\""
|
||||
multiDexEnabled true
|
||||
|
||||
versionCode 2004
|
||||
versionName "1.6"
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
|
|
|
|||
BIN
Habitica/res/drawable-hdpi/hello_onboarding.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
Habitica/res/drawable-hdpi/veteranpets2018_promo.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
Habitica/res/drawable-mdpi/hello_onboarding.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
Habitica/res/drawable-mdpi/veteranpets2018_promo.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
Habitica/res/drawable-xhdpi/hello_onboarding.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
Habitica/res/drawable-xhdpi/veteranpets2018_promo.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
Habitica/res/drawable-xxhdpi/hello_onboarding.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
Habitica/res/drawable-xxhdpi/veteranpets2018_promo.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
8
Habitica/res/drawable/rounded_border_white.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/white" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/gray_600"/>
|
||||
<corners android:radius="6dp" />
|
||||
</shape>
|
||||
|
|
@ -130,6 +130,23 @@
|
|||
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:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -1,61 +1,123 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/light_gray_bg"
|
||||
android:gravity="center_vertical">
|
||||
<RelativeLayout
|
||||
android:paddingLeft="@dimen/spacing_medium"
|
||||
android:paddingRight="@dimen/spacing_medium"
|
||||
android:paddingTop="32dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="294dp"
|
||||
android:layout_height="121dp"
|
||||
android:src="@drawable/hello_onboarding"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="@dimen/spacing_large"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageView
|
||||
android:id="@+id/exp_icon"
|
||||
android:layout_centerHorizontal="true"
|
||||
style="@style/welcome_floating_icon"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/brand_200"
|
||||
android:text="@string/welcomeNameTitle"
|
||||
android:gravity="center"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
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_white">
|
||||
<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"
|
||||
/>
|
||||
<ImageView
|
||||
android:id="@+id/heart_icon"
|
||||
style="@style/welcome_floating_icon"
|
||||
android:layout_toLeftOf="@id/exp_icon"
|
||||
android:layout_marginTop="35dp"
|
||||
android:layout_marginRight="8dp"/>
|
||||
<ImageView
|
||||
android:id="@+id/magic_icon"
|
||||
style="@style/welcome_floating_icon"
|
||||
android:layout_toRightOf="@id/exp_icon"
|
||||
android:layout_marginTop="35dp"
|
||||
android:layout_marginLeft="8dp"/>
|
||||
<ImageView
|
||||
android:id="@+id/gold_icon"
|
||||
style="@style/welcome_floating_icon"
|
||||
android:layout_below="@id/heart_icon"
|
||||
android:layout_toLeftOf="@id/exp_icon"
|
||||
android:layout_marginRight="33dp"
|
||||
android:layout_marginTop="8dp"
|
||||
/>
|
||||
<ImageView
|
||||
android:id="@+id/gem_icon"
|
||||
style="@style/welcome_floating_icon"
|
||||
android:layout_below="@id/magic_icon"
|
||||
android:layout_toRightOf="@id/exp_icon"
|
||||
android:layout_marginLeft="33dp"
|
||||
android:layout_marginTop="8dp"
|
||||
/>
|
||||
<ImageView
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="105dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_below="@id/exp_icon"
|
||||
android:src="@drawable/npc_justin_only"
|
||||
android:layout_marginTop="18dp"/>
|
||||
</RelativeLayout>
|
||||
<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"/>
|
||||
|
||||
<Space
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="@dimen/spacing_large"/>
|
||||
|
||||
<com.habitrpg.android.habitica.ui.SpeechBubbleView
|
||||
android:id="@+id/speech_bubble"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:namePlate="Justin"
|
||||
android:layout_marginLeft="@dimen/content_inset"
|
||||
android:layout_marginRight="@dimen/content_inset"/>
|
||||
app:npcDrawable="@drawable/justin_textbox"
|
||||
android:layout_marginTop="@dimen/spacing_large"/>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
-->
|
||||
<!-- Layout used for PreferenceCategory in a PreferenceActivity. -->
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+android:id/title"
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dip"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
android:layout_weight="1" >
|
||||
|
||||
<TextView
|
||||
android:id="@+android:id/title"
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
tools:text="Title"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+android:id/summary"
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@android:id/title"
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary" />
|
||||
</RelativeLayout>
|
||||
<LinearLayout android:id="@+android:id/widget_frame"
|
||||
<LinearLayout android:id="@android:id/widget_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<string name="SP_APIToken" translatable="false">APIToken</string>
|
||||
<string name="SP_username" translatable="false">Username</string>
|
||||
<string name="SP_email" translatable="false">E-mail</string>
|
||||
<string name="base_url" translatable="false">https://habitica.com</string>
|
||||
<string name="base_url" translatable="false">https://habitrpg-delta.herokuapp.com</string>
|
||||
|
||||
<!-- Local notification actions -->
|
||||
<string name="accept_party_invite" translatable="false">ACCEPT_PARTY_INVITE</string>
|
||||
|
|
|
|||
|
|
@ -561,7 +561,7 @@
|
|||
<string name="login_btn_fb">Login with Facebook</string>
|
||||
<string name="login_btn_google">Login with Google</string>
|
||||
<string name="action_back">Back</string>
|
||||
<string name="welcome_text">Oh, you must be new here. I’m Justin, I’ll be your guide in Habitica.\n\nTo start, you’ll need to create an avatar.</string>
|
||||
<string name="welcome_text">Oh, you must be new here. I’m Justin, I’ll be your guide in Habitica.\n\nFirst, what should we call you? Feel free to change what I picked. When you’re all set, let’s create your avatar!</string>
|
||||
<string name="randomize">Randomize</string>
|
||||
<string name="avatar_extras">Extras</string>
|
||||
<string name="avatar_skin_color">Skin Color</string>
|
||||
|
|
@ -830,4 +830,7 @@
|
|||
<string name="username_level">%s ・Lvl %d</string>
|
||||
<string name="enter_recipient_username">Enter a Recipient\'s username</string>
|
||||
<string name="username_copied">Username copied to clipboard</string>
|
||||
<string name="verification_pet">One of these Veteran Pets will be waiting for you after you’ve finished confirming!</string>
|
||||
<string name="welcomeNameTitle">What should we call you?</string>
|
||||
<string name="display_name_length_error">Display names must be between 1 and 30 characters</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -172,7 +172,6 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
|||
|
||||
@SuppressLint("ObsoleteSdkInt")
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
Trace.beginSection("MainActivity.launch")
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
|
|
@ -315,7 +314,6 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
|||
AmplitudeManager.sendEvent("open notification", AmplitudeManager.EVENT_CATEGORY_BEHAVIOUR, AmplitudeManager.EVENT_HITTYPE_EVENT, additionalData)
|
||||
NotificationOpenHandler.handleOpenedByNotification(identifier, intent, this, user)
|
||||
}
|
||||
Trace.endSection()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.habitrpg.android.habitica.ui.activities
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Build
|
||||
|
|
@ -12,6 +13,7 @@ import android.support.v4.view.ViewPager
|
|||
import android.support.v7.content.res.AppCompatResources
|
||||
import android.support.v7.preference.PreferenceManager
|
||||
import android.view.View
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.Button
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.api.HostConfig
|
||||
|
|
@ -33,9 +35,9 @@ import com.habitrpg.android.habitica.ui.helpers.bindView
|
|||
import com.habitrpg.android.habitica.ui.views.FadingViewPager
|
||||
import com.viewpagerindicator.IconPageIndicator
|
||||
import com.viewpagerindicator.IconPagerAdapter
|
||||
import io.reactivex.BackpressureStrategy
|
||||
import io.reactivex.functions.Consumer
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.solovyev.android.checkout.Inventory
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
@ -57,6 +59,7 @@ class SetupActivity : BaseActivity(), ViewPager.OnPageChangeListener {
|
|||
private val previousButton: Button by bindView(R.id.previousButton)
|
||||
private val indicator: IconPageIndicator by bindView(R.id.view_pager_indicator)
|
||||
|
||||
internal var welcomeFragment: WelcomeFragment? = null
|
||||
internal var avatarSetupFragment: AvatarSetupFragment? = null
|
||||
internal var taskSetupFragment: TaskSetupFragment? = null
|
||||
internal var user: User? = null
|
||||
|
|
@ -81,8 +84,8 @@ class SetupActivity : BaseActivity(), ViewPager.OnPageChangeListener {
|
|||
val currentDeviceLanguage = Locale.getDefault().language
|
||||
for (language in resources.getStringArray(R.array.LanguageValues)) {
|
||||
if (language == currentDeviceLanguage) {
|
||||
apiClient.registrationLanguage(currentDeviceLanguage)
|
||||
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError())
|
||||
compositeSubscription.add(apiClient.registrationLanguage(currentDeviceLanguage)
|
||||
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -123,14 +126,14 @@ class SetupActivity : BaseActivity(), ViewPager.OnPageChangeListener {
|
|||
|
||||
@Subscribe
|
||||
fun onEvent(event: UpdateUserCommand) {
|
||||
this.userRepository.updateUser(user, event.updateData)
|
||||
.subscribe(Consumer<User> { this.onUserReceived(it) }, RxErrorHandler.handleEmptyError())
|
||||
compositeSubscription.add(this.userRepository.updateUser(user, event.updateData)
|
||||
.subscribe(Consumer<User> { this.onUserReceived(it) }, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onEvent(event: EquipCommand) {
|
||||
this.inventoryRepository.equip(user, event.type, event.key)
|
||||
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError())
|
||||
compositeSubscription.add(this.inventoryRepository.equip(user, event.type, event.key)
|
||||
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
private fun nextClicked() {
|
||||
|
|
@ -147,6 +150,11 @@ class SetupActivity : BaseActivity(), ViewPager.OnPageChangeListener {
|
|||
newTasks.notNull {
|
||||
this.taskRepository.createTasks(it).subscribe(Consumer { onUserReceived(user) }, RxErrorHandler.handleEmptyError())
|
||||
}
|
||||
} else if (pager.currentItem == 0) {
|
||||
confirmNames(welcomeFragment?.displayName ?: "", welcomeFragment?.username ?: "")
|
||||
|
||||
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
|
||||
imm?.hideSoftInputFromWindow(currentFocus?.windowToken, 0)
|
||||
}
|
||||
this.pager.currentItem = this.pager.currentItem + 1
|
||||
}
|
||||
|
|
@ -167,6 +175,19 @@ class SetupActivity : BaseActivity(), ViewPager.OnPageChangeListener {
|
|||
previousButton.setCompoundDrawablesWithIntrinsicBounds(leftDrawable, null, null, null)
|
||||
}
|
||||
|
||||
private fun setNextButtonEnabled(enabled: Boolean) {
|
||||
nextButton.isEnabled = enabled
|
||||
val rightDrawable = AppCompatResources.getDrawable(this, R.drawable.forward_arrow_enabled)
|
||||
if (enabled) {
|
||||
nextButton.setTextColor(ContextCompat.getColor(this, R.color.white))
|
||||
rightDrawable?.alpha = 255
|
||||
} else {
|
||||
nextButton.setTextColor(ContextCompat.getColor(this, R.color.white_50_alpha))
|
||||
rightDrawable?.alpha = 127
|
||||
}
|
||||
nextButton.setCompoundDrawablesWithIntrinsicBounds(null, null, rightDrawable, null)
|
||||
}
|
||||
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
|
||||
}
|
||||
|
|
@ -220,6 +241,12 @@ class SetupActivity : BaseActivity(), ViewPager.OnPageChangeListener {
|
|||
finish()
|
||||
}
|
||||
|
||||
private fun confirmNames(displayName: String, username: String) {
|
||||
compositeSubscription.add(userRepository.updateUser(null, "profile.name", displayName)
|
||||
.flatMap { userRepository.updateLoginName(username).toFlowable() }
|
||||
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
private inner class ViewPageAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm), IconPagerAdapter {
|
||||
|
||||
override fun getItem(position: Int): Fragment {
|
||||
|
|
@ -238,7 +265,14 @@ class SetupActivity : BaseActivity(), ViewPager.OnPageChangeListener {
|
|||
taskSetupFragment = fragment
|
||||
fragment
|
||||
}
|
||||
else -> { WelcomeFragment() }
|
||||
else -> {
|
||||
val fragment = WelcomeFragment()
|
||||
welcomeFragment = fragment
|
||||
welcomeFragment?.nameValidEvents?.toFlowable(BackpressureStrategy.DROP)?.subscribe {
|
||||
setNextButtonEnabled(it)
|
||||
}
|
||||
fragment
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,10 +76,10 @@ class VerifyUsernameActivity: BaseActivity() {
|
|||
}
|
||||
|
||||
})
|
||||
verificationEvents.toFlowable(BackpressureStrategy.DROP)
|
||||
compositeSubscription.add(verificationEvents.toFlowable(BackpressureStrategy.DROP)
|
||||
.throttleLast(1, TimeUnit.SECONDS)
|
||||
.flatMap { userRepository.verifyUsername(usernameEditText.text.toString()) }
|
||||
.subscribe(Consumer {
|
||||
.subscribe {
|
||||
if (it.isUsable) {
|
||||
usernameEditText.setCompoundDrawablesWithIntrinsicBounds(null, null, checkmarkIcon, null)
|
||||
issuesTextView.visibility = View.GONE
|
||||
|
|
@ -94,11 +94,11 @@ class VerifyUsernameActivity: BaseActivity() {
|
|||
|
||||
private fun confirmNames() {
|
||||
confirmUsernameButton.isEnabled = false
|
||||
userRepository.updateUser(null, "profile.name", displayNameEditText.text.toString())
|
||||
compositeSubscription.add(userRepository.updateUser(null, "profile.name", displayNameEditText.text.toString())
|
||||
.flatMap { userRepository.updateLoginName(usernameEditText.text.toString()).toFlowable() }
|
||||
.doOnComplete { showConfirmationAndFinish() }
|
||||
.doOnEach { confirmUsernameButton.isEnabled = true }
|
||||
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError())
|
||||
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
private fun showConfirmationAndFinish() {
|
||||
|
|
|
|||
|
|
@ -1,29 +1,59 @@
|
|||
package com.habitrpg.android.habitica.ui.fragments.setup
|
||||
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Bundle
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.AppComponent
|
||||
import com.habitrpg.android.habitica.data.UserRepository
|
||||
import com.habitrpg.android.habitica.extensions.inflate
|
||||
import com.habitrpg.android.habitica.helpers.AmplitudeManager
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.ui.SpeechBubbleView
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseFragment
|
||||
import com.habitrpg.android.habitica.ui.helpers.bindView
|
||||
import com.habitrpg.android.habitica.ui.helpers.resetViews
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
|
||||
import java.util.HashMap
|
||||
import io.reactivex.BackpressureStrategy
|
||||
import io.reactivex.functions.Consumer
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
|
||||
class WelcomeFragment : BaseFragment() {
|
||||
|
||||
val nameValidEvents = PublishSubject.create<Boolean>()
|
||||
|
||||
@Inject
|
||||
lateinit var userRepository: UserRepository
|
||||
|
||||
private val speechBubbleView: SpeechBubbleView? by bindView(R.id.speech_bubble)
|
||||
private val heartIconView: ImageView? by bindView(R.id.heart_icon)
|
||||
private val magicIconView: ImageView? by bindView(R.id.magic_icon)
|
||||
private val expIconView: ImageView? by bindView(R.id.exp_icon)
|
||||
private val goldIconView: ImageView? by bindView(R.id.gold_icon)
|
||||
private val gemIconView: ImageView? by bindView(R.id.gem_icon)
|
||||
private val displayNameEditText: EditText by bindView(R.id.display_name_edit_text)
|
||||
private val usernameEditText: EditText by bindView(R.id.username_edit_text)
|
||||
private val issuesTextView: TextView by bindView(R.id.issues_text_view)
|
||||
|
||||
private val displayNameVerificationEvents = PublishSubject.create<String>()
|
||||
private val usernameVerificationEvents = PublishSubject.create<String>()
|
||||
|
||||
private val checkmarkIcon: Drawable by lazy {
|
||||
BitmapDrawable(resources, HabiticaIconsHelper.imageOfCheckmark(ContextCompat.getColor(context!!, R.color.green_50), 1f))
|
||||
}
|
||||
private val alertIcon: Drawable by lazy {
|
||||
BitmapDrawable(resources, HabiticaIconsHelper.imageOfAlertIcon())
|
||||
}
|
||||
val username: String
|
||||
get() = usernameEditText.text.toString()
|
||||
val displayName: String
|
||||
get() = displayNameEditText.text.toString()
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
|
|
@ -42,11 +72,64 @@ class WelcomeFragment : BaseFragment() {
|
|||
|
||||
speechBubbleView?.animateText(context?.getString(R.string.welcome_text) ?: "")
|
||||
|
||||
heartIconView?.setImageBitmap(HabiticaIconsHelper.imageOfHeartLightBg())
|
||||
expIconView?.setImageBitmap(HabiticaIconsHelper.imageOfExperience())
|
||||
magicIconView?.setImageBitmap(HabiticaIconsHelper.imageOfMagic())
|
||||
goldIconView?.setImageBitmap(HabiticaIconsHelper.imageOfGold())
|
||||
gemIconView?.setImageBitmap(HabiticaIconsHelper.imageOfGem())
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
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?) {
|
||||
}
|
||||
|
||||
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
|
||||
}
|
||||
|
||||
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
|
||||
usernameVerificationEvents.onNext(p0.toString())
|
||||
}
|
||||
})
|
||||
|
||||
compositeSubscription.add(displayNameVerificationEvents.toFlowable(BackpressureStrategy.DROP)
|
||||
.map { it.length in 1..30 }
|
||||
.subscribe {
|
||||
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 = context?.getString(R.string.display_name_length_error)
|
||||
}
|
||||
})
|
||||
compositeSubscription.add(usernameVerificationEvents.toFlowable(BackpressureStrategy.DROP)
|
||||
.throttleLast(1, TimeUnit.SECONDS)
|
||||
.flatMap { userRepository.verifyUsername(usernameEditText.text.toString()) }
|
||||
.subscribe {
|
||||
if (it.isUsable) {
|
||||
usernameEditText.setCompoundDrawablesWithIntrinsicBounds(null, null, checkmarkIcon, null)
|
||||
issuesTextView.visibility = View.GONE
|
||||
} else {
|
||||
usernameEditText.setCompoundDrawablesWithIntrinsicBounds(null, null, alertIcon, null)
|
||||
issuesTextView.visibility = View.VISIBLE
|
||||
issuesTextView.text = it.issues.joinToString("\n")
|
||||
}
|
||||
nameValidEvents.onNext(it.isUsable)
|
||||
})
|
||||
|
||||
compositeSubscription.add(userRepository.getUser().firstElement().subscribe {
|
||||
displayNameEditText.setText(it.profile?.name)
|
||||
displayNameVerificationEvents.onNext(it.profile?.name ?: "")
|
||||
usernameEditText.setText(it.username)
|
||||
usernameVerificationEvents.onNext(it.username ?: "")
|
||||
})
|
||||
}
|
||||
|
||||
override fun injectFragment(component: AppComponent) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.2.71'
|
||||
ext.kotlin_version = '1.3.0'
|
||||
ext.build_tools_version = '28.0.3'
|
||||
ext.sdk_version = 28
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
org.gradle.configureondemand=true
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xmx6656M
|
||||
org.gradle.warning.mode=all
|
||||