From 1c8650073665927c69d0084eb83733008d436086 Mon Sep 17 00:00:00 2001 From: jackkray Date: Fri, 23 Aug 2024 14:48:27 +0200 Subject: [PATCH 1/3] 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 From 8a2d2e2b110934f493650566e63a2dfa38872d47 Mon Sep 17 00:00:00 2001 From: jackkray Date: Mon, 26 Aug 2024 17:20:19 +0200 Subject: [PATCH 2/3] refactoring(capture-sdk) Change align for tablets. Add string resources PP-143 --- .../gc_fragment_camera.xml | 26 +++++++++--------- .../res/layout-sw600dp/gc_fragment_camera.xml | 27 +++++++++---------- .../res/layout/gc_detection_error_layout.xml | 4 +-- .../sdk/src/main/res/values-en/strings.xml | 1 + .../sdk/src/main/res/values/strings.xml | 1 + 5 files changed, 30 insertions(+), 29 deletions(-) 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 a330e4b0b0..3622c534fe 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 @@ -357,20 +357,20 @@ app:layout_constraintStart_toStartOf="@+id/gc_injected_loading_indicator" app:layout_constraintTop_toBottomOf="@+id/gc_injected_loading_indicator" /> - + - + - - - + + + android:text="@string/gc_detection_error_layout_description"/> + android:text="@string/gc_snackbar_dismiss"/> diff --git a/capture-sdk/sdk/src/main/res/values-en/strings.xml b/capture-sdk/sdk/src/main/res/values-en/strings.xml index 8f62f2e790..e3ef4f1ad9 100644 --- a/capture-sdk/sdk/src/main/res/values-en/strings.xml +++ b/capture-sdk/sdk/src/main/res/values-en/strings.xml @@ -159,4 +159,5 @@ Select Cancel + QR code scanning is currently unavailable. Please take a picture of your invoice instead. \ No newline at end of file diff --git a/capture-sdk/sdk/src/main/res/values/strings.xml b/capture-sdk/sdk/src/main/res/values/strings.xml index 54a4d1fab6..b8bfded8e7 100644 --- a/capture-sdk/sdk/src/main/res/values/strings.xml +++ b/capture-sdk/sdk/src/main/res/values/strings.xml @@ -177,4 +177,5 @@ Auswählen Abbrechen + QR-Code scannen ist derzeit nicht verfügbar. Bitte fotografieren Sie stattdessen Ihre Rechnung. From 2e761fe67c2401516f2e2192a3ce74cbd9d0c7db Mon Sep 17 00:00:00 2001 From: jackkray Date: Tue, 27 Aug 2024 18:22:54 +0200 Subject: [PATCH 3/3] refactoring(capture-sdk) Change alignment. Add shadow. Change padding PP-143 --- .../res/drawable-sw600dp/gc_camera_frame.xml | 4 +-- .../src/main/res/drawable/gc_camera_frame.xml | 4 +-- .../gc_fragment_camera.xml | 5 ++-- .../res/layout-sw600dp/gc_fragment_camera.xml | 7 ++--- .../res/layout/gc_detection_error_layout.xml | 5 +++- .../main/res/layout/gc_fragment_camera.xml | 27 ++++++++++--------- .../src/main/res/values-sw600dp/dimens.xml | 1 + .../sdk/src/main/res/values/dimens.xml | 1 + 8 files changed, 31 insertions(+), 23 deletions(-) diff --git a/capture-sdk/sdk/src/main/res/drawable-sw600dp/gc_camera_frame.xml b/capture-sdk/sdk/src/main/res/drawable-sw600dp/gc_camera_frame.xml index ed583b6881..ff4b356107 100644 --- a/capture-sdk/sdk/src/main/res/drawable-sw600dp/gc_camera_frame.xml +++ b/capture-sdk/sdk/src/main/res/drawable-sw600dp/gc_camera_frame.xml @@ -9,7 +9,7 @@ android:fillColor="#00000000" android:strokeColor="#ffffff"/> @@ -19,7 +19,7 @@ android:fillColor="#00000000" android:strokeColor="#ffffff"/> diff --git a/capture-sdk/sdk/src/main/res/drawable/gc_camera_frame.xml b/capture-sdk/sdk/src/main/res/drawable/gc_camera_frame.xml index ce9e139956..4e08e8b0e7 100644 --- a/capture-sdk/sdk/src/main/res/drawable/gc_camera_frame.xml +++ b/capture-sdk/sdk/src/main/res/drawable/gc_camera_frame.xml @@ -9,7 +9,7 @@ android:fillColor="#00000000" android:strokeColor="#ffffff"/> @@ -19,7 +19,7 @@ android:fillColor="#00000000" android:strokeColor="#ffffff"/> 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 3622c534fe..2080d60c03 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 @@ -362,13 +362,14 @@ 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_constraintBottom_toBottomOf="@+id/gc_camera_frame" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" android:layout_marginHorizontal="@dimen/gc_large_32" app:layout_constraintTop_toTopOf="parent" + android:layout_marginBottom="@dimen/gc_large" android:visibility="gone" - app:layout_constraintVertical_bias="0.85" /> + app:layout_constraintVertical_bias="1" /> diff --git a/capture-sdk/sdk/src/main/res/layout-sw600dp/gc_fragment_camera.xml b/capture-sdk/sdk/src/main/res/layout-sw600dp/gc_fragment_camera.xml index a28cc5ad9c..e0436d2d2e 100644 --- a/capture-sdk/sdk/src/main/res/layout-sw600dp/gc_fragment_camera.xml +++ b/capture-sdk/sdk/src/main/res/layout-sw600dp/gc_fragment_camera.xml @@ -364,13 +364,14 @@ 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_constraintBottom_toBottomOf="@+id/gc_camera_frame" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" android:layout_marginHorizontal="@dimen/gc_large_32" - android:visibility="gone" + android:layout_marginBottom="@dimen/gc_large" app:layout_constraintTop_toTopOf="parent" - app:layout_constraintVertical_bias="0.9" /> + android:visibility="gone" + app:layout_constraintVertical_bias="1.0" /> diff --git a/capture-sdk/sdk/src/main/res/layout/gc_detection_error_layout.xml b/capture-sdk/sdk/src/main/res/layout/gc_detection_error_layout.xml index 7cea0c147b..25f80b50da 100644 --- a/capture-sdk/sdk/src/main/res/layout/gc_detection_error_layout.xml +++ b/capture-sdk/sdk/src/main/res/layout/gc_detection_error_layout.xml @@ -1,11 +1,13 @@ - - + + 80dp 96dp 96dp + 16dp 336dp 152dp diff --git a/capture-sdk/sdk/src/main/res/values/dimens.xml b/capture-sdk/sdk/src/main/res/values/dimens.xml index da52e5687f..b0f5dafcdd 100644 --- a/capture-sdk/sdk/src/main/res/values/dimens.xml +++ b/capture-sdk/sdk/src/main/res/values/dimens.xml @@ -11,6 +11,7 @@ 64dp 80dp 96dp + 8dp 80dp