Merge pull request #23 from lacerta-doc/source/add_files

画像ファイルの追加(保存), メタデータの管理
This commit is contained in:
ろむねこ authored and GitHub committed 2024-01-08 16:18:36 +09:00
commit 717b8e9637
32 files changed
+1348 -3

No files matched your search

+3
View File
@@ -65,4 +65,7 @@ dependencies {
// Scanner
implementation project(':component:scanner')
// Processor
implementation project(':processor')
}
@@ -0,0 +1,44 @@
package one.nem.lacerta.feature.debug;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* A simple {@link Fragment} subclass.
* Use the {@link DebugMenuDocProcessorTesterFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class DebugMenuDocProcessorTesterFragment extends Fragment {
public DebugMenuDocProcessorTesterFragment() {
// Required empty public constructor
}
public static DebugMenuDocProcessorTesterFragment newInstance() {
DebugMenuDocProcessorTesterFragment fragment = new DebugMenuDocProcessorTesterFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_debug_menu_doc_processor_tester, container, false);
return view;
}
}
@@ -0,0 +1,110 @@
package one.nem.lacerta.feature.debug;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.source.file.FileManager;
import one.nem.lacerta.source.file.factory.FileManagerFactory;
import one.nem.lacerta.utils.repository.DeviceInfoUtils;
import javax.inject.Inject;
/**
* A simple {@link Fragment} subclass.
* Use the {@link DebugMenuFileManagerTesterFragment#newInstance} factory method to
* create an instance of this fragment.
*/
@AndroidEntryPoint
public class DebugMenuFileManagerTesterFragment extends Fragment {
public DebugMenuFileManagerTesterFragment() {
// Required empty public constructor
}
@Inject
FileManagerFactory fileManagerFactory;
@Inject
DeviceInfoUtils deviceInfoUtils;
// TODO: Rename and change types and number of parameters
public static DebugMenuFileManagerTesterFragment newInstance() {
DebugMenuFileManagerTesterFragment fragment = new DebugMenuFileManagerTesterFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_debug_menu_file_manager_tester, container, false);
view.findViewById(R.id.button_create_directory).setOnClickListener(v -> {
EditText editText = view.findViewById(R.id.edit_text_dir_name);
String dirName = editText.getText().toString();
FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory());
fileManager.createDir(dirName);
});
view.findViewById(R.id.button_save_item).setOnClickListener(v -> {
FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory());
fileManager.createDir("test");
fileManager.changeDir("test");
Bitmap bitmap = Bitmap.createBitmap(1000, 1000, Bitmap.Config.ARGB_8888);
// Bitmapに描画処理を行う
Canvas canvas = new Canvas(bitmap);
// 大きな山の形状を作成
android.graphics.Path bigMountainPath = new android.graphics.Path();
bigMountainPath.moveTo(100, 800); // 左下の開始点
bigMountainPath.lineTo(500, 300); // 頂点
bigMountainPath.lineTo(900, 800); // 右下
bigMountainPath.close(); // パスを閉じる
// 山の描画設定
Paint mountainPaint = new Paint();
mountainPaint.setColor(Color.GREEN);
mountainPaint.setStyle(Paint.Style.FILL);
// 大きな山を描画
canvas.drawPath(bigMountainPath, mountainPaint);
// 小さな山の形状を作成
android.graphics.Path smallMountainPath = new android.graphics.Path();
smallMountainPath.moveTo(400, 800); // 左下の開始点
smallMountainPath.lineTo(650, 400); // 頂点
smallMountainPath.lineTo(900, 800); // 右下
smallMountainPath.close(); // パスを閉じる
Paint smallMountainPaint = new Paint();
smallMountainPaint.setColor(Color.parseColor("#006e54"));
smallMountainPaint.setStyle(Paint.Style.FILL);
// 小さな山を描画
canvas.drawPath(smallMountainPath, smallMountainPaint);
fileManager.saveBitmapAtCurrent(bitmap, "test.png");
});
return view;
}
}
@@ -12,6 +12,7 @@ import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.feature.debug.common.adapter.DebugMenuListItemAdapter;
import one.nem.lacerta.feature.debug.common.model.DebugMenuListItem;
@@ -20,6 +21,7 @@ import one.nem.lacerta.feature.debug.common.model.DebugMenuListItem;
* Use the {@link DebugMenuTopFragment#newInstance} factory method to
* create an instance of this fragment.
*/
@AndroidEntryPoint
public class DebugMenuTopFragment extends Fragment {
public DebugMenuTopFragment() {
// Required empty public constructor
@@ -49,6 +51,7 @@ public class DebugMenuTopFragment extends Fragment {
debugMenuListItems.add(new DebugMenuListItem("Meta Data", "View meta data", R.id.action_debugMenuTopFragment_to_debugMenuMetaDataFragment, true));
debugMenuListItems.add(new DebugMenuListItem("Document Tester", "placeholder", R.id.action_debugMenuTopFragment_to_debugMenuDocumentTesterTopFragment, true));
debugMenuListItems.add(new DebugMenuListItem("Scanner", "placeholder", R.id.action_debugMenuTopFragment_to_scannerDataManagerStubFragment, true));
debugMenuListItems.add(new DebugMenuListItem("File Manager", "placeholder", R.id.action_debugMenuTopFragment_to_debugMenuFileManagerTesterFragment, true));
DebugMenuListItemAdapter adapter = new DebugMenuListItemAdapter(debugMenuListItems);
recyclerView.setAdapter(adapter);
@@ -0,0 +1,36 @@
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/Theme.Lacerta"
tools:context=".DebugMenuDocProcessorTesterFragment" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="1dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="1dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.google.android.material.button.MaterialButton
android:id="@+id/button_gen_random_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Generate random image" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,40 @@
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".DebugMenuFileManagerTesterFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<EditText
android:id="@+id/edit_text_dir_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/button_create_directory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Create dir" />
<Button
android:id="@+id/button_dir_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="List item in current" />
<Button
android:id="@+id/button_save_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Save Test Image" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -19,6 +19,9 @@
<action
android:id="@+id/action_debugMenuTopFragment_to_scannerDataManagerStubFragment"
app:destination="@id/scannerDataManagerStubFragment" />
<action
android:id="@+id/action_debugMenuTopFragment_to_debugMenuFileManagerTesterFragment"
app:destination="@id/debugMenuFileManagerTesterFragment" />
</fragment>
<fragment
android:id="@+id/debugMenuMetaDataFragment"
@@ -51,4 +54,9 @@
android:id="@+id/scannerDataManagerStubFragment"
android:name="one.nem.lacerta.component.scanner.ScannerDataManagerStubFragment"
android:label="ScannerDataManagerStubFragment" />
<fragment
android:id="@+id/debugMenuFileManagerTesterFragment"
android:name="one.nem.lacerta.feature.debug.DebugMenuFileManagerTesterFragment"
android:label="fragment_debug_menu_file_manager_tester"
tools:layout="@layout/fragment_debug_menu_file_manager_tester" />
</navigation>