Fix text of delete account confirmation

Should ask user to input password on a secure input text box when
user has a local authentication. Otherwise ask the user to input
the text DELETE on a plain text box.

Fixes #882
This commit is contained in:
Angelo Viado 2019-02-04 01:39:12 +09:00 committed by Phillip Thelen
parent 8e8e39accd
commit da7acb5502
2 changed files with 9 additions and 2 deletions

View file

@ -657,6 +657,7 @@
<string name="reset_account_description">WARNING! This resets many parts of your account. This is highly discouraged, but some people find it useful in the beginning after playing with the site for a short time.\n\nYou will lose all your levels, gold, and experience points. All your tasks (except those from challenges) will be deleted permanently and you will lose all of their historical data. You will lose all your equipment but you will be able to buy it all back, including all limited edition equipment or subscriber Mystery items that you already own (you will need to be in the correct class to re-buy class-specific gear). You will keep your current class and your pets and mounts. You might prefer to use an Orb of Rebirth instead, which is a much safer option and which will preserve your tasks and equipment.</string>
<string name="delete_account">Delete Account</string>
<string name="delete_account_description">Are you sure? This will delete your account forever, and it can never be restored! You will need to register a new account to use Habitica again. Banked or spent Gems will not be refunded. If you\'re absolutely certain, type your password into the text box below.</string>
<string name="delete_oauth_account_description">Are you sure? This will delete your account forever, and it can never be restored! You will need to register a new account to use Habitica again. Banked or spent Gems will not be refunded. If you\'re absolutely certain, type DELETE into the text box below.</string>
<string name="reset_account_confirmation">reset my account</string>
<string name="delete_account_confirmation">delete my account</string>
<string name="danger_zone">Danger Zone</string>

View file

@ -134,7 +134,13 @@ class AuthenticationPreferenceFragment: BasePreferencesFragment() {
private fun showAccountDeleteConfirmation() {
val input = EditText(context)
input.inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD
var deleteMessage = getString(R.string.delete_account_description)
if (user?.authentication?.localAuthentication != null) {
input.inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD
} else {
deleteMessage = getString(R.string.delete_oauth_account_description)
input.inputType = InputType.TYPE_CLASS_TEXT
}
val lp = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT)
@ -142,7 +148,7 @@ class AuthenticationPreferenceFragment: BasePreferencesFragment() {
context.notNull { context ->
val dialog = AlertDialog.Builder(context)
.setTitle(R.string.delete_account)
.setMessage(R.string.delete_account_description)
.setMessage(deleteMessage)
.setPositiveButton(R.string.delete_account_confirmation) { thisDialog, _ ->
thisDialog.dismiss()
deleteAccount(input.text.toString())