Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
84576f8
Setup payment info feature
Jay13Panchal Nov 8, 2024
a127223
Set OTP verification screen
Jay13Panchal Nov 11, 2024
fb22bb4
Add name on post params
Jay13Panchal Nov 22, 2024
3cba3ea
Solved OTP verification API issues
Jay13Panchal Nov 26, 2024
3d8e8d6
Set resend button on OTP verification screen
Jay13Panchal Nov 26, 2024
269f0f1
Set payment info in local DB
Jay13Panchal Nov 30, 2024
b3de0d8
Added payment info in local DB
Jay13Panchal Dec 9, 2024
01c5b81
Merge branch 'connect_qa' into jp/CCCT-467-user-payment-info
Jay13Panchal Dec 9, 2024
9826d41
Merge branch 'connect_qa' into jp/CCCT-467-user-payment-info
shubham1g5 Jan 9, 2025
15981b7
Merge branch 'connect_qa' of https://github.com/dimagi/commcare-andro…
OrangeAndGreen Jan 20, 2025
630fc78
Merge branch 'connect_qa' into jp/CCCT-467-user-payment-info
OrangeAndGreen Jan 20, 2025
475428b
Merge branch 'connect_qa' of https://github.com/dimagi/commcare-andro…
OrangeAndGreen Jan 21, 2025
c8ae94a
Added javadoc comments for ConnectUserRecord fields.
OrangeAndGreen Jan 21, 2025
8d23e74
Added NotNull annotation to ConnectUserRecord constructor inputs.
OrangeAndGreen Jan 21, 2025
a3453d5
Moved 3x repeated code for parsing recovery package from server into …
OrangeAndGreen Jan 21, 2025
4bf277b
Added a little top margin to side icons in Connect screens to better …
OrangeAndGreen Jan 21, 2025
ca7c9bb
Localized some strings.
OrangeAndGreen Jan 21, 2025
4317d50
Merge branch 'connect_qa' into jp/CCCT-467-user-payment-info
OrangeAndGreen Feb 3, 2025
7d45fa5
Merge branch 'connect_qa' into jp/CCCT-467-user-payment-info
OrangeAndGreen Feb 3, 2025
8365404
Merge branch 'connect_qa' into jp/CCCT-467-user-payment-info
OrangeAndGreen Feb 18, 2025
4c25fab
Payment phone verification via ConnectIdActivity instead of duplicate…
OrangeAndGreen Feb 19, 2025
1650861
Added analytics for payment info events
OrangeAndGreen Feb 19, 2025
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
167 changes: 167 additions & 0 deletions app/res/layout/fragment_connect_payment_setup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/connect_background_color"
android:padding="16dp"
tools:context="org.commcare.fragments.connect.ConnectPaymentSetupFragment">

<org.commcare.views.connect.connecttextview.ConnectRegularTextView
android:id="@+id/connectMediumTextView"
android:layout_width="match_parent"
android:textSize="14sp"
android:letterSpacing="0.08"
android:layout_height="wrap_content"
android:text="@string/connect_payment_info_description"
android:textColor="@color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<LinearLayout
android:id="@+id/name_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:gravity="start"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/connectMediumTextView">

<LinearLayout
android:layout_width="42dp"
android:layout_height="42dp"
android:background="@drawable/connect_side_icon_bg"
android:layout_marginTop="6dp"
android:gravity="center">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="1dp"
android:src="@drawable/ic_outline_person_24" />

</LinearLayout>

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/nameTextValue"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginLeft="16dp"
android:background="@drawable/connect_edit_text_bg"
android:hint="@string/connect_payment_info_name_hint"
android:imeOptions="actionNext"
android:paddingStart="16dp"
android:textColorHint="@color/connect_grey"
tools:ignore="RtlSymmetry" />

</LinearLayout>

<LinearLayout
android:id="@+id/phone_layout"
android:layout_width="match_parent"
android:layout_marginTop="16dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintTop_toBottomOf="@+id/name_layout"
tools:layout_editor_absoluteX="16dp">

<LinearLayout
android:layout_width="42dp"
android:layout_height="42dp"
android:background="@drawable/connect_side_icon_bg"
android:layout_marginTop="6dp"
android:gravity="center">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="1dp"
android:src="@drawable/ic_outline_phone_24" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:background="@drawable/connect_edit_text_bg"
android:padding="0dp">

<EditText
android:id="@+id/countryCode"
android:layout_width="64dp"
android:layout_height="55dp"
android:background="@null"
android:gravity="center"
android:hint="@string/connect_phone_country_code_default"
android:inputType="number"
android:text="@string/connect_phone_country_code_default"
android:textColorHint="@color/connect_grey" />
Comment on lines +98 to +107
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Enhance phone number input security.

The country code input field allows direct text editing which could lead to invalid input.

Apply these changes to improve input validation:

 <EditText
     android:id="@+id/countryCode"
     android:layout_width="64dp"
     android:layout_height="55dp"
-    android:background="@null"
+    android:background="?android:attr/selectableItemBackground"
-    android:inputType="number"
+    android:inputType="phone"
+    android:maxLength="4"
+    android:digits="+0123456789"
     ... />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<EditText
android:id="@+id/countryCode"
android:layout_width="64dp"
android:layout_height="55dp"
android:background="@null"
android:gravity="center"
android:hint="@string/connect_phone_country_code_default"
android:inputType="number"
android:text="@string/connect_phone_country_code_default"
android:textColorHint="@color/connect_grey" />
<EditText
android:id="@+id/countryCode"
android:layout_width="64dp"
android:layout_height="55dp"
android:background="?android:attr/selectableItemBackground"
android:gravity="center"
android:hint="@string/connect_phone_country_code_default"
android:inputType="phone"
android:maxLength="4"
android:digits="+0123456789"
android:text="@string/connect_phone_country_code_default"
android:textColorHint="@color/connect_grey" />


<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginVertical="10dp"
android:background="@color/connect_blue_color_10" />

<AutoCompleteTextView
android:id="@+id/connect_primary_phone_input"
android:layout_width="fill_parent"
android:layout_height="55dp"
android:background="@null"
android:digits="1234567890"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="@string/connect_phone_number_hint"
android:inputType="numberDecimal"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason inputType is not phone here ?

android:paddingStart="16dp"
android:textAlignment="textStart"
android:textColorHint="@color/connect_grey"
tools:ignore="RtlSymmetry" />
Comment on lines +115 to +128
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve phone number input validation.

The phone number input field needs stronger validation constraints.

Apply these changes:

 <AutoCompleteTextView
     android:id="@+id/connect_primary_phone_input"
-    android:digits="1234567890"
+    android:digits="0123456789"
+    android:maxLength="15"
     android:inputType="phone"
+    android:imeOptions="actionDone"
     ... />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<AutoCompleteTextView
android:id="@+id/connect_primary_phone_input"
android:layout_width="fill_parent"
android:layout_height="55dp"
android:background="@null"
android:digits="1234567890"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="@string/connect_phone_number_hint"
android:inputType="numberDecimal"
android:paddingStart="16dp"
android:textAlignment="textStart"
android:textColorHint="@color/connect_grey"
tools:ignore="RtlSymmetry" />
<AutoCompleteTextView
android:id="@+id/connect_primary_phone_input"
android:layout_width="fill_parent"
android:layout_height="55dp"
android:background="@null"
android:digits="0123456789"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="@string/connect_phone_number_hint"
android:inputType="phone"
android:maxLength="15"
android:imeOptions="actionDone"
android:paddingStart="16dp"
android:textAlignment="textStart"
android:textColorHint="@color/connect_grey"
tools:ignore="RtlSymmetry" />

</LinearLayout>

<org.commcare.views.connect.connecttextview.ConnectMediumTextView
android:id="@+id/errorTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingTop="4dp"
android:textColor="@android:color/holo_red_light"
android:textSize="14sp"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>

<org.commcare.views.connect.connecttextview.ConnectRegularTextView
android:id="@+id/connectPaymentInfoNextStepText"
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:textSize="14sp"
android:letterSpacing="0.08"
android:layout_height="wrap_content"
android:text="@string/connect_verify_payment_phone_message"
android:textColor="@color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/phone_layout" />

<com.google.android.material.button.MaterialButton
android:id="@+id/continue_button"
style="@style/CustomButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_gravity="end"
android:text="@string/connect_payment_info_next"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/connectPaymentInfoNextStepText"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 2 additions & 0 deletions app/res/layout/fragment_recovery_code.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
android:layout_width="42dp"
android:layout_height="42dp"
android:background="@drawable/connect_side_icon_bg"
android:layout_marginTop="6dp"
android:gravity="center">

<ImageView
Expand Down Expand Up @@ -124,6 +125,7 @@
android:layout_width="42dp"
android:layout_height="42dp"
android:background="@drawable/connect_side_icon_bg"
android:layout_marginTop="6dp"
android:gravity="center">

<ImageView
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 @@ -97,6 +97,7 @@
android:layout_width="42dp"
android:layout_height="42dp"
android:background="@drawable/connect_side_icon_bg"
android:layout_marginTop="6dp"
android:gravity="center">

<ImageView
Expand Down
2 changes: 2 additions & 0 deletions app/res/layout/fragment_signup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
android:layout_width="42dp"
android:layout_height="42dp"
android:background="@drawable/connect_side_icon_bg"
android:layout_marginTop="6dp"
android:gravity="center">

<ImageView
Expand Down Expand Up @@ -118,6 +119,7 @@
android:layout_width="42dp"
android:layout_height="42dp"
android:background="@drawable/connect_side_icon_bg"
android:layout_marginTop="6dp"
android:gravity="center">

<ImageView
Expand Down
1 change: 1 addition & 0 deletions app/res/layout/screen_connect_password_verify.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
android:layout_width="42dp"
android:layout_height="42dp"
android:background="@drawable/connect_side_icon_bg"
android:layout_marginTop="6dp"
android:gravity="center">

<ImageView
Expand Down
1 change: 1 addition & 0 deletions app/res/layout/screen_connect_phone_verify.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
android:layout_width="42dp"
android:layout_height="42dp"
android:background="@drawable/connect_side_icon_bg"
android:layout_marginTop="6dp"
android:gravity="center">

<ImageView
Expand Down
1 change: 1 addition & 0 deletions app/res/layout/screen_connect_primary_phone.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
android:layout_width="42dp"
android:layout_height="42dp"
android:background="@drawable/connect_side_icon_bg"
android:layout_marginTop="6dp"
android:gravity="center">

<ImageView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
android:layout_width="42dp"
android:layout_height="42dp"
android:background="@drawable/connect_side_icon_bg"
android:layout_marginTop="6dp"
android:gravity="center">

<ImageView
Expand Down
16 changes: 13 additions & 3 deletions app/res/navigation/nav_graph_connect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
<action
android:id="@+id/action_connect_jobs_list_fragment_to_connect_downloading_fragment2"
app:destination="@id/connect_downloading_fragment" />
<action
android:id="@+id/action_connect_jobs_list_fragment_to_connectPaymentSetupFragment"
app:destination="@id/connectPaymentSetupFragment" />
</fragment>

<fragment
Expand Down Expand Up @@ -157,13 +160,20 @@
android:name="unitId"
app:argType="string" />
</fragment>
<fragment
android:id="@+id/connectPaymentSetupFragment"
android:name="org.commcare.fragments.connect.ConnectPaymentSetupFragment"
android:label="fragment_connect_payment_setup"
tools:layout="@layout/fragment_connect_payment_setup">
<action
android:id="@+id/action_connectPaymentSetupFragment_to_connectJobIntroFragment"
app:destination="@id/connect_job_intro_fragment" />
</fragment>

<dialog
android:id="@+id/connect_job_detail_bottom_sheet_dialog_fragment"
android:name="org.commcare.fragments.connect.ConnectJobDetailBottomSheetDialogFragment"
tools:layout="@layout/fragment_connect_job_detail_bottom_sheet_dialog"
android:label="ConnectJobDetailBottomSheetDialogFragment">


</dialog>

</navigation>
3 changes: 3 additions & 0 deletions app/res/navigation/nav_graph_connectid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@
<action
android:id="@+id/action_connectid_signup_fragment_self"
app:destination="@id/connectid_signup_fragment" />
<action
android:id="@+id/action_connectid_signup_fragment_to_connectid_phone_verify"
app:destination="@id/connectid_phone_verify" />
</fragment>

<fragment
Expand Down
15 changes: 13 additions & 2 deletions app/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<string name="ConnectClaimJobURL">https://%s/api/opportunity/%d/claim</string>
<string name="ConnectDeliveriesURL">https://%s/api/opportunity/%d/delivery_progress</string>
<string name="ConnectPaymentConfirmationURL">https://%s/api/payment/%s/confirm</string>
<string name="ConnectPaymentPhoneNumberURL">https://connectid.dimagi.com/users/profile/payment_phone_number</string>
<string name="ConnectConfirmPaymentOtpURL">https://connectid.dimagi.com/users/profile/confirm_payment_otp</string>
Comment on lines +25 to +26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think these should be relative urls to host so that we can easily configure host separately. (eg. prod vs staging)


<!-- Connect Messaging URLs-->
<string name="ConnectMessageRetrieveMessagesURL">https://connectid.dimagi.com/messaging/retrieve_messages/</string>
Expand Down Expand Up @@ -479,8 +481,6 @@
<string name="connect_pin_verify_forgot">Forgot Code</string>
<string name="connect_recovery_title">ConnectID Recovery</string>



<string name="connect_recovery_decision_new">Choose a step below</string>
<string name="connect_recovery_button_new">Create New ConnectID Account</string>
<string name="connect_recovery_button_recover">Recover Existing Account</string>
Expand Down Expand Up @@ -529,12 +529,18 @@

<string name="connect_verify_phone_title">Verification Code</string>
<string name="connect_verify_phone_label">We attempted to send you a SMS ending with %s.</string>
<string name="connect_verify_phone_label_payment">We attempted to send you a SMS on your payment phone number.</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_deactivate">In order to deactivate your account, please enter the code sent by SMS to your primary phone number.</string>
<string name="connect_verify_phone_resend">Didn\'t receive your code? Resend</string>
<string name="connect_verify_phone_error">Error verifying SMS code</string>
<string name="connect_verify_phone_resend_code">Resend Code</string>

<string name="connect_verify_payment_phone_title">Verification Code</string>
<string name="connect_verify_payment_phone_message">On the next screen, we\'ll send a code via SMS to the payment phone number you entered.</string>
<string name="connect_verify_payment_phone_back">Back</string>
<string name="connect_verify_payment_phone_ok">OK</string>

<string name="connect_verify_phone_resend_wait">Didn\'t receive your code? Resend in %d s</string>
<string name="connect_verify_phone_change">Change</string>

Expand Down Expand Up @@ -778,6 +784,11 @@
<string name="connect_expired">Expired</string>
<string name="connect_job_tile_daily_limit_description">Daily Limit reached. No Payment for submitting forms</string>
<string name="connect_job_tile_daily_limit">Over Limit</string>
<string name="connect_payment_info">Payment Info</string>
<string name="connect_payment_info_description">Please confirm your exact name and phone number to receive payment</string>
<string name="connect_payment_info_name_hint">Official Name</string>
<string name="connect_payment_info_next">Next</string>
<string name="connect_payment_info_resend_otp">Resend OTP</string>
<string name="connect_job_tile_daily_visits">Daily Visits</string>
<string name="connect_appbar_title_app_lock">App Lock</string>
<string name="connect_appbar_title_password_verification">Password Verification</string>
Expand Down
20 changes: 16 additions & 4 deletions app/src/org/commcare/activities/connect/ConnectActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;

import com.google.common.base.Strings;

import org.commcare.activities.CommCareActivity;
import org.commcare.activities.CommCareVerificationActivity;
import org.commcare.android.database.connect.models.ConnectJobRecord;
import org.commcare.connect.ConnectConstants;
import org.commcare.connect.ConnectDatabaseHelper;
import org.commcare.connect.ConnectManager;
import org.commcare.connect.MessageManager;
import org.commcare.dalvik.R;
import org.commcare.fragments.connect.ConnectDownloadingFragment;
import org.commcare.fragments.connect.ConnectJobsListsFragmentDirections;
import org.commcare.fragments.connect.ConnectPaymentSetupFragment;
import org.commcare.google.services.analytics.FirebaseAnalyticsUtil;
import org.commcare.services.CommCareFirebaseMessagingService;
import org.commcare.tasks.ResourceEngineListener;
Expand Down Expand Up @@ -144,7 +144,19 @@ public void setTitle(CharSequence title) {
@Override
protected void onActivityResult(int requestCode, int resultCode, @androidx.annotation.Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
ConnectManager.handleFinishedActivity(this, requestCode, resultCode, data);

if (resultCode == RESULT_OK) {
Fragment fragment = getCurrentFragment();

if(fragment instanceof ConnectPaymentSetupFragment) {
if (requestCode == ConnectConstants.CONNECTID_REQUEST_CODE) {
navController.navigate(ConnectJobsListsFragmentDirections.
actionConnectJobsListFragmentToConnectJobIntroFragment());
}
Comment on lines +151 to +155
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you describe what's happening here. I am confused as to what workflow is this code handling and why are we using actionConnectJobsListFragmentToConnectJobIntroFragment for the ConnectPaymentSetupFragment

} else {
ConnectManager.handleFinishedActivity(this, requestCode, resultCode, data);
}
}
}

@Override
Expand Down
Loading