Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ data class Configuration(
val instantPaymentEnabled: Boolean,
val isEInvoiceEnabled: Boolean,
val qrCodeEducationEnabled: Boolean,
val paymentHintsEnabled: Boolean
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ data class ConfigurationResponse(
@Json(name = "qrCodeEducationEnabled") val qrCodeEducationEnabled: Boolean?,
@Json(name = "instantPaymentEnabled") val instantPaymentEnabled: Boolean?,
@Json(name = "eInvoiceEnabled") val eInvoiceEnabled: Boolean?,
@Json(name = "paymentHintsEnabled") val paymentHintsEnabled: Boolean?,
)

internal fun ConfigurationResponse.toConfiguration() = Configuration(
Expand All @@ -26,6 +27,7 @@ internal fun ConfigurationResponse.toConfiguration() = Configuration(
transactionDocsEnabled = transactionDocsEnabled ?: false,
qrCodeEducationEnabled = qrCodeEducationEnabled ?: false,
instantPaymentEnabled = instantPaymentEnabled ?: false,
isEInvoiceEnabled = eInvoiceEnabled ?: false
isEInvoiceEnabled = eInvoiceEnabled ?: false,
paymentHintsEnabled = paymentHintsEnabled ?:false
)

Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ class ConfigurationActivity : AppCompatActivity() {
binding.layoutFeatureToggle.switchReturnAssistantFeature.isChecked =
configuration.isReturnAssistantEnabled

// enable payment hints
binding.layoutFeatureToggle.switchSetupPaymentHints.isChecked =
configuration.isPaymentHintsEnabled

// enable return reasons dialog
binding.layoutReturnAssistantToggles.switchReturnReasonsDialog.isChecked =
configuration.isReturnReasonsEnabled
Expand Down Expand Up @@ -556,6 +560,15 @@ class ConfigurationActivity : AppCompatActivity() {
)
}

//enable payment hints for showing warning
binding.layoutFeatureToggle.switchSetupPaymentHints.setOnCheckedChangeListener{ _, isChecked ->
configurationViewModel.setConfiguration(
configurationViewModel.configurationFlow.value.copy(
isPaymentHintsEnabled = isChecked
)
)
}

// enable supported format help screen
binding.layoutHelpToggles.switchSupportedFormatsScreen.setOnCheckedChangeListener { _, isChecked ->
configurationViewModel.setConfiguration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ class ConfigurationViewModel @Inject constructor(
documentImportEnabledFileTypes = configuration.documentImportEnabledFileTypes,
// enable bottom navigation bar
bottomNavigationBarEnabled = configuration.isBottomNavigationBarEnabled,

// enable payment hints
paymentHintsEnabled = configuration.isPaymentHintsEnabled,
// enable onboarding screens at first launch
showOnboardingAtFirstRun = configuration.isOnboardingAtFirstRunEnabled,
// enable onboarding at every launch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ data class Configuration(
// enable return reasons dialog
val isReturnReasonsEnabled: Boolean = false,

// enable show warning for paid invoices
val isPaymentHintsEnabled: Boolean = true,

// Digital invoice onboarding custom illustration
val isDigitalInvoiceOnboardingCustomIllustrationEnabled: Boolean = false,

Expand Down Expand Up @@ -187,7 +190,7 @@ data class Configuration(
// enable Capture Sdk
val isCaptureSDK: Boolean = false,

) : Parcelable {
) : Parcelable {

companion object {
fun setupSDKWithDefaultConfiguration(
Expand All @@ -203,6 +206,7 @@ data class Configuration(
isFlashDefaultStateEnabled = defaultCaptureConfiguration.flashOnByDefault,
documentImportEnabledFileTypes = defaultCaptureConfiguration.documentImportEnabledFileTypes,
isBottomNavigationBarEnabled = defaultCaptureConfiguration.bottomNavigationBarEnabled,
isPaymentHintsEnabled = defaultCaptureConfiguration.paymentHintsEnabled,
isOnboardingAtFirstRunEnabled = defaultCaptureConfiguration.showOnboardingAtFirstRun,
isOnboardingAtEveryLaunchEnabled = defaultCaptureConfiguration.showOnboarding,
isSupportedFormatsHelpScreenEnabled = defaultCaptureConfiguration.supportedFormatsHelpScreenEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,18 @@
android:layout_marginTop="@dimen/gc_medium_12"
android:text="@string/event_tracker_switch_label" />

<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/switch_setupPaymentHints"
style="@style/SwitchConfigurationStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/payment_hint_switch_label" />

<TextView
android:id="@+id/tv_paymentHintsDescription"
style="@style/TextAppearance.MaterialComponents.Caption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/payment_hint_switch_description" />
</LinearLayout>

2 changes: 2 additions & 0 deletions bank-sdk/example-app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<string name="relaunch_to_use_default_configuration">Please relaunch the app to use the default GiniConfiguration values.</string>
<string name="close_screen_for_configurations_to_take_place">The configuration changes will take effect after closing this screen.</string>
<string name="default_sdk_configuration_switch_label">SDK default configurations</string>
<string name="payment_hint_switch_label">Payment Hint State</string>
<string name="open_with_switch_label">Open with</string>
<string name="qr_code_scanning_switch_label">QR code scanning</string>
<string name="only_qr_code_scanning_switch_label">QR code scanning only</string>
Expand Down Expand Up @@ -110,6 +111,7 @@
<string name="custom_primary_compose_button_switch_label">Custom primary button in Skonto</string>
<string name="return_assistant_feature_switch_label">Return assistant feature</string>
<string name="return_assistant_feature_switch_description">Present a digital representation of the invoice</string>
<string name="payment_hint_switch_description">Toggle to show a warning when an invoice is marked as paid or similar states</string>
<string name="skonto_feature_switch_label">Skonto feature</string>
<string name="transaction_docs_feature_switch_label">Transaction Docs feature</string>
<string name="return_assistant_onboarding_custom_illustration_switch_label">Return assistant onboarding custom illustration</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ data class CaptureConfiguration(
*/
val bottomNavigationBarEnabled: Boolean = false,

/**
* Enable/disable the payment hint.
*
* On by default.
*/
val paymentHintsEnabled: Boolean = true,

/**
* Set an adapter implementation to show a custom bottom navigation bar on the onboarding screen.
*/
Expand Down Expand Up @@ -247,6 +254,7 @@ internal fun GiniCapture.Builder.applyConfiguration(configuration: CaptureConfig
.setGiniErrorLoggerIsOn(configuration.giniErrorLoggerIsOn)
.setImportedFileSizeBytesLimit(configuration.importedFileSizeBytesLimit)
.setBottomNavigationBarEnabled(configuration.bottomNavigationBarEnabled)
.setShowPaymentHintsEnabled(configuration.paymentHintsEnabled)
.setEntryPoint(configuration.entryPoint)
.setAllowScreenshots(configuration.allowScreenshots)
.addCustomUploadMetadata(GiniBank.USER_COMMENT_GINI_BANK_VERSION, BuildConfig.VERSION_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ internal constructor(
isTransactionDocsEnabled = configuration.transactionDocsEnabled,
isQrCodeEducationEnabled = configuration.qrCodeEducationEnabled,
isInstantPaymentEnabled = configuration.instantPaymentEnabled,
paymentHintsEnabled = configuration.paymentHintsEnabled,
isEInvoiceEnabled = configuration.isEInvoiceEnabled,
amplitudeApiKey = configuration.amplitudeApiKey ?: "",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public class GiniCapture {
private final InjectedViewAdapterInstance<CameraNavigationBarBottomAdapter> cameraNavigationBarBottomAdapterInstance;
private final InjectedViewAdapterInstance<ErrorNavigationBarBottomAdapter> errorNavigationBarBottomAdapterInstance;
private final boolean isBottomNavigationBarEnabled;
private final boolean isPaymentHintsEnabled;
private final InjectedViewAdapterInstance<OnboardingIllustrationAdapter> onboardingAlignCornersIllustrationAdapterInstance;
private final InjectedViewAdapterInstance<OnboardingIllustrationAdapter> onboardingLightingIllustrationAdapterInstance;
private final InjectedViewAdapterInstance<OnboardingIllustrationAdapter> onboardingMultiPageIllustrationAdapterInstance;
Expand Down Expand Up @@ -427,6 +428,7 @@ private GiniCapture(@NonNull final Builder builder) {
helpNavigationBarBottomAdapterInstance = builder.getHelpNavigationBarBottomAdapterInstance();
errorNavigationBarBottomAdapterInstance = builder.getErrorNavigationBarBottomAdapterInstance();
isBottomNavigationBarEnabled = builder.isBottomNavigationBarEnabled();
isPaymentHintsEnabled = builder.isPaymentHintsEnabled();
onboardingAlignCornersIllustrationAdapterInstance = builder.getOnboardingAlignCornersIllustrationAdapterInstance();
onboardingLightingIllustrationAdapterInstance = builder.getOnboardingLightingIllustrationAdapterInstance();
onboardingMultiPageIllustrationAdapterInstance = builder.getOnboardingMultiPageIllustrationAdapterInstance();
Expand Down Expand Up @@ -715,6 +717,10 @@ public boolean isBottomNavigationBarEnabled() {
return isBottomNavigationBarEnabled;
}

public boolean isPaymentHintsEnabled() {
return isPaymentHintsEnabled;
}

@Nullable
public OnboardingIllustrationAdapter getOnboardingAlignCornersIllustrationAdapter() {
if (onboardingAlignCornersIllustrationAdapterInstance == null) {
Expand Down Expand Up @@ -914,6 +920,7 @@ public void onAnalysisScreenEvent(@NotNull final Event<AnalysisScreenEvent> even
private InjectedViewAdapterInstance<ErrorNavigationBarBottomAdapter> errorNavigationBarBottomAdapterInstance = new InjectedViewAdapterInstance<>(new DefaultErrorNavigationBarBottomAdapter());
private InjectedViewAdapterInstance<CameraNavigationBarBottomAdapter> cameraNavigationBarBottomAdapterInstance = new InjectedViewAdapterInstance<>(new DefaultCameraNavigationBarBottomAdapter());
private boolean isBottomNavigationBarEnabled = false;
private boolean isPaymentHintsEnabled = true;
private InjectedViewAdapterInstance<OnboardingIllustrationAdapter> onboardingAlignCornersIllustrationAdapterInstance;
private InjectedViewAdapterInstance<OnboardingIllustrationAdapter> onboardingLightingIllustrationAdapterInstance;
private InjectedViewAdapterInstance<OnboardingIllustrationAdapter> onboardingMultiPageIllustrationAdapterInstance;
Expand Down Expand Up @@ -1334,10 +1341,19 @@ public Builder setBottomNavigationBarEnabled(final Boolean enabled) {
return this;
}

public Builder setShowPaymentHintsEnabled(final Boolean enabled){
isPaymentHintsEnabled = enabled;
return this;
}

private boolean isBottomNavigationBarEnabled() {
return isBottomNavigationBarEnabled;
}

private boolean isPaymentHintsEnabled(){
return isPaymentHintsEnabled;
}

@NonNull
private InjectedViewAdapterInstance<OnboardingIllustrationAdapter> getOnboardingAlignCornersIllustrationAdapterInstance() {
return onboardingAlignCornersIllustrationAdapterInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,27 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.navigation.NavController;
import androidx.navigation.fragment.NavHostFragment;

import net.gini.android.capture.Document;
import net.gini.android.capture.analysis.warning.WarningType;
import net.gini.android.capture.internal.ui.FragmentImplCallback;
import net.gini.android.capture.internal.util.AlertDialogHelperCompat;
import net.gini.android.capture.internal.util.CancelListener;
import net.gini.android.capture.analysis.warning.WarningBottomSheet;

/**
* Internal use only.
*/
public class AnalysisFragment extends Fragment implements FragmentImplCallback,
AnalysisFragmentInterface {

private static final String WARNING_TAG = "WarningBottomSheet";
private AnalysisFragmentImpl mFragmentImpl;
private AnalysisFragmentListener mListener;
private CancelListener mCancelListener;
Expand Down Expand Up @@ -66,7 +68,7 @@ public LayoutInflater onGetLayoutInflater(@Nullable Bundle savedInstanceState) {
@Nullable
@Override
public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container,
@Nullable final Bundle savedInstanceState) {
@Nullable final Bundle savedInstanceState) {
return mFragmentImpl.onCreateView(inflater, container, savedInstanceState);
}

Expand Down Expand Up @@ -138,7 +140,6 @@ public void setCancelListener(@NonNull final CancelListener cancelListener) {
* ReviewFragmentListener#onProceedToAnalysisScreen
* (Document)}
* @param documentAnalysisErrorMessage an optional error message shown to the user
*
* @return a new instance of the Fragment
*/
public static AnalysisFragment createInstance(@NonNull final Document document,
Expand All @@ -165,6 +166,41 @@ public void showAlertDialog(@NonNull final String message,
cancelListener);
}

@Override
public void showWarning(@NonNull WarningType type, @NonNull Runnable onProceed) {
FragmentManager fm = getParentFragmentManager();

WarningBottomSheet sheet = (WarningBottomSheet) fm.findFragmentByTag(WARNING_TAG);
if (sheet == null) {
sheet = WarningBottomSheet.Companion.newInstance(type);
}

sheet.setCancelable(false);
sheet.setListener(makeWarningListener(onProceed));
if (!sheet.isAdded()) {
if (!fm.isStateSaved()) {
sheet.show(fm, WARNING_TAG);
} else {
fm.beginTransaction().add(sheet, WARNING_TAG).commitAllowingStateLoss();
}
}
}

private WarningBottomSheet.Listener makeWarningListener(@NonNull Runnable onProceed) {
return new WarningBottomSheet.Listener() {
@Override
public void onCancelAction() {
if (mCancelListener != null) {
mCancelListener.onCancelFlow();
}
}
@Override
public void onProceedAction() {
onProceed.run();
}
};
}

@NonNull
@Override
public NavController findNavController() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.compose.ui.platform.ComposeView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.FragmentActivity;

import net.gini.android.capture.Document;
import net.gini.android.capture.GiniCapture;
import net.gini.android.capture.R;
import net.gini.android.capture.analysis.education.EducationCompleteListener;
import net.gini.android.capture.analysis.warning.WarningType;
import net.gini.android.capture.error.ErrorFragment;
import net.gini.android.capture.error.ErrorType;
import net.gini.android.capture.internal.ui.FragmentImplCallback;
Expand Down Expand Up @@ -225,6 +225,11 @@ void showError(String error, Document document) {
);
}

@Override
void showPaidWarningThen(@NonNull WarningType warningType, @NonNull Runnable onProceed) {
mFragment.showWarning(warningType, onProceed);
}

@Override
void showError(ErrorType errorType, Document document) {
ErrorFragment.Companion.navigateToErrorFragment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@
import net.gini.android.capture.GiniCaptureBasePresenter;
import net.gini.android.capture.GiniCaptureBaseView;
import net.gini.android.capture.analysis.education.EducationCompleteListener;
import net.gini.android.capture.analysis.warning.WarningType;
import net.gini.android.capture.error.ErrorType;
import net.gini.android.capture.internal.util.Size;

import java.util.List;

import jersey.repackaged.jsr166e.CompletableFuture;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;

/**
* Created by Alpar Szotyori on 08.05.2019.
Expand Down Expand Up @@ -66,6 +64,7 @@ abstract void showAlertDialog(@NonNull final String message,
abstract void showHints(List<AnalysisHint> hints);

abstract void showError(String errorMessage, Document document);
abstract void showPaidWarningThen(@NonNull WarningType warningType, @NonNull Runnable onProceed);
abstract void showError(ErrorType errorType, Document document);

abstract void showEducation(EducationCompleteListener listener);
Expand Down
Loading
Loading