Skip to content
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
20 changes: 14 additions & 6 deletions app/res/layout/fragment_signup.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
<layout xmlns:android="http://schemas.android.com/apk/res/android">

<FrameLayout xmlns:app="http://schemas.android.com/apk/res-auto"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/PhoneFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context="org.commcare.fragments.connectId.ConnectIDSignupFragment">

<LinearLayout
<ScrollView
android:id="@+id/firstLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/ll_recover"
app:layout_constraintTop_toTopOf="parent"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
Expand Down Expand Up @@ -217,13 +224,14 @@
android:drawableRight="@drawable/connect_right_arrow"
/>

</LinearLayout>

</LinearLayout>
</ScrollView>

<LinearLayout
android:id="@+id/ll_recover"
android:layout_width="match_parent"
android:layout_gravity="bottom"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_height="wrap_content">

Comment on lines 230 to 236
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

ll_recover is only bottom-constrained – add start/end constraints for RTL safety

Without start/end constraints the view relies on match_parent width, which is acceptable but discouraged because RTL mirroring can break the position. Add explicit constraints:

 <LinearLayout
     android:id="@+id/ll_recover"
     android:layout_width="match_parent"
     android:orientation="vertical"
     app:layout_constraintBottom_toBottomOf="parent"
+    app:layout_constraintStart_toStartOf="parent"
+    app:layout_constraintEnd_toEndOf="parent"
     android:layout_height="wrap_content">
🤖 Prompt for AI Agents (early access)
In app/res/layout/fragment_signup.xml around lines 229 to 235, the LinearLayout with id ll_recover only has a bottom constraint and uses match_parent width, which can cause layout issues in RTL languages. Add explicit start and end constraints to this LinearLayout to ensure proper positioning and RTL safety, replacing or supplementing the match_parent width usage.

<View
Expand Down Expand Up @@ -262,5 +270,5 @@

</LinearLayout>
</LinearLayout>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
158 changes: 158 additions & 0 deletions app/res/layout/screen_connect_primary_phone.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="@color/white"
android:orientation="vertical">

<ImageView
android:id="@+id/company_logo"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:contentDescription="@null"
android:src="@drawable/ic_dimagi_logo" />

<View
android:id="@+id/divider"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="40dp"
android:background="@color/connect_light_grey" />

<TextView
android:id="@+id/connect_primary_phone_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:text="@string/connect_phone_title_primary"
android:textColor="@color/connect_blue_color"
android:textSize="16sp"
android:textStyle="bold"/>

<TextView
android:id="@+id/connect_primary_phone_message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:gravity="start"
android:text="@string/connect_phone_message_primary"
android:textColor="@color/connect_subtext"
android:textSize="14sp"
android:textStyle="bold"/>

<LinearLayout
android:id="@+id/phone_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="16dp"
android:orientation="horizontal">

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

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
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" />

<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"
android:paddingLeft="16dp"
android:textAlignment="textStart"
android:textColorHint="@color/connect_grey" />
</LinearLayout>

<TextView
android:id="@+id/errorTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingTop="4dp"
android:textSize="14sp"
android:textColor="@android:color/holo_red_light"
android:visibility="gone"
android:textStyle="bold"/>
</LinearLayout>


</LinearLayout>

<TextView
android:id="@+id/connect_primary_phone_availability"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:gravity="start"
android:textColor="@color/connect_subtext"
android:textSize="16sp"
android:textStyle="bold"/>

<com.google.android.material.button.MaterialButton
android:id="@+id/connect_primary_phone_button"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:text="@string/connect_phone_button" />
</LinearLayout>

</layout>
18 changes: 18 additions & 0 deletions app/res/navigation/nav_graph_connectid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@
<action
android:id="@+id/action_connectid_phone_verify_to_connectid_signup_fragment2"
app:destination="@id/connectid_signup_fragment" />
<action
android:id="@+id/action_connectid_phone_verify_to_connectid_phoneNo"
app:destination="@id/connectid_phoneNo" />
</fragment>

<dialog
Expand Down Expand Up @@ -322,4 +325,19 @@
app:argType="string"
app:nullable="true" />
</fragment>

<fragment
android:id="@+id/connectid_phoneNo"
android:name="org.commcare.fragments.connectId.ConnectIdPhoneFragment"
android:label="fragment_connectid_phoneNo"
tools:layout="@layout/screen_connect_primary_phone">
<action
android:id="@+id/action_connectid_phoneNo_to_connectid_phone_verify"
app:destination="@id/connectid_phone_verify"
app:popUpTo="@id/connectid_phoneNo" />
<argument
android:name="phone"
app:argType="string"
app:nullable="true" />
</fragment>
</navigation>
5 changes: 3 additions & 2 deletions app/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,12 @@
<string name="dependency_missing_dialog_playstore_not_found" cc:translatable="true">No Play Store found on your device</string>
<string name="fcm_notification">FCM Notification</string>
<string name="fcm_default_notification_channel">notification-channel-push-notifications</string>
<string name="app_with_id_not_found">Required CommCare App is not installed on device</string>
<string name="audio_recording_notification">Audio Recording Notification</string>
<string name="app_select_message" cc:translatable="true">Select an app:</string>
<!-- ConnectID strings -->
<string name="choice_or">_____________ OR _____________</string>
<string name="connect_registration_title">ConnectID Signup</string>
<string name="app_with_id_not_found">Required CommCare App is not installed on device</string>
<string name="audio_recording_notification">Audio Recording Notification</string>
<string name="connect_signup">Signup</string>
<string name="connect_recover">Recover</string>
<string name="connect_registration_have_account">Already have\nan Account?</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/org/commcare/activities/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public class LoginActivity extends CommCareActivity<LoginActivity>
public static final String CONNECT_MANAGED_LOGIN = "connect-managed-login";
private ConnectIDManager connectIDManager;
private ConnectIDManager.ConnectAppMangement connectAppState = Unmanaged;
private boolean connectLaunchPerformed;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -139,6 +140,7 @@ protected void onCreate(Bundle savedInstanceState) {
connectIDManager.init(this);
presetAppId = getIntent().getStringExtra(EXTRA_APP_ID);
appLaunchedFromConnect = connectIDManager.wasAppLaunchedFromConnect(presetAppId);
connectLaunchPerformed = false;
if (savedInstanceState == null) {
// Only restore last user on the initial creation
uiController.restoreLastUser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == ConnectConstants.CONNECT_UNLOCK_PIN) {
if (requestCode == ConnectConstants.CONNECT_UNLOCK_PIN || requestCode == ConnectConstants.CONFIGURE_BIOMETRIC_REQUEST_CODE) {
//PIN unlock should only be requested while BiometricConfig fragment is active, else this will crash
getCurrentFragment().handleFinishedPinActivity(requestCode, resultCode, data);
} else if (requestCode == ConnectConstants.CONNECTID_REQUEST_CODE) {
Expand Down
1 change: 1 addition & 0 deletions app/src/org/commcare/connect/ConnectConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class ConnectConstants {
public static final int LOGIN_CONNECT_LAUNCH_REQUEST_CODE = 1050;
public static final int COMMCARE_SETUP_CONNECT_LAUNCH_REQUEST_CODE = 1051;
public static final int STANDARD_HOME_CONNECT_LAUNCH_REQUEST_CODE = 1052;
public static final int CONFIGURE_BIOMETRIC_REQUEST_CODE = 1053;
public static final int NETWORK_ACTIVITY_ID = 7000;
public static final String USERNAME = "USERNAME";
public static final String PASSWORD = "PASSWORD";
Expand Down
11 changes: 6 additions & 5 deletions app/src/org/commcare/connect/ConnectIDManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,6 @@ public void init(Context parent) {
}
}

public boolean wasAppLaunchedFromConnect(String appId) {
String primed = primedAppIdForAutoLogin;
primedAppIdForAutoLogin = null;
return primed != null && primed.equals(appId);
}

public String generatePassword() {
int passwordLength = 20;
Expand Down Expand Up @@ -499,6 +494,12 @@ public AuthInfo.TokenAuth getTokenCredentialsForApp(String appId, String userId)
return null;
}

public boolean wasAppLaunchedFromConnect(String appId) {
String primed = primedAppIdForAutoLogin;
primedAppIdForAutoLogin = null;
return primed != null && primed.equals(appId);
}

private void getRemoteDbPassphrase(Context context, ConnectUserRecord user) {
ApiConnectId.fetchDbPassphrase(context, user, new IApiCallback() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ public void handleFinishedPinActivity(int requestCode, int resultCode, Intent in
if (requestCode == ConnectConstants.CONNECT_UNLOCK_PIN) {
finish(true, false);
}
if (requestCode == ConnectConstants.CONFIGURE_BIOMETRIC_REQUEST_CODE) {
finish(true, false);
}
}

private void performFingerprintUnlock() {
Expand Down
Loading
Loading