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

biometric design changes #2770

Open
wants to merge 3 commits into
base: connect_qa
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
528 changes: 240 additions & 288 deletions app/AndroidManifest.xml

Large diffs are not rendered by default.

Binary file added app/res/drawable/arow_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/res/drawable/commcare_diamgi_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/res/drawable/dialpad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions app/res/drawable/grey_small_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="135dp"
android:height="40dp"
android:viewportWidth="135"
android:viewportHeight="40"
>
<group>
<clip-path
android:pathData="M20 0H115C126.046 0 135 8.95431 135 20C135 31.0457 126.046 40 115 40H20C8.95431 40 0 31.0457 0 20C0 8.95431 8.95431 0 20 0Z"
/>
<path
android:pathData="M0 0V40H135V0"
android:fillColor="#D9D9D9"
/>
</group>
</vector>
Binary file added app/res/drawable/lock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions app/res/drawable/rounded_rect.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- res/drawable/rounded_background.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#09666666"/> <!-- Background color, white in this case -->
<corners android:radius="16dp"/> <!-- Adjust the radius as needed -->
<padding
android:left="16dp"
android:top="16dp"
android:right="16dp"
android:bottom="16dp"/>
<stroke
android:width="1dp"
android:color="#09666666"/> <!-- Border color -->
</shape>
167 changes: 167 additions & 0 deletions app/res/layout/activity_biometric_signup_page.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:padding="16dp"
tools:context="org.commcare.activities.connect.BiometricSignupPage">


<ImageView
android:id="@+id/ivCommCareLogo"
android:layout_width="250dp"
android:layout_height="70dp"
android:layout_marginTop="59dp"
android:layout_marginBottom="43dp"
android:src="@drawable/commcare_diamgi_logo" />

<TextView
android:id="@+id/text_view_name"
android:layout_width="wrap_content"
android:layout_height="23dp"
android:layout_below="@id/ivCommCareLogo"
android:layout_marginTop="2dp"
android:layout_marginBottom="8dp"
android:text="@string/app_lock"
android:textColor="@color/black"
android:textSize="18sp"
android:textStyle="bold" />

<!-- Unlock with Biometric Section -->
<LinearLayout
android:id="@+id/biometricSection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/text_view_name"
android:layout_marginTop="5dp"
android:background="@drawable/rounded_rect"
android:orientation="vertical"
android:padding="16dp">

<TextView
android:id="@+id/tvUnlockWithBiometric"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:text="@string/unlock_with_biometric"
android:textSize="16sp"
android:textStyle="bold" />

<TextView
android:id="@+id/tvBiometricDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:lines="3"
android:text="@string/unlock_with_biometric_text"
android:textSize="16sp" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginBottom="16dp"
android:orientation="horizontal">

<!-- Fingerprint Icon -->
<ImageView
android:id="@+id/ivFingerprint"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginEnd="16dp"
android:src="@drawable/fingerprint"
app:tint="@color/pattern_color"
/>

<!-- Face Icon -->
<ImageView
android:id="@+id/ivFace"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginEnd="16dp"
android:src="@drawable/pattern"
app:tint="@color/pattern_color" />

<!-- Pattern Icon -->
<ImageView
android:id="@+id/ivPattern"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginEnd="16dp"
android:src="@drawable/dialpad"
app:tint="@color/pattern_color"/>

</LinearLayout>

<Switch
android:id="@+id/switchBiometric"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_gravity="right"
/>

</LinearLayout>

<!-- Setup 6 Digit PIN Section -->
<LinearLayout
android:id="@+id/pinSection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/biometricSection"
android:layout_marginTop="32dp"
android:gravity="center_vertical"
android:orientation="horizontal">

<ImageView
android:id="@+id/ivLockIcon"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginEnd="16dp"
android:src="@drawable/lock" />

<TextView
android:id="@+id/tvSetupPin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/set_up_pin"
android:textColor="@color/black"
android:textSize="16sp" />

<LinearLayout
android:id="@+id/btnContinue"
android:layout_width="135dp"
android:layout_height="52dp"
android:layout_below="@id/pinSection"
android:layout_alignParentEnd="true"
android:layout_marginStart="60dp"
android:background="@drawable/grey_small_button"
android:clickable="true"
android:focusable="true"
android:gravity="right"
android:orientation="horizontal"
android:padding="12dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="16dp"
android:text="@string/connect_verify_button_configured"
android:textAllCaps="false"
android:textColor="@color/black"
android:textSize="16sp" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:adjustViewBounds="true"
android:maxWidth="18dp"
android:maxHeight="18dp"
android:scaleType="fitCenter"
android:src="@drawable/arow_icon" />
</LinearLayout>
</LinearLayout>


</RelativeLayout>
2 changes: 2 additions & 0 deletions app/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,6 @@
<!-- Button colors -->
<color name="button_primary">#005ab2</color>
<color name="button_disabled">#d0e3ff</color>

<color name="pattern_color">#1c1b1f</color>
</resources>
12 changes: 9 additions & 3 deletions app/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<string name="expirenotification">CommCare Login Expired</string>
<string name="submission_notification_title">Submitting Data</string>
<string name="submission_logs_title">Submitting CommCare Logs</string>
<string name="remote_form_payload_url"/>
<string name="remote_form_payload_url" />

<item name="login_screen_hide_all_cuttoff" type="integer">200</item>
<item name="login_screen_hide_banner_cuttoff" type="integer">250</item>
Expand Down Expand Up @@ -466,7 +466,7 @@
<string name="area_format" cc:translatable="true">%1s sq m</string>
<string name="parse_coordinates_failure" cc:translatable="true">Could not parse input coordinates</string>
<string name="location_provider_disabled" cc:translatable="true">Turn on your location to receive location updates</string>
<string name="wait_for_location_fix" cc:translatable="true">CommCare is still trying to get your location. Please wait or click Cancel to abort.</string>
<string name="wait_for_location_fix" cc:translatable="true">CommCare is still trying to get your location. Please wait or click Cancel to abort.</string>
<string name="invalid_case_property_length" cc:translatable="true">Invalid %1s, value must be 255 characters or less</string>
<string name="invalid_case_graph_error" cc:translatable="true">This form introduces an invalid case relationship</string>
<string name="root_detected_title" cc:translatable="true">Rooted Device Detected</string>
Expand Down Expand Up @@ -783,11 +783,17 @@
<string name="login_menu_connect_sign_in">Sign up for ConnectID</string>
<string name="login_menu_connect_sign_out">Sign out of ConnectID</string>
<string name="login_menu_connect_forget">Forget ConnectID user</string>

<string name="connect_app_install_unknown_error">App install failed due to an unknown error</string>
<string name="connect_app_installed">App installed</string>
<string name="app_with_id_not_found">Required CommCare App is not installed on device</string>
<string name="phone_code_plus">+</string>
<string name="audio_recording_notification">Audio Recording Notification</string>
<string name="connect_home_progress_today">Today\'s Visits: %d</string>

<string name="app_lock">App Lock</string>
pm-dimagi marked this conversation as resolved.
Show resolved Hide resolved
<string name="unlock_with_biometric">Unlock with biometric</string>
<string name="set_up_pin">Setup 6 Digit PIN</string>
<string name="unlock_with_biometric_text">When enabled, you’ll need to use fingerprint, face or other unique identifiers to open the CommCare App</string>

</resources>
75 changes: 75 additions & 0 deletions app/src/org/commcare/activities/connect/BiometricSignupPage.java
pm-dimagi marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package org.commcare.activities.connect;

import android.content.Intent;
import android.os.Bundle;

import androidx.biometric.BiometricManager;

import org.commcare.activities.CommCareActivity;
import org.commcare.connect.ConnectConstants;
import org.commcare.dalvik.R;
import org.commcare.interfaces.CommCareActivityUIController;
import org.commcare.interfaces.WithUIController;
import org.commcare.utils.BiometricsHelper;

public class BiometricSignupPage extends CommCareActivity<BiometricSignupPage>
implements WithUIController {
private BiometricSignupPageUiController uiController;

private BiometricManager biometricManager;

@Override
public CommCareActivityUIController getUIController() {
return this.uiController;
}

@Override
public void initUIController() {
uiController = new BiometricSignupPageUiController(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setTitle(getString(R.string.app_lock));
biometricManager = BiometricManager.from(this);

uiController.setupUI();

BiometricsHelper.ConfigurationStatus fingerprint = BiometricsHelper.checkFingerprintStatus(this,
biometricManager);
BiometricsHelper.ConfigurationStatus pin = BiometricsHelper.checkPinStatus(this, biometricManager);
if (fingerprint == BiometricsHelper.ConfigurationStatus.NotAvailable &&
pin == BiometricsHelper.ConfigurationStatus.NotAvailable) {
// Skip to password-only workflow
finish(true, true);
} else {
// updateState(fingerprint, pin);
}
}

public void handleFingerprintButton() {
BiometricsHelper.ConfigurationStatus fingerprint = BiometricsHelper.checkFingerprintStatus(this,
biometricManager);
if (fingerprint == BiometricsHelper.ConfigurationStatus.Configured) {
finish(true, false);
} else if (!BiometricsHelper.configureFingerprint(this)) {
finish(true, true);
}
}

public void finish(boolean success, boolean failedEnrollment) {
Intent intent = new Intent(getIntent());

BiometricsHelper.ConfigurationStatus fingerprint = BiometricsHelper.checkFingerprintStatus(this,
biometricManager);
BiometricsHelper.ConfigurationStatus pin = BiometricsHelper.checkPinStatus(this, biometricManager);
boolean configured = fingerprint == BiometricsHelper.ConfigurationStatus.Configured ||
pin == BiometricsHelper.ConfigurationStatus.Configured;

intent.putExtra(ConnectConstants.ENROLL_FAIL, failedEnrollment || !configured);

setResult(success ? RESULT_OK : RESULT_CANCELED, intent);
finish();
}
}
pm-dimagi marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.commcare.activities.connect;

import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.Switch;

import org.commcare.dalvik.R;
import org.commcare.interfaces.CommCareActivityUIController;
import org.commcare.views.ManagedUi;
import org.commcare.views.UiElement;

@ManagedUi(R.layout.activity_biometric_signup_page)
public class BiometricSignupPageUiController implements CommCareActivityUIController {
@UiElement(value = R.id.switchBiometric)
private Switch fingerprintButton;

private final BiometricSignupPage activity;

public BiometricSignupPageUiController(BiometricSignupPage activity) {
this.activity = activity;
}

@Override
public void setupUI() {
fingerprintButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
activity.handleFingerprintButton();
}
}
});


}

@Override
public void refreshView() {

}
}
Loading