Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(capture-sdk) Add inform "qr code not available" message #547

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Expand Up @@ -9,7 +9,7 @@
android:fillColor="#00000000"
android:strokeColor="#ffffff"/>
<path
android:pathData="M745,927L745,1044L628,1044"
android:pathData="M745,935L745,1052L628,1052"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#ffffff"/>
Expand All @@ -19,7 +19,7 @@
android:fillColor="#00000000"
android:strokeColor="#ffffff"/>
<path
android:pathData="M122,1044L5,1044L5,927"
android:pathData="M122,1052L5,1052L5,935"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#ffffff"/>
Expand Down
4 changes: 2 additions & 2 deletions capture-sdk/sdk/src/main/res/drawable/gc_camera_frame.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:fillColor="#00000000"
android:strokeColor="#ffffff"/>
<path
android:pathData="M349,431.47L349,486L294.38,486"
android:pathData="M349,439.47L349,494L294.38,494"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#ffffff"/>
Expand All @@ -19,7 +19,7 @@
android:fillColor="#00000000"
android:strokeColor="#ffffff"/>
<path
android:pathData="M59.62,486L5,486L5,431.47"
android:pathData="M59.92,494L5,494L5,439.47"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#ffffff"/>
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 @@ -357,6 +357,20 @@
app:layout_constraintStart_toStartOf="@+id/gc_injected_loading_indicator"
app:layout_constraintTop_toBottomOf="@+id/gc_injected_loading_indicator" />

<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"
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="1" />

</androidx.constraintlayout.widget.ConstraintLayout>

<net.gini.android.capture.view.InjectedViewContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,21 @@
app:layout_constraintStart_toStartOf="@+id/gc_injected_loading_indicator"
app:layout_constraintTop_toBottomOf="@+id/gc_injected_loading_indicator" />

</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"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginHorizontal="@dimen/gc_large_32"
android:layout_marginBottom="@dimen/gc_large"
app:layout_constraintTop_toTopOf="parent"
android:visibility="gone"
app:layout_constraintVertical_bias="1.0" />

</androidx.constraintlayout.widget.ConstraintLayout>

<net.gini.android.capture.view.InjectedViewContainer
android:id="@+id/gc_injected_navigation_bar_container_bottom"
Expand Down
33 changes: 33 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,33 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="@dimen/gc_large"
android:padding="@dimen/gc_inner_padding_detection_error_layout"
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Request] Please use style="@style/GiniCaptureTheme.Typography.Body2" for the text.

style="@style/GiniCaptureTheme.Typography.Body2"
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="@string/gc_detection_error_layout_description"/>


<TextView
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Request] Also here please use style="@style/GiniCaptureTheme.Typography.Body2".

style="@style/GiniCaptureTheme.Typography.Body2"
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="@string/gc_snackbar_dismiss"/>
</androidx.constraintlayout.widget.ConstraintLayout>
16 changes: 15 additions & 1 deletion capture-sdk/sdk/src/main/res/layout/gc_fragment_camera.xml
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,22 @@
app:layout_constraintStart_toStartOf="@+id/gc_injected_loading_indicator"
app:layout_constraintTop_toBottomOf="@+id/gc_injected_loading_indicator" />

</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"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginHorizontal="@dimen/gc_large_32"
android:layout_marginBottom="@dimen/gc_medium"
app:layout_constraintTop_toTopOf="parent"
android:visibility="gone"
app:layout_constraintVertical_bias="1.0" />

</androidx.constraintlayout.widget.ConstraintLayout>

<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-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,5 @@
<string name="gc_date_picker_select">Select</string>
<string name="gc_date_picker_cancel">Cancel</string>
<!-- endregion -->
<string name="gc_detection_error_layout_description">QR code scanning is currently unavailable. Please take a picture of your invoice instead.</string>
</resources>
1 change: 1 addition & 0 deletions capture-sdk/sdk/src/main/res/values-sw600dp/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<dimen name="gc_large_64">80dp</dimen>
<dimen name="gc_large_80">96dp</dimen>
<dimen name="gc_large_96">96dp</dimen>
<dimen name="gc_inner_padding_detection_error_layout">16dp</dimen>

<dimen name="gc_analysis_hint_container_width">336dp</dimen>
<dimen name="gc_analysis_hint_container_bottom_margin_portrait">152dp</dimen>
Expand Down
2 changes: 2 additions & 0 deletions capture-sdk/sdk/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<dimen name="gc_large_64">64dp</dimen>
<dimen name="gc_large_80">80dp</dimen>
<dimen name="gc_large_96">96dp</dimen>
<dimen name="gc_inner_padding_detection_error_layout">8dp</dimen>

<dimen name="gc_review_bottom_bar_height">80dp</dimen>

Expand All @@ -30,6 +31,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
1 change: 1 addition & 0 deletions capture-sdk/sdk/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,5 @@
<string name="gc_date_picker_select">Auswählen</string>
<string name="gc_date_picker_cancel">Abbrechen</string>
<!-- endregion -->
<string name="gc_detection_error_layout_description">QR-Code scannen ist derzeit nicht verfügbar. Bitte fotografieren Sie stattdessen Ihre Rechnung.</string>
</resources>