From 1c8650073665927c69d0084eb83733008d436086 Mon Sep 17 00:00:00 2001 From: jackkray Date: Fri, 23 Aug 2024 14:48:27 +0200 Subject: [PATCH] feat(capture-sdk) Add inform "qr code not available" message PP-143 --- .../capture/camera/CameraFragmentImpl.java | 16 ++++++++++ .../gc_detection_error_background.xml | 6 ++++ .../gc_fragment_camera.xml | 13 ++++++++ .../res/layout-sw600dp/gc_fragment_camera.xml | 13 ++++++++ .../res/layout/gc_detection_error_layout.xml | 30 +++++++++++++++++++ .../main/res/layout/gc_fragment_camera.xml | 13 ++++++++ .../sdk/src/main/res/values/dimens.xml | 1 + 7 files changed, 92 insertions(+) create mode 100644 capture-sdk/sdk/src/main/res/drawable/gc_detection_error_background.xml create mode 100644 capture-sdk/sdk/src/main/res/layout/gc_detection_error_layout.xml diff --git a/capture-sdk/sdk/src/main/java/net/gini/android/capture/camera/CameraFragmentImpl.java b/capture-sdk/sdk/src/main/java/net/gini/android/capture/camera/CameraFragmentImpl.java index dd2ada2294..d3e779b177 100644 --- a/capture-sdk/sdk/src/main/java/net/gini/android/capture/camera/CameraFragmentImpl.java +++ b/capture-sdk/sdk/src/main/java/net/gini/android/capture/camera/CameraFragmentImpl.java @@ -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; @@ -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; @@ -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; @@ -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, @@ -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, @@ -672,6 +681,7 @@ private CompletableFuture 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() { @@ -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); @@ -947,6 +959,10 @@ private void setInputHandlers() { ); onBackPressed(); }); + + ClickListenerExtKt.setIntervalClickListener(mDetectionErrorDismissButton, v -> { + mDetectionErrorLayout.setVisibility(View.GONE); + }); } @VisibleForTesting diff --git a/capture-sdk/sdk/src/main/res/drawable/gc_detection_error_background.xml b/capture-sdk/sdk/src/main/res/drawable/gc_detection_error_background.xml new file mode 100644 index 0000000000..5bf16f3c71 --- /dev/null +++ b/capture-sdk/sdk/src/main/res/drawable/gc_detection_error_background.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/capture-sdk/sdk/src/main/res/layout-sw600dp-land/gc_fragment_camera.xml b/capture-sdk/sdk/src/main/res/layout-sw600dp-land/gc_fragment_camera.xml index ec997a8aa1..a330e4b0b0 100644 --- a/capture-sdk/sdk/src/main/res/layout-sw600dp-land/gc_fragment_camera.xml +++ b/capture-sdk/sdk/src/main/res/layout-sw600dp-land/gc_fragment_camera.xml @@ -359,6 +359,19 @@ + + + + + + + + + diff --git a/capture-sdk/sdk/src/main/res/layout/gc_fragment_camera.xml b/capture-sdk/sdk/src/main/res/layout/gc_fragment_camera.xml index 5c7824bb94..672807902b 100644 --- a/capture-sdk/sdk/src/main/res/layout/gc_fragment_camera.xml +++ b/capture-sdk/sdk/src/main/res/layout/gc_fragment_camera.xml @@ -373,6 +373,19 @@ + + 80dp 48dp 250dp + 350dp 76dp 50dp