mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 11:46:32 +00:00
tweaks
This commit is contained in:
parent
5ff6574b17
commit
80a30bf4ad
11 changed files with 44 additions and 121 deletions
|
|
@ -203,7 +203,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:text="@string/subscription_benefit_armoire_sub"
|
||||
android:textColor="@color/white"
|
||||
style="@style/Body2"
|
||||
style="@style/Body1"
|
||||
android:gravity="center"
|
||||
android:paddingHorizontal="48dp"
|
||||
android:layout_marginTop="6dp"/>
|
||||
|
|
@ -256,8 +256,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:text="@string/armoire_drop_rates"
|
||||
android:textColor="@color/brand_600"
|
||||
android:layout_marginTop="22dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
style="@style/Body2"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -195,4 +195,10 @@
|
|||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
<FrameLayout
|
||||
android:id="@+id/snackbar_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="400dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:paddingBottom="20dp"/>
|
||||
</FrameLayout>
|
||||
|
|
|
|||
|
|
@ -1458,6 +1458,7 @@
|
|||
<string name="preference_push_joined_group_plan_mention">\@Mentions in Group Plans</string>
|
||||
<string name="subscribe_incentive_button_faint">Subscribe to hold on with 1HP!</string>
|
||||
<string name="subscription_benefit_armoire_sub">Your subscription gives you an extra chance at the Armoire!</string>
|
||||
<string name="subscriber_benefit_success_faint">You got a second chance with 1HP!</string>
|
||||
|
||||
|
||||
<plurals name="you_x_others">
|
||||
|
|
|
|||
|
|
@ -100,7 +100,13 @@ class UserRepositoryImpl(
|
|||
|
||||
override suspend fun revive(): User? {
|
||||
val revivedUser = apiClient.revive()
|
||||
val currentUser = localRepository.getLiveUser(currentUserID)
|
||||
if (revivedUser != null && currentUser != null) {
|
||||
val brokenItem = currentUser.items?.gear?.owned?.firstOrNull { equipment ->
|
||||
revivedUser.items?.gear?.owned?.filter { it.key == equipment.key }?.size == 0
|
||||
}
|
||||
|
||||
}
|
||||
return retrieveUser(false, true)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ class ArmoireActivity : BaseActivity() {
|
|||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
userRepository.updateUser("stats.gp", currentGold + 100)
|
||||
val buyResponse =
|
||||
inventoryRepository.buyItem(user, "armoire", 100.0, 1) ?: return@launch
|
||||
inventoryRepository.buyItem(user, "armoire", 0.0, 1) ?: return@launch
|
||||
configure(
|
||||
buyResponse.armoire["type"] ?: "",
|
||||
buyResponse.armoire["dropKey"] ?: "",
|
||||
|
|
|
|||
|
|
@ -4,9 +4,12 @@ import android.content.SharedPreferences
|
|||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.animation.AccelerateInterpolator
|
||||
import androidx.core.content.edit
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.habitrpg.android.habitica.HabiticaApplication
|
||||
import com.habitrpg.android.habitica.HabiticaBaseApplication
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.data.InventoryRepository
|
||||
import com.habitrpg.android.habitica.databinding.ActivityDeathBinding
|
||||
|
|
@ -35,7 +38,7 @@ import java.util.Date
|
|||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class DeathActivity : BaseActivity() {
|
||||
class DeathActivity : BaseActivity(), SnackbarActivity {
|
||||
private lateinit var binding: ActivityDeathBinding
|
||||
|
||||
@Inject
|
||||
|
|
@ -135,16 +138,15 @@ class DeathActivity : BaseActivity() {
|
|||
putLong("last_sub_revive", Date().time)
|
||||
}
|
||||
lifecycleScope.launchCatching {
|
||||
delay(400)
|
||||
delay(300)
|
||||
binding.reviveSubscriberWrapper.startAnimation(Animations.fadeOutAnimation())
|
||||
}
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
userRepository.updateUser("stats.hp", 1)
|
||||
HabiticaSnackbar.showSnackbar(
|
||||
this@DeathActivity.snackbarContainer(), getString(R.string.subscriber_benefit_success_faint), HabiticaSnackbar.SnackbarDisplayType.SUCCESS, isSubscriberBenefit = true)
|
||||
delay(2000)
|
||||
finish()
|
||||
(parent as? SnackbarActivity)?.snackbarContainer()?.let { it1 ->
|
||||
HabiticaSnackbar.showSnackbar(
|
||||
it1, getString(R.string.subscriber_benefit_used_faint), HabiticaSnackbar.SnackbarDisplayType.SUCCESS, isSubscriberBenefit = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -153,6 +155,11 @@ class DeathActivity : BaseActivity() {
|
|||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
userRepository.revive()
|
||||
finish()
|
||||
delay(1000)
|
||||
(HabiticaBaseApplication.getInstance(this@DeathActivity)?.currentActivity as? SnackbarActivity)?.let {activity ->
|
||||
HabiticaSnackbar.showSnackbar(
|
||||
activity.snackbarContainer(), getString(R.string.subscriber_benefit_success_faint), HabiticaSnackbar.SnackbarDisplayType.SUCCESS, isSubscriberBenefit = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
startAnimating()
|
||||
|
|
@ -186,4 +193,8 @@ class DeathActivity : BaseActivity() {
|
|||
override fun onBackPressed() {
|
||||
moveTaskToBack(true)
|
||||
}
|
||||
|
||||
override fun snackbarContainer(): ViewGroup {
|
||||
return binding.snackbarContainer
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
NAME=4.3
|
||||
CODE=6511
|
||||
CODE=6521
|
||||
|
|
@ -20,8 +20,7 @@ import dagger.hilt.android.AndroidEntryPoint
|
|||
class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>() {
|
||||
enum class State {
|
||||
INITIAL,
|
||||
OTHER,
|
||||
INPUT
|
||||
OTHER
|
||||
}
|
||||
override val viewModel: LoginViewModel by viewModels()
|
||||
private var currentState: State = State.INITIAL
|
||||
|
|
@ -34,32 +33,14 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>() {
|
|||
binding.otherButton.isVisible = true
|
||||
binding.googleLoginButton.isVisible = false
|
||||
binding.registerButton.isVisible = false
|
||||
binding.usernamePasswordButton.isVisible = false
|
||||
binding.usernameEditText.isVisible = false
|
||||
binding.passwordEditText.isVisible = false
|
||||
binding.loginButton.isVisible = false
|
||||
}
|
||||
State.OTHER -> {
|
||||
binding.descriptionView.isVisible = false
|
||||
binding.signInOnPhoneButton.isVisible = false
|
||||
binding.otherButton.isVisible = false
|
||||
binding.googleLoginButton.isVisible = true
|
||||
binding.registerButton.isVisible = binding.registerButton.isEnabled
|
||||
binding.usernamePasswordButton.isVisible = true
|
||||
binding.usernameEditText.isVisible = false
|
||||
binding.passwordEditText.isVisible = false
|
||||
binding.loginButton.isVisible = false
|
||||
}
|
||||
State.INPUT -> {
|
||||
binding.descriptionView.isVisible = false
|
||||
binding.signInOnPhoneButton.isVisible = false
|
||||
binding.otherButton.isVisible = false
|
||||
binding.googleLoginButton.isVisible = false
|
||||
binding.registerButton.isVisible = false
|
||||
binding.usernamePasswordButton.isVisible = false
|
||||
binding.usernameEditText.isVisible = true
|
||||
binding.passwordEditText.isVisible = true
|
||||
binding.loginButton.isVisible = true
|
||||
binding.registerButton.isVisible = true
|
||||
binding.registerButton.alpha = if (binding.registerButton.isEnabled) 1.0f else 0.7f
|
||||
}
|
||||
}
|
||||
binding.scrollView.smoothScrollTo(0, 0)
|
||||
|
|
@ -75,20 +56,10 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>() {
|
|||
|
||||
binding.signInOnPhoneButton.setOnClickListener { openLoginOnPhone() }
|
||||
binding.otherButton.setOnClickListener { currentState = State.OTHER }
|
||||
binding.usernamePasswordButton.setOnClickListener { currentState = State.INPUT }
|
||||
|
||||
binding.loginButton.setOnClickListener { loginLocal() }
|
||||
binding.googleLoginButton.setOnClickListener { loginGoogle() }
|
||||
binding.registerButton.setOnClickListener { openRegisterOnPhone() }
|
||||
|
||||
binding.passwordEditText.transformationMethod = PasswordTransformationMethod()
|
||||
binding.usernameEditText.doOnTextChanged { text, start, before, count ->
|
||||
setLoginButtonIsEnabled()
|
||||
}
|
||||
binding.passwordEditText.doOnTextChanged { text, start, before, count ->
|
||||
setLoginButtonIsEnabled()
|
||||
}
|
||||
|
||||
currentState = State.INITIAL
|
||||
}
|
||||
|
||||
|
|
@ -100,37 +71,10 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>() {
|
|||
openRemoteActivity(DeviceCommunication.SHOW_LOGIN)
|
||||
}
|
||||
|
||||
private fun loginLocal() {
|
||||
val username: String = binding.usernameEditText.text.toString().trim { it <= ' ' }
|
||||
val password: String = binding.passwordEditText.text.toString()
|
||||
if (username.isEmpty() || password.isEmpty()) {
|
||||
showValidationError(getString(R.string.login_validation_error_fieldsmissing))
|
||||
return
|
||||
}
|
||||
viewModel.login(username, password) {
|
||||
stopAnimatingProgress()
|
||||
}
|
||||
startAnimatingProgress()
|
||||
}
|
||||
|
||||
private fun loginGoogle() {
|
||||
viewModel.handleGoogleLogin(this, pickAccountResult)
|
||||
}
|
||||
|
||||
private fun showValidationError(message: String) {
|
||||
val alert = AlertDialog.Builder(this).create()
|
||||
alert.setTitle(R.string.login_validation_error_title)
|
||||
alert.setMessage(message)
|
||||
alert.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.ok)) { thisAlert, _ ->
|
||||
thisAlert.dismiss()
|
||||
}
|
||||
alert.show()
|
||||
}
|
||||
|
||||
private fun setLoginButtonIsEnabled() {
|
||||
binding.loginButton.isEnabled = binding.usernameEditText.text.isNotEmpty() && binding.passwordEditText.text.isNotEmpty()
|
||||
}
|
||||
|
||||
private val pickAccountResult = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
||||
val task = GoogleSignIn.getSignedInAccountFromIntent(it.data)
|
||||
viewModel.handleGoogleLoginResult(this, task, recoverFromPlayServicesErrorResult)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class ConnectedActionChipView(context: Context, attrs: AttributeSet? = null) :
|
|||
val result = Tasks.await(capabilityClient.getCapability("open_activity", CapabilityClient.FILTER_REACHABLE))
|
||||
launch(Dispatchers.Main) {
|
||||
isEnabled = result.nodes.firstOrNull { it.isNearby } != null
|
||||
isVisible = isEnabled
|
||||
alpha = if (isEnabled) 1.0f else 0.7f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@
|
|||
android:gravity="center"
|
||||
android:animateLayoutChanges="true">
|
||||
<ImageView
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:src="@drawable/ic_gryphon_white"
|
||||
android:importantForAccessibility="no"
|
||||
android:layout_marginBottom="@dimen/spacing_medium"
|
||||
|
|
@ -62,15 +62,6 @@
|
|||
android:layout_marginBottom="4dp"
|
||||
app:chipImage="@drawable/google_icon"
|
||||
app:chipText="@string/login_btn_google" />
|
||||
|
||||
<com.habitrpg.wearos.habitica.ui.views.TextActionChipView
|
||||
android:id="@+id/username_password_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp"
|
||||
app:chipImage="@drawable/ic_keyboard"
|
||||
app:chipText="@string/sign_in_password" />
|
||||
|
||||
<com.habitrpg.wearos.habitica.ui.views.ConnectedActionChipView
|
||||
android:id="@+id/register_button"
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -78,42 +69,6 @@
|
|||
android:layout_marginBottom="4dp"
|
||||
app:chipImage="@drawable/handoff"
|
||||
app:chipText="@string/create_account" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/username_edit_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="52dp"
|
||||
android:inputType="textEmailAddress"
|
||||
android:imeOptions="actionNext"
|
||||
android:hint="@string/email_username"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:background="@drawable/row_background_outline"
|
||||
android:autofillHints="username"
|
||||
style="@style/EditText"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginBottom="@dimen/spacing_small"/>
|
||||
<EditText
|
||||
android:id="@+id/password_edit_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="52dp"
|
||||
android:hint="@string/password"
|
||||
android:background="@drawable/row_background_outline"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:autofillHints="password"
|
||||
style="@style/EditText"
|
||||
android:inputType="textPassword|text"
|
||||
android:textSize="14sp"
|
||||
android:imeOptions="actionDone"
|
||||
android:layout_marginBottom="@dimen/spacing_small"/>
|
||||
<Button
|
||||
android:id="@+id/login_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/sign_in"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:enabled="false"
|
||||
android:textAlignment="center"
|
||||
style="@style/ChipButton.Purple"/>
|
||||
</LinearLayout>
|
||||
</com.habitrpg.wearos.habitica.ui.views.HabiticaScrollView>
|
||||
<com.habitrpg.wearos.habitica.ui.views.TimeText
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:autoSizeMaxTextSize="16sp"
|
||||
android:autoSizeMaxTextSize="20sp"
|
||||
android:autoSizeMinTextSize="12sp"
|
||||
android:autoSizeStepGranularity="2sp"
|
||||
android:autoSizeTextType="uniform"
|
||||
|
|
@ -51,7 +51,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="3dp"
|
||||
android:autoSizeMaxTextSize="6sp"
|
||||
android:autoSizeMaxTextSize="10sp"
|
||||
android:autoSizeMinTextSize="4sp"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:fontFamily="@font/press_start_reg"
|
||||
|
|
@ -62,4 +62,4 @@
|
|||
app:layout_constraintStart_toEndOf="@+id/view"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</merge>
|
||||
</merge>
|
||||
|
|
|
|||
Loading…
Reference in a new issue