Skip to content

Commit

Permalink
Merge pull request #4 from regulaforensics/v3.2upd
Browse files Browse the repository at this point in the history
Release 3.2
  • Loading branch information
DzmitrySmaliakou authored Jun 8, 2022
2 parents dc6a6e5 + dac69f5 commit 9a978a7
Show file tree
Hide file tree
Showing 10 changed files with 321 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -62,6 +64,7 @@ public String getTitle() {
}
},
new HideCloseButtonItem(),
new HideFlashButtonItem(),
new HideNotificationViewItem(),
new NotificationViewItem(),
new ButtonsColorItem(),
Expand All @@ -71,6 +74,7 @@ public String getTitle() {
new BasicCustomItem(),
new AdvancedCustomItem(),
new OverlayCustomItem(),
new LivenessProcessingCustomItem(),
new HeaderItem() {
@Override
public String getTitle() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
}
}
Original file line number Diff line number Diff line change
@@ -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";
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="25dp"/>
<solid android:color="@android:color/holo_blue_bright" />
</shape>
18 changes: 18 additions & 0 deletions FaceSample/app/src/main/res/layout/custom_liveness_processing.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
xmlns:tools="http://schemas.android.com/tools">

<include
android:id="@+id/processing_layout"
layout="@layout/custom_liveness_processing_layout" />

<include
android:id="@+id/result_layout"
android:visibility="invisible"
tools:visibility="visible"
layout="@layout/custom_liveness_retry_layout" />

</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:background="@android:color/white">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/holo_blue_dark"
android:textSize="22sp"
android:text="In process"
android:gravity="center"
android:layout_marginTop="15dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>

<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/button_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.90" />

<Button
android:id="@+id/cancel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_button_corner"
android:textColor="@color/white"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingStart="25dp"
android:paddingEnd="25dp"
android:text="Cancel"
android:textAllCaps="true"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="@id/button_guideline" />

</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:background="@android:color/white"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:padding="@dimen/reg_small_img_button_padding">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/holo_red_dark"
android:textSize="22sp"
android:text="Let's try one more time"
android:padding="@dimen/reg_small_img_button_padding"
android:layout_gravity="center_horizontal"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/holo_blue_dark"
android:textSize="19sp"
android:layout_marginTop="10dp"
android:padding="6dp"
android:text="Make sure that"
android:layout_gravity="center_horizontal"/>

<TextView
android:id="@+id/guidelines_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_gravity="center_horizontal"
android:textColor="@android:color/holo_purple"
android:textSize="19sp"
tools:text="- Some guideliness for the user"/>

</LinearLayout>

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.65" />

<Button
android:id="@+id/retry_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_button_corner"
android:textColor="@color/white"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingStart="25dp"
android:paddingEnd="25dp"
android:text="Try again"
android:textAllCaps="true"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/guideline" />

<Button
android:id="@+id/close_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:textColor="@android:color/holo_blue_light"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingStart="25dp"
android:paddingEnd="25dp"
android:text="Cancel"
android:textAllCaps="true"
android:layout_marginTop="10dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/retry_button" />

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 9a978a7

Please sign in to comment.