mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Update PIN switch keyboard button to be more straightforward.
Addresses #12866.
This commit is contained in:
committed by
Nicholas Tinsley
parent
2dd0221680
commit
8ae115028e
@@ -10,10 +10,11 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
@@ -49,7 +50,7 @@ public abstract class BaseRegistrationLockFragment extends LoggingFragment {
|
||||
private View forgotPin;
|
||||
protected CircularProgressMaterialButton pinButton;
|
||||
private TextView errorLabel;
|
||||
private TextView keyboardToggle;
|
||||
private MaterialButton keyboardToggle;
|
||||
private long timeRemaining;
|
||||
|
||||
private BaseRegistrationViewModel viewModel;
|
||||
@@ -101,11 +102,11 @@ public abstract class BaseRegistrationLockFragment extends LoggingFragment {
|
||||
PinKeyboardType keyboardType = getPinEntryKeyboardType();
|
||||
|
||||
updateKeyboard(keyboardType.getOther());
|
||||
keyboardToggle.setText(resolveKeyboardToggleText(keyboardType));
|
||||
keyboardToggle.setIconResource(keyboardType.getIconResource());
|
||||
});
|
||||
|
||||
PinKeyboardType keyboardType = getPinEntryKeyboardType().getOther();
|
||||
keyboardToggle.setText(resolveKeyboardToggleText(keyboardType));
|
||||
keyboardToggle.setIconResource(keyboardType.getIconResource());
|
||||
|
||||
disposables.bindTo(getViewLifecycleOwner().getLifecycle());
|
||||
viewModel = getViewModel();
|
||||
@@ -274,14 +275,6 @@ public abstract class BaseRegistrationLockFragment extends LoggingFragment {
|
||||
pinEntry.getText().clear();
|
||||
}
|
||||
|
||||
private @StringRes static int resolveKeyboardToggleText(@NonNull PinKeyboardType keyboard) {
|
||||
if (keyboard == PinKeyboardType.ALPHA_NUMERIC) {
|
||||
return R.string.RegistrationLockFragment__enter_alphanumeric_pin;
|
||||
} else {
|
||||
return R.string.RegistrationLockFragment__enter_numeric_pin;
|
||||
}
|
||||
}
|
||||
|
||||
private void enableAndFocusPinEntry() {
|
||||
pinEntry.setEnabled(true);
|
||||
pinEntry.setFocusable(true);
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.text.InputType
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
@@ -74,13 +73,12 @@ class ReRegisterWithPinFragment : LoggingFragment(R.layout.pin_restore_entry_fra
|
||||
}
|
||||
|
||||
binding.pinRestoreKeyboardToggle.setOnClickListener {
|
||||
val keyboardType: PinKeyboardType = getPinEntryKeyboardType()
|
||||
updateKeyboard(keyboardType.other)
|
||||
binding.pinRestoreKeyboardToggle.setText(resolveKeyboardToggleText(keyboardType))
|
||||
val currentKeyboardType: PinKeyboardType = getPinEntryKeyboardType()
|
||||
updateKeyboard(currentKeyboardType.other)
|
||||
binding.pinRestoreKeyboardToggle.setIconResource(currentKeyboardType.iconResource)
|
||||
}
|
||||
|
||||
val keyboardType: PinKeyboardType = getPinEntryKeyboardType().other
|
||||
binding.pinRestoreKeyboardToggle.setText(resolveKeyboardToggleText(keyboardType))
|
||||
binding.pinRestoreKeyboardToggle.setIconResource(getPinEntryKeyboardType().other.iconResource)
|
||||
|
||||
reRegisterViewModel.updateTokenData(registrationViewModel.keyBackupCurrentToken)
|
||||
|
||||
@@ -212,15 +210,6 @@ class ReRegisterWithPinFragment : LoggingFragment(R.layout.pin_restore_entry_fra
|
||||
binding.pinRestorePinInput.text?.clear()
|
||||
}
|
||||
|
||||
@StringRes
|
||||
private fun resolveKeyboardToggleText(keyboard: PinKeyboardType): Int {
|
||||
return if (keyboard == PinKeyboardType.ALPHA_NUMERIC) {
|
||||
R.string.RegistrationLockFragment__enter_alphanumeric_pin
|
||||
} else {
|
||||
R.string.RegistrationLockFragment__enter_numeric_pin
|
||||
}
|
||||
}
|
||||
|
||||
private fun onNeedHelpClicked() {
|
||||
val message = if (reRegisterViewModel.isLocalVerification) R.string.ReRegisterWithPinFragment_need_help_local else R.string.PinRestoreEntryFragment_your_pin_is_a_d_digit_code
|
||||
|
||||
|
||||
Reference in New Issue
Block a user