Fix bug with back navigation during payment lock.

fork-5.53.8
Greyson Parrelli 2022-08-25 08:51:31 -04:00
rodzic f8aedca08e
commit cdad45096b
2 zmienionych plików z 29 dodań i 3 usunięć

Wyświetl plik

@ -27,12 +27,14 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import org.signal.core.util.ThreadUtil;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.BiometricDeviceAuthentication;
import org.thoughtcrime.securesms.BiometricDeviceLockContract;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.components.settings.app.AppSettingsActivity;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.payments.CanNotSendPaymentDialog;
import org.thoughtcrime.securesms.payments.FiatMoneyUtil;
@ -218,7 +220,19 @@ public class ConfirmPaymentFragment extends BottomSheetDialogFragment {
public void onConfirmPayment() {
setCancelable(false);
if (isPaymentLockEnabled(requireContext())) {
biometricAuth.authenticate(requireContext(), true, this::showConfirmDeviceCredentialIntent);
boolean success = biometricAuth.authenticate(requireContext(), true, this::showConfirmDeviceCredentialIntent);
if (!success) {
setCancelable(true);
new MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.ConfirmPaymentFragment__failed_to_show_payment_lock)
.setMessage(R.string.ConfirmPaymentFragment__you_enabled_payment_lock_in_the_settings)
.setNeutralButton(android.R.string.ok, (d, i) -> d.dismiss())
.setNegativeButton(R.string.ConfirmPaymentFragment__go_to_settings, (d, i) -> {
startActivity(AppSettingsActivity.privacy(requireContext()));
d.dismiss();
})
.show();
}
} else {
viewModel.confirmPayment();
}
@ -234,8 +248,14 @@ public class ConfirmPaymentFragment extends BottomSheetDialogFragment {
@Override
public void onAuthenticationError(int errorCode, @NonNull CharSequence errorString) {
Log.w(TAG, "Authentication error: " + errorCode);
if (errorCode != BiometricPrompt.ERROR_CANCELED && errorCode != BiometricPrompt.ERROR_USER_CANCELED) {
onAuthenticationFailed();
switch (errorCode) {
case BiometricPrompt.ERROR_CANCELED:
case BiometricPrompt.ERROR_USER_CANCELED:
setCancelable(true);
break;
default:
onAuthenticationFailed();
break;
}
}

Wyświetl plik

@ -2992,6 +2992,12 @@
<string name="ConfirmPaymentFragment__invalid_recipient">Invalid recipient</string>
<!-- Biometric/Device authentication prompt title which comes up before sending a payment -->
<string name="ConfirmPaymentFragment__unlock_to_send_payment">Unlock to Send Payment</string>
<!-- Title of a dialog show when we were unable to present the user's screenlock before sending a payment -->
<string name="ConfirmPaymentFragment__failed_to_show_payment_lock">Failed to show payment lock</string>
<!-- Body of a dialog show when we were unable to present the user's screenlock before sending a payment -->
<string name="ConfirmPaymentFragment__you_enabled_payment_lock_in_the_settings">You enabled payment lock in the settings, but it cannot be shown.</string>
<!-- Button in a dialog that will take the user to the privacy settings -->
<string name="ConfirmPaymentFragment__go_to_settings">Go to settings</string>
<string name="ConfirmPaymentFragment__this_person_has_not_activated_payments">This person has not activated payments</string>
<string name="ConfirmPaymentFragment__unable_to_request_a_network_fee">Unable to request a network fee. To continue this payment tap okay to try again.</string>