アクティビティ作成

This commit is contained in:
ろむねこ 2024-01-15 15:09:58 +09:00
parent b99efb3336
commit 35b998eebe
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168
5 changed files with 70 additions and 24 deletions

View File

@ -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

View File

@ -1,4 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<activity
android:name=".ScannerManagerActivity"
android:exported="false" />
</application>
</manifest>

View File

@ -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;
});
}
}

View File

@ -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();
}
});
}
}

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ScannerManagerActivity">
</androidx.constraintlayout.widget.ConstraintLayout>