Skip to content

Commit

Permalink
feat(capture-sdk) Add inform "qr code not available" message
Browse files Browse the repository at this point in the history
PP-143
  • Loading branch information
jackkray committed Aug 23, 2024
1 parent 4fe266f commit 1c86500
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public void onExtractionsAvailable(

private static final String IN_MULTI_PAGE_STATE_KEY = "IN_MULTI_PAGE_STATE_KEY";
private static final String IS_FLASH_ENABLED_KEY = "IS_FLASH_ENABLED_KEY";
private static final String IS_NOT_AVAILABLE_DETECTION_POPUP_SHOWED_KEY = "IS_ARGS_NOT_AVAILABLE_DETECTION_POPUP_SHOWED_KEY";

private final FragmentImplCallback mFragment;
private final CancelListener mCancelListener;
Expand Down Expand Up @@ -221,9 +222,11 @@ public void onExtractionsAvailable(
private ImageView mImageFrame;
private ViewStubSafeInflater mViewStubInflater;
private ConstraintLayout mPaneWrapper;
private ConstraintLayout mDetectionErrorLayout;
private TextView mScanTextView;
private TextView mIbanDetectedTextView;
private boolean mIsTakingPicture;
private boolean mIsDetectionErrorPopupShowed;

private boolean mImportDocumentButtonEnabled;
private ImportImageFileUrisAsyncTask mImportUrisAsyncTask;
Expand All @@ -239,6 +242,7 @@ public void onExtractionsAvailable(
private IBANRecognizerFilter ibanRecognizerFilter;
private CropToCameraFrameTextRecognizer cropToCameraFrameTextRecognizer;
private final UserAnalyticsScreen screenName = UserAnalyticsScreen.Camera.INSTANCE;
private View mDetectionErrorDismissButton;

CameraFragmentImpl(@NonNull final FragmentImplCallback fragment, @NonNull final CancelListener cancelListener, final boolean addPages) {
mFragment = fragment;
Expand All @@ -265,6 +269,10 @@ public void onQRCodeReaderFail() {
"QRCode detector dependencies are not yet available. QRCode detection is disabled.");

setQRDisabledTexts();
if (!mIsDetectionErrorPopupShowed) {
mIsDetectionErrorPopupShowed = true;
mDetectionErrorLayout.setVisibility(View.VISIBLE);
}
}

private void handleQRCodeDetected(@Nullable final PaymentQRCodeData paymentQRCodeData,
Expand Down Expand Up @@ -355,6 +363,7 @@ private void initFlashState() {
private void restoreSavedState(@NonNull final Bundle savedInstanceState) {
mInMultiPageState = savedInstanceState.getBoolean(IN_MULTI_PAGE_STATE_KEY);
mIsFlashEnabled = savedInstanceState.getBoolean(IS_FLASH_ENABLED_KEY);
mIsDetectionErrorPopupShowed = savedInstanceState.getBoolean(IS_NOT_AVAILABLE_DETECTION_POPUP_SHOWED_KEY);
}

View onCreateView(final LayoutInflater inflater, final ViewGroup container,
Expand Down Expand Up @@ -672,6 +681,7 @@ private CompletableFuture<Void> openCamera() {
void onSaveInstanceState(@NonNull final Bundle outState) {
outState.putBoolean(IN_MULTI_PAGE_STATE_KEY, mInMultiPageState);
outState.putBoolean(IS_FLASH_ENABLED_KEY, mIsFlashEnabled);
outState.putBoolean(IS_NOT_AVAILABLE_DETECTION_POPUP_SHOWED_KEY, mIsDetectionErrorPopupShowed);
}

void onStop() {
Expand Down Expand Up @@ -733,6 +743,8 @@ private void bindViews(final View view) {
mPaneWrapper = view.findViewById(R.id.gc_pane_wrapper);
mLoadingIndicator = view.findViewById(R.id.gc_injected_loading_indicator);
mIbanDetectedTextView = view.findViewById(R.id.gc_iban_detected);
mDetectionErrorLayout = view.findViewById(R.id.gc_detection_error_layout);
mDetectionErrorDismissButton = mDetectionErrorLayout.findViewById(R.id.gc_detection_error_popup_dismiss_button);

if (!ContextHelper.isTablet(mFragment.getActivity())) {
mScanTextView = view.findViewById(R.id.gc_camera_title);
Expand Down Expand Up @@ -947,6 +959,10 @@ private void setInputHandlers() {
);
onBackPressed();
});

ClickListenerExtKt.setIntervalClickListener(mDetectionErrorDismissButton, v -> {
mDetectionErrorLayout.setVisibility(View.GONE);
});
}

@VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/gc_light_01"/>
<corners android:radius="@dimen/gc_small"/>
</shape>
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,19 @@

</androidx.constraintlayout.widget.ConstraintLayout>

<include
layout="@layout/gc_detection_error_layout"
android:id="@+id/gc_detection_error_layout"
android:layout_width="@dimen/gc_photo_disabled_detection_width"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/gc_camera_frame_wrapper"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginHorizontal="@dimen/gc_large_32"
app:layout_constraintTop_toTopOf="parent"
android:visibility="gone"
app:layout_constraintVertical_bias="0.85" />

<net.gini.android.capture.view.InjectedViewContainer
android:id="@+id/gc_injected_navigation_bar_container_bottom"
android:layout_width="match_parent"
Expand Down
13 changes: 13 additions & 0 deletions capture-sdk/sdk/src/main/res/layout-sw600dp/gc_fragment_camera.xml
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,19 @@

</androidx.constraintlayout.widget.ConstraintLayout>

<include
layout="@layout/gc_detection_error_layout"
android:id="@+id/gc_detection_error_layout"
android:layout_width="@dimen/gc_photo_disabled_detection_width"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/gc_camera_frame_wrapper"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginHorizontal="@dimen/gc_large_32"
app:layout_constraintTop_toTopOf="parent"
android:visibility="gone"
app:layout_constraintVertical_bias="0.9" />


<net.gini.android.capture.view.InjectedViewContainer
android:id="@+id/gc_injected_navigation_bar_container_bottom"
Expand Down
30 changes: 30 additions & 0 deletions capture-sdk/sdk/src/main/res/layout/gc_detection_error_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/gc_medium"
android:background="@drawable/gc_detection_error_background"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/gc_detection_error_popup_dismiss_button"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="parent"
android:textColor="@color/gc_dark_02"
android:text="QR code scanning is currently unavailable. Please take a picture of your invoice instead."/>


<TextView
android:id="@+id/gc_detection_error_popup_dismiss_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:textColor="@color/gc_accent_01"
android:padding="@dimen/gc_large"
android:text="Dismiss"/>
</androidx.constraintlayout.widget.ConstraintLayout>
13 changes: 13 additions & 0 deletions capture-sdk/sdk/src/main/res/layout/gc_fragment_camera.xml
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,19 @@

</androidx.constraintlayout.widget.ConstraintLayout>

<include
layout="@layout/gc_detection_error_layout"
android:id="@+id/gc_detection_error_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/gc_camera_frame_wrapper"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginHorizontal="@dimen/gc_large_32"
app:layout_constraintTop_toTopOf="parent"
android:visibility="gone"
app:layout_constraintVertical_bias="0.9" />


<net.gini.android.capture.view.InjectedViewContainer
android:id="@+id/gc_injected_navigation_bar_container_bottom"
Expand Down
1 change: 1 addition & 0 deletions capture-sdk/sdk/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<dimen name="gc_photo_tips_tip_icon_size_width">80dp</dimen>
<dimen name="gc_photo_tips_tip_icon_size_height">48dp</dimen>
<dimen name="gc_photo_tips_tip_text_max_width">250dp</dimen>
<dimen name="gc_photo_disabled_detection_width">350dp</dimen>
<dimen name="gc_photo_tips_row_min_height">76dp</dimen>

<dimen name="gc_file_import_paragraphs_margin">50dp</dimen>
Expand Down

0 comments on commit 1c86500

Please sign in to comment.