From 35b998eebe39d9998dfe1e3e38d870dc1efe163c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 15 Jan 2024 15:09:58 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A2=E3=82=AF=E3=83=86=E3=82=A3=E3=83=93?= =?UTF-8?q?=E3=83=86=E3=82=A3=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/scanner/build.gradle | 2 + .../scanner/src/main/AndroidManifest.xml | 6 +++ .../scanner/ScannerManagerActivity.java | 24 +++++++++ .../scanner/ScannerManagerFragment.java | 52 ++++++++++--------- .../res/layout/activity_scanner_manager.xml | 10 ++++ 5 files changed, 70 insertions(+), 24 deletions(-) create mode 100644 component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerActivity.java create mode 100644 component/scanner/src/main/res/layout/activity_scanner_manager.xml diff --git a/component/scanner/build.gradle b/component/scanner/build.gradle index 735535ff..defa4b6e 100644 --- a/component/scanner/build.gradle +++ b/component/scanner/build.gradle @@ -30,6 +30,8 @@ dependencies { implementation libs.androidx.appcompat implementation libs.com.google.android.material + implementation libs.androidx.activity + implementation libs.androidx.constraintlayout testImplementation libs.junit androidTestImplementation libs.androidx.test.ext.junit androidTestImplementation libs.androidx.test.espresso.core diff --git a/component/scanner/src/main/AndroidManifest.xml b/component/scanner/src/main/AndroidManifest.xml index a5918e68..74cc7c29 100644 --- a/component/scanner/src/main/AndroidManifest.xml +++ b/component/scanner/src/main/AndroidManifest.xml @@ -1,4 +1,10 @@ + + + + \ No newline at end of file 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 new file mode 100644 index 00000000..f5109892 --- /dev/null +++ b/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerActivity.java @@ -0,0 +1,24 @@ +package one.nem.lacerta.component.scanner; + +import android.os.Bundle; + +import androidx.activity.EdgeToEdge; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; + +public class ScannerManagerActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + EdgeToEdge.enable(this); + setContentView(R.layout.activity_scanner_manager); + ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> { + Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); + return insets; + }); + } +} \ 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 f50332ca..7203e691 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 @@ -31,24 +31,7 @@ public class ScannerManagerFragment extends Fragment { @Inject LacertaVcsFactory vcsFactory; - DocumentScanner documentScanner = new DocumentScanner( - requireActivity(), - (croppedImage) -> { - // TODO-rca: 画像を保存する - return null; - }, - (error) -> { - // TODO-rca: エラー処理 - return null; - }, - () -> { - // TODO-rca: キャンセル処理 - return null; - }, - null, - null, - null - ); + DocumentScanner documentScanner; private static final boolean DEFAULT_SINGLE_PAGE = false; private boolean singlePage; @@ -79,6 +62,25 @@ 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 @@ -87,11 +89,11 @@ public class ScannerManagerFragment extends Fragment { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_scanner_manager, container, false); - ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT - ); - view.setLayoutParams(layoutParams); +// ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams( +// ViewGroup.LayoutParams.MATCH_PARENT, +// ViewGroup.LayoutParams.MATCH_PARENT +// ); +// view.setLayoutParams(layoutParams); return view; } @@ -104,7 +106,9 @@ public class ScannerManagerFragment extends Fragment { logger.debug(TAG, "called"); view.findViewById(R.id.button_start_scan).setOnClickListener(v -> { - documentScanner.startScan(); + if (documentScanner != null) { + documentScanner.startScan(); + } }); } } \ 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 new file mode 100644 index 00000000..1b0b261a --- /dev/null +++ b/component/scanner/src/main/res/layout/activity_scanner_manager.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file