Skip to content

Commit

Permalink
Update demos for version 5.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
The Grizzly Labs committed Nov 26, 2024
1 parent afdfdc1 commit b6e7818
Show file tree
Hide file tree
Showing 21 changed files with 462 additions and 57 deletions.
2 changes: 1 addition & 1 deletion android/demo-custom/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ android {
}

dependencies {
implementation 'com.geniusscansdk:gssdk:5.3.1'
implementation 'com.geniusscansdk:gssdk:5.4.0'

implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.12.0'
Expand Down
2 changes: 1 addition & 1 deletion android/demo-simple/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ android {
}

dependencies {
implementation 'com.geniusscansdk:gssdk:5.3.1'
implementation 'com.geniusscansdk:gssdk:5.4.0'

implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.12.0'
Expand Down
2 changes: 1 addition & 1 deletion android/demo-simple/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<activity
android:name=".MainActivity"
android:theme="@style/AppTheme.NoActionBar"
android:theme="@style/AppTheme"
android:exported="true"
>
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
package com.geniusscansdk.simpledemo;

import static com.geniusscansdk.scanflow.ScanConfiguration.Filter.*;
import static com.geniusscansdk.scanflow.ScanConfiguration.Filter.AUTOMATIC;
import static com.geniusscansdk.scanflow.ScanConfiguration.Filter.AUTOMATIC_BLACK_AND_WHITE;
import static com.geniusscansdk.scanflow.ScanConfiguration.Filter.AUTOMATIC_COLOR;
import static com.geniusscansdk.scanflow.ScanConfiguration.Filter.NONE;
import static com.geniusscansdk.scanflow.ScanConfiguration.Filter.PHOTO;
import static com.geniusscansdk.scanflow.ScanConfiguration.Filter.SOFT_COLOR;
import static com.geniusscansdk.scanflow.ScanConfiguration.Filter.SOFT_GRAYSCALE;
import static com.geniusscansdk.scanflow.ScanConfiguration.Filter.STRONG_MONOCHROME;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RawRes;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.core.graphics.Insets;
import androidx.core.view.OnApplyWindowInsetsListener;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.geniusscansdk.core.LicenseException;
import com.geniusscansdk.scanflow.ScanConfiguration;
import com.geniusscansdk.scanflow.ScanFlow;
import com.geniusscansdk.scanflow.ScanResult;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;

import java.io.File;
import java.io.FileOutputStream;
Expand All @@ -38,10 +51,20 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);

setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("GS SDK Simple Demo");
ViewCompat.setOnApplyWindowInsetsListener(toolbar, new OnApplyWindowInsetsListener() {
@NonNull
@Override
public WindowInsetsCompat onApplyWindowInsets(@NonNull View v, @NonNull WindowInsetsCompat insets) {
Insets systemInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(v.getPaddingLeft(), systemInsets.top, v.getPaddingRight(), v.getPaddingBottom());
return insets;
}
});

// This code shows how to initialize the SDK with a license key.
// Without a license key, the SDK runs for 60 seconds and then the app needs to be restarted.
Expand All @@ -67,9 +90,9 @@ private ScanConfiguration createBaseConfiguration() {
scanConfiguration.photoLibraryButtonHidden = false;
scanConfiguration.flashButtonHidden = false;
scanConfiguration.defaultFlashMode = ScanConfiguration.FlashMode.AUTO;
scanConfiguration.backgroundColor = Color.WHITE;
scanConfiguration.foregroundColor = ContextCompat.getColor(this, R.color.colorPrimary);
scanConfiguration.highlightColor = ContextCompat.getColor(this, R.color.colorAccent);
scanConfiguration.backgroundColor = ContextCompat.getColor(this, R.color.md_theme_background);
scanConfiguration.foregroundColor = ContextCompat.getColor(this, R.color.md_theme_primary);
scanConfiguration.highlightColor = Color.BLUE;
scanConfiguration.availableFilters = Arrays.asList(NONE, AUTOMATIC, AUTOMATIC_BLACK_AND_WHITE,
AUTOMATIC_COLOR, PHOTO, SOFT_GRAYSCALE, SOFT_COLOR, STRONG_MONOCHROME
);
Expand Down Expand Up @@ -137,20 +160,20 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
startActivity(intent);
} catch (LicenseException e) {
if (e.errorCode == LicenseException.ErrorCode.ExpiredDemo) {
new AlertDialog.Builder(this)
new MaterialAlertDialogBuilder(this)
.setMessage(e.getMessage())
.setPositiveButton("Restart", (dialog, which) -> restartApp())
.show();
} else {
// The license key is invalid or expired, either ask the user to update the app or provide a fallback
new AlertDialog.Builder(this)
new MaterialAlertDialogBuilder(this)
.setMessage("Please update to the latest version.")
.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {})
.show();
}
} catch (Exception e) {
Log.e(TAG, "Error during scan flow", e);
new AlertDialog.Builder(this)
new MaterialAlertDialogBuilder(this)
.setMessage("An error occurred: " + e.getMessage())
.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {})
.show();
Expand Down
10 changes: 3 additions & 7 deletions android/demo-simple/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand All @@ -10,16 +9,13 @@
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
android:fitsSystemWindows="true"
>

<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
android:layout_height="match_parent"
/>

</com.google.android.material.appbar.AppBarLayout>

Expand Down
143 changes: 143 additions & 0 deletions android/demo-simple/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<resources>
<color name="md_theme_primary">#73D8C7</color>
<color name="md_theme_onPrimary">#003731</color>
<color name="md_theme_primaryContainer">#007A6D</color>
<color name="md_theme_onPrimaryContainer">#FFFFFF</color>
<color name="md_theme_secondary">#A8CEC6</color>
<color name="md_theme_onSecondary">#113631</color>
<color name="md_theme_secondaryContainer">#21453F</color>
<color name="md_theme_onSecondaryContainer">#B5DBD3</color>
<color name="md_theme_tertiary">#D5BBFF</color>
<color name="md_theme_onTertiary">#3B2264</color>
<color name="md_theme_tertiaryContainer">#7A60A5</color>
<color name="md_theme_onTertiaryContainer">#FFFFFF</color>
<color name="md_theme_error">#FFB4AB</color>
<color name="md_theme_onError">#690005</color>
<color name="md_theme_errorContainer">#93000A</color>
<color name="md_theme_onErrorContainer">#FFDAD6</color>
<color name="md_theme_background">#0F1413</color>
<color name="md_theme_onBackground">#DFE3E1</color>
<color name="md_theme_surface">#0F1413</color>
<color name="md_theme_onSurface">#DFE3E1</color>
<color name="md_theme_surfaceVariant">#3E4946</color>
<color name="md_theme_onSurfaceVariant">#BDC9C5</color>
<color name="md_theme_outline">#879390</color>
<color name="md_theme_outlineVariant">#3E4946</color>
<color name="md_theme_scrim">#000000</color>
<color name="md_theme_inverseSurface">#DFE3E1</color>
<color name="md_theme_inverseOnSurface">#2C3130</color>
<color name="md_theme_inversePrimary">#006B5F</color>
<color name="md_theme_primaryFixed">#90F4E3</color>
<color name="md_theme_onPrimaryFixed">#00201C</color>
<color name="md_theme_primaryFixedDim">#73D8C7</color>
<color name="md_theme_onPrimaryFixedVariant">#005047</color>
<color name="md_theme_secondaryFixed">#C4EAE2</color>
<color name="md_theme_onSecondaryFixed">#00201C</color>
<color name="md_theme_secondaryFixedDim">#A8CEC6</color>
<color name="md_theme_onSecondaryFixedVariant">#2A4D47</color>
<color name="md_theme_tertiaryFixed">#ECDCFF</color>
<color name="md_theme_onTertiaryFixed">#25084E</color>
<color name="md_theme_tertiaryFixedDim">#D5BBFF</color>
<color name="md_theme_onTertiaryFixedVariant">#523A7C</color>
<color name="md_theme_surfaceDim">#0F1413</color>
<color name="md_theme_surfaceBright">#353A39</color>
<color name="md_theme_surfaceContainerLowest">#0A0F0E</color>
<color name="md_theme_surfaceContainerLow">#171D1B</color>
<color name="md_theme_surfaceContainer">#1B211F</color>
<color name="md_theme_surfaceContainerHigh">#262B2A</color>
<color name="md_theme_surfaceContainerHighest">#313634</color>
<color name="md_theme_primary_mediumContrast">#77DCCB</color>
<color name="md_theme_onPrimary_mediumContrast">#001A16</color>
<color name="md_theme_primaryContainer_mediumContrast">#36A092</color>
<color name="md_theme_onPrimaryContainer_mediumContrast">#000000</color>
<color name="md_theme_secondary_mediumContrast">#ACD2CA</color>
<color name="md_theme_onSecondary_mediumContrast">#001A16</color>
<color name="md_theme_secondaryContainer_mediumContrast">#739890</color>
<color name="md_theme_onSecondaryContainer_mediumContrast">#000000</color>
<color name="md_theme_tertiary_mediumContrast">#D8C0FF</color>
<color name="md_theme_onTertiary_mediumContrast">#200249</color>
<color name="md_theme_tertiaryContainer_mediumContrast">#9F84CC</color>
<color name="md_theme_onTertiaryContainer_mediumContrast">#000000</color>
<color name="md_theme_error_mediumContrast">#FFBAB1</color>
<color name="md_theme_onError_mediumContrast">#370001</color>
<color name="md_theme_errorContainer_mediumContrast">#FF5449</color>
<color name="md_theme_onErrorContainer_mediumContrast">#000000</color>
<color name="md_theme_background_mediumContrast">#0F1413</color>
<color name="md_theme_onBackground_mediumContrast">#DFE3E1</color>
<color name="md_theme_surface_mediumContrast">#0F1413</color>
<color name="md_theme_onSurface_mediumContrast">#F7FCF9</color>
<color name="md_theme_surfaceVariant_mediumContrast">#3E4946</color>
<color name="md_theme_onSurfaceVariant_mediumContrast">#C1CDCA</color>
<color name="md_theme_outline_mediumContrast">#99A5A2</color>
<color name="md_theme_outlineVariant_mediumContrast">#798682</color>
<color name="md_theme_scrim_mediumContrast">#000000</color>
<color name="md_theme_inverseSurface_mediumContrast">#DFE3E1</color>
<color name="md_theme_inverseOnSurface_mediumContrast">#262B2A</color>
<color name="md_theme_inversePrimary_mediumContrast">#005248</color>
<color name="md_theme_primaryFixed_mediumContrast">#90F4E3</color>
<color name="md_theme_onPrimaryFixed_mediumContrast">#001511</color>
<color name="md_theme_primaryFixedDim_mediumContrast">#73D8C7</color>
<color name="md_theme_onPrimaryFixedVariant_mediumContrast">#003E37</color>
<color name="md_theme_secondaryFixed_mediumContrast">#C4EAE2</color>
<color name="md_theme_onSecondaryFixed_mediumContrast">#001511</color>
<color name="md_theme_secondaryFixedDim_mediumContrast">#A8CEC6</color>
<color name="md_theme_onSecondaryFixedVariant_mediumContrast">#183C36</color>
<color name="md_theme_tertiaryFixed_mediumContrast">#ECDCFF</color>
<color name="md_theme_onTertiaryFixed_mediumContrast">#1A003E</color>
<color name="md_theme_tertiaryFixedDim_mediumContrast">#D5BBFF</color>
<color name="md_theme_onTertiaryFixedVariant_mediumContrast">#41286A</color>
<color name="md_theme_surfaceDim_mediumContrast">#0F1413</color>
<color name="md_theme_surfaceBright_mediumContrast">#353A39</color>
<color name="md_theme_surfaceContainerLowest_mediumContrast">#0A0F0E</color>
<color name="md_theme_surfaceContainerLow_mediumContrast">#171D1B</color>
<color name="md_theme_surfaceContainer_mediumContrast">#1B211F</color>
<color name="md_theme_surfaceContainerHigh_mediumContrast">#262B2A</color>
<color name="md_theme_surfaceContainerHighest_mediumContrast">#313634</color>
<color name="md_theme_primary_highContrast">#EBFFFA</color>
<color name="md_theme_onPrimary_highContrast">#000000</color>
<color name="md_theme_primaryContainer_highContrast">#77DCCB</color>
<color name="md_theme_onPrimaryContainer_highContrast">#000000</color>
<color name="md_theme_secondary_highContrast">#EBFFFA</color>
<color name="md_theme_onSecondary_highContrast">#000000</color>
<color name="md_theme_secondaryContainer_highContrast">#ACD2CA</color>
<color name="md_theme_onSecondaryContainer_highContrast">#000000</color>
<color name="md_theme_tertiary_highContrast">#FFF9FE</color>
<color name="md_theme_onTertiary_highContrast">#000000</color>
<color name="md_theme_tertiaryContainer_highContrast">#D8C0FF</color>
<color name="md_theme_onTertiaryContainer_highContrast">#000000</color>
<color name="md_theme_error_highContrast">#FFF9F9</color>
<color name="md_theme_onError_highContrast">#000000</color>
<color name="md_theme_errorContainer_highContrast">#FFBAB1</color>
<color name="md_theme_onErrorContainer_highContrast">#000000</color>
<color name="md_theme_background_highContrast">#0F1413</color>
<color name="md_theme_onBackground_highContrast">#DFE3E1</color>
<color name="md_theme_surface_highContrast">#0F1413</color>
<color name="md_theme_onSurface_highContrast">#FFFFFF</color>
<color name="md_theme_surfaceVariant_highContrast">#3E4946</color>
<color name="md_theme_onSurfaceVariant_highContrast">#F1FEF9</color>
<color name="md_theme_outline_highContrast">#C1CDCA</color>
<color name="md_theme_outlineVariant_highContrast">#C1CDCA</color>
<color name="md_theme_scrim_highContrast">#000000</color>
<color name="md_theme_inverseSurface_highContrast">#DFE3E1</color>
<color name="md_theme_inverseOnSurface_highContrast">#000000</color>
<color name="md_theme_inversePrimary_highContrast">#00302A</color>
<color name="md_theme_primaryFixed_highContrast">#94F9E7</color>
<color name="md_theme_onPrimaryFixed_highContrast">#000000</color>
<color name="md_theme_primaryFixedDim_highContrast">#77DCCB</color>
<color name="md_theme_onPrimaryFixedVariant_highContrast">#001A16</color>
<color name="md_theme_secondaryFixed_highContrast">#C8EFE6</color>
<color name="md_theme_onSecondaryFixed_highContrast">#000000</color>
<color name="md_theme_secondaryFixedDim_highContrast">#ACD2CA</color>
<color name="md_theme_onSecondaryFixedVariant_highContrast">#001A16</color>
<color name="md_theme_tertiaryFixed_highContrast">#EFE1FF</color>
<color name="md_theme_onTertiaryFixed_highContrast">#000000</color>
<color name="md_theme_tertiaryFixedDim_highContrast">#D8C0FF</color>
<color name="md_theme_onTertiaryFixedVariant_highContrast">#200249</color>
<color name="md_theme_surfaceDim_highContrast">#0F1413</color>
<color name="md_theme_surfaceBright_highContrast">#353A39</color>
<color name="md_theme_surfaceContainerLowest_highContrast">#0A0F0E</color>
<color name="md_theme_surfaceContainerLow_highContrast">#171D1B</color>
<color name="md_theme_surfaceContainer_highContrast">#1B211F</color>
<color name="md_theme_surfaceContainerHigh_highContrast">#262B2A</color>
<color name="md_theme_surfaceContainerHighest_highContrast">#313634</color>
</resources>
Loading

0 comments on commit b6e7818

Please sign in to comment.