mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Fix inconsistent default PIN keyboard type.
This commit is contained in:
committed by
Greyson Parrelli
parent
7f429dc769
commit
c24993960d
@@ -10,6 +10,7 @@ import com.google.i18n.phonenumbers.PhoneNumberUtil
|
||||
import com.google.i18n.phonenumbers.Phonenumber
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.lock.v2.PinKeyboardType
|
||||
import org.thoughtcrime.securesms.registration.data.network.Challenge
|
||||
import org.thoughtcrime.securesms.registration.data.network.RegisterAccountResult
|
||||
import org.thoughtcrime.securesms.registration.data.network.RegistrationSessionResult
|
||||
@@ -48,6 +49,7 @@ data class RegistrationState(
|
||||
val nextVerificationAttempt: Duration = 0.seconds,
|
||||
val verified: Boolean = false,
|
||||
val smsListenerTimeout: Long = 0L,
|
||||
val pinKeyboardType: PinKeyboardType = SignalStore.pin.keyboardType,
|
||||
val registrationCheckpoint: RegistrationCheckpoint = RegistrationCheckpoint.INITIALIZATION,
|
||||
val networkError: Throwable? = null,
|
||||
val sessionCreationError: RegistrationSessionResult? = null,
|
||||
|
||||
@@ -211,6 +211,12 @@ class RegistrationViewModel : ViewModel() {
|
||||
return fcmToken
|
||||
}
|
||||
|
||||
fun togglePinKeyboardType() {
|
||||
store.update { previousState ->
|
||||
previousState.copy(pinKeyboardType = previousState.pinKeyboardType.other)
|
||||
}
|
||||
}
|
||||
|
||||
fun onBackupSuccessfullyRestored() {
|
||||
val recoveryPassword = SignalStore.svr.recoveryPassword
|
||||
store.update {
|
||||
@@ -723,6 +729,8 @@ class RegistrationViewModel : ViewModel() {
|
||||
|
||||
fun verifyCodeAndRegisterAccountWithRegistrationLock(context: Context, pin: String) {
|
||||
Log.v(TAG, "verifyCodeAndRegisterAccountWithRegistrationLock()")
|
||||
SignalStore.pin.keyboardType = store.value.pinKeyboardType
|
||||
|
||||
store.update {
|
||||
it.copy(
|
||||
inProgress = true,
|
||||
|
||||
@@ -19,8 +19,6 @@ import org.thoughtcrime.securesms.LoggingFragment
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.components.ViewBinderDelegate
|
||||
import org.thoughtcrime.securesms.databinding.FragmentRegistrationLockBinding
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.lock.v2.PinKeyboardType
|
||||
import org.thoughtcrime.securesms.lock.v2.SvrConstants
|
||||
import org.thoughtcrime.securesms.registration.data.network.RegisterAccountResult
|
||||
import org.thoughtcrime.securesms.registration.data.network.VerificationCodeRequestResult
|
||||
@@ -43,9 +41,6 @@ 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,10 +69,7 @@ class RegistrationLockFragment : LoggingFragment(R.layout.fragment_registration_
|
||||
handlePinEntry()
|
||||
}
|
||||
|
||||
binding.kbsLockKeyboardToggle.setOnClickListener {
|
||||
updateKeyboard(pinEntryKeyboardType.other)
|
||||
}
|
||||
updateKeyboard(pinEntryKeyboardType)
|
||||
binding.kbsLockKeyboardToggle.setOnClickListener { viewModel.togglePinKeyboardType() }
|
||||
|
||||
viewModel.lockedTimeRemaining.observe(viewLifecycleOwner) { t: Long -> timeRemaining = t }
|
||||
|
||||
@@ -114,6 +106,11 @@ class RegistrationLockFragment : LoggingFragment(R.layout.fragment_registration_
|
||||
handleRegistrationErrorResponse(error)
|
||||
viewModel.registerAccountErrorShown()
|
||||
}
|
||||
|
||||
it.pinKeyboardType.applyTo(
|
||||
pinEditText = binding.kbsLockPinInput,
|
||||
toggleTypeButton = binding.kbsLockKeyboardToggle
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,8 +132,6 @@ class RegistrationLockFragment : LoggingFragment(R.layout.fragment_registration_
|
||||
return
|
||||
}
|
||||
|
||||
SignalStore.pin.keyboardType = pinEntryKeyboardType
|
||||
|
||||
binding.kbsLockPinConfirm.setSpinning()
|
||||
|
||||
viewModel.verifyCodeAndRegisterAccountWithRegistrationLock(requireContext(), pin)
|
||||
@@ -263,13 +258,6 @@ class RegistrationLockFragment : LoggingFragment(R.layout.fragment_registration_
|
||||
ViewUtil.focusAndShowKeyboard(binding.kbsLockPinInput)
|
||||
}
|
||||
|
||||
private fun updateKeyboard(newType: PinKeyboardType) {
|
||||
newType.applyTo(
|
||||
pinEditText = binding.kbsLockPinInput,
|
||||
toggleTypeButton = binding.kbsLockKeyboardToggle
|
||||
)
|
||||
}
|
||||
|
||||
private fun sendEmailToSupport() {
|
||||
val subject = R.string.RegistrationLockFragment__signal_registration_need_help_with_pin_for_android_v2_pin
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import org.thoughtcrime.securesms.LoggingFragment
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.components.ViewBinderDelegate
|
||||
import org.thoughtcrime.securesms.databinding.FragmentRegistrationPinRestoreEntryV2Binding
|
||||
import org.thoughtcrime.securesms.lock.v2.PinKeyboardType
|
||||
import org.thoughtcrime.securesms.lock.v2.SvrConstants
|
||||
import org.thoughtcrime.securesms.registration.data.network.RegisterAccountResult
|
||||
import org.thoughtcrime.securesms.registration.fragments.RegistrationViewDelegate
|
||||
@@ -41,9 +40,6 @@ 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,10 +67,7 @@ class ReRegisterWithPinFragment : LoggingFragment(R.layout.fragment_registration
|
||||
handlePinEntry()
|
||||
}
|
||||
|
||||
binding.pinRestoreKeyboardToggle.setOnClickListener {
|
||||
updateKeyboard(newType = pinEntryKeyboardType.other)
|
||||
}
|
||||
updateKeyboard(newType = pinEntryKeyboardType)
|
||||
binding.pinRestoreKeyboardToggle.setOnClickListener { reRegisterViewModel.toggleKeyboardType() }
|
||||
|
||||
LiveDataUtil
|
||||
.combineLatest(registrationViewModel.uiState, reRegisterViewModel.uiState) { reg, rereg -> reg to rereg }
|
||||
@@ -96,6 +89,11 @@ class ReRegisterWithPinFragment : LoggingFragment(R.layout.fragment_registration
|
||||
presentTriesRemaining(reRegisterState, state.svrTriesRemaining)
|
||||
}
|
||||
|
||||
reRegisterState.pinKeyboardType.applyTo(
|
||||
pinEditText = binding.pinRestorePinInput,
|
||||
toggleTypeButton = binding.pinRestoreKeyboardToggle
|
||||
)
|
||||
|
||||
state.registerAccountError?.let { error ->
|
||||
registrationErrorHandler(error)
|
||||
registrationViewModel.registerAccountErrorShown()
|
||||
@@ -193,13 +191,6 @@ class ReRegisterWithPinFragment : LoggingFragment(R.layout.fragment_registration
|
||||
ViewUtil.focusAndShowKeyboard(binding.pinRestorePinInput)
|
||||
}
|
||||
|
||||
private fun updateKeyboard(newType: PinKeyboardType) {
|
||||
newType.applyTo(
|
||||
pinEditText = binding.pinRestorePinInput,
|
||||
toggleTypeButton = binding.pinRestoreKeyboardToggle
|
||||
)
|
||||
}
|
||||
|
||||
private fun onNeedHelpClicked() {
|
||||
Log.i(TAG, "User clicked need help dialog.")
|
||||
val message = if (reRegisterViewModel.isLocalVerification) R.string.ReRegisterWithPinFragment_need_help_local else R.string.PinRestoreEntryFragment_your_pin_is_a_d_digit_code
|
||||
|
||||
@@ -5,8 +5,12 @@
|
||||
|
||||
package org.thoughtcrime.securesms.registration.ui.reregisterwithpin
|
||||
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.lock.v2.PinKeyboardType
|
||||
|
||||
data class ReRegisterWithPinState(
|
||||
val isLocalVerification: Boolean = false,
|
||||
val hasIncorrectGuess: Boolean = false,
|
||||
val localPinMatches: Boolean = false
|
||||
val localPinMatches: Boolean = false,
|
||||
val pinKeyboardType: PinKeyboardType = SignalStore.pin.keyboardType
|
||||
)
|
||||
|
||||
@@ -29,4 +29,10 @@ class ReRegisterWithPinViewModel : ViewModel() {
|
||||
it.copy(hasIncorrectGuess = true)
|
||||
}
|
||||
}
|
||||
|
||||
fun toggleKeyboardType() {
|
||||
store.update { previousState ->
|
||||
previousState.copy(pinKeyboardType = previousState.pinKeyboardType.other)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user