mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Prompt to setup payment bioauth, require to disable payment lock.
This commit is contained in:
@@ -65,7 +65,7 @@ public class PaymentsRecoveryStartFragment extends Fragment {
|
||||
message.setText(getDescription(state));
|
||||
message.setLink(getString(R.string.PaymentsRecoveryStartFragment__learn_more__view));
|
||||
startButton.setOnClickListener(v -> {
|
||||
if (state == RecoveryPhraseStates.FROM_PAYMENTS_MENU_WITH_MNEMONIC_CONFIRMED && ServiceUtil.getKeyguardManager(requireContext()).isKeyguardSecure() && SignalStore.paymentsValues().getPaymentLock()) {
|
||||
if (state == RecoveryPhraseStates.FROM_PAYMENTS_MENU_WITH_MNEMONIC_CONFIRMED && ServiceUtil.getKeyguardManager(requireContext()).isKeyguardSecure() && SignalStore.paymentsValues().isPaymentLockEnabled()) {
|
||||
BiometricPrompt.PromptInfo promptInfo = new BiometricPrompt.PromptInfo
|
||||
.Builder()
|
||||
.setAllowedAuthenticators(BiometricDeviceAuthentication.ALLOWED_AUTHENTICATORS)
|
||||
|
||||
@@ -211,7 +211,7 @@ public class ConfirmPaymentFragment extends BottomSheetDialogFragment {
|
||||
|
||||
|
||||
private boolean isPaymentLockEnabled(Context context) {
|
||||
return SignalStore.paymentsValues().getPaymentLock() && ServiceUtil.getKeyguardManager(context).isKeyguardSecure();
|
||||
return SignalStore.paymentsValues().isPaymentLockEnabled() && ServiceUtil.getKeyguardManager(context).isKeyguardSecure();
|
||||
}
|
||||
|
||||
private class Callbacks implements ConfirmPaymentAdapter.Callbacks {
|
||||
|
||||
@@ -222,6 +222,9 @@ public class PaymentsHomeFragment extends LoggingFragment {
|
||||
});
|
||||
break;
|
||||
case ACTIVATED:
|
||||
if (!SignalStore.paymentsValues().isPaymentLockEnabled()) {
|
||||
SafeNavigation.safeNavigate(NavHostFragment.findNavController(this), R.id.action_paymentsHome_to_securitySetup);
|
||||
}
|
||||
return;
|
||||
default:
|
||||
throw new IllegalStateException("Unsupported event type: " + paymentStateEvent.name());
|
||||
|
||||
@@ -203,6 +203,7 @@ public class PaymentsHomeViewModel extends ViewModel {
|
||||
@Override
|
||||
public void onComplete(@Nullable Void result) {
|
||||
store.update(state -> state.updatePaymentsEnabled(PaymentsHomeState.PaymentsState.ACTIVATED));
|
||||
paymentStateEvents.postValue(PaymentStateEvent.ACTIVATED);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.thoughtcrime.securesms.payments.securitysetup
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.databinding.PaymentsSecuritySetupFragmentBinding
|
||||
import org.thoughtcrime.securesms.payments.preferences.PaymentsHomeFragmentDirections
|
||||
import org.thoughtcrime.securesms.util.navigation.safeNavigate
|
||||
|
||||
/**
|
||||
* Fragment to let user know to enable payment lock to protect their funds
|
||||
*/
|
||||
class PaymentsSecuritySetupFragment : Fragment(R.layout.payments_security_setup_fragment) {
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
val binding = PaymentsSecuritySetupFragmentBinding.bind(view)
|
||||
|
||||
requireActivity().onBackPressedDispatcher.addCallback(
|
||||
viewLifecycleOwner,
|
||||
object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
showSkipDialog()
|
||||
}
|
||||
}
|
||||
)
|
||||
binding.paymentsSecuritySetupEnableLock.setOnClickListener {
|
||||
findNavController().safeNavigate(PaymentsHomeFragmentDirections.actionPaymentsHomeToPrivacySettings(true))
|
||||
}
|
||||
binding.paymentsSecuritySetupFragmentNotNow.setOnClickListener { showSkipDialog() }
|
||||
binding.toolbar.setNavigationOnClickListener { showSkipDialog() }
|
||||
}
|
||||
|
||||
private fun showSkipDialog() {
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(getString(R.string.PaymentsSecuritySetupFragment__skip_this_step))
|
||||
.setMessage(getString(R.string.PaymentsSecuritySetupFragment__skipping_this_step))
|
||||
.setPositiveButton(R.string.PaymentsSecuritySetupFragment__skip) { _, _ -> findNavController().popBackStack() }
|
||||
.setNegativeButton(R.string.PaymentsSecuritySetupFragment__cancel) { _, _ -> }
|
||||
.setCancelable(false)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user