Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pm connect bug fixes #2863

Merged
merged 3 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/res/layout/fragment_connect_learning_progress.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_marginTop="10dp"
android:paddingBottom="16dp"
android:textColor="@color/white"
android:textAlignment="center"/>
<androidx.constraintlayout.widget.ConstraintLayout
Expand Down Expand Up @@ -261,12 +262,14 @@
android:text="@string/connect_learn_warning_ended"
android:visibility="gone"/>

<Button
<org.commcare.views.connect.RoundedButton
android:id="@+id/connect_learning_review_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
tools:text="@string/connect_learn_review"
app:roundButtonTextColor="@color/white"
app:roundButtonBackgroundColor="@color/connect_blue_color"
android:visibility="gone"/>
<org.commcare.views.connect.RoundedButton
android:id="@+id/connect_learning_button"
Expand Down Expand Up @@ -302,7 +305,7 @@
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="14sp"
android:text="@string/connect_progress_title"/>
android:text="@string/connect_learn_progress_title"/>
<TextView
android:id="@+id/connect_job_intro_learning_summary"
android:layout_width="match_parent"
Expand Down
1 change: 1 addition & 0 deletions app/res/layout/fragment_secondary_phone_number.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
android:layout_marginTop="16dp"
android:layout_width="wrap_content"
android:text="Learn More"
android:visibility="gone"
app:roundButtonBorderColor="@color/border_grey"
app:roundButtonBorderVisible="true"
app:roundButtonTextColor="@color/connect_blue_color" />
Expand Down
File renamed without changes.
32 changes: 15 additions & 17 deletions app/res/navigation/nav_graph_connectid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,16 @@
android:id="@+id/connectid_signup_fragment"
android:label="fragment_connectid_signup_fragment"
android:name="org.commcare.fragments.connectId.ConnectIDSignupFragment"
tools:layout="@layout/fragment_phone">
<action
android:id="@+id/action_connectid_phone_fragment_self"
app:destination="@id/connectid_signup_fragment" />
tools:layout="@layout/fragment_signup">
<argument
android:name="callingClass"
android:defaultValue="1002"
app:argType="integer" />
<argument
android:defaultValue=""
android:name="phone"
app:argType="string"
app:nullable="true"/>
<action
android:id="@+id/action_connectid_phone_fragment_to_connectid_phone_not_available"
app:destination="@id/connectid_phone_not_available" />
Expand All @@ -264,25 +270,17 @@
<action
android:id="@+id/action_connectid_phone_fragment_to_connectid_message"
app:destination="@id/connectid_message" />

<action
android:id="@+id/action_connectid_phone_fragment_self2"
app:destination="@id/connectid_signup_fragment" />
<action
android:id="@+id/action_connectid_phone_fragment_to_connectid_password"
app:destination="@id/connectid_password" />
<action
android:id="@+id/action_connectid_phone_fragment_to_connectid_pin"
app:destination="@id/connectid_pin" />
<argument
android:defaultValue=""
android:name="phone"
app:argType="string"
app:nullable="true" />
<argument
android:defaultValue="1003"
android:name="callingClass"
app:argType="integer" />
<action
android:id="@+id/action_connectid_signup_fragment_self"
app:destination="@id/connectid_signup_fragment" />


</fragment>

<fragment
Expand Down
18 changes: 9 additions & 9 deletions app/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@
<string name="connect_phone_message_primary">Please enter your primary phone number</string>

<string name="connect_phone_title_alternate">Alternate Phone</string>
<string name="connect_phone_message_alternate">Enter a phone number of a friend or family who can provide you an SMS OTP if you forget your password or PIN.</string>
<string name="connect_phone_message_alternate">Enter a phone number of a friend or family who can provide you an SMS OTP if you forget your Code.</string>

<string name="connect_phone_button">OK</string>
<string name="connect_phone_checking">Checking…</string>
Expand Down Expand Up @@ -489,11 +489,11 @@
<string name="connect_password_fail_message">You entered the wrong password, please try again.</string>
<string name="connect_password_recovery_message">You entered the wrong password too many times, you will need to recover your account.</string>
<string name="connect_password_fail_button">OK</string>
<string name="connect_pin_fail_title">Wrong PIN</string>
<string name="connect_pin_fail_message">You entered the wrong PIN, please try again.</string>
<string name="connect_pin_recovery_message">You entered the wrong PIN too many times, you will need to recover your account.\n On the next screen, we\'ll send a code via SMS to the alternate phone number associated with your account.</string>
<string name="connect_pin_fail_title">Wrong Code</string>
<string name="connect_pin_fail_message">You entered the wrong Code, please try again.</string>
<string name="connect_pin_recovery_message">You entered the wrong Code too many times, you will need to recover your account.\n On the next screen, we\'ll send a code via SMS to the alternate phone number associated with your account.</string>

<string name="connect_pin_confirm_message">You entered the wrong PIN too many times, you will have to configure the pin again.\n On the next screen, we\'ll redirect you to the configure pin page.</string>
<string name="connect_pin_confirm_message">You entered the wrong Code too many times, you will have to configure the code again.\n On the next screen, we\'ll redirect you to the configure code page.</string>
<string name="connect_pin_verify_forgot">Don\'t have or forgot your Code?</string>
<string name="connect_pin_fail_button">OK</string>
<string name="connect_recovery_title">ConnectID Setup</string>
Expand Down Expand Up @@ -568,8 +568,8 @@
<string name="connect_verify_button_password">Use Password Only</string>
<string name="connect_verify_phone_title">Verification Code</string>
<string name="connect_verify_phone_title2">Enter verification code</string>
<string name="connect_verify_phone_label">We attempted to send you a code on number ending with %s.</string>
<string name="connect_verify_phone_label_secondary">We attempted to send you a code on your secondary phone number.</string>
<string name="connect_verify_phone_label">We attempted to send you a SMS ending with %s.</string>
<string name="connect_verify_phone_label_secondary">We attempted to send you a SMS on your secondary phone number.</string>
<string name="connect_verify_phone_label_alternate">Almost there! Please enter the code sent via SMS to your alternate phone%s.</string>
<string name="connect_verify_phone_resend">Didn\'t receive your code? Resend</string>

Expand Down Expand Up @@ -614,7 +614,7 @@

<string name="connect_job_download_learn_app">Download Learn App</string>
<string name="connect_job_learn_summary">%d modules, %d hours</string>
<string name="connect_learn_progress_title">Your Learning Progress</string>
<string name="connect_learn_progress_title">Learning Progress</string>
<string name="connect_learn_complete_title">Training Complete!</string>
<string name="connect_learn_need_assessment_title">Training Pending</string>
<string name="connect_learn_failed_title">Training Failed</string>
Expand Down Expand Up @@ -733,7 +733,7 @@
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="consent_string">I have read and agree to Dimagi’s Privacy Policy, Terms of Service, Business Agreement and Acceptable Use Policy.</string>
<string name="already_have_an_account">Already Have an account?</string>
<string name="enter_otp">Enter OTP</string>
<string name="enter_otp">Enter SMS Code</string>
<string name="change">Change</string>
<string name="create_a_new_recovery_code">Create a new Recovery Code</string>
<string name="confirm_code">Confirm Code</string>
Expand Down
18 changes: 10 additions & 8 deletions app/src/org/commcare/activities/connect/ConnectIdActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ protected void onCreate(Bundle savedInstanceState) {
window.setStatusBarColor(getResources().getColor(R.color.connect_status_bar_color));
NavHostFragment host2 = (NavHostFragment)getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment_connectid);
controller = host2.getNavController();
Bundle extras = getIntent().getExtras();
ColorDrawable colorDrawable
= new ColorDrawable(getResources().getColor(R.color.connect_blue_color));
getSupportActionBar().setBackgroundDrawable(colorDrawable);
Expand Down Expand Up @@ -91,11 +90,12 @@ public void beginRegistration(Context parent) {
forgotPassword = false;
forgotPin = false;
NavDirections navDirections = null;
int requestCode = ConnectConstants.CONNECT_NO_ACTIVITY;
int requestCode = ConnectConstants.CONNECT_REGISTRATION_PRIMARY_PHONE;
switch (ConnectManager.getStatus()) {
case NotIntroduced ->
navDirections = ConnectIDSignupFragmentDirections.actionConnectidPhoneFragmentSelf().setCallingClass(ConnectConstants.CONNECT_NO_ACTIVITY);
case Registering -> {
case NotIntroduced :
navDirections = ConnectIDSignupFragmentDirections.actionConnectidSignupFragmentSelf().setCallingClass(ConnectConstants.CONNECT_REGISTRATION_PRIMARY_PHONE);
break;
case Registering :
ConnectUserRecord user = ConnectDatabaseHelper.getUser(parent);
int phase = user.getRegistrationPhase();
if (phase != ConnectConstants.CONNECT_NO_ACTIVITY) {
Expand All @@ -116,9 +116,11 @@ public void beginRegistration(Context parent) {
.actionConnectidPhoneFragmentToConnectidBiometricConfig(
(ConnectConstants.CONNECT_UNLOCK_BIOMETRIC));
}
}
default -> {
}
break;

default :
// navDirections = ConnectIDSignupFragmentDirections.actionConnectidSignupFragmentSelf().setCallingClass(ConnectConstants.CONNECT_REGISTRATION_PRIMARY_PHONE);

}

if (navDirections != null && requestCode != ConnectConstants.CONNECT_NO_ACTIVITY) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ private void updateUi(View view) {
ProgressBar progressBar = view.findViewById(R.id.connect_learning_progress_bar);
LinearLayout progressBarTextContainer = view.findViewById(R.id.connect_learn_progress_bar_text_container);

progressText.setVisibility(learningFinished ? View.GONE : View.VISIBLE);
progressBar.setVisibility(learningFinished ? View.GONE : View.VISIBLE);
progressText.setVisibility(assessmentPassed ? View.GONE : View.VISIBLE);
progressBar.setVisibility(assessmentPassed ? View.GONE : View.VISIBLE);
progressBarTextContainer.setVisibility(learningFinished ? View.GONE : View.VISIBLE);
if(!learningFinished) {
progressBar.setProgress(percent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
existingPhone = ConnectIDSecondaryPhoneNumberArgs.fromBundle(getArguments()).getPhone();
callingClass = ConnectIDSecondaryPhoneNumberArgs.fromBundle(getArguments()).getCallingClass();
}
String code= "+"+String.valueOf(PhoneNumberHelper.getCountryCode(requireActivity()));
binding.countryCode.setText(code);
binding.countryCode.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
Expand All @@ -80,7 +82,7 @@ public void afterTextChanged(Editable s) {
});
binding.continueButton.setOnClickListener(v -> handleButtonPress());
binding.secondaryPhoneTitle.setText(getString(R.string.connect_phone_title_alternate));
requireActivity().setTitle(getString(R.string.connect_phone_title_alternate));
requireActivity().setTitle(getString(R.string.connect_phone_title_alternate));
binding.secondaryPhoneSubTitle.setText(getString(R.string.connect_phone_message_alternate));

return view;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.commcare.connect.network.ConnectNetworkHelper;
import org.commcare.connect.network.IApiCallback;
import org.commcare.dalvik.R;
import org.commcare.dalvik.databinding.FragmentPhoneBinding;
import org.commcare.dalvik.databinding.FragmentSignupBinding;
import org.commcare.utils.PhoneNumberHelper;
import org.javarosa.core.io.StreamsUtil;
import org.javarosa.core.services.Logger;
Expand All @@ -49,10 +49,11 @@

public class ConnectIDSignupFragment extends Fragment {
private String existingPhone = "";
private int callingClass = 1003;
private int callingClass = ConnectConstants.CONNECT_REGISTRATION_PRIMARY_PHONE;
protected boolean skipPhoneNumberCheck = false;
private FragmentPhoneBinding binding;
private boolean isValidNo;
private FragmentSignupBinding binding;
private boolean isValidNo = false;
private boolean showhPhoneDialog = true;
private ConnectUserRecord user;
NavDirections directions = null;

Expand All @@ -74,19 +75,19 @@ public void onCreate(Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
binding = FragmentPhoneBinding.inflate(inflater, container, false);
binding = FragmentSignupBinding.inflate(inflater, container, false);
View view = binding.getRoot();
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

binding.connectConsentCheck.setOnClickListener(v -> updateButtonEnabled());
if (getArguments() != null) {
existingPhone = ConnectIDSignupFragmentArgs.fromBundle(getArguments()).getPhone();
callingClass = ConnectIDSignupFragmentArgs.fromBundle(getArguments()).getCallingClass();
existingPhone = ConnectIDSignupFragmentArgs.fromBundle(getArguments()).getPhone();
}

View.OnFocusChangeListener listener = (v, hasFocus) -> {
if(hasFocus) {
if(hasFocus && showhPhoneDialog) {
PhoneNumberHelper.requestPhoneNumberHint(getActivity());
showhPhoneDialog = false;
}
};

Expand Down Expand Up @@ -214,12 +215,12 @@ void handleContinueButtonPress() {
}

void handleRecoverButtonPress() {
directions = ConnectIDSignupFragmentDirections.actionConnectidPhoneFragmentSelf().setCallingClass(ConnectConstants.CONNECT_RECOVERY_PRIMARY_PHONE);
directions = ConnectIDSignupFragmentDirections.actionConnectidSignupFragmentSelf().setCallingClass(ConnectConstants.CONNECT_RECOVERY_PRIMARY_PHONE);
Navigation.findNavController(binding.continueButton).navigate(directions);
}

void handleSignupButtonPress() {
directions = ConnectIDSignupFragmentDirections.actionConnectidPhoneFragmentSelf().setCallingClass(ConnectConstants.CONNECT_REGISTRATION_PRIMARY_PHONE);
directions = ConnectIDSignupFragmentDirections.actionConnectidSignupFragmentSelf().setCallingClass(ConnectConstants.CONNECT_REGISTRATION_PRIMARY_PHONE);
Navigation.findNavController(binding.continueButton).navigate(directions);
}

Expand All @@ -239,9 +240,10 @@ public void checkPhoneNumber() {
case ConnectConstants.CONNECT_REGISTRATION_PRIMARY_PHONE,
ConnectConstants.CONNECT_REGISTRATION_CHANGE_PRIMARY_PHONE,
ConnectConstants.CONNECT_RECOVERY_PRIMARY_PHONE -> {
if (existingPrimary != null && existingPrimary.equals(phone)) {
binding.errorTextView.setText("");
} else if (existingAlternate != null && existingAlternate.equals(phone)) {
// if (existingPrimary != null && existingPrimary.equals(phone)) {
// binding.errorTextView.setText("");
// }
if (existingAlternate != null && existingAlternate.equals(phone)) {
binding.errorTextView.setText(getString(R.string.connect_phone_not_alt));
} else {
//Make sure the number isn't already in use
Expand All @@ -257,6 +259,7 @@ public void processSuccess(int responseCode, InputStream responseData) {
updateButtonEnabled();
createAccount();
} else if (callingClass == ConnectConstants.CONNECT_RECOVERY_PRIMARY_PHONE) {
isValidNo=false;
binding.errorTextView.setText(getString(R.string.connect_phone_not_found));
}
}
Expand All @@ -268,7 +271,7 @@ public void processFailure(int responseCode, IOException e) {
Logger.exception("Checking phone number", e);
}
if (callingClass == ConnectConstants.CONNECT_REGISTRATION_PRIMARY_PHONE) {
isValidNo=false;
isValidNo=true;
updateButtonEnabled();
binding.errorTextView.setText(getString(R.string.connect_phone_unavailable));
directions = ConnectIDSignupFragmentDirections.actionConnectidPhoneFragmentToConnectidPhoneNotAvailable(finalPhone, ConnectConstants.CONNECT_REGISTRATION_PRIMARY_PHONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public void finish(boolean success, boolean secondButton) {
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);
ConnectManager.setFailureAttempt(0);
} else {
directions = ConnectIdMessageFragmentDirections.actionConnectidMessageToConnectidPin(ConnectConstants.CONNECT_RECOVERY_VERIFY_PIN, ConnectIdActivity.recoverPhone, ConnectIdActivity.recoverSecret).setChange(false).setRecover(true);
}
Expand Down
Loading