mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-24 19:56:00 +00:00
Disable keyboard suggestions when typing PIN.
Converts `PinKeyboardType` to Kotlin and introduces methods to consistently configure PIN entry fields throughout the app, including a fix to disable keyboard suggestions.
This commit is contained in:
@@ -3,8 +3,6 @@ package org.thoughtcrime.securesms.components.settings.app.account
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Typeface
|
||||
import android.text.InputType
|
||||
import android.text.method.PasswordTransformationMethod
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
@@ -115,13 +113,11 @@ class AccountSettingsFragment : ComposeFragment() {
|
||||
val changeKeyboard = DialogCompat.requireViewById(dialog, R.id.reminder_change_keyboard) as MaterialButton
|
||||
|
||||
changeKeyboard.setOnClickListener {
|
||||
if (pinEditText.inputType and InputType.TYPE_CLASS_NUMBER == 0) {
|
||||
pinEditText.inputType = InputType.TYPE_CLASS_NUMBER
|
||||
changeKeyboard.setIconResource(PinKeyboardType.ALPHA_NUMERIC.iconResource)
|
||||
} else {
|
||||
pinEditText.inputType = InputType.TYPE_CLASS_TEXT
|
||||
changeKeyboard.setIconResource(PinKeyboardType.NUMERIC.iconResource)
|
||||
}
|
||||
val newType = PinKeyboardType.fromEditText(pinEditText).other
|
||||
newType.applyTo(
|
||||
pinEditText = pinEditText,
|
||||
toggleTypeButton = changeKeyboard
|
||||
)
|
||||
pinEditText.typeface = Typeface.DEFAULT
|
||||
}
|
||||
|
||||
@@ -129,19 +125,11 @@ class AccountSettingsFragment : ComposeFragment() {
|
||||
ViewUtil.focusAndShowKeyboard(pinEditText)
|
||||
}
|
||||
|
||||
when (SignalStore.pin.keyboardType) {
|
||||
PinKeyboardType.NUMERIC -> {
|
||||
pinEditText.inputType = InputType.TYPE_CLASS_NUMBER
|
||||
changeKeyboard.setIconResource(PinKeyboardType.ALPHA_NUMERIC.iconResource)
|
||||
}
|
||||
SignalStore.pin.keyboardType.applyTo(
|
||||
pinEditText = pinEditText,
|
||||
toggleTypeButton = changeKeyboard
|
||||
)
|
||||
|
||||
PinKeyboardType.ALPHA_NUMERIC -> {
|
||||
pinEditText.inputType = InputType.TYPE_CLASS_TEXT
|
||||
changeKeyboard.setIconResource(PinKeyboardType.NUMERIC.iconResource)
|
||||
}
|
||||
}
|
||||
|
||||
pinEditText.transformationMethod = PasswordTransformationMethod.getInstance()
|
||||
pinEditText.addTextChangedListener(object : SimpleTextWatcher() {
|
||||
override fun onTextChanged(text: String) {
|
||||
turnOffButton.isEnabled = text.length >= SvrConstants.MINIMUM_PIN_LENGTH
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
package org.thoughtcrime.securesms.components.settings.app.changenumber
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.InputType
|
||||
import android.text.method.PasswordTransformationMethod
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
@@ -53,6 +51,9 @@ class ChangeNumberRegistrationLockFragment : LoggingFragment(R.layout.fragment_c
|
||||
|
||||
private var timeRemaining: Long = 0
|
||||
|
||||
private val pinEntryKeyboardType: PinKeyboardType
|
||||
get() = PinKeyboardType.fromEditText(editText = binding.kbsLockPinInput)
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
RegistrationViewDelegate.setDebugLogSubmitMultiTapView(view.findViewById(R.id.kbs_lock_pin_title))
|
||||
@@ -93,13 +94,9 @@ class ChangeNumberRegistrationLockFragment : LoggingFragment(R.layout.fragment_c
|
||||
}
|
||||
|
||||
binding.kbsLockKeyboardToggle.setOnClickListener {
|
||||
val keyboardType: PinKeyboardType = getPinEntryKeyboardType()
|
||||
updateKeyboard(keyboardType.other)
|
||||
binding.kbsLockKeyboardToggle.setIconResource(keyboardType.iconResource)
|
||||
updateKeyboard(pinEntryKeyboardType.other)
|
||||
}
|
||||
|
||||
val keyboardType: PinKeyboardType = getPinEntryKeyboardType().getOther()
|
||||
binding.kbsLockKeyboardToggle.setIconResource(keyboardType.iconResource)
|
||||
updateKeyboard(pinEntryKeyboardType)
|
||||
|
||||
viewModel.liveLockedTimeRemaining.observe(viewLifecycleOwner) { t: Long -> timeRemaining = t }
|
||||
|
||||
@@ -275,26 +272,14 @@ class ChangeNumberRegistrationLockFragment : LoggingFragment(R.layout.fragment_c
|
||||
private fun enableAndFocusPinEntry() {
|
||||
binding.kbsLockPinInput.setEnabled(true)
|
||||
binding.kbsLockPinInput.setFocusable(true)
|
||||
binding.kbsLockPinInput.transformationMethod = PasswordTransformationMethod.getInstance()
|
||||
ViewUtil.focusAndShowKeyboard(binding.kbsLockPinInput)
|
||||
}
|
||||
|
||||
private fun getPinEntryKeyboardType(): PinKeyboardType {
|
||||
val isNumeric = (binding.kbsLockPinInput.inputType and InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_NUMBER
|
||||
|
||||
return if (isNumeric) PinKeyboardType.NUMERIC else PinKeyboardType.ALPHA_NUMERIC
|
||||
}
|
||||
|
||||
private fun updateKeyboard(keyboard: PinKeyboardType) {
|
||||
val isAlphaNumeric = keyboard == PinKeyboardType.ALPHA_NUMERIC
|
||||
|
||||
binding.kbsLockPinInput.setInputType(
|
||||
if (isAlphaNumeric) InputType.TYPE_CLASS_TEXT
|
||||
else InputType.TYPE_CLASS_NUMBER
|
||||
private fun updateKeyboard(newType: PinKeyboardType) {
|
||||
newType.applyTo(
|
||||
pinEditText = binding.kbsLockPinInput,
|
||||
toggleTypeButton = binding.kbsLockKeyboardToggle
|
||||
)
|
||||
|
||||
binding.kbsLockPinInput.getText().clear()
|
||||
binding.kbsLockPinInput.transformationMethod = PasswordTransformationMethod.getInstance()
|
||||
}
|
||||
|
||||
private fun navigateToAccountLocked() {
|
||||
|
||||
@@ -3,13 +3,11 @@ package org.thoughtcrime.securesms.lock;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Display;
|
||||
@@ -74,15 +72,7 @@ public final class SignalPinReminderDialog {
|
||||
|
||||
ViewUtil.focusAndShowKeyboard(pinEditText);
|
||||
|
||||
switch (SignalStore.pin().getKeyboardType()) {
|
||||
case NUMERIC:
|
||||
pinEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
break;
|
||||
case ALPHA_NUMERIC:
|
||||
pinEditText.setInputType(InputType.TYPE_CLASS_TEXT );
|
||||
break;
|
||||
}
|
||||
pinEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||
SignalStore.pin().getKeyboardType().applyInputTypeTo(pinEditText);
|
||||
|
||||
ClickableSpan clickableSpan = new ClickableSpan() {
|
||||
@Override
|
||||
|
||||
@@ -2,8 +2,6 @@ package org.thoughtcrime.securesms.lock.v2;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
@@ -71,9 +69,8 @@ public abstract class BaseSvrPinFragment<ViewModel extends BaseSvrPinViewModel>
|
||||
});
|
||||
|
||||
viewModel.getKeyboard().observe(getViewLifecycleOwner(), keyboardType -> {
|
||||
updateKeyboard(keyboardType);
|
||||
keyboardType.applyTo(input, keyboardToggle);
|
||||
keyboardToggle.setText(resolveKeyboardToggleText(keyboardType));
|
||||
keyboardToggle.setIconResource(keyboardType.getOther().getIconResource());
|
||||
});
|
||||
|
||||
description.setOnLinkClickListener(v -> {
|
||||
@@ -190,15 +187,8 @@ public abstract class BaseSvrPinFragment<ViewModel extends BaseSvrPinViewModel>
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateKeyboard(@NonNull PinKeyboardType keyboard) {
|
||||
boolean isAlphaNumeric = keyboard == PinKeyboardType.ALPHA_NUMERIC;
|
||||
|
||||
input.setInputType(isAlphaNumeric ? InputType.TYPE_CLASS_TEXT : InputType.TYPE_CLASS_NUMBER);
|
||||
input.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||
}
|
||||
|
||||
private @StringRes int resolveKeyboardToggleText(@NonNull PinKeyboardType keyboard) {
|
||||
if (keyboard == PinKeyboardType.ALPHA_NUMERIC) {
|
||||
private @StringRes int resolveKeyboardToggleText(@NonNull PinKeyboardType keyboardType) {
|
||||
if (keyboardType == PinKeyboardType.ALPHA_NUMERIC) {
|
||||
return R.string.BaseKbsPinFragment__create_numeric_pin;
|
||||
} else {
|
||||
return R.string.BaseKbsPinFragment__create_alphanumeric_pin;
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package org.thoughtcrime.securesms.lock.v2;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
|
||||
public enum PinKeyboardType {
|
||||
NUMERIC("numeric"),
|
||||
ALPHA_NUMERIC("alphaNumeric");
|
||||
|
||||
private final String code;
|
||||
|
||||
PinKeyboardType(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public PinKeyboardType getOther() {
|
||||
if (this == NUMERIC) return ALPHA_NUMERIC;
|
||||
else return NUMERIC;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static PinKeyboardType fromCode(@Nullable String code) {
|
||||
for (PinKeyboardType type : PinKeyboardType.values()) {
|
||||
if (type.code.equals(code)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
return NUMERIC;
|
||||
}
|
||||
|
||||
public int getIconResource() {
|
||||
if (this == ALPHA_NUMERIC) return R.drawable.ic_keyboard_24;
|
||||
else return R.drawable.ic_number_pad_conversation_filter_24;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright 2025 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.thoughtcrime.securesms.lock.v2
|
||||
|
||||
import android.text.InputType
|
||||
import android.text.method.PasswordTransformationMethod
|
||||
import android.widget.EditText
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import org.thoughtcrime.securesms.R
|
||||
|
||||
/**
|
||||
* The available keyboard input types for Signal PIN entry.
|
||||
*/
|
||||
enum class PinKeyboardType(val code: String) {
|
||||
NUMERIC("numeric"),
|
||||
ALPHA_NUMERIC("alphaNumeric");
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Gets the PinKeyboardType that is associated with a string code representation.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun fromCode(code: String?): PinKeyboardType = entries.firstOrNull { it.code == code } ?: NUMERIC
|
||||
|
||||
/**
|
||||
* Gets the keyboard type that is associated with an [EditText]'s current input type.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun fromEditText(editText: EditText): PinKeyboardType = when {
|
||||
(editText.inputType and InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_NUMBER -> NUMERIC
|
||||
else -> ALPHA_NUMERIC
|
||||
}
|
||||
}
|
||||
|
||||
private val inputType: Int by lazy {
|
||||
when (this) {
|
||||
NUMERIC -> InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD
|
||||
ALPHA_NUMERIC -> InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS or InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
|
||||
}
|
||||
}
|
||||
|
||||
private val toggleIconResource: Int by lazy {
|
||||
when (this) {
|
||||
NUMERIC -> R.drawable.ic_number_pad_conversation_filter_24
|
||||
ALPHA_NUMERIC -> R.drawable.ic_keyboard_24
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the opposite keyboard type to the current one.
|
||||
*/
|
||||
val other: PinKeyboardType
|
||||
get() {
|
||||
return when (this) {
|
||||
NUMERIC -> ALPHA_NUMERIC
|
||||
ALPHA_NUMERIC -> NUMERIC
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures an [EditText] and toggle button for this keyboard type.
|
||||
*/
|
||||
fun applyTo(pinEditText: EditText, toggleTypeButton: MaterialButton) {
|
||||
applyInputTypeTo(pinEditText)
|
||||
applyToggleIconTo(toggleTypeButton)
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures an [EditText] for this keyboard type.
|
||||
*/
|
||||
fun applyInputTypeTo(editText: EditText) {
|
||||
val currentInputClass = editText.inputType and InputType.TYPE_MASK_CLASS
|
||||
val desiredInputClass = this.inputType and InputType.TYPE_MASK_CLASS
|
||||
if (currentInputClass != desiredInputClass) {
|
||||
editText.getText().clear()
|
||||
}
|
||||
|
||||
editText.inputType = this.inputType
|
||||
editText.transformationMethod = PasswordTransformationMethod.getInstance()
|
||||
}
|
||||
|
||||
private fun applyToggleIconTo(toggleTypeButton: MaterialButton) {
|
||||
toggleTypeButton.setIconResource(this.other.toggleIconResource)
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -15,8 +14,6 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.autofill.HintConstants;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
@@ -37,8 +34,8 @@ import org.thoughtcrime.securesms.lock.v2.SvrConstants;
|
||||
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||
import org.thoughtcrime.securesms.profiles.edit.CreateProfileActivity;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.registration.util.RegistrationUtil;
|
||||
import org.thoughtcrime.securesms.registration.fragments.RegistrationViewDelegate;
|
||||
import org.thoughtcrime.securesms.registration.util.RegistrationUtil;
|
||||
import org.thoughtcrime.securesms.restore.RestoreActivity;
|
||||
import org.thoughtcrime.securesms.util.CommunicationActions;
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig;
|
||||
@@ -104,14 +101,9 @@ public class PinRestoreEntryFragment extends LoggingFragment {
|
||||
});
|
||||
|
||||
keyboardToggle.setOnClickListener((v) -> {
|
||||
PinKeyboardType keyboardType = getPinEntryKeyboardType();
|
||||
|
||||
keyboardToggle.setIconResource(keyboardType.getIconResource());
|
||||
|
||||
updateKeyboard(keyboardType.getOther());
|
||||
getPinEntryKeyboardType().getOther().applyTo(pinEntry, keyboardToggle);
|
||||
});
|
||||
|
||||
keyboardToggle.setIconResource(getPinEntryKeyboardType().getOther().getIconResource());
|
||||
getPinEntryKeyboardType().applyTo(pinEntry, keyboardToggle);
|
||||
}
|
||||
|
||||
private void initViewModel() {
|
||||
@@ -125,10 +117,10 @@ public class PinRestoreEntryFragment extends LoggingFragment {
|
||||
if (triesRemaining.hasIncorrectGuess()) {
|
||||
if (triesRemaining.getCount() == 1) {
|
||||
new MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.PinRestoreEntryFragment_incorrect_pin)
|
||||
.setMessage(getResources().getQuantityString(R.plurals.PinRestoreEntryFragment_you_have_d_attempt_remaining, triesRemaining.getCount(), triesRemaining.getCount()))
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show();
|
||||
.setTitle(R.string.PinRestoreEntryFragment_incorrect_pin)
|
||||
.setMessage(getResources().getQuantityString(R.plurals.PinRestoreEntryFragment_you_have_d_attempt_remaining, triesRemaining.getCount(), triesRemaining.getCount()))
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
errorLabel.setText(R.string.PinRestoreEntryFragment_incorrect_pin);
|
||||
@@ -137,9 +129,9 @@ public class PinRestoreEntryFragment extends LoggingFragment {
|
||||
if (triesRemaining.getCount() == 1) {
|
||||
helpButton.setVisibility(View.VISIBLE);
|
||||
new MaterialAlertDialogBuilder(requireContext())
|
||||
.setMessage(getResources().getQuantityString(R.plurals.PinRestoreEntryFragment_you_have_d_attempt_remaining, triesRemaining.getCount(), triesRemaining.getCount()))
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show();
|
||||
.setMessage(getResources().getQuantityString(R.plurals.PinRestoreEntryFragment_you_have_d_attempt_remaining, triesRemaining.getCount(), triesRemaining.getCount()))
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,9 +176,7 @@ public class PinRestoreEntryFragment extends LoggingFragment {
|
||||
}
|
||||
|
||||
private PinKeyboardType getPinEntryKeyboardType() {
|
||||
boolean isNumeric = (pinEntry.getInputType() & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_NUMBER;
|
||||
|
||||
return isNumeric ? PinKeyboardType.NUMERIC : PinKeyboardType.ALPHA_NUMERIC;
|
||||
return PinKeyboardType.fromEditText(pinEntry);
|
||||
}
|
||||
|
||||
private void onPinSubmitted() {
|
||||
@@ -197,36 +187,36 @@ public class PinRestoreEntryFragment extends LoggingFragment {
|
||||
|
||||
private void onNeedHelpClicked() {
|
||||
new MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.PinRestoreEntryFragment_need_help)
|
||||
.setMessage(getString(R.string.PinRestoreEntryFragment_your_pin_is_a_d_digit_code, SvrConstants.MINIMUM_PIN_LENGTH))
|
||||
.setPositiveButton(R.string.PinRestoreEntryFragment_create_new_pin, ((dialog, which) -> {
|
||||
SvrRepository.onPinRestoreForgottenOrSkipped();
|
||||
((PinRestoreActivity) requireActivity()).navigateToPinCreation();
|
||||
}))
|
||||
.setNeutralButton(R.string.PinRestoreEntryFragment_contact_support, (dialog, which) -> {
|
||||
String body = SupportEmailUtil.generateSupportEmailBody(requireContext(),
|
||||
R.string.PinRestoreEntryFragment_signal_registration_need_help_with_pin,
|
||||
null,
|
||||
null);
|
||||
CommunicationActions.openEmail(requireContext(),
|
||||
SupportEmailUtil.getSupportEmailAddress(requireContext()),
|
||||
getString(R.string.PinRestoreEntryFragment_signal_registration_need_help_with_pin),
|
||||
body);
|
||||
})
|
||||
.setNegativeButton(R.string.PinRestoreEntryFragment_cancel, null)
|
||||
.show();
|
||||
.setTitle(R.string.PinRestoreEntryFragment_need_help)
|
||||
.setMessage(getString(R.string.PinRestoreEntryFragment_your_pin_is_a_d_digit_code, SvrConstants.MINIMUM_PIN_LENGTH))
|
||||
.setPositiveButton(R.string.PinRestoreEntryFragment_create_new_pin, ((dialog, which) -> {
|
||||
SvrRepository.onPinRestoreForgottenOrSkipped();
|
||||
((PinRestoreActivity) requireActivity()).navigateToPinCreation();
|
||||
}))
|
||||
.setNeutralButton(R.string.PinRestoreEntryFragment_contact_support, (dialog, which) -> {
|
||||
String body = SupportEmailUtil.generateSupportEmailBody(requireContext(),
|
||||
R.string.PinRestoreEntryFragment_signal_registration_need_help_with_pin,
|
||||
null,
|
||||
null);
|
||||
CommunicationActions.openEmail(requireContext(),
|
||||
SupportEmailUtil.getSupportEmailAddress(requireContext()),
|
||||
getString(R.string.PinRestoreEntryFragment_signal_registration_need_help_with_pin),
|
||||
body);
|
||||
})
|
||||
.setNegativeButton(R.string.PinRestoreEntryFragment_cancel, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void onSkipClicked() {
|
||||
new MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.PinRestoreEntryFragment_skip_pin_entry)
|
||||
.setMessage(R.string.PinRestoreEntryFragment_if_you_cant_remember_your_pin)
|
||||
.setPositiveButton(R.string.PinRestoreEntryFragment_create_new_pin, (dialog, which) -> {
|
||||
SvrRepository.onPinRestoreForgottenOrSkipped();
|
||||
((PinRestoreActivity) requireActivity()).navigateToPinCreation();
|
||||
})
|
||||
.setNegativeButton(R.string.PinRestoreEntryFragment_cancel, null)
|
||||
.show();
|
||||
.setTitle(R.string.PinRestoreEntryFragment_skip_pin_entry)
|
||||
.setMessage(R.string.PinRestoreEntryFragment_if_you_cant_remember_your_pin)
|
||||
.setPositiveButton(R.string.PinRestoreEntryFragment_create_new_pin, (dialog, which) -> {
|
||||
SvrRepository.onPinRestoreForgottenOrSkipped();
|
||||
((PinRestoreActivity) requireActivity()).navigateToPinCreation();
|
||||
})
|
||||
.setNegativeButton(R.string.PinRestoreEntryFragment_cancel, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void onAccountLocked() {
|
||||
@@ -259,19 +249,9 @@ public class PinRestoreEntryFragment extends LoggingFragment {
|
||||
activity.finish();
|
||||
}
|
||||
|
||||
private void updateKeyboard(@NonNull PinKeyboardType keyboard) {
|
||||
boolean isAlphaNumeric = keyboard == PinKeyboardType.ALPHA_NUMERIC;
|
||||
|
||||
pinEntry.setInputType(isAlphaNumeric ? InputType.TYPE_CLASS_TEXT : InputType.TYPE_CLASS_NUMBER);
|
||||
pinEntry.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||
|
||||
pinEntry.getText().clear();
|
||||
}
|
||||
|
||||
private void enableAndFocusPinEntry() {
|
||||
pinEntry.setEnabled(true);
|
||||
pinEntry.setFocusable(true);
|
||||
pinEntry.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||
ViewUtil.focusAndShowKeyboard(pinEntry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
package org.thoughtcrime.securesms.registration.ui.registrationlock
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.InputType
|
||||
import android.text.method.PasswordTransformationMethod
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
@@ -45,6 +43,9 @@ class RegistrationLockFragment : LoggingFragment(R.layout.fragment_registration_
|
||||
|
||||
private var timeRemaining: Long = 0
|
||||
|
||||
private val pinEntryKeyboardType: PinKeyboardType
|
||||
get() = PinKeyboardType.fromEditText(editText = binding.kbsLockPinInput)
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setDebugLogSubmitMultiTapView(view.findViewById(R.id.kbs_lock_pin_title))
|
||||
@@ -74,13 +75,9 @@ class RegistrationLockFragment : LoggingFragment(R.layout.fragment_registration_
|
||||
}
|
||||
|
||||
binding.kbsLockKeyboardToggle.setOnClickListener {
|
||||
val keyboardType: PinKeyboardType = getPinEntryKeyboardType()
|
||||
updateKeyboard(keyboardType.other)
|
||||
binding.kbsLockKeyboardToggle.setIconResource(keyboardType.iconResource)
|
||||
updateKeyboard(pinEntryKeyboardType.other)
|
||||
}
|
||||
|
||||
val keyboardType: PinKeyboardType = getPinEntryKeyboardType().getOther()
|
||||
binding.kbsLockKeyboardToggle.setIconResource(keyboardType.iconResource)
|
||||
updateKeyboard(pinEntryKeyboardType)
|
||||
|
||||
viewModel.lockedTimeRemaining.observe(viewLifecycleOwner) { t: Long -> timeRemaining = t }
|
||||
|
||||
@@ -138,7 +135,7 @@ class RegistrationLockFragment : LoggingFragment(R.layout.fragment_registration_
|
||||
return
|
||||
}
|
||||
|
||||
SignalStore.pin.keyboardType = getPinEntryKeyboardType()
|
||||
SignalStore.pin.keyboardType = pinEntryKeyboardType
|
||||
|
||||
binding.kbsLockPinConfirm.setSpinning()
|
||||
|
||||
@@ -263,25 +260,14 @@ class RegistrationLockFragment : LoggingFragment(R.layout.fragment_registration_
|
||||
private fun enableAndFocusPinEntry() {
|
||||
binding.kbsLockPinInput.setEnabled(true)
|
||||
binding.kbsLockPinInput.setFocusable(true)
|
||||
binding.kbsLockPinInput.transformationMethod = PasswordTransformationMethod.getInstance()
|
||||
ViewUtil.focusAndShowKeyboard(binding.kbsLockPinInput)
|
||||
}
|
||||
|
||||
private fun getPinEntryKeyboardType(): PinKeyboardType {
|
||||
val isNumeric = (binding.kbsLockPinInput.inputType and InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_NUMBER
|
||||
|
||||
return if (isNumeric) PinKeyboardType.NUMERIC else PinKeyboardType.ALPHA_NUMERIC
|
||||
}
|
||||
|
||||
private fun updateKeyboard(keyboard: PinKeyboardType) {
|
||||
val isAlphaNumeric = keyboard == PinKeyboardType.ALPHA_NUMERIC
|
||||
|
||||
binding.kbsLockPinInput.setInputType(
|
||||
if (isAlphaNumeric) InputType.TYPE_CLASS_TEXT else InputType.TYPE_CLASS_NUMBER
|
||||
private fun updateKeyboard(newType: PinKeyboardType) {
|
||||
newType.applyTo(
|
||||
pinEditText = binding.kbsLockPinInput,
|
||||
toggleTypeButton = binding.kbsLockKeyboardToggle
|
||||
)
|
||||
|
||||
binding.kbsLockPinInput.getText().clear()
|
||||
binding.kbsLockPinInput.transformationMethod = PasswordTransformationMethod.getInstance()
|
||||
}
|
||||
|
||||
private fun sendEmailToSupport() {
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
package org.thoughtcrime.securesms.registration.ui.reregisterwithpin
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.InputType
|
||||
import android.text.method.PasswordTransformationMethod
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.Toast
|
||||
@@ -43,6 +41,9 @@ class ReRegisterWithPinFragment : LoggingFragment(R.layout.fragment_registration
|
||||
|
||||
private val binding: FragmentRegistrationPinRestoreEntryV2Binding by ViewBinderDelegate(FragmentRegistrationPinRestoreEntryV2Binding::bind)
|
||||
|
||||
private val pinEntryKeyboardType: PinKeyboardType
|
||||
get() = PinKeyboardType.fromEditText(editText = binding.pinRestorePinInput)
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
@@ -71,12 +72,9 @@ class ReRegisterWithPinFragment : LoggingFragment(R.layout.fragment_registration
|
||||
}
|
||||
|
||||
binding.pinRestoreKeyboardToggle.setOnClickListener {
|
||||
val currentKeyboardType: PinKeyboardType = getPinEntryKeyboardType()
|
||||
updateKeyboard(currentKeyboardType.other)
|
||||
binding.pinRestoreKeyboardToggle.setIconResource(currentKeyboardType.iconResource)
|
||||
updateKeyboard(newType = pinEntryKeyboardType.other)
|
||||
}
|
||||
|
||||
binding.pinRestoreKeyboardToggle.setIconResource(getPinEntryKeyboardType().other.iconResource)
|
||||
updateKeyboard(newType = pinEntryKeyboardType)
|
||||
|
||||
LiveDataUtil
|
||||
.combineLatest(registrationViewModel.uiState, reRegisterViewModel.uiState) { reg, rereg -> reg to rereg }
|
||||
@@ -192,20 +190,14 @@ class ReRegisterWithPinFragment : LoggingFragment(R.layout.fragment_registration
|
||||
private fun enableAndFocusPinEntry() {
|
||||
binding.pinRestorePinInput.isEnabled = true
|
||||
binding.pinRestorePinInput.isFocusable = true
|
||||
binding.pinRestorePinInput.transformationMethod = PasswordTransformationMethod.getInstance()
|
||||
ViewUtil.focusAndShowKeyboard(binding.pinRestorePinInput)
|
||||
}
|
||||
|
||||
private fun getPinEntryKeyboardType(): PinKeyboardType {
|
||||
val isNumeric = binding.pinRestorePinInput.inputType and InputType.TYPE_MASK_CLASS == InputType.TYPE_CLASS_NUMBER
|
||||
return if (isNumeric) PinKeyboardType.NUMERIC else PinKeyboardType.ALPHA_NUMERIC
|
||||
}
|
||||
|
||||
private fun updateKeyboard(keyboard: PinKeyboardType) {
|
||||
val isAlphaNumeric = keyboard == PinKeyboardType.ALPHA_NUMERIC
|
||||
binding.pinRestorePinInput.inputType = if (isAlphaNumeric) InputType.TYPE_CLASS_TEXT else InputType.TYPE_CLASS_NUMBER
|
||||
binding.pinRestorePinInput.text?.clear()
|
||||
binding.pinRestorePinInput.transformationMethod = PasswordTransformationMethod.getInstance()
|
||||
private fun updateKeyboard(newType: PinKeyboardType) {
|
||||
newType.applyTo(
|
||||
pinEditText = binding.pinRestorePinInput,
|
||||
toggleTypeButton = binding.pinRestoreKeyboardToggle
|
||||
)
|
||||
}
|
||||
|
||||
private fun onNeedHelpClicked() {
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
package org.thoughtcrime.securesms.registrationv3.ui.registrationlock
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.InputType
|
||||
import android.text.method.PasswordTransformationMethod
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
@@ -45,6 +43,9 @@ class RegistrationLockFragment : LoggingFragment(R.layout.fragment_registration_
|
||||
|
||||
private var timeRemaining: Long = 0
|
||||
|
||||
private val pinEntryKeyboardType: PinKeyboardType
|
||||
get() = PinKeyboardType.fromEditText(editText = binding.kbsLockPinInput)
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setDebugLogSubmitMultiTapView(view.findViewById(R.id.kbs_lock_pin_title))
|
||||
@@ -74,13 +75,9 @@ class RegistrationLockFragment : LoggingFragment(R.layout.fragment_registration_
|
||||
}
|
||||
|
||||
binding.kbsLockKeyboardToggle.setOnClickListener {
|
||||
val keyboardType: PinKeyboardType = getPinEntryKeyboardType()
|
||||
updateKeyboard(keyboardType.other)
|
||||
binding.kbsLockKeyboardToggle.setIconResource(keyboardType.iconResource)
|
||||
updateKeyboard(newType = pinEntryKeyboardType.other)
|
||||
}
|
||||
|
||||
val keyboardType: PinKeyboardType = getPinEntryKeyboardType().getOther()
|
||||
binding.kbsLockKeyboardToggle.setIconResource(keyboardType.iconResource)
|
||||
updateKeyboard(newType = pinEntryKeyboardType)
|
||||
|
||||
viewModel.lockedTimeRemaining.observe(viewLifecycleOwner) { t: Long -> timeRemaining = t }
|
||||
|
||||
@@ -138,7 +135,7 @@ class RegistrationLockFragment : LoggingFragment(R.layout.fragment_registration_
|
||||
return
|
||||
}
|
||||
|
||||
SignalStore.pin.keyboardType = getPinEntryKeyboardType()
|
||||
SignalStore.pin.keyboardType = pinEntryKeyboardType
|
||||
|
||||
binding.kbsLockPinConfirm.setSpinning()
|
||||
|
||||
@@ -263,26 +260,14 @@ class RegistrationLockFragment : LoggingFragment(R.layout.fragment_registration_
|
||||
private fun enableAndFocusPinEntry() {
|
||||
binding.kbsLockPinInput.setEnabled(true)
|
||||
binding.kbsLockPinInput.setFocusable(true)
|
||||
binding.kbsLockPinInput.transformationMethod = PasswordTransformationMethod.getInstance()
|
||||
ViewUtil.focusAndShowKeyboard(binding.kbsLockPinInput)
|
||||
}
|
||||
|
||||
private fun getPinEntryKeyboardType(): PinKeyboardType {
|
||||
val isNumeric = (binding.kbsLockPinInput.inputType and InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_NUMBER
|
||||
|
||||
return if (isNumeric) PinKeyboardType.NUMERIC else PinKeyboardType.ALPHA_NUMERIC
|
||||
}
|
||||
|
||||
private fun updateKeyboard(keyboard: PinKeyboardType) {
|
||||
val isAlphaNumeric = keyboard == PinKeyboardType.ALPHA_NUMERIC
|
||||
|
||||
binding.kbsLockPinInput.setInputType(
|
||||
if (isAlphaNumeric) InputType.TYPE_CLASS_TEXT
|
||||
else InputType.TYPE_CLASS_NUMBER
|
||||
private fun updateKeyboard(newType: PinKeyboardType) {
|
||||
newType.applyTo(
|
||||
pinEditText = binding.kbsLockPinInput,
|
||||
toggleTypeButton = binding.kbsLockKeyboardToggle
|
||||
)
|
||||
|
||||
binding.kbsLockPinInput.getText().clear()
|
||||
binding.kbsLockPinInput.transformationMethod = PasswordTransformationMethod.getInstance()
|
||||
}
|
||||
|
||||
private fun sendEmailToSupport() {
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
package org.thoughtcrime.securesms.registrationv3.ui.reregisterwithpin
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.InputType
|
||||
import android.text.method.PasswordTransformationMethod
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.Toast
|
||||
@@ -44,6 +42,9 @@ class ReRegisterWithPinFragment : LoggingFragment(R.layout.fragment_registration
|
||||
|
||||
private val binding: FragmentRegistrationPinRestoreEntryV2Binding by ViewBinderDelegate(FragmentRegistrationPinRestoreEntryV2Binding::bind)
|
||||
|
||||
private val pinEntryKeyboardType: PinKeyboardType
|
||||
get() = PinKeyboardType.fromEditText(editText = binding.pinRestorePinInput)
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
@@ -72,12 +73,9 @@ class ReRegisterWithPinFragment : LoggingFragment(R.layout.fragment_registration
|
||||
}
|
||||
|
||||
binding.pinRestoreKeyboardToggle.setOnClickListener {
|
||||
val currentKeyboardType: PinKeyboardType = getPinEntryKeyboardType()
|
||||
updateKeyboard(currentKeyboardType.other)
|
||||
binding.pinRestoreKeyboardToggle.setIconResource(currentKeyboardType.iconResource)
|
||||
updateKeyboard(newType = pinEntryKeyboardType.other)
|
||||
}
|
||||
|
||||
binding.pinRestoreKeyboardToggle.setIconResource(getPinEntryKeyboardType().other.iconResource)
|
||||
updateKeyboard(newType = pinEntryKeyboardType)
|
||||
|
||||
LiveDataUtil
|
||||
.combineLatest(registrationViewModel.uiState, reRegisterViewModel.uiState) { reg, rereg -> reg to rereg }
|
||||
@@ -193,20 +191,14 @@ class ReRegisterWithPinFragment : LoggingFragment(R.layout.fragment_registration
|
||||
private fun enableAndFocusPinEntry() {
|
||||
binding.pinRestorePinInput.isEnabled = true
|
||||
binding.pinRestorePinInput.isFocusable = true
|
||||
binding.pinRestorePinInput.transformationMethod = PasswordTransformationMethod.getInstance()
|
||||
ViewUtil.focusAndShowKeyboard(binding.pinRestorePinInput)
|
||||
}
|
||||
|
||||
private fun getPinEntryKeyboardType(): PinKeyboardType {
|
||||
val isNumeric = binding.pinRestorePinInput.inputType and InputType.TYPE_MASK_CLASS == InputType.TYPE_CLASS_NUMBER
|
||||
return if (isNumeric) PinKeyboardType.NUMERIC else PinKeyboardType.ALPHA_NUMERIC
|
||||
}
|
||||
|
||||
private fun updateKeyboard(keyboard: PinKeyboardType) {
|
||||
val isAlphaNumeric = keyboard == PinKeyboardType.ALPHA_NUMERIC
|
||||
binding.pinRestorePinInput.inputType = if (isAlphaNumeric) InputType.TYPE_CLASS_TEXT else InputType.TYPE_CLASS_NUMBER
|
||||
binding.pinRestorePinInput.text?.clear()
|
||||
binding.pinRestorePinInput.transformationMethod = PasswordTransformationMethod.getInstance()
|
||||
private fun updateKeyboard(newType: PinKeyboardType) {
|
||||
newType.applyTo(
|
||||
pinEditText = binding.pinRestorePinInput,
|
||||
toggleTypeButton = binding.pinRestoreKeyboardToggle
|
||||
)
|
||||
}
|
||||
|
||||
private fun onNeedHelpClicked() {
|
||||
|
||||
Reference in New Issue
Block a user