diff --git a/app/res/layout/fragment_phone_available_bottom_sheet.xml b/app/res/layout/fragment_phone_available_bottom_sheet.xml index a57f547456..356dd0abf4 100644 --- a/app/res/layout/fragment_phone_available_bottom_sheet.xml +++ b/app/res/layout/fragment_phone_available_bottom_sheet.xml @@ -36,7 +36,7 @@ android:textSize="16sp" /> - - - - + android:layout_height="match_parent" + android:background="@color/transparent"> - + android:layout_gravity="bottom" + android:background="@color/white" + android:orientation="vertical" + android:padding="16dp"> - - android:layout_width="fill_parent" - android:textSize="@dimen/text_medium" /> + - + - + - - + + \ No newline at end of file diff --git a/app/res/layout/screen_connect_phone_verify.xml b/app/res/layout/screen_connect_phone_verify.xml index 98e6f81d99..7264d83731 100644 --- a/app/res/layout/screen_connect_phone_verify.xml +++ b/app/res/layout/screen_connect_phone_verify.xml @@ -77,7 +77,7 @@ android:id="@+id/connect_phone_verify_code" android:layout_width="match_parent" android:layout_height="55dp" - android:layout_marginLeft="16dp" + android:layout_marginStart="16dp" android:background="@drawable/connect_edit_text_bg" android:hint="OTP" android:imeOptions="actionNext" @@ -120,23 +120,51 @@ android:textColor="@android:color/holo_blue_dark" android:textSize="12sp" /> - + android:orientation="horizontal"> + + + + + + \ No newline at end of file diff --git a/app/res/layout/select_install_mode_fragment.xml b/app/res/layout/select_install_mode_fragment.xml index d382c332d5..67ad08a164 100644 --- a/app/res/layout/select_install_mode_fragment.xml +++ b/app/res/layout/select_install_mode_fragment.xml @@ -12,7 +12,7 @@ - - - - @@ -84,14 +80,13 @@ android:name="method" app:argType="string" app:nullable="true" /> - + @@ -112,8 +110,8 @@ - - - - + + - - - - - + app:nullable="true" /> @@ -279,14 +276,12 @@ - - - - \ No newline at end of file diff --git a/app/res/values-fr/strings.xml b/app/res/values-fr/strings.xml index bea43f4af3..31cc4089e7 100644 --- a/app/res/values-fr/strings.xml +++ b/app/res/values-fr/strings.xml @@ -293,4 +293,13 @@ License. Non Oui Revenir + + Désactiver le compte + Vous êtes sur le point de désactiver définitivement ce compte… + Supprimer le compte + Retourner + Compte désactivé, vous pouvez maintenant créer un nouveau compte avec votre numéro de téléphone principal + D\'accord + Es-tu sûr? + Vous souhaitez désactiver votre compte définitivement ? diff --git a/app/res/values-pt/strings.xml b/app/res/values-pt/strings.xml index a5ca6d5715..4924262296 100644 --- a/app/res/values-pt/strings.xml +++ b/app/res/values-pt/strings.xml @@ -467,4 +467,13 @@ Não Sim Reverter + + Desativar conta + Você está prestes a desativar permanentemente esta conta… + Excluir conta + Volte + Conta desativada, agora você pode registrar uma nova conta com seu número de telefone principal + OK + Tem certeza? + Você deseja desativar sua conta permanentemente? \ No newline at end of file diff --git a/app/res/values/strings.xml b/app/res/values/strings.xml index b61dacaff6..79f3f4b014 100644 --- a/app/res/values/strings.xml +++ b/app/res/values/strings.xml @@ -40,6 +40,8 @@ https://%s/api/opportunity/%d/claim https://%s/api/opportunity/%d/delivery_progress https://%s/api/payment/%s/confirm + https://connectid.dimagi.com/users/recover/initiate_deactivation + https://connectid.dimagi.com/users/recover/confirm_deactivation @@ -840,4 +842,14 @@ No Yes Revert + + Deactivate Account + You are about to permanently deactivate this account… + Delete Account + Go Back + Account deactivated, you may now register a new account with your primary phone number + Ok + Are you sure? + You want to deactivate you account permanently? + diff --git a/app/res/values/themes.xml b/app/res/values/themes.xml index 4b018153bc..91999a8f0c 100644 --- a/app/res/values/themes.xml +++ b/app/res/values/themes.xml @@ -147,5 +147,7 @@ - + diff --git a/app/src/org/commcare/activities/connect/ConnectIdActivity.java b/app/src/org/commcare/activities/connect/ConnectIdActivity.java index 2cbc027eee..32a2159e19 100644 --- a/app/src/org/commcare/activities/connect/ConnectIdActivity.java +++ b/app/src/org/commcare/activities/connect/ConnectIdActivity.java @@ -147,7 +147,7 @@ public static void beginSecondaryPhoneVerification(Context parent) { parent.getString(R.string.connect_recovery_alt_message), ConnectConstants.CONNECT_VERIFY_ALT_PHONE_MESSAGE, parent.getString(R.string.connect_password_fail_button), - parent.getString(R.string.connect_recovery_alt_change_button)); + parent.getString(R.string.connect_recovery_alt_change_button),null,null); controller.navigate(navDirections); } diff --git a/app/src/org/commcare/connect/ConnectConstants.java b/app/src/org/commcare/connect/ConnectConstants.java index 94359f5bd8..00ac0d96ba 100644 --- a/app/src/org/commcare/connect/ConnectConstants.java +++ b/app/src/org/commcare/connect/ConnectConstants.java @@ -61,4 +61,8 @@ public class ConnectConstants { public final static int CONNECT_VERIFY_ALT_PHONE_CHANGE = ConnectConstants.ConnectIdTaskIdOffset + 37; public final static int CONNECT_RECOVERY_WRONG_PIN = ConnectConstants.ConnectIdTaskIdOffset + 38; public final static int CONNECT_REGISTRATION_WRONG_PIN = ConnectConstants.ConnectIdTaskIdOffset + 39; + + public final static int CONNECT_USER_DEACTIVATE_CONFIRMATION = ConnectConstants.ConnectIdTaskIdOffset + 40; + public final static int CONNECT_VERIFY_USER_DEACTIVATE = ConnectConstants.ConnectIdTaskIdOffset + 41; + public final static int CONNECT_USER_DEACTIVATE_SUCCESS = ConnectConstants.ConnectIdTaskIdOffset + 42; } diff --git a/app/src/org/commcare/connect/network/ApiConnectId.java b/app/src/org/commcare/connect/network/ApiConnectId.java index 40414e4954..f330c39316 100644 --- a/app/src/org/commcare/connect/network/ApiConnectId.java +++ b/app/src/org/commcare/connect/network/ApiConnectId.java @@ -398,4 +398,30 @@ public static boolean confirmVerificationOtpSecondary(Context context, String us return ConnectNetworkHelper.post(context, context.getString(urlId), API_VERSION_CONNECT_ID, authInfo, params, false, false, callback); } + + public static boolean requestInitiateAccountDeactivation(Context context, String phone,String secretKey, IApiCallback callback) { + int urlId = R.string.ConnectInitiateUserAccountDeactivationURL; + AuthInfo authInfo = new AuthInfo.NoAuth(); + + HashMap params = new HashMap<>(); + params.put("secret_key", secretKey); + params.put("phone_number", phone); + + return ConnectNetworkHelper.post(context, context.getString(urlId), + API_VERSION_CONNECT_ID, authInfo, params, false, false, callback); + } + + public static boolean confirmUserDeactivation(Context context, String phone, String secret, + String token, IApiCallback callback) { + int urlId = R.string.ConnectConfirmUserAccountDeactivationURL; + AuthInfo authInfo = new AuthInfo.NoAuth(); + + HashMap params = new HashMap<>(); + params.put("phone_number", phone); + params.put("secret_key", secret); + params.put("token", token); + + return ConnectNetworkHelper.post(context, context.getString(urlId), + API_VERSION_CONNECT_ID, authInfo, params, false, false, callback); + } } diff --git a/app/src/org/commcare/fragments/connectId/ConnectIDSecondaryPhoneNumber.java b/app/src/org/commcare/fragments/connectId/ConnectIDSecondaryPhoneNumber.java index 3b17fe303e..1f9edc2cbf 100644 --- a/app/src/org/commcare/fragments/connectId/ConnectIDSecondaryPhoneNumber.java +++ b/app/src/org/commcare/fragments/connectId/ConnectIDSecondaryPhoneNumber.java @@ -59,7 +59,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, existingPhone = ConnectIDSecondaryPhoneNumberArgs.fromBundle(getArguments()).getPhone(); callingClass = ConnectIDSecondaryPhoneNumberArgs.fromBundle(getArguments()).getCallingClass(); } - String code= "+"+String.valueOf(PhoneNumberHelper.getCountryCode(requireActivity())); + String code = "+" + String.valueOf(PhoneNumberHelper.getCountryCode(requireActivity())); binding.countryCode.setText(code); binding.countryCode.addTextChangedListener(new TextWatcher() { @Override @@ -165,6 +165,7 @@ public void processOldApiError() { if (isBusy) { Toast.makeText(getContext(), R.string.busy_message, Toast.LENGTH_SHORT).show(); } + } else { finish(true, phone); } @@ -187,15 +188,15 @@ public void finish(boolean success, String phone) { } case ConnectConstants.CONNECT_UNLOCK_ALT_PHONE_CHANGE -> { directions = ConnectIDSecondaryPhoneNumberDirections.actionConnectidSecondaryPhoneFragmentToConnectidPhoneVerify(ConnectConstants.CONNECT_UNLOCK_VERIFY_ALT_PHONE, String.format(Locale.getDefault(), "%d", - ConnectIdPhoneVerificationFragmnet.MethodVerifyAlternate), null, user.getUserId(), user.getPassword(), null).setAllowChange(false); + ConnectIdPhoneVerificationFragmnet.MethodVerifyAlternate), null, user.getUserId(), user.getPassword(), null,false).setAllowChange(false); } case ConnectConstants.CONNECT_VERIFY_ALT_PHONE_CHANGE -> { if (success) { directions = ConnectIDSecondaryPhoneNumberDirections.actionConnectidSecondaryPhoneFragmentToConnectidPhoneVerify(ConnectConstants.CONNECT_VERIFY_ALT_PHONE, String.format(Locale.getDefault(), "%d", - ConnectIdPhoneVerificationFragmnet.MethodVerifyAlternate), null, user.getUserId(), user.getPassword(), null).setAllowChange(false); + ConnectIdPhoneVerificationFragmnet.MethodVerifyAlternate), null, user.getUserId(), user.getPassword(), null,false).setAllowChange(false); } else { - directions = ConnectIDSecondaryPhoneNumberDirections.actionConnectidSecondaryPhoneFragmentToConnectidMessage(getString(R.string.connect_recovery_alt_title), getString(R.string.connect_recovery_alt_message), ConnectConstants.CONNECT_VERIFY_ALT_PHONE_MESSAGE, getString(R.string.connect_password_fail_button), getString(R.string.connect_recovery_alt_change_button)); + directions = ConnectIDSecondaryPhoneNumberDirections.actionConnectidSecondaryPhoneFragmentToConnectidMessage(getString(R.string.connect_recovery_alt_title), getString(R.string.connect_recovery_alt_message), ConnectConstants.CONNECT_VERIFY_ALT_PHONE_MESSAGE, getString(R.string.connect_password_fail_button), getString(R.string.connect_recovery_alt_change_button), null, null); } } diff --git a/app/src/org/commcare/fragments/connectId/ConnectIDSignupFragment.java b/app/src/org/commcare/fragments/connectId/ConnectIDSignupFragment.java index d3d5c01321..d3c3ea82f9 100644 --- a/app/src/org/commcare/fragments/connectId/ConnectIDSignupFragment.java +++ b/app/src/org/commcare/fragments/connectId/ConnectIDSignupFragment.java @@ -1,36 +1,27 @@ package org.commcare.fragments.connectId; import android.app.Activity; -import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.os.Bundle; - -import androidx.activity.result.contract.ActivityResultContracts; -import androidx.databinding.adapters.TextViewBindingAdapter; -import androidx.fragment.app.Fragment; -import androidx.navigation.NavDirections; -import androidx.navigation.Navigation; import android.text.Editable; import android.text.TextWatcher; import android.text.method.LinkMovementMethod; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.Toast; - -import com.google.android.gms.auth.api.identity.GetPhoneNumberHintIntentRequest; -import com.google.android.gms.auth.api.identity.Identity; -import com.google.android.gms.common.api.ApiException; -import com.google.android.gms.tasks.OnSuccessListener; +import androidx.activity.result.contract.ActivityResultContracts; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.navigation.NavDirections; import androidx.navigation.Navigation; +import com.google.android.gms.auth.api.identity.Identity; +import com.google.android.gms.common.api.ApiException; + import org.commcare.activities.connect.ConnectIdActivity; import org.commcare.android.database.connect.models.ConnectUserRecord; import org.commcare.connect.ConnectConstants; diff --git a/app/src/org/commcare/fragments/connectId/ConnectIdBiometricConfigFragment.java b/app/src/org/commcare/fragments/connectId/ConnectIdBiometricConfigFragment.java index 7eabf642ef..541c77e366 100644 --- a/app/src/org/commcare/fragments/connectId/ConnectIdBiometricConfigFragment.java +++ b/app/src/org/commcare/fragments/connectId/ConnectIdBiometricConfigFragment.java @@ -272,16 +272,16 @@ public void finish(boolean success, boolean failedEnrollment) { switch (callingActivity) { case ConnectConstants.CONNECT_REGISTRATION_CONFIGURE_BIOMETRICS -> { if (success) { - directions = failedEnrollment || !configured ? ConnectIdBiometricConfigFragmentDirections.actionConnectidBiometricConfigToConnectidMessage(getResources().getString(R.string.connect_biometric_enroll_fail_title), getResources().getString(R.string.connect_biometric_enroll_fail_message), ConnectConstants.CONNECT_BIOMETRIC_ENROLL_FAIL, getResources().getString(R.string.connect_biometric_enroll_fail_button), null) : + directions = failedEnrollment || !configured ? ConnectIdBiometricConfigFragmentDirections.actionConnectidBiometricConfigToConnectidMessage(getResources().getString(R.string.connect_biometric_enroll_fail_title), getResources().getString(R.string.connect_biometric_enroll_fail_message), ConnectConstants.CONNECT_BIOMETRIC_ENROLL_FAIL, getResources().getString(R.string.connect_biometric_enroll_fail_button), null, null, null) : ConnectIdBiometricConfigFragmentDirections.actionConnectidBiometricConfigToConnectidPhoneVerify(ConnectConstants.CONNECT_REGISTRATION_VERIFY_PRIMARY_PHONE, String.format(Locale.getDefault(), "%d", - ConnectManager.MethodRegistrationPrimary), user.getPrimaryPhone(), user.getUserId(), user.getPassword(), user.getAlternatePhone()).setAllowChange(true); + ConnectManager.MethodRegistrationPrimary), user.getPrimaryPhone(), user.getUserId(), user.getPassword(), user.getAlternatePhone(),false).setAllowChange(true); } } case ConnectConstants.CONNECT_RECOVERY_CONFIGURE_BIOMETRICS -> { if (success) { directions = ConnectIdBiometricConfigFragmentDirections.actionConnectidBiometricConfigToConnectidPhoneVerify(ConnectConstants.CONNECT_RECOVERY_VERIFY_PRIMARY_PHONE, String.format(Locale.getDefault(), "%d", - ConnectManager.MethodRecoveryPrimary), ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverPhone, "", null).setAllowChange(false); + ConnectManager.MethodRecoveryPrimary), ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverPhone, "", null,false).setAllowChange(false); } } case ConnectConstants.CONNECT_UNLOCK_BIOMETRIC -> { diff --git a/app/src/org/commcare/fragments/connectId/ConnectIdMessageFragment.java b/app/src/org/commcare/fragments/connectId/ConnectIdMessageFragment.java index fcf24bf042..f9ca332eef 100644 --- a/app/src/org/commcare/fragments/connectId/ConnectIdMessageFragment.java +++ b/app/src/org/commcare/fragments/connectId/ConnectIdMessageFragment.java @@ -21,7 +21,6 @@ import org.commcare.connect.ConnectManager; import org.commcare.dalvik.R; import org.commcare.dalvik.databinding.ScreenConnectMessageBinding; - import java.util.Locale; /** @@ -34,6 +33,8 @@ public class ConnectIdMessageFragment extends BottomSheetDialogFragment { private String message; private String buttonText; private String button2Text; + private String userName; + private String password; private int callingClass; private ScreenConnectMessageBinding binding; @@ -63,9 +64,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, message = ConnectIdMessageFragmentArgs.fromBundle(getArguments()).getMessage(); buttonText = ConnectIdMessageFragmentArgs.fromBundle(getArguments()).getButtonText(); callingClass = ConnectIdMessageFragmentArgs.fromBundle(getArguments()).getCallingClass(); + userName = ConnectIdMessageFragmentArgs.fromBundle(getArguments()).getPhone(); + password = ConnectIdMessageFragmentArgs.fromBundle(getArguments()).getPassword(); if (ConnectIdMessageFragmentArgs.fromBundle(getArguments()).getButton2Text() != null && !ConnectIdMessageFragmentArgs.fromBundle(getArguments()).getButton2Text().isEmpty()) { button2Text = ConnectIdMessageFragmentArgs.fromBundle(getArguments()).getButton2Text(); - } return view; } @@ -108,12 +110,16 @@ public void finish(boolean success, boolean secondButton) { case ConnectConstants.CONNECT_RECOVERY_ALT_PHONE_MESSAGE: if (success) { if (secondButton) { - directions = ConnectIdMessageFragmentDirections.actionConnectidMessageToConnectidPin(ConnectConstants.CONNECT_RECOVERY_VERIFY_PIN, ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverSecret).setRecover(true).setChange(false); - + directions = ConnectIdMessageFragmentDirections.actionConnectidMessageSelf(getString(R.string.connect_deactivate_account), getString(R.string.connect_deactivate_account_message), ConnectConstants.CONNECT_USER_DEACTIVATE_CONFIRMATION, getString(R.string.connect_deactivate_account_delete), getString(R.string.connect_deactivate_account_go_back), userName, password); } else { - directions = ConnectIdMessageFragmentDirections.actionConnectidMessageToConnectidPhoneVerify(ConnectConstants.CONNECT_RECOVERY_VERIFY_ALT_PHONE, String.format(Locale.getDefault(), "%d", - ConnectIdPhoneVerificationFragmnet.MethodRecoveryAlternate), null, ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverSecret, ConnectIdActivity.recoveryAltPhone).setAllowChange(false); - + directions = ConnectIdMessageFragmentDirections.actionConnectidMessageToConnectidPhoneVerify( + ConnectConstants.CONNECT_RECOVERY_VERIFY_ALT_PHONE, + String.format(Locale.getDefault(), "%d", ConnectIdPhoneVerificationFragmnet.MethodRecoveryAlternate), null, + ConnectIdActivity.recoverPhone, + ConnectIdActivity.recoverSecret, + ConnectIdActivity.recoveryAltPhone, + true + ).setAllowChange(false); } } break; @@ -133,13 +139,13 @@ public void finish(boolean success, boolean secondButton) { case ConnectConstants.CONNECT_RECOVERY_VERIFY_PASSWORD: if (success) { if (ConnectIdActivity.forgotPassword) { - directions = ConnectIdMessageFragmentDirections.actionConnectidMessageSelf(getString(R.string.connect_recovery_alt_title), getString(R.string.connect_recovery_alt_message), ConnectConstants.CONNECT_RECOVERY_ALT_PHONE_MESSAGE, getString(R.string.connect_recovery_alt_button), null); + directions = ConnectIdMessageFragmentDirections.actionConnectidMessageSelf(getString(R.string.connect_recovery_alt_title), getString(R.string.connect_recovery_alt_message), ConnectConstants.CONNECT_RECOVERY_ALT_PHONE_MESSAGE, getString(R.string.connect_recovery_alt_button), null, userName, password); } else { directions = ConnectIdMessageFragmentDirections.actionConnectidMessageToConnectidPin(ConnectConstants.CONNECT_RECOVERY_CHANGE_PIN, ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverSecret).setRecover(true).setChange(true); } } else { directions = ConnectIdMessageFragmentDirections.actionConnectidMessageToConnectidPhoneVerify(ConnectConstants.CONNECT_RECOVERY_VERIFY_PRIMARY_PHONE, String.format(Locale.getDefault(), "%d", - ConnectIdPhoneVerificationFragmnet.MethodRecoveryPrimary), ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverPhone, null, null).setAllowChange(false); + ConnectIdPhoneVerificationFragmnet.MethodRecoveryPrimary), ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverPhone, null, null,false).setAllowChange(false); } case ConnectConstants.CONNECT_UNLOCK_ALT_PHONE_MESSAGE: if (success) { @@ -147,7 +153,7 @@ public void finish(boolean success, boolean secondButton) { directions = ConnectIdMessageFragmentDirections.actionConnectidMessageToConnectidSecondaryPhoneFragment(ConnectConstants.CONNECT_UNLOCK_ALT_PHONE_CHANGE, ConnectConstants.METHOD_CHANGE_ALTERNATE, null); } else { directions = ConnectIdMessageFragmentDirections.actionConnectidMessageToConnectidPhoneVerify(ConnectConstants.CONNECT_UNLOCK_VERIFY_ALT_PHONE, String.format(Locale.getDefault(), "%d", - ConnectIdPhoneVerificationFragmnet.MethodVerifyAlternate), null, user.getUserId(), user.getPassword(), null).setAllowChange(false); + ConnectIdPhoneVerificationFragmnet.MethodVerifyAlternate), null, user.getUserId(), user.getPassword(), null,false).setAllowChange(false); } } break; @@ -156,7 +162,7 @@ public void finish(boolean success, boolean secondButton) { if (success) { if (ConnectManager.getFailureAttempt() > 2) { directions = ConnectIdMessageFragmentDirections.actionConnectidMessageToConnectidPhoneVerify(ConnectConstants.CONNECT_RECOVERY_VERIFY_ALT_PHONE, String.format(Locale.getDefault(), "%d", - ConnectIdPhoneVerificationFragmnet.MethodRecoveryAlternate), null, ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverSecret, ConnectIdActivity.recoveryAltPhone).setAllowChange(false); + ConnectIdPhoneVerificationFragmnet.MethodRecoveryAlternate), null, ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverSecret, ConnectIdActivity.recoveryAltPhone,false).setAllowChange(false); ConnectManager.setFailureAttempt(0); } else { directions = ConnectIdMessageFragmentDirections.actionConnectidMessageToConnectidPin(ConnectConstants.CONNECT_RECOVERY_VERIFY_PIN, ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverSecret).setChange(false).setRecover(true); @@ -167,7 +173,6 @@ public void finish(boolean success, boolean secondButton) { if (success) { if (ConnectManager.getFailureAttempt() > 2) { directions = ConnectIdMessageFragmentDirections.actionConnectidMessageToConnectidPin(ConnectConstants.CONNECT_REGISTRATION_CHANGE_PIN, user.getPrimaryPhone(), "").setChange(true).setRecover(false); - } else { directions = ConnectIdMessageFragmentDirections.actionConnectidMessageToConnectidPin(ConnectConstants.CONNECT_REGISTRATION_CONFIRM_PIN, user.getPrimaryPhone(), "").setChange(false).setRecover(false); } @@ -179,7 +184,30 @@ public void finish(boolean success, boolean secondButton) { directions = ConnectIdMessageFragmentDirections.actionConnectidMessageToConnectidPhone(ConnectConstants.METHOD_CHANGE_ALTERNATE, user.getAlternatePhone(), ConnectConstants.CONNECT_VERIFY_ALT_PHONE_CHANGE); } else { directions = ConnectIdMessageFragmentDirections.actionConnectidMessageToConnectidPhoneVerify(ConnectConstants.CONNECT_VERIFY_ALT_PHONE, String.format(Locale.getDefault(), "%d", - ConnectIdPhoneVerificationFragmnet.MethodVerifyAlternate), null, user.getUserId(), user.getPassword(), null).setAllowChange(false); + ConnectIdPhoneVerificationFragmnet.MethodVerifyAlternate), null, user.getUserId(), user.getPassword(), null,false).setAllowChange(false); + } + } + break; + case ConnectConstants.CONNECT_USER_DEACTIVATE_CONFIRMATION: + if (success) { + if (!secondButton) { + directions = ConnectIdMessageFragmentDirections.actionConnectidMessageToConnectidPhoneVerify( + ConnectConstants.CONNECT_VERIFY_USER_DEACTIVATE, + String.format(Locale.getDefault(), "%d", ConnectIdPhoneVerificationFragmnet.MethodUserDeactivate), + null, + userName, + password, + null,false).setAllowChange(false); + } else { + NavHostFragment.findNavController(this).popBackStack(); + } + } + break; + case ConnectConstants.CONNECT_USER_DEACTIVATE_SUCCESS: + if (success) { + if (!secondButton) { + ConnectDatabaseHelper.forgetUser(requireActivity()); + requireActivity().finish(); } } break; @@ -190,6 +218,4 @@ public void finish(boolean success, boolean secondButton) { } } } - - } \ No newline at end of file diff --git a/app/src/org/commcare/fragments/connectId/ConnectIdPasswordVerificationFragment.java b/app/src/org/commcare/fragments/connectId/ConnectIdPasswordVerificationFragment.java index 862d4d5dd6..3c736eab8f 100644 --- a/app/src/org/commcare/fragments/connectId/ConnectIdPasswordVerificationFragment.java +++ b/app/src/org/commcare/fragments/connectId/ConnectIdPasswordVerificationFragment.java @@ -58,6 +58,7 @@ public static ConnectIdPasswordVerificationFragment newInstance() { return fragment; } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -92,11 +93,11 @@ public void finish(boolean success, boolean forgot) { if (success) { directions = ConnectIdPasswordVerificationFragmentDirections.actionConnectidPasswordToConnectidPin(ConnectConstants.CONNECT_RECOVERY_CHANGE_PIN, ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverSecret).setChange(true).setRecover(true); if (forgot) { - directions = ConnectIdPasswordVerificationFragmentDirections.actionConnectidPasswordToConnectidMessage(getString(R.string.connect_recovery_alt_title), getString(R.string.connect_recovery_alt_message), ConnectConstants.CONNECT_RECOVERY_ALT_PHONE_MESSAGE, getString(R.string.connect_recovery_alt_button), null); + directions = ConnectIdPasswordVerificationFragmentDirections.actionConnectidPasswordToConnectidMessage(getString(R.string.connect_recovery_alt_title), getString(R.string.connect_recovery_alt_message), ConnectConstants.CONNECT_RECOVERY_ALT_PHONE_MESSAGE, getString(R.string.connect_recovery_alt_button), getString(R.string.connect_deactivate_account), phone, secretKey); } } else { directions = ConnectIdPasswordVerificationFragmentDirections.actionConnectidPasswordToConnectidPhoneVerify(ConnectConstants.CONNECT_RECOVERY_VERIFY_PRIMARY_PHONE, String.format(Locale.getDefault(), "%d", - ConnectIdPhoneVerificationFragmnet.MethodRecoveryPrimary), ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverPhone, "", null).setAllowChange(false); + ConnectIdPhoneVerificationFragmnet.MethodRecoveryPrimary), ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverPhone, "", null,false).setAllowChange(false); } break; case ConnectConstants.CONNECT_UNLOCK_PASSWORD: @@ -111,7 +112,7 @@ public void finish(boolean success, boolean forgot) { user.setLastPinDate(new Date()); ConnectDatabaseHelper.storeUser(requireActivity(), user); if (user.shouldRequireSecondaryPhoneVerification()) { - directions = ConnectIdPasswordVerificationFragmentDirections.actionConnectidPasswordToConnectidMessage(getString(R.string.connect_recovery_alt_title), getString(R.string.connect_recovery_alt_message), ConnectConstants.CONNECT_UNLOCK_ALT_PHONE_MESSAGE, getString(R.string.connect_password_fail_button), getString(R.string.connect_recovery_alt_change_button)); + directions = ConnectIdPasswordVerificationFragmentDirections.actionConnectidPasswordToConnectidMessage(getString(R.string.connect_recovery_alt_title), getString(R.string.connect_recovery_alt_message), ConnectConstants.CONNECT_UNLOCK_ALT_PHONE_MESSAGE, getString(R.string.connect_password_fail_button), getString(R.string.connect_recovery_alt_change_button), phone, secretKey); } else { ConnectManager.setStatus(ConnectManager.ConnectIdStatus.LoggedIn); ConnectDatabaseHelper.setRegistrationPhase(getActivity(), ConnectConstants.CONNECT_NO_ACTIVITY); @@ -139,7 +140,7 @@ public void handleWrongPassword() { requestCode = PASSWORD_LOCK; message = R.string.connect_password_recovery_message; } - NavDirections directions = ConnectIdPasswordVerificationFragmentDirections.actionConnectidPasswordToConnectidMessage(getString(R.string.connect_password_fail_title), getString(message), ConnectConstants.CONNECT_RECOVERY_VERIFY_PASSWORD, getString(R.string.connect_recovery_success_button), null); + NavDirections directions = ConnectIdPasswordVerificationFragmentDirections.actionConnectidPasswordToConnectidMessage(getString(R.string.connect_password_fail_title), getString(message), ConnectConstants.CONNECT_RECOVERY_VERIFY_PASSWORD, getString(R.string.connect_recovery_success_button), null, phone, secretKey); Navigation.findNavController(binding.connectPasswordVerifyButton).navigate(directions); diff --git a/app/src/org/commcare/fragments/connectId/ConnectIdPhoneAvailableBottomSheet.java b/app/src/org/commcare/fragments/connectId/ConnectIdPhoneAvailableBottomSheet.java index 14fbaae943..1723be0d1b 100644 --- a/app/src/org/commcare/fragments/connectId/ConnectIdPhoneAvailableBottomSheet.java +++ b/app/src/org/commcare/fragments/connectId/ConnectIdPhoneAvailableBottomSheet.java @@ -5,6 +5,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; +import android.widget.TextView; import androidx.navigation.NavDirections; import androidx.navigation.fragment.NavHostFragment; @@ -18,7 +19,7 @@ public class ConnectIdPhoneAvailableBottomSheet extends BottomSheetDialogFragment { - ConnectMediumTextView phoneTextView; + TextView phoneTextView; Button recover; Button back; String phoneNumber; @@ -46,7 +47,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, View view = inflater.inflate(R.layout.fragment_phone_available_bottom_sheet, container, false); back = (Button) view.findViewById(R.id.back_button); recover = (Button) view.findViewById(R.id.recover_button); - phoneTextView = (ConnectMediumTextView) view.findViewById(R.id.phone_number); + phoneTextView = (TextView) view.findViewById(R.id.phone_number); if (getArguments() != null) { phoneNumber = ConnectIdPhoneAvailableBottomSheetArgs.fromBundle(getArguments()).getPhone(); } diff --git a/app/src/org/commcare/fragments/connectId/ConnectIdPhoneFragment.java b/app/src/org/commcare/fragments/connectId/ConnectIdPhoneFragment.java index 0391623130..b251f6f239 100644 --- a/app/src/org/commcare/fragments/connectId/ConnectIdPhoneFragment.java +++ b/app/src/org/commcare/fragments/connectId/ConnectIdPhoneFragment.java @@ -1,8 +1,6 @@ package org.commcare.fragments.connectId; import android.app.Activity; -import android.app.PendingIntent; - import android.content.Intent; import android.os.Bundle; import android.text.Editable; @@ -12,18 +10,16 @@ import android.view.ViewGroup; import android.widget.Toast; - -import com.google.android.gms.auth.api.identity.GetPhoneNumberHintIntentRequest; -import com.google.android.gms.auth.api.identity.Identity; -import com.google.android.gms.common.api.ApiException; -import com.google.android.gms.tasks.OnSuccessListener; - +import androidx.activity.result.contract.ActivityResultContracts; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.navigation.NavDirections; import androidx.navigation.Navigation; +import com.google.android.gms.auth.api.identity.Identity; +import com.google.android.gms.common.api.ApiException; + import org.commcare.activities.connect.ConnectIdActivity; import org.commcare.android.database.connect.models.ConnectUserRecord; import org.commcare.connect.ConnectConstants; @@ -42,14 +38,6 @@ import java.io.InputStream; import java.util.Locale; - -import androidx.activity.result.contract.ActivityResultContracts; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; -import androidx.navigation.NavDirections; -import androidx.navigation.Navigation; - /** * A simple {@link Fragment} subclass. * Use the {@link ConnectIdPhoneFragment#newInstance} factory method to @@ -187,7 +175,7 @@ public void finish(boolean success, String phone) { ConnectDatabaseHelper.setRegistrationPhase(getActivity(), ConnectConstants.CONNECT_REGISTRATION_VERIFY_PRIMARY_PHONE); } directions = ConnectIdPhoneFragmentDirections.actionConnectidPhoneNoToConnectidPhoneVerify(ConnectConstants.CONNECT_REGISTRATION_VERIFY_PRIMARY_PHONE, String.format(Locale.getDefault(), "%d", - ConnectIdPhoneVerificationFragmnet.MethodRegistrationPrimary), phone, user.getUserId(), user.getPassword(), null).setAllowChange(true); + ConnectIdPhoneVerificationFragmnet.MethodRegistrationPrimary), phone, user.getUserId(), user.getPassword(), null,false).setAllowChange(true); } case ConnectConstants.CONNECT_RECOVERY_PRIMARY_PHONE -> { if (success) { @@ -197,15 +185,15 @@ public void finish(boolean success, String phone) { } case ConnectConstants.CONNECT_UNLOCK_ALT_PHONE_CHANGE -> { directions = ConnectIdPhoneFragmentDirections.actionConnectidPhoneNoToConnectidPhoneVerify(ConnectConstants.CONNECT_UNLOCK_VERIFY_ALT_PHONE, String.format(Locale.getDefault(), "%d", - ConnectIdPhoneVerificationFragmnet.MethodVerifyAlternate), null, user.getUserId(), user.getPassword(), null).setAllowChange(false); + ConnectIdPhoneVerificationFragmnet.MethodVerifyAlternate), null, user.getUserId(), user.getPassword(), null,false).setAllowChange(false); } case ConnectConstants.CONNECT_VERIFY_ALT_PHONE_CHANGE -> { if (success) { directions = ConnectIdPhoneFragmentDirections.actionConnectidPhoneNoToConnectidPhoneVerify(ConnectConstants.CONNECT_VERIFY_ALT_PHONE, String.format(Locale.getDefault(), "%d", - ConnectIdPhoneVerificationFragmnet.MethodVerifyAlternate), null, user.getUserId(), user.getPassword(), null).setAllowChange(false); + ConnectIdPhoneVerificationFragmnet.MethodVerifyAlternate), null, user.getUserId(), user.getPassword(), null,false).setAllowChange(false); } else { - directions = ConnectIdPhoneFragmentDirections.actionConnectidPhoneNoToConnectidMessage(getString(R.string.connect_recovery_alt_title), getString(R.string.connect_recovery_alt_message), ConnectConstants.CONNECT_VERIFY_ALT_PHONE_MESSAGE, getString(R.string.connect_password_fail_button), getString(R.string.connect_recovery_alt_change_button)); + directions = ConnectIdPhoneFragmentDirections.actionConnectidPhoneNoToConnectidMessage(getString(R.string.connect_recovery_alt_title), getString(R.string.connect_recovery_alt_message), ConnectConstants.CONNECT_VERIFY_ALT_PHONE_MESSAGE, getString(R.string.connect_password_fail_button), getString(R.string.connect_recovery_alt_change_button), null, null); } } diff --git a/app/src/org/commcare/fragments/connectId/ConnectIdPhoneVerificationFragmnet.java b/app/src/org/commcare/fragments/connectId/ConnectIdPhoneVerificationFragmnet.java index 07b932ace7..7e6a6ba5e0 100644 --- a/app/src/org/commcare/fragments/connectId/ConnectIdPhoneVerificationFragmnet.java +++ b/app/src/org/commcare/fragments/connectId/ConnectIdPhoneVerificationFragmnet.java @@ -2,13 +2,16 @@ import static android.app.Activity.RESULT_OK; +import android.app.AlertDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.graphics.Color; import android.os.Bundle; import android.os.Handler; import android.text.Editable; +import android.text.InputType; import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.View; @@ -61,12 +64,14 @@ public class ConnectIdPhoneVerificationFragmnet extends Fragment { public static final int MethodRecoveryPrimary = 2; public static final int MethodRecoveryAlternate = 3; public static final int MethodVerifyAlternate = 4; + public static final int MethodUserDeactivate = 5; public static final int REQ_USER_CONSENT = 200; private int method; private String primaryPhone; private String username; private String password; private String recoveryPhone; + private boolean deactivateButton; private boolean allowChange; private int callingClass; private SMSBroadcastReceiver smsBroadcastReceiver; @@ -138,8 +143,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, password = ConnectIdPhoneVerificationFragmnetArgs.fromBundle(getArguments()).getPassword(); recoveryPhone = ConnectIdPhoneVerificationFragmnetArgs.fromBundle(getArguments()).getSecondaryPhone(); callingClass = ConnectIdPhoneVerificationFragmnetArgs.fromBundle(getArguments()).getCallingClass(); + deactivateButton = ConnectIdPhoneVerificationFragmnetArgs.fromBundle(getArguments()).getDeactivateButton(); } + handleDeactivateButton(); + + handleKeyboardType(); + updateMessage(); requestSmsCode(); @@ -149,6 +159,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, binding.connectPhoneVerifyResend.setOnClickListener(arg0 -> requestSmsCode()); binding.connectPhoneVerifyChange.setOnClickListener(arg0 -> changeNumber()); binding.connectPhoneVerifyButton.setOnClickListener(arg0 -> verifySmsCode()); + binding.connectDeactivateButton.setOnClickListener(arg0 -> showYesNoDialog()); binding.connectPhoneVerifyCode.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { @@ -165,14 +176,21 @@ public void afterTextChanged(Editable s) { } }); + return view; + } + private void handleDeactivateButton() { + binding.connectDeactivateButton.setVisibility(!deactivateButton ? View.GONE : View.VISIBLE); + } - return view; + private void handleKeyboardType() { + int inputType = (method == MethodUserDeactivate) ? InputType.TYPE_CLASS_TEXT : InputType.TYPE_CLASS_PHONE; + binding.connectPhoneVerifyCode.setInputType(inputType); } + private void buttonEnabled(String code) { binding.connectPhoneVerifyButton.setEnabled(!code.isEmpty() && code.length() > 5); -// binding.connectPhoneVerifyButton.setBackgroundColor(!code.isEmpty() && code.length() > 5 ? getResources().getColor(R.color.connect_blue_color) : Color.GRAY); } @Override @@ -352,6 +370,9 @@ public void processOldApiError() { case MethodVerifyAlternate -> { isBusy = !ApiConnectId.requestVerificationOtpSecondary(requireActivity(), username, password, callback); } + case MethodUserDeactivate -> { + isBusy = !ApiConnectId.requestInitiateAccountDeactivation(requireActivity(), username, password, callback); + } default -> { isBusy = !ApiConnectId.requestRegistrationOtpPrimary(requireActivity(), username, password, callback); } @@ -376,7 +397,7 @@ public void processSuccess(int responseCode, InputStream responseData) { try { switch (method) { - case MethodRegistrationPrimary -> { + case MethodRegistrationPrimary, MethodUserDeactivate -> { finish(true, false, null); } case MethodVerifyAlternate -> { @@ -456,6 +477,9 @@ public void processOldApiError() { case MethodVerifyAlternate -> { isBusy = !ApiConnectId.confirmVerificationOtpSecondary(requireActivity(), username, password, token, callback); } + case MethodUserDeactivate -> { + isBusy = !ApiConnectId.confirmUserDeactivation(requireActivity(), username, password, token, callback); + } default -> { isBusy = !ApiConnectId.confirmRegistrationOtpPrimary(requireActivity(), username, password, token, callback); } @@ -526,11 +550,10 @@ public void finish(boolean success, boolean changeNumber, String secondaryPhone) case ConnectConstants.CONNECT_REGISTRATION_VERIFY_PRIMARY_PHONE -> { if (success) { if (changeNumber) { -// Navigation.findNavController(binding.connectPhoneVerifyButton).popBackStack(); +// Navigation.findNavController(binding.connectPhoneVerifyButton).popBackStack(); directions = ConnectIdPhoneVerificationFragmnetDirections.actionConnectidPhoneVerifyToConnectidPhoneNo(ConnectConstants.METHOD_CHANGE_PRIMARY, primaryPhone, ConnectConstants.CONNECT_REGISTRATION_CHANGE_PRIMARY_PHONE); } else { directions = ConnectIdPhoneVerificationFragmnetDirections.actionConnectidPhoneVerifyToConnectidPin(ConnectConstants.CONNECT_REGISTRATION_CONFIGURE_PIN, user.getPrimaryPhone(), password).setRecover(false).setChange(true); - } } else { directions = ConnectIdPhoneVerificationFragmnetDirections.actionConnectidPhoneVerifyToConnectidBiometricConfig(ConnectConstants.CONNECT_REGISTRATION_CONFIGURE_BIOMETRICS); @@ -543,22 +566,25 @@ public void finish(boolean success, boolean changeNumber, String secondaryPhone) directions = ConnectIdPhoneVerificationFragmnetDirections.actionConnectidPhoneVerifyToConnectidPin(ConnectConstants.CONNECT_RECOVERY_VERIFY_PIN, ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverSecret).setRecover(true).setChange(false); if (ConnectIdActivity.forgotPin) { if (ConnectIdActivity.forgotPassword) { - directions = ConnectIdPhoneVerificationFragmnetDirections.actionConnectidPhoneVerifyToConnectidMessage(getString(R.string.connect_recovery_alt_title), getString(R.string.connect_recovery_alt_message), ConnectConstants.CONNECT_RECOVERY_ALT_PHONE_MESSAGE, getString(R.string.connect_recovery_alt_button), null); + directions = ConnectIdPhoneVerificationFragmnetDirections.actionConnectidPhoneVerifyToConnectidMessage(getString(R.string.connect_recovery_alt_title), getString(R.string.connect_recovery_alt_message), ConnectConstants.CONNECT_RECOVERY_ALT_PHONE_MESSAGE, getString(R.string.connect_recovery_alt_button), null, username, password); } else { directions = ConnectIdPhoneVerificationFragmnetDirections.actionConnectidPhoneVerifyToConnectidPassword(ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverSecret, ConnectConstants.CONNECT_RECOVERY_VERIFY_PASSWORD); - } } } } case ConnectConstants.CONNECT_RECOVERY_VERIFY_ALT_PHONE -> { if (success) { - directions = ConnectIdPhoneVerificationFragmnetDirections.actionConnectidPhoneVerifyToConnectidPin(ConnectConstants.CONNECT_RECOVERY_CHANGE_PIN, ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverSecret).setRecover(true).setChange(true); - + if (!deactivateButton) { + directions = ConnectIdPhoneVerificationFragmnetDirections.actionConnectidPhoneVerifyToConnectidPin(ConnectConstants.CONNECT_RECOVERY_CHANGE_PIN, ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverSecret).setRecover(true).setChange(true); + } else { + directions = ConnectIdPhoneVerificationFragmnetDirections.actionConnectidPhoneVerifySelf(ConnectConstants.CONNECT_VERIFY_USER_DEACTIVATE, String.format(Locale.getDefault(), "%d", + ConnectIdPhoneVerificationFragmnet.MethodUserDeactivate), ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverPhone, password, "", false).setAllowChange(false); + } } else { directions = ConnectIdPhoneVerificationFragmnetDirections.actionConnectidPhoneVerifySelf(ConnectConstants.CONNECT_RECOVERY_VERIFY_PRIMARY_PHONE, String.format(Locale.getDefault(), "%d", - ConnectIdPhoneVerificationFragmnet.MethodRecoveryPrimary), ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverPhone, "", "").setAllowChange(false); + ConnectIdPhoneVerificationFragmnet.MethodRecoveryPrimary), ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverPhone, "", "", false).setAllowChange(false); } } case ConnectConstants.CONNECT_VERIFY_ALT_PHONE -> { @@ -568,7 +594,6 @@ public void finish(boolean success, boolean changeNumber, String secondaryPhone) requireActivity().setResult(RESULT_OK); requireActivity().finish(); } - } case ConnectConstants.CONNECT_UNLOCK_VERIFY_ALT_PHONE -> { if (success) { @@ -580,10 +605,29 @@ public void finish(boolean success, boolean changeNumber, String secondaryPhone) requireActivity().finish(); } } + case ConnectConstants.CONNECT_VERIFY_USER_DEACTIVATE -> { + if (success) { + directions = ConnectIdPhoneVerificationFragmnetDirections.actionConnectidPhoneVerifyToConnectidMessage(getString(R.string.connect_deactivate_account), getString(R.string.connect_deactivate_account_deactivated), ConnectConstants.CONNECT_USER_DEACTIVATE_SUCCESS, getString(R.string.connect_deactivate_account_creation), null, username, password); + } + } } if (directions != null) { Navigation.findNavController(binding.connectPhoneVerifyButton).navigate(directions); } } + + public void showYesNoDialog() { + AlertDialog.Builder builder = new AlertDialog.Builder(getContext(),R.style.AlertDialogTheme); + builder.setTitle(R.string.connect_deactivate_dialog_title); + builder.setMessage(R.string.connect_deactivate_dialog_description) + .setPositiveButton(R.string.connect_payment_dialog_yes, (dialog, which) -> { + finish(true, true, null); + dialog.dismiss(); + }) + .setNegativeButton(R.string.connect_payment_dialog_no, (dialog, which) -> dialog.dismiss()) + .setCancelable(false); + AlertDialog alertDialog = builder.create(); + alertDialog.show(); + } } \ No newline at end of file diff --git a/app/src/org/commcare/fragments/connectId/ConnectIdPinFragment.java b/app/src/org/commcare/fragments/connectId/ConnectIdPinFragment.java index 61889e39ed..e7343cca61 100644 --- a/app/src/org/commcare/fragments/connectId/ConnectIdPinFragment.java +++ b/app/src/org/commcare/fragments/connectId/ConnectIdPinFragment.java @@ -155,6 +155,7 @@ public void afterTextChanged(Editable s) { binding.connectPinInput.addTextChangedListener(watcher); binding.connectPinRepeatInput.addTextChangedListener(watcher); + return view; } @@ -371,7 +372,7 @@ public void finish(boolean success, boolean forgot, String pin) { directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidPhoneNo(ConnectConstants.METHOD_RECOVER_PRIMARY, null, ConnectConstants.CONNECT_RECOVERY_PRIMARY_PHONE); } else { if (user.shouldRequireSecondaryPhoneVerification()) { - directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidMessage(getString(R.string.connect_recovery_alt_title), getString(R.string.connect_recovery_alt_message), ConnectConstants.CONNECT_UNLOCK_ALT_PHONE_MESSAGE, getString(R.string.connect_password_fail_button), getString(R.string.connect_recovery_alt_change_button)); + directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidMessage(getString(R.string.connect_recovery_alt_title), getString(R.string.connect_recovery_alt_message), ConnectConstants.CONNECT_UNLOCK_ALT_PHONE_MESSAGE, getString(R.string.connect_password_fail_button), getString(R.string.connect_recovery_alt_change_button), phone, secret); } else { ConnectManager.setStatus(ConnectManager.ConnectIdStatus.LoggedIn); ConnectDatabaseHelper.setRegistrationPhase(getActivity(), ConnectConstants.CONNECT_NO_ACTIVITY); @@ -381,7 +382,7 @@ public void finish(boolean success, boolean forgot, String pin) { } } else { directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidPhoneVerify(ConnectConstants.CONNECT_RECOVERY_VERIFY_PRIMARY_PHONE, String.format(Locale.getDefault(), "%d", - ConnectIdPhoneVerificationFragmnet.MethodRecoveryPrimary), ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverPhone, "", null); + ConnectIdPhoneVerificationFragmnet.MethodRecoveryPrimary), ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverPhone, "", null,false); } } case ConnectConstants.CONNECT_REGISTRATION_CONFIGURE_PIN -> { @@ -396,7 +397,7 @@ public void finish(boolean success, boolean forgot, String pin) { } } else { directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidPhoneVerify(ConnectConstants.CONNECT_REGISTRATION_VERIFY_PRIMARY_PHONE, String.format(Locale.getDefault(), "%d", - ConnectManager.MethodRegistrationPrimary), user.getPrimaryPhone(), user.getUserId(), user.getPassword(), user.getAlternatePhone()).setAllowChange(true); + ConnectManager.MethodRegistrationPrimary), user.getPrimaryPhone(), user.getUserId(), user.getPassword(), user.getAlternatePhone(),false).setAllowChange(true); } } case ConnectConstants.CONNECT_REGISTRATION_CONFIRM_PIN -> { @@ -408,11 +409,11 @@ public void finish(boolean success, boolean forgot, String pin) { } else { ConnectDatabaseHelper.setRegistrationPhase(getActivity(), ConnectConstants.CONNECT_NO_ACTIVITY); - directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidMessage(getString(R.string.connect_register_success_title), getString(R.string.connect_register_success_message), ConnectConstants.CONNECT_REGISTRATION_SUCCESS, getString(R.string.connect_register_success_button), null); + directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidMessage(getString(R.string.connect_register_success_title), getString(R.string.connect_register_success_message), ConnectConstants.CONNECT_REGISTRATION_SUCCESS, getString(R.string.connect_register_success_button), null, phone, secret); } } else { if (!forgot) { - directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidMessage(getString(R.string.connect_pin_fail_title), ConnectManager.getFailureAttempt() > 2 ? getString(R.string.connect_pin_confirm_message) : getString(R.string.connect_pin_fail_message), ConnectConstants.CONNECT_REGISTRATION_WRONG_PIN, getString(R.string.connect_recovery_alt_button), null); + directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidMessage(getString(R.string.connect_pin_fail_title), ConnectManager.getFailureAttempt() > 2 ? getString(R.string.connect_pin_confirm_message) : getString(R.string.connect_pin_fail_message), ConnectConstants.CONNECT_REGISTRATION_WRONG_PIN, getString(R.string.connect_recovery_alt_button), null, phone, secret); } else { directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidSecondaryPhoneFragment(ConnectConstants.CONNECT_REGISTRATION_ALTERNATE_PHONE, ConnectConstants.METHOD_CHANGE_ALTERNATE, ""); } @@ -423,15 +424,15 @@ public void finish(boolean success, boolean forgot, String pin) { ConnectIdActivity.forgotPin = forgot; if (forgot) { if (ConnectIdActivity.forgotPassword) { - directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidMessage(getString(R.string.connect_recovery_alt_title), getString(R.string.connect_recovery_alt_message), ConnectConstants.CONNECT_REGISTRATION_SUCCESS, getString(R.string.connect_recovery_alt_button), null); + directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidMessage(getString(R.string.connect_recovery_alt_title), getString(R.string.connect_recovery_alt_message), ConnectConstants.CONNECT_REGISTRATION_SUCCESS, getString(R.string.connect_recovery_alt_button), null, phone, secret); } else { directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidPassword(ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverSecret, ConnectConstants.CONNECT_RECOVERY_VERIFY_PASSWORD); } } else { - directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidMessage(getString(R.string.connect_recovery_success_title), getString(R.string.connect_recovery_success_message), ConnectConstants.CONNECT_RECOVERY_SUCCESS, getString(R.string.connect_recovery_success_button), null); + directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidMessage(getString(R.string.connect_recovery_success_title), getString(R.string.connect_recovery_success_message), ConnectConstants.CONNECT_RECOVERY_SUCCESS, getString(R.string.connect_recovery_success_button), null, phone, secret); } } else { - directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidMessage(getString(R.string.connect_pin_fail_title), ConnectManager.getFailureAttempt() > 2 ? getString(R.string.connect_pin_recovery_message) : getString(R.string.connect_pin_fail_message), ConnectConstants.CONNECT_RECOVERY_WRONG_PIN, getString(R.string.connect_recovery_alt_button), null); + directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidMessage(getString(R.string.connect_pin_fail_title), ConnectManager.getFailureAttempt() > 2 ? getString(R.string.connect_pin_recovery_message) : getString(R.string.connect_pin_fail_message), ConnectConstants.CONNECT_RECOVERY_WRONG_PIN, getString(R.string.connect_recovery_alt_button), null, phone, secret); } } case ConnectConstants.CONNECT_RECOVERY_CHANGE_PIN -> { @@ -442,11 +443,11 @@ public void finish(boolean success, boolean forgot, String pin) { user.setLastPinDate(new Date()); ConnectDatabaseHelper.storeUser(requireActivity(), user); } - directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidMessage(getString(R.string.connect_recovery_success_title), getString(R.string.connect_recovery_success_message), ConnectConstants.CONNECT_RECOVERY_SUCCESS, getString(R.string.connect_recovery_success_button), null); + directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidMessage(getString(R.string.connect_recovery_success_title), getString(R.string.connect_recovery_success_message), ConnectConstants.CONNECT_RECOVERY_SUCCESS, getString(R.string.connect_recovery_success_button), null, phone, secret); } else { directions = ConnectIdPinFragmentDirections.actionConnectidPinToConnectidPhoneVerify(ConnectConstants.CONNECT_RECOVERY_VERIFY_ALT_PHONE, String.format(Locale.getDefault(), "%d", - ConnectIdPhoneVerificationFragmnet.MethodRecoveryAlternate), null, ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverSecret, ConnectIdActivity.recoveryAltPhone).setAllowChange(false); + ConnectIdPhoneVerificationFragmnet.MethodRecoveryAlternate), null, ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverSecret, ConnectIdActivity.recoveryAltPhone,false).setAllowChange(false); } } case ConnectConstants.CONNECT_REGISTRATION_CHANGE_PIN -> {