From aefe5d10015713c663d86a677c181f0f819f965c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Tue, 16 Jan 2024 10:16:58 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B9=E3=82=AD=E3=83=A3=E3=83=8A=E5=AE=9F?= =?UTF-8?q?=E8=A3=85=E3=81=84=E3=82=8D=E3=81=84=E3=82=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scanner/ScannerManagerActivity.java | 35 +++++++++++++++++++ .../scanner/ScannerManagerFragment.java | 31 ++++------------ .../res/layout/activity_scanner_manager.xml | 8 +++++ .../res/layout/fragment_scanner_manager.xml | 2 +- 4 files changed, 50 insertions(+), 26 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 f5109892..fed35e21 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 @@ -1,15 +1,45 @@ package one.nem.lacerta.component.scanner; import android.os.Bundle; +import android.util.Log; import androidx.activity.EdgeToEdge; +import androidx.annotation.AnimatorRes; import androidx.appcompat.app.AppCompatActivity; import androidx.core.graphics.Insets; import androidx.core.view.ViewCompat; import androidx.core.view.WindowInsetsCompat; +import com.websitebeaver.documentscanner.DocumentScanner; + +import javax.inject.Inject; + +import dagger.hilt.android.AndroidEntryPoint; + +@AndroidEntryPoint public class ScannerManagerActivity extends AppCompatActivity { + DocumentScanner documentScanner = new DocumentScanner( + this, + (croppedImageResults) -> { + // display the first cropped image + return null; + }, + (errorMessage) -> { + // an error happened + Log.v("documentscannerlogs", errorMessage); + return null; + }, + () -> { + // user canceled document scan + Log.v("documentscannerlogs", "User canceled document scan"); + return null; + }, + null, + null, + 5 + ); + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -20,5 +50,10 @@ public class ScannerManagerActivity extends AppCompatActivity { v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); return insets; }); + + documentScanner.startScan(); + // Init + } + } \ No newline at end of file diff --git a/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerFragment.java b/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerFragment.java index 7203e691..b820111e 100644 --- a/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerFragment.java +++ b/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerFragment.java @@ -1,5 +1,6 @@ package one.nem.lacerta.component.scanner; +import android.content.Intent; import android.os.Bundle; import androidx.fragment.app.Fragment; @@ -9,6 +10,7 @@ import android.view.View; import android.view.ViewGroup; import com.websitebeaver.documentscanner.DocumentScanner; +import com.websitebeaver.documentscanner.DocumentScannerActivity; import java.util.Objects; @@ -31,8 +33,6 @@ public class ScannerManagerFragment extends Fragment { @Inject LacertaVcsFactory vcsFactory; - DocumentScanner documentScanner; - private static final boolean DEFAULT_SINGLE_PAGE = false; private boolean singlePage; @@ -62,25 +62,6 @@ public class ScannerManagerFragment extends Fragment { if (getArguments() != null) { singlePage = getArguments().getBoolean("singlePage", DEFAULT_SINGLE_PAGE); } - - documentScanner = new DocumentScanner( - requireActivity(), - (croppedImage) -> { - // TODO-rca: 画像を保存する - return null; - }, - (error) -> { - // TODO-rca: エラー処理 - return null; - }, - () -> { - // TODO-rca: キャンセル処理 - return null; - }, - null, - null, - null - ); } @Override @@ -105,10 +86,10 @@ public class ScannerManagerFragment extends Fragment { // Init logger.debug(TAG, "called"); - view.findViewById(R.id.button_start_scan).setOnClickListener(v -> { - if (documentScanner != null) { - documentScanner.startScan(); - } + view.findViewById(R.id.button_intent_scanner_manager_activity).setOnClickListener(v -> { + // DocumentScannerActivityを起動する + Intent intent = new Intent(requireActivity().getApplicationContext(), ScannerManagerActivity.class); + startActivity(intent); }); } } \ No newline at end of file diff --git a/component/scanner/src/main/res/layout/activity_scanner_manager.xml b/component/scanner/src/main/res/layout/activity_scanner_manager.xml index 1b0b261a..db5c0e80 100644 --- a/component/scanner/src/main/res/layout/activity_scanner_manager.xml +++ b/component/scanner/src/main/res/layout/activity_scanner_manager.xml @@ -7,4 +7,12 @@ android:layout_height="match_parent" tools:context=".ScannerManagerActivity"> +