-
-
Notifications
You must be signed in to change notification settings - Fork 45
Implement Personal ID face capture Page #3116
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
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
ead3b87
baseline code for micro image capture pulled from micro image widget …
shubham1g5 b18d901
adds a new fragment and UI to capture photo
shubham1g5 665b451
Default to front camera
shubham1g5 2d4cc9b
Crop, Scale, compress and return image as base64 from the microImageA…
shubham1g5 f90c39b
minor lint and renaming
shubham1g5 bcd205e
Adds a api call to upload photo
shubham1g5 ff8c268
Display and upload Photo on server
shubham1g5 227c114
Adds a save button to upload, error handling
shubham1g5 59bedc6
set contextual title
shubham1g5 e82b7af
UI tweaks
shubham1g5 b56bc79
Implement padding for crop, take image size as intent extra
shubham1g5 91c298f
Save Photo to db
shubham1g5 519c33e
Adds user name to update photo call
shubham1g5 9616daf
rename to personal id
shubham1g5 2cec482
wire in photo capture fragment in the workflow
shubham1g5 2421137
error handling, validation
shubham1g5 aa45aa7
connectId -> personalId
shubham1g5 498fa80
remove stray quotes
shubham1g5 943db9d
reuse error handler
shubham1g5 10bd50a
Minor linty corrections
shubham1g5 0d7db9b
remove exceptions that are not thrown anymore
shubham1g5 efefbd0
call set_profile endpoint instead on photo capture page
shubham1g5 98d20c2
Adds a prefix to denote the format and compression type to image string
shubham1g5 1587119
use vector drawable
shubham1g5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="120dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="120dp"> | ||
|
|
||
| <path android:fillColor="@android:color/white" android:pathData="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/> | ||
|
|
||
| </vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"> | ||
|
|
||
| <path android:fillColor="@android:color/white" android:pathData="M9.4,10.5l4.77,-8.26C13.47,2.09 12.75,2 12,2c-2.4,0 -4.6,0.85 -6.32,2.25l3.66,6.35 0.06,-0.1zM21.54,9c-0.92,-2.92 -3.15,-5.26 -6,-6.34L11.88,9h9.66zM21.8,10h-7.49l0.29,0.5 4.76,8.25C21,16.97 22,14.61 22,12c0,-0.69 -0.07,-1.35 -0.2,-2zM8.54,12l-3.9,-6.75C3.01,7.03 2,9.39 2,12c0,0.69 0.07,1.35 0.2,2h7.49l-1.15,-2zM2.46,15c0.92,2.92 3.15,5.26 6,6.34L12.12,15L2.46,15zM13.73,15l-3.9,6.76c0.7,0.15 1.42,0.24 2.17,0.24 2.4,0 4.6,-0.85 6.32,-2.25l-3.66,-6.35 -0.93,1.6z"/> | ||
|
|
||
| </vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <FrameLayout 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" | ||
| tools:viewBindingIgnore="true"> | ||
|
|
||
| <androidx.camera.view.PreviewView | ||
| android:id="@+id/view_finder" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" /> | ||
|
|
||
| <LinearLayout | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| android:orientation="vertical" | ||
| android:layout_gravity="center"> | ||
|
|
||
| <org.commcare.views.FaceCaptureView | ||
| android:id="@+id/face_overlay" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="0dp" | ||
| app:background_color="@color/cc_neutral_bg_tr" | ||
| app:face_capture_area_delimiter_color="@color/white" | ||
| app:face_marker_color="@color/cc_attention_positive_color" | ||
| app:countdown_text_size="@dimen/font_size_large" | ||
| android:layout_weight="1"/> | ||
|
|
||
| <ImageView | ||
| android:id="@+id/camera_shutter_button" | ||
| android:layout_height="wrap_content" | ||
| android:layout_width="match_parent" | ||
| android:src="@drawable/ic_camera_shutter" | ||
| android:background="@color/cc_neutral_bg_tr" | ||
| android:visibility="gone" | ||
| android:paddingBottom="15dp"/> | ||
| </LinearLayout> | ||
| </FrameLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| <?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" | ||
| xmlns:tools="http://schemas.android.com/tools"> | ||
|
|
||
| <LinearLayout | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| android:background="@color/white" | ||
| android:orientation="vertical"> | ||
|
|
||
| <ImageView | ||
| android:id="@+id/company_logo" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_gravity="center" | ||
| android:layout_margin="40dp" | ||
| android:contentDescription="@null" | ||
| android:src="@drawable/ic_dimagi_logo" /> | ||
|
|
||
| <View | ||
| android:id="@+id/divider" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="1dp" | ||
| android:layout_marginHorizontal="20dp" | ||
| android:background="@color/connect_light_grey" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/title" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_gravity="start" | ||
| android:layout_margin="@dimen/activity_horizontal_margin" | ||
| android:text="@string/connectid_photo_capture_title" | ||
| android:textColor="@color/connect_blue_color" | ||
| android:textSize="16sp" | ||
| android:textStyle="bold"/> | ||
|
|
||
| <TextView | ||
| android:id="@+id/subtitle" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:gravity="start" | ||
| android:layout_margin="@dimen/activity_horizontal_margin" | ||
| android:text="@string/connectid_photo_capture_subtitle" | ||
| android:textColor="@color/connect_subtext" | ||
| android:textSize="14sp" | ||
| android:textStyle="bold"/> | ||
|
|
||
| <ImageView | ||
| android:id="@+id/photo_image_view" | ||
| android:layout_width="160dp" | ||
| android:layout_height="160dp" | ||
| android:layout_gravity="center" | ||
| android:layout_margin="@dimen/activity_horizontal_margin" | ||
| android:contentDescription="@null" | ||
| android:src="@drawable/baseline_person_24" /> | ||
|
|
||
| <com.google.android.material.button.MaterialButton | ||
| android:id="@+id/take_photo_button" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_gravity="center" | ||
| android:layout_margin="@dimen/activity_horizontal_margin" | ||
| android:text="@string/connectid_photo_capture_take_photo_button" /> | ||
|
|
||
| <com.google.android.material.button.MaterialButton | ||
| android:id="@+id/save_photo_button" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_gravity="center" | ||
| android:enabled="false" | ||
| android:text="@string/connectid_photo_capture_save_photo_button" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/errorTextView" | ||
| tools:text="Error uploading photo" | ||
| android:textStyle="bold" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_margin="@dimen/activity_horizontal_margin" | ||
| android:layout_gravity="center_horizontal" | ||
| android:textColor="@android:color/holo_red_light" | ||
| android:visibility="gone" | ||
| android:textSize="14sp" /> | ||
| </LinearLayout> | ||
|
|
||
| </layout> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ | |
| import java.net.URL; | ||
| import java.util.Date; | ||
| import java.util.HashMap; | ||
| import java.util.Objects; | ||
|
|
||
| import androidx.annotation.NonNull; | ||
| import okhttp3.ResponseBody; | ||
|
|
@@ -214,9 +215,9 @@ public static void dismissProgressDialog(Context context) { | |
| } | ||
| } | ||
|
|
||
| static void callApi(Context context, Call<ResponseBody> call, IApiCallback callback) { | ||
| private static void callApi(Context context, Call<ResponseBody> call, IApiCallback callback) { | ||
| showProgressDialog(context); | ||
| call.enqueue(new Callback<ResponseBody>() { | ||
| call.enqueue(new Callback<>() { | ||
| @Override | ||
| public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) { | ||
| dismissProgressDialog(context); | ||
|
|
@@ -230,7 +231,7 @@ public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<Respo | |
| } | ||
| } else { | ||
| // Handle validation errors | ||
| handleApiError(response); | ||
| logNetworkError(response); | ||
| callback.processFailure(response.code()); | ||
| } | ||
| } | ||
|
|
@@ -241,7 +242,6 @@ public void onFailure(Call<ResponseBody> call, Throwable t) { | |
| // Handle network errors, etc. | ||
| handleNetworkError(t); | ||
| callback.processNetworkFailure(); | ||
|
|
||
| } | ||
| }); | ||
| } | ||
|
|
@@ -317,6 +317,23 @@ public static void updateUserProfile(Context context, String username, | |
| callApi(context, call, callback); | ||
| } | ||
|
|
||
| public static void setPhotoAndName(Context context, String userId, String password, String userName, | ||
| String photoAsBase64, IApiCallback callback) { | ||
| Objects.requireNonNull(photoAsBase64); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Requires Objects.requireNonNull(username)?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| Objects.requireNonNull(userName); | ||
| AuthInfo authInfo = new AuthInfo.ProvidedAuth(userId, password, false); | ||
| String token = HttpUtils.getCredential(authInfo); | ||
| Objects.requireNonNull(token); | ||
|
|
||
| HashMap<String, String> params = new HashMap<>(); | ||
| params.put("photo", photoAsBase64); | ||
| params.put("name", userName); | ||
|
|
||
| ApiService apiService = ApiClient.getClient().create(ApiService.class); | ||
| Call<ResponseBody> call = apiService.setProfile(token, params); | ||
| callApi(context, call, callback); | ||
| } | ||
|
|
||
| public static void requestRegistrationOtpPrimary(Context context, String username, String password, | ||
| IApiCallback callback) { | ||
| AuthInfo authInfo = new AuthInfo.ProvidedAuth(username, password, false); | ||
|
|
@@ -379,7 +396,7 @@ public static void confirmUserDeactivation(Context context, String phone, String | |
| callApi(context, call, callback); | ||
| } | ||
|
|
||
| private static void handleApiError(Response<?> response) { | ||
| private static void logNetworkError(Response<?> response) { | ||
| String message = response.message(); | ||
| if (response.code() == 400) { | ||
| // Bad request (e.g., validation failed) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove hard coded text, also visibility should be gone by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch on visibility.
tools:text is stripped down in the final apk and is there only for debugging layouts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10bd50a