From dac69f52865c778e25b9420ebc363b42ac628912 Mon Sep 17 00:00:00 2001 From: Mark Tsiushkevich Date: Wed, 8 Jun 2022 13:54:51 +0300 Subject: [PATCH] Release 3.2 --- .../facesample/data/CategoryDataProvider.java | 4 + .../customization/HideCloseButtonItem.java | 5 +- .../customization/HideFlashButtonItem.java | 34 +++++++ .../LivenessProcessingCustomItem.java | 34 +++++++ .../fragment/HideCloseButtonFragment.java | 20 ----- .../LivenessProcessingCustomFragment.java | 83 +++++++++++++++++ .../res/drawable/rounded_button_corner.xml | 5 ++ .../res/layout/custom_liveness_processing.xml | 18 ++++ .../custom_liveness_processing_layout.xml | 52 +++++++++++ .../layout/custom_liveness_retry_layout.xml | 89 +++++++++++++++++++ 10 files changed, 321 insertions(+), 23 deletions(-) create mode 100644 FaceSample/app/src/main/java/com/regula/facesample/items/customization/HideFlashButtonItem.java create mode 100644 FaceSample/app/src/main/java/com/regula/facesample/items/customization/LivenessProcessingCustomItem.java delete mode 100644 FaceSample/app/src/main/java/com/regula/facesample/items/customization/fragment/HideCloseButtonFragment.java create mode 100644 FaceSample/app/src/main/java/com/regula/facesample/items/customization/fragment/LivenessProcessingCustomFragment.java create mode 100644 FaceSample/app/src/main/res/drawable/rounded_button_corner.xml create mode 100644 FaceSample/app/src/main/res/layout/custom_liveness_processing.xml create mode 100644 FaceSample/app/src/main/res/layout/custom_liveness_processing_layout.xml create mode 100644 FaceSample/app/src/main/res/layout/custom_liveness_retry_layout.xml diff --git a/FaceSample/app/src/main/java/com/regula/facesample/data/CategoryDataProvider.java b/FaceSample/app/src/main/java/com/regula/facesample/data/CategoryDataProvider.java index 7de5fa7..d3fc41f 100644 --- a/FaceSample/app/src/main/java/com/regula/facesample/data/CategoryDataProvider.java +++ b/FaceSample/app/src/main/java/com/regula/facesample/data/CategoryDataProvider.java @@ -9,7 +9,9 @@ import com.regula.facesample.items.customization.ButtonsColorItem; import com.regula.facesample.items.customization.FlashButtonItem; import com.regula.facesample.items.customization.HideCloseButtonItem; +import com.regula.facesample.items.customization.HideFlashButtonItem; import com.regula.facesample.items.customization.HideNotificationViewItem; +import com.regula.facesample.items.customization.LivenessProcessingCustomItem; import com.regula.facesample.items.customization.NotificationViewItem; import com.regula.facesample.items.customization.NotificationViewPositionItem; import com.regula.facesample.items.customization.OverlayCustomItem; @@ -62,6 +64,7 @@ public String getTitle() { } }, new HideCloseButtonItem(), + new HideFlashButtonItem(), new HideNotificationViewItem(), new NotificationViewItem(), new ButtonsColorItem(), @@ -71,6 +74,7 @@ public String getTitle() { new BasicCustomItem(), new AdvancedCustomItem(), new OverlayCustomItem(), + new LivenessProcessingCustomItem(), new HeaderItem() { @Override public String getTitle() { diff --git a/FaceSample/app/src/main/java/com/regula/facesample/items/customization/HideCloseButtonItem.java b/FaceSample/app/src/main/java/com/regula/facesample/items/customization/HideCloseButtonItem.java index 20989ad..43a69c4 100644 --- a/FaceSample/app/src/main/java/com/regula/facesample/items/customization/HideCloseButtonItem.java +++ b/FaceSample/app/src/main/java/com/regula/facesample/items/customization/HideCloseButtonItem.java @@ -3,7 +3,6 @@ import android.content.Context; import com.regula.facesample.items.CategoryItem; -import com.regula.facesample.items.customization.fragment.HideCloseButtonFragment; import com.regula.facesdk.FaceSDK; import com.regula.facesdk.configuration.FaceCaptureConfiguration; @@ -17,14 +16,14 @@ public class HideCloseButtonItem extends CategoryItem { @Override public void onItemSelected(Context context) { FaceCaptureConfiguration configuration = new FaceCaptureConfiguration.Builder() - .registerUiFragmentClass(HideCloseButtonFragment.class) + .setCloseButtonEnabled(false) .build(); FaceSDK.Instance().presentFaceCaptureActivity(context, configuration, faceCaptureResponse -> { }); } @Override public String getDescription() { - return "Hide close button using default UI fragment"; + return "Hide close button using default UI"; } @Override diff --git a/FaceSample/app/src/main/java/com/regula/facesample/items/customization/HideFlashButtonItem.java b/FaceSample/app/src/main/java/com/regula/facesample/items/customization/HideFlashButtonItem.java new file mode 100644 index 0000000..0ffa9dd --- /dev/null +++ b/FaceSample/app/src/main/java/com/regula/facesample/items/customization/HideFlashButtonItem.java @@ -0,0 +1,34 @@ +package com.regula.facesample.items.customization; + +import android.content.Context; + +import com.regula.facesample.items.CategoryItem; +import com.regula.facesdk.FaceSDK; +import com.regula.facesdk.configuration.FaceCaptureConfiguration; + +/** + * Created by Sergey Yakimchik on 6.09.21. + * Copyright (c) 2021 Regula. All rights reserved. + */ + +public class HideFlashButtonItem extends CategoryItem { + + @Override + public void onItemSelected(Context context) { + FaceCaptureConfiguration configuration = new FaceCaptureConfiguration.Builder() + .setTorchButtonEnabled(false) + .setCameraId(0) + .build(); + FaceSDK.Instance().presentFaceCaptureActivity(context, configuration, faceCaptureResponse -> { }); + } + + @Override + public String getDescription() { + return "Hide flash button using default UI"; + } + + @Override + public String getTitle() { + return "Hide flash button"; + } +} diff --git a/FaceSample/app/src/main/java/com/regula/facesample/items/customization/LivenessProcessingCustomItem.java b/FaceSample/app/src/main/java/com/regula/facesample/items/customization/LivenessProcessingCustomItem.java new file mode 100644 index 0000000..dcc7e8f --- /dev/null +++ b/FaceSample/app/src/main/java/com/regula/facesample/items/customization/LivenessProcessingCustomItem.java @@ -0,0 +1,34 @@ +package com.regula.facesample.items.customization; + +import android.content.Context; + +import com.regula.facesample.items.CategoryItem; +import com.regula.facesample.items.customization.fragment.LivenessProcessingCustomFragment; +import com.regula.facesdk.FaceSDK; +import com.regula.facesdk.configuration.LivenessConfiguration; + +/** + * Created by Sergey Yakimchik on 29.04.22. + * Copyright (c) 2022 Regula. All rights reserved. + */ + +public class LivenessProcessingCustomItem extends CategoryItem { + + @Override + public void onItemSelected(Context context) { + LivenessConfiguration configuration = new LivenessConfiguration.Builder() + .registerProcessingFragment(LivenessProcessingCustomFragment.class) + .build(); + FaceSDK.Instance().startLiveness(context, configuration, livenessResponse -> {}); + } + + @Override + public String getDescription() { + return "Customize liveness processing and retry screens"; + } + + @Override + public String getTitle() { + return "Custom liveness process"; + } +} diff --git a/FaceSample/app/src/main/java/com/regula/facesample/items/customization/fragment/HideCloseButtonFragment.java b/FaceSample/app/src/main/java/com/regula/facesample/items/customization/fragment/HideCloseButtonFragment.java deleted file mode 100644 index ba40d8d..0000000 --- a/FaceSample/app/src/main/java/com/regula/facesample/items/customization/fragment/HideCloseButtonFragment.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.regula.facesample.items.customization.fragment; - -import android.view.View; - -import com.regula.facesdk.fragment.FaceDefaultUiFragment; - -/** - * Created by Sergey Yakimchik on 6.09.21. - * Copyright (c) 2021 Regula. All rights reserved. - */ - -public class HideCloseButtonFragment extends FaceDefaultUiFragment { - - @Override - public View getCloseButton(View view) { - View button = super.getCloseButton(view); - button.setVisibility(View.INVISIBLE); - return button; - } -} diff --git a/FaceSample/app/src/main/java/com/regula/facesample/items/customization/fragment/LivenessProcessingCustomFragment.java b/FaceSample/app/src/main/java/com/regula/facesample/items/customization/fragment/LivenessProcessingCustomFragment.java new file mode 100644 index 0000000..9c572da --- /dev/null +++ b/FaceSample/app/src/main/java/com/regula/facesample/items/customization/fragment/LivenessProcessingCustomFragment.java @@ -0,0 +1,83 @@ +package com.regula.facesample.items.customization.fragment; + +import android.graphics.PorterDuff; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ProgressBar; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.regula.facesample.R; +import com.regula.common.utils.RegulaLog; +import com.regula.facesdk.fragment.BaseFaceLivenessProcessingFragment; + +/** + * Created by Sergey Yakimchik on 04/29/22. + * Copyright (c) 2020 Regula. All rights reserved. + */ + +public final class LivenessProcessingCustomFragment extends BaseFaceLivenessProcessingFragment { + + private TextView guidelinesTextView; + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = super.onCreateView(inflater, container, savedInstanceState); + if (view == null) + return null; + + guidelinesTextView = view.findViewById(R.id.guidelines_text_view); + + return view; + } + + @Override + public int getResourceLayoutId() { + return R.layout.custom_liveness_processing; + } + + @Override + public View getRetryButton(View view) { + return view.findViewById(R.id.retry_button); + } + + @Override + public View getCancelButton(View view) { + return view.findViewById(R.id.cancel_button); + } + + @Override + public void faceSdkError(int[] stringResourceId) { + StringBuilder guidelineTextBuilder = new StringBuilder(); + if (stringResourceId == null) { + stringResourceId = new int[] { com.regula.facesdk.R.string.livenessRetry_text_environment, com.regula.facesdk.R.string.livenessRetry_text_subject }; + RegulaLog.e("Not defined error caught"); + } + + for (int strId : stringResourceId) { + guidelineTextBuilder.append(String.format("- %s\n", getString(strId))); + } + + guidelinesTextView.setText(guidelineTextBuilder); + } + + @Override + public View getProcessingLayout(View v) { + return v.findViewById(R.id.processing_layout); + } + + @Override + public View getRetryLayout(View v) { + return v.findViewById(R.id.result_layout); + } + + @Override + public View getCloseButton(View v) { + return v.findViewById(R.id.close_button); + } + +} diff --git a/FaceSample/app/src/main/res/drawable/rounded_button_corner.xml b/FaceSample/app/src/main/res/drawable/rounded_button_corner.xml new file mode 100644 index 0000000..dab644e --- /dev/null +++ b/FaceSample/app/src/main/res/drawable/rounded_button_corner.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/FaceSample/app/src/main/res/layout/custom_liveness_processing.xml b/FaceSample/app/src/main/res/layout/custom_liveness_processing.xml new file mode 100644 index 0000000..86a7b98 --- /dev/null +++ b/FaceSample/app/src/main/res/layout/custom_liveness_processing.xml @@ -0,0 +1,18 @@ + + + + + + + + \ No newline at end of file diff --git a/FaceSample/app/src/main/res/layout/custom_liveness_processing_layout.xml b/FaceSample/app/src/main/res/layout/custom_liveness_processing_layout.xml new file mode 100644 index 0000000..22cd29f --- /dev/null +++ b/FaceSample/app/src/main/res/layout/custom_liveness_processing_layout.xml @@ -0,0 +1,52 @@ + + + + + + + + + +