From 719769c045394e2733962260200d48b2ade5cc92 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 04:17:01 +0900 Subject: [PATCH] =?UTF-8?q?Single=E3=83=A2=E3=83=BC=E3=83=89=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scanner/ScannerManagerActivity.java | 49 +++++++++++++++---- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerActivity.java b/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerActivity.java index b48fb62d..d38140ed 100644 --- a/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerActivity.java +++ b/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerActivity.java @@ -57,8 +57,7 @@ public class ScannerManagerActivity extends AppCompatActivity { // Variables private ArrayList croppedImages = new ArrayList<>(); - private int maxPage = 0; - private boolean withOutLimit = false; + private boolean single = false; View view; @@ -86,9 +85,37 @@ public class ScannerManagerActivity extends AppCompatActivity { }, null, null, - withOutLimit ? null : maxPage + null ); + DocumentScanner documentScannerSingle = new DocumentScanner( // TODO-rca: ひどすぎるのでなんとかする + this, + (croppedImageResults) -> { + logger.debug(TAG, "croppedImage size: " + croppedImageResults.size()); + ArrayList croppedImages = new ArrayList<>(); + for (String result : croppedImageResults) { + croppedImages.add(BitmapFactory.decodeFile(result)); + } + processResult(croppedImages); + return null; + }, + (errorMessage) -> { + // an error happened + logger.error(TAG, "Error: " + errorMessage); + logger.e_code("543a230e-cb9a-47a2-8131-3beecfe1c458"); + return null; + }, + () -> { + // user canceled document scan + logger.debug(TAG, "User canceled document scan"); + return null; + }, + null, + null, + 1 + ); + + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -112,17 +139,21 @@ public class ScannerManagerActivity extends AppCompatActivity { setSupportActionBar(toolbar); Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true); + Intent intent = getIntent(); + Bundle bundle = intent.getExtras(); + if (bundle != null) { + this.single = bundle.getBoolean("single", false); + } + + if (this.single) { + documentScanner = documentScannerSingle; + } documentScanner.startScan(); // Init this.view = findViewById(R.id.main); // TODO-rca:なんとかする - Intent intent = getIntent(); - Bundle bundle = intent.getExtras(); - if (bundle != null) { - this.maxPage = bundle.getInt("maxPage", 0); - this.withOutLimit = bundle.getBoolean("withOutLimit", false); - } + } @Override