diff --git a/Habitica/res/values/strings.xml b/Habitica/res/values/strings.xml index eda78cf4e..8cc1978a8 100644 --- a/Habitica/res/values/strings.xml +++ b/Habitica/res/values/strings.xml @@ -592,8 +592,8 @@ You will lose all your levels, Gold, and Experience. All your tasks and their historical data will be deleted (Challenge tasks will stay). You will lose all equipment, including limited edition or subscriber equipment, but you will be able to buy it back (you will need to be the correct class to re-buy class-specific gear). You will keep your current class and your Pets and Mounts. To confirm reset, type RESET below. DELETE Delete Account - This will delete your account forever and it can never be restored! Banked or spent Gems will not be refunded. If you’re absolutely certain, type DELETE into the text box below. - Deleted accounts are permanent and cannot be restored. Gems cannot be refunded. If you still want to delete, type DELETE below. + This will delete your account forever and it can never be restored! Banked or spent Gems will not be refunded. If you’re absolutely certain, type your password into the text box below. + This will delete your account forever and it can never be restored! Banked or spent Gems will not be refunded. If you’re absolutely certain, type DELETE into the text box below. Reset my Account Delete my Account Danger Zone diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/preferences/AccountPreferenceFragment.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/preferences/AccountPreferenceFragment.kt index 883db682a..b674e3e09 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/preferences/AccountPreferenceFragment.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/preferences/AccountPreferenceFragment.kt @@ -183,8 +183,8 @@ class AccountPreferenceFragment : disconnect("facebook", "Facebook") } } - "reset_account" -> showAccountResetConfirmation() - "delete_account" -> showAccountDeleteConfirmation() + "reset_account" -> showAccountResetConfirmation(user) + "delete_account" -> showAccountDeleteConfirmation(user) "fixCharacterValues" -> { val intent = Intent(activity, FixCharacterValuesActivity::class.java) activity?.startActivity(intent) @@ -410,8 +410,8 @@ class AccountPreferenceFragment : } } - private fun showAccountDeleteConfirmation() { - val habiticaAccountDialog = context?.let { HabiticaAccountDialog(it, "delete_account", this) } + private fun showAccountDeleteConfirmation(user: User?) { + val habiticaAccountDialog = context?.let { HabiticaAccountDialog(it, "delete_account", this, user) } habiticaAccountDialog?.show(parentFragmentManager, "account") if (habiticaAccountDialog != null) { @@ -434,8 +434,8 @@ class AccountPreferenceFragment : ) } - private fun showAccountResetConfirmation() { - val habiticaAccountDialog = context?.let { HabiticaAccountDialog(it, "reset_account", this) } + private fun showAccountResetConfirmation(user: User?) { + val habiticaAccountDialog = context?.let { HabiticaAccountDialog(it, "reset_account", this, user) } habiticaAccountDialog?.show(parentFragmentManager, "account") if (habiticaAccountDialog != null) { diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/preferences/HabiticaAccountDialog.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/preferences/HabiticaAccountDialog.kt index 200536602..3c0b4a276 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/preferences/HabiticaAccountDialog.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/preferences/HabiticaAccountDialog.kt @@ -14,9 +14,10 @@ import androidx.fragment.app.DialogFragment import com.google.android.material.textfield.TextInputEditText import com.google.android.material.textfield.TextInputLayout import com.habitrpg.android.habitica.R +import com.habitrpg.android.habitica.models.user.User -class HabiticaAccountDialog(private var thisContext: Context, private val accountAction: String, val accountUpdateConfirmed: AccountUpdateConfirmed) : DialogFragment() { +class HabiticaAccountDialog(private var thisContext: Context, private val accountAction: String, val accountUpdateConfirmed: AccountUpdateConfirmed, val user: User?) : DialogFragment() { private lateinit var mainView: View private var backBtn: ImageButton? = null @@ -77,9 +78,13 @@ class HabiticaAccountDialog(private var thisContext: Context, private val accoun private fun setDeleteAccountViews() { title?.setText(R.string.are_you_sure_you_want_to_delete) - warningDescription?.setText(R.string.delete_account_description) confirmationTextInputLayout?.setHint(R.string.password) confirmationAction?.setText(R.string.delete_account) + warningDescription?.text = context?.getString(R.string.delete_account_description) + if (user?.authentication?.hasPassword != true) { + warningDescription?.text = context?.getString(R.string.delete_oauth_account_description) + confirmationTextInputLayout?.setHint(R.string.confirm_deletion) + } confirmationText?.addTextChangedListener(object : TextWatcher { override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { @@ -88,9 +93,12 @@ class HabiticaAccountDialog(private var thisContext: Context, private val accoun } override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { - if (confirmationText?.text.toString() == context?.getString(R.string.delete_caps)) { - confirmationAction?.setTextColor(ContextCompat.getColor(thisContext, R.color.red_100)) - confirmationAction?.alpha = 1.0f + if (confirmationText?.text.toString().length >= 5) { + if ((user?.authentication?.hasPassword != true && confirmationText?.text.toString() == context?.getString(R.string.delete_caps)) || + user?.authentication?.hasPassword == true) { + confirmationAction?.setTextColor(ContextCompat.getColor(thisContext, R.color.red_100)) + confirmationAction?.alpha = 1.0f + } } else { confirmationAction?.setTextColor(ContextCompat.getColor(thisContext, R.color.gray_10)) confirmationAction?.alpha = .4f @@ -102,7 +110,7 @@ class HabiticaAccountDialog(private var thisContext: Context, private val accoun }) confirmationAction?.setOnClickListener { if (confirmationText?.text.toString() == context?.getString(R.string.delete_caps)) { - accountUpdateConfirmed.resetConfirmedClicked() + accountUpdateConfirmed.deletionConfirmClicked(confirmationText?.text.toString()) } } }