mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2026-11-08 03:47:36 +00:00
Compare commits
50
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7286f0a4a | ||
|
|
cbe34bfed2 | ||
|
|
62f5d53bb3 | ||
|
|
cd1f2b2261 | ||
|
|
54abcb1ac9 | ||
|
|
ea2307e347 | ||
|
|
af383835b3 | ||
|
|
d325866c3a | ||
|
|
a37648d9d5 | ||
|
|
98565c799f | ||
|
|
df70d27f23 | ||
|
|
deac33a3d6 | ||
|
|
19c52b89a6 | ||
|
|
2e617baf1c | ||
|
|
aea6ea3808 | ||
|
|
ba4ff5652e | ||
|
|
c0e64ad5fd | ||
|
|
9a71fb5c26 | ||
|
|
1419100e1f | ||
|
|
576d1d7c9b | ||
|
|
c1d132a460 | ||
|
|
94faf3c56d | ||
|
|
cc9423ef17 | ||
|
|
714b3e9e6e | ||
|
|
aadd0ae17c | ||
|
|
3bfbd904f4 | ||
|
|
64fe9abc20 | ||
|
|
e4d77d9245 | ||
|
|
05586c181f | ||
|
|
a8d27e408c | ||
|
|
a9273561b1 | ||
|
|
0946fa80f1 | ||
|
|
06a0e53639 | ||
|
|
d9a56fd2ce | ||
|
|
d78ebd0b7c | ||
|
|
9f11005c4f | ||
|
|
3fd0a3efe5 | ||
|
|
8054f0d4f9 | ||
|
|
7de08a4d62 | ||
|
|
81411d5271 | ||
|
|
ca8e272980 | ||
|
|
562034d8a5 | ||
|
|
d64038b9eb | ||
|
|
71c6ab68e1 | ||
|
|
4855f6c75e | ||
|
|
b1bdfb4ae4 | ||
|
|
a70f92a872 | ||
|
|
9a48dbdaea | ||
|
|
b083a98ef6 | ||
|
|
05e2a0360f |
No files matched your search
Generated
+5
-12
@@ -1,17 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="deploymentTargetDropDown">
|
<component name="deploymentTargetDropDown">
|
||||||
<runningDeviceTargetSelectedWithDropDown>
|
<value>
|
||||||
<Target>
|
<entry key="app">
|
||||||
<type value="RUNNING_DEVICE_TARGET" />
|
<State />
|
||||||
<deviceKey>
|
</entry>
|
||||||
<Key>
|
</value>
|
||||||
<type value="SERIAL_NUMBER" />
|
|
||||||
<value value="ZY227DCBHN" />
|
|
||||||
</Key>
|
|
||||||
</deviceKey>
|
|
||||||
</Target>
|
|
||||||
</runningDeviceTargetSelectedWithDropDown>
|
|
||||||
<timeTargetWasSelectedWithDropDown value="2023-12-21T04:53:14.729902700Z" />
|
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
Generated
-1
@@ -4,7 +4,6 @@
|
|||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="testRunner" value="GRADLE" />
|
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="jbr-17" />
|
<option name="gradleJvm" value="jbr-17" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
|
|||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|||||||
@@ -7,12 +7,6 @@
|
|||||||
android:required="false" />
|
android:required="false" />
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
|
|
||||||
<queries>
|
|
||||||
<intent>
|
|
||||||
<action android:name="android.media.action.IMAGE_CAPTURE" />
|
|
||||||
</intent>
|
|
||||||
</queries>
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
|
|||||||
-110
@@ -1,110 +0,0 @@
|
|||||||
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,7 +12,6 @@ import android.view.ViewGroup;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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.adapter.DebugMenuListItemAdapter;
|
||||||
import one.nem.lacerta.feature.debug.common.model.DebugMenuListItem;
|
import one.nem.lacerta.feature.debug.common.model.DebugMenuListItem;
|
||||||
|
|
||||||
@@ -21,7 +20,6 @@ import one.nem.lacerta.feature.debug.common.model.DebugMenuListItem;
|
|||||||
* Use the {@link DebugMenuTopFragment#newInstance} factory method to
|
* Use the {@link DebugMenuTopFragment#newInstance} factory method to
|
||||||
* create an instance of this fragment.
|
* create an instance of this fragment.
|
||||||
*/
|
*/
|
||||||
@AndroidEntryPoint
|
|
||||||
public class DebugMenuTopFragment extends Fragment {
|
public class DebugMenuTopFragment extends Fragment {
|
||||||
public DebugMenuTopFragment() {
|
public DebugMenuTopFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
@@ -51,7 +49,6 @@ 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("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("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("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);
|
DebugMenuListItemAdapter adapter = new DebugMenuListItemAdapter(debugMenuListItems);
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
<?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,9 +19,6 @@
|
|||||||
<action
|
<action
|
||||||
android:id="@+id/action_debugMenuTopFragment_to_scannerDataManagerStubFragment"
|
android:id="@+id/action_debugMenuTopFragment_to_scannerDataManagerStubFragment"
|
||||||
app:destination="@id/scannerDataManagerStubFragment" />
|
app:destination="@id/scannerDataManagerStubFragment" />
|
||||||
<action
|
|
||||||
android:id="@+id/action_debugMenuTopFragment_to_debugMenuFileManagerTesterFragment"
|
|
||||||
app:destination="@id/debugMenuFileManagerTesterFragment" />
|
|
||||||
</fragment>
|
</fragment>
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/debugMenuMetaDataFragment"
|
android:id="@+id/debugMenuMetaDataFragment"
|
||||||
@@ -54,9 +51,4 @@
|
|||||||
android:id="@+id/scannerDataManagerStubFragment"
|
android:id="@+id/scannerDataManagerStubFragment"
|
||||||
android:name="one.nem.lacerta.component.scanner.ScannerDataManagerStubFragment"
|
android:name="one.nem.lacerta.component.scanner.ScannerDataManagerStubFragment"
|
||||||
android:label="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>
|
</navigation>
|
||||||
@@ -29,8 +29,6 @@ dependencies {
|
|||||||
|
|
||||||
implementation libs.androidx.appcompat
|
implementation libs.androidx.appcompat
|
||||||
implementation libs.com.google.android.material
|
implementation libs.com.google.android.material
|
||||||
implementation 'androidx.navigation:navigation-fragment:2.7.5'
|
|
||||||
implementation 'androidx.navigation:navigation-ui:2.7.5'
|
|
||||||
testImplementation libs.junit
|
testImplementation libs.junit
|
||||||
androidTestImplementation libs.androidx.test.ext.junit
|
androidTestImplementation libs.androidx.test.ext.junit
|
||||||
androidTestImplementation libs.androidx.test.espresso.core
|
androidTestImplementation libs.androidx.test.espresso.core
|
||||||
@@ -40,11 +38,4 @@ dependencies {
|
|||||||
implementation libs.navigation.ui
|
implementation libs.navigation.ui
|
||||||
implementation libs.navigation.dynamic.features.fragment
|
implementation libs.navigation.dynamic.features.fragment
|
||||||
|
|
||||||
// Hilt (DI)
|
|
||||||
implementation libs.com.google.dagger.hilt.android
|
|
||||||
annotationProcessor libs.com.google.dagger.hilt.compiler
|
|
||||||
|
|
||||||
implementation project(':shared:ui')
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package one.nem.lacerta.feature.library;
|
|
||||||
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.DocumentViewHolder> {
|
|
||||||
|
|
||||||
private List<String> documentList;
|
|
||||||
|
|
||||||
public DocumentAdapter(List<String> documentList) {
|
|
||||||
this.documentList = documentList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public DocumentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
||||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_library_menu, parent, false);
|
|
||||||
return new DocumentViewHolder(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(@NonNull DocumentViewHolder holder, int position) {
|
|
||||||
holder.title.setText(documentList.get(position));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return documentList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
class DocumentViewHolder extends RecyclerView.ViewHolder {
|
|
||||||
TextView title;
|
|
||||||
|
|
||||||
DocumentViewHolder(View itemView) {
|
|
||||||
super(itemView);
|
|
||||||
title = itemView.findViewById(R.id.debug_menu_item_title);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-35
@@ -1,35 +0,0 @@
|
|||||||
package one.nem.lacerta.feature.library;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
// LibraryArchiveFragment.java
|
|
||||||
public class LibraryArchiveFragment extends AppCompatActivity {
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.fragment_library_top);
|
|
||||||
|
|
||||||
// ここに入力された内容を表示する機能
|
|
||||||
TextView textView = findViewById(R.id.document_list);
|
|
||||||
|
|
||||||
textView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
// 文字をタップしたときの処理
|
|
||||||
|
|
||||||
// 移動先のアクティビティを指定
|
|
||||||
Intent intent = new Intent(LibraryArchiveFragment.this, LibraryDocFragment.class);
|
|
||||||
|
|
||||||
// データを付加する
|
|
||||||
intent.putExtra("key_name", "value_data");
|
|
||||||
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package one.nem.lacerta.feature.library;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
|
|
||||||
public class LibraryDocFragment extends Fragment {
|
|
||||||
|
|
||||||
private TextView textView; // フィールドとして TextView を定義
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
View view = inflater.inflate(R.layout.fragment_library_file, container, false);
|
|
||||||
|
|
||||||
textView = view.findViewById(R.id.textView);
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
// フラグメントに渡されたデータを取得
|
|
||||||
if (getArguments() != null) {
|
|
||||||
String receivedData = getArguments().getString("key_name");
|
|
||||||
|
|
||||||
// onCreateView メソッドで取得した TextView にデータをセットする
|
|
||||||
if (textView != null) {
|
|
||||||
textView.setText(receivedData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Factory method for creating a new instance of the fragment
|
|
||||||
public static LibraryDocFragment newInstance(String data) {
|
|
||||||
LibraryDocFragment fragment = new LibraryDocFragment();
|
|
||||||
|
|
||||||
// フラグメントにデータを渡す
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putString("key_name", data);
|
|
||||||
fragment.setArguments(args);
|
|
||||||
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+3
-30
@@ -2,20 +2,11 @@ package one.nem.lacerta.feature.library;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple {@link Fragment} subclass.
|
* A simple {@link Fragment} subclass.
|
||||||
@@ -64,28 +55,10 @@ public class LibraryTopFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View view = inflater.inflate(R.layout.fragment_library_top, container, false);
|
return inflater.inflate(R.layout.fragment_library_top, container, false);
|
||||||
|
|
||||||
// Use view.findViewById instead of findViewById
|
|
||||||
RecyclerView documentRecyclerView = view.findViewById(R.id.document_list);
|
|
||||||
|
|
||||||
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
|
|
||||||
documentRecyclerView.setLayoutManager(layoutManager);
|
|
||||||
|
|
||||||
List<String> documentList = new ArrayList<>();
|
|
||||||
documentList.add("Document A");
|
|
||||||
documentList.add("Document B");
|
|
||||||
documentList.add("Document C");
|
|
||||||
|
|
||||||
// Create and set the adapter
|
|
||||||
DocumentAdapter adapter = new DocumentAdapter(documentList);
|
|
||||||
documentRecyclerView.setAdapter(adapter);
|
|
||||||
|
|
||||||
// Use a LinearLayoutManager to specify the layout
|
|
||||||
return view;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<?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"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:padding="16dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
@@ -1,32 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout 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"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:theme="@style/Theme.Lacerta"
|
|
||||||
tools:context=".LibraryTopFragment">
|
tools:context=".LibraryTopFragment">
|
||||||
|
|
||||||
<com.google.android.material.appbar.MaterialToolbar
|
<!-- TODO: Update blank fragment layout -->
|
||||||
android:id="@+id/tool_bar"
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/colorPrimaryContainer"
|
android:text="@string/hello_blank_fragment" />
|
||||||
android:minHeight="?attr/actionBarSize"
|
|
||||||
android:theme="?attr/actionBarTheme"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:title="Library"
|
|
||||||
app:titleTextColor="@color/colorOnPrimaryContainer" />
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
</FrameLayout>
|
||||||
android:id="@+id/document_list"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tool_bar" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<?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"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:padding="16dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/debug_menu_item_title"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/debug_menu_item_description"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="14sp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/debug_menu_item_title" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Library</string>
|
<!-- TODO: Remove or change this placeholder text -->
|
||||||
|
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -32,16 +32,4 @@ dependencies {
|
|||||||
testImplementation libs.junit
|
testImplementation libs.junit
|
||||||
androidTestImplementation libs.androidx.test.ext.junit
|
androidTestImplementation libs.androidx.test.ext.junit
|
||||||
androidTestImplementation libs.androidx.test.espresso.core
|
androidTestImplementation libs.androidx.test.espresso.core
|
||||||
|
|
||||||
// DI
|
|
||||||
implementation libs.com.google.dagger.hilt.android
|
|
||||||
annotationProcessor libs.com.google.dagger.hilt.compiler
|
|
||||||
|
|
||||||
// JGit
|
|
||||||
implementation 'org.eclipse.jgit:org.eclipse.jgit:6.8.0.202311291450-r'
|
|
||||||
|
|
||||||
implementation project(':model')
|
|
||||||
implementation project(':source')
|
|
||||||
implementation project(':utils')
|
|
||||||
implementation project(':data')
|
|
||||||
}
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package one.nem.lacerta.processor;
|
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
|
|
||||||
public interface DocumentProcessor {
|
|
||||||
|
|
||||||
// ページ操作
|
|
||||||
void addNewPageToLast(Bitmap bitmap);
|
|
||||||
void addNewPagesToLast(Bitmap[] bitmaps);
|
|
||||||
void addNewPageAfterIndex(Bitmap bitmap, int index);
|
|
||||||
void addNewPageBeforeIndex(Bitmap bitmap, int index);
|
|
||||||
void removePageAtIndex(int index);
|
|
||||||
|
|
||||||
// 更新
|
|
||||||
void updatePageAtIndex(Bitmap bitmap, int index);
|
|
||||||
|
|
||||||
// ページ取得
|
|
||||||
Bitmap getPageAtIndex(int index);
|
|
||||||
int getPageCount();
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package one.nem.lacerta.processor;
|
|
||||||
|
|
||||||
import one.nem.lacerta.processor.model.XmlMetaModel;
|
|
||||||
import one.nem.lacerta.processor.model.XmlMetaPageModel;
|
|
||||||
|
|
||||||
public interface XmlMetaProcessor {
|
|
||||||
|
|
||||||
void saveXmlMeta(XmlMetaModel xmlMetaModel);
|
|
||||||
XmlMetaModel loadXmlMeta();
|
|
||||||
}
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
package one.nem.lacerta.processor.factory;
|
|
||||||
|
|
||||||
public class DocumentProcessorFactory {
|
|
||||||
}
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
package one.nem.lacerta.processor.impl;
|
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import one.nem.lacerta.processor.DocumentProcessor;
|
|
||||||
|
|
||||||
import one.nem.lacerta.model.document.DocumentDetail;
|
|
||||||
import one.nem.lacerta.model.document.DocumentMeta;
|
|
||||||
|
|
||||||
import one.nem.lacerta.source.file.FileManager;
|
|
||||||
import one.nem.lacerta.source.file.factory.FileManagerFactory;
|
|
||||||
|
|
||||||
public class DocumentProcessorImpl implements DocumentProcessor{
|
|
||||||
|
|
||||||
// Magic Numbers
|
|
||||||
private static final String DEFAULT_SAVE_DIR = "raw";
|
|
||||||
|
|
||||||
private DocumentDetail documentDetail;
|
|
||||||
|
|
||||||
// Injection
|
|
||||||
@Inject
|
|
||||||
FileManagerFactory fileManagerFactory;
|
|
||||||
|
|
||||||
// Internal utils
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addNewPageToLast(Bitmap bitmap) {
|
|
||||||
Path path = documentDetail.getPath().getFullPath();
|
|
||||||
String fileName = String.format(UUID.randomUUID().toString() + ".png"); // TODO-rca: 対応表をもたせる
|
|
||||||
FileManager fileManager = fileManagerFactory.create(path);
|
|
||||||
if(fileManager.getList().contains(path.resolve(DEFAULT_SAVE_DIR))) {
|
|
||||||
fileManager.changeDir(DEFAULT_SAVE_DIR);
|
|
||||||
} else {
|
|
||||||
fileManager.createDir(DEFAULT_SAVE_DIR);
|
|
||||||
fileManager.changeDir(DEFAULT_SAVE_DIR);
|
|
||||||
}
|
|
||||||
fileManager.saveBitmapAtCurrent(bitmap, fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addNewPagesToLast(Bitmap[] bitmaps) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addNewPageAfterIndex(Bitmap bitmap, int index) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addNewPageBeforeIndex(Bitmap bitmap, int index) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removePageAtIndex(int index) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updatePageAtIndex(Bitmap bitmap, int index) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Bitmap getPageAtIndex(int index) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getPageCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package one.nem.lacerta.processor.impl;
|
|
||||||
|
|
||||||
import one.nem.lacerta.processor.XmlMetaProcessor;
|
|
||||||
import one.nem.lacerta.processor.model.XmlMetaModel;
|
|
||||||
|
|
||||||
public class XmlMetaProcessorImpl implements XmlMetaProcessor{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveXmlMeta(XmlMetaModel xmlMetaModel) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public XmlMetaModel loadXmlMeta() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Whitespace-only changes.
@@ -1,105 +0,0 @@
|
|||||||
package one.nem.lacerta.processor.model;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class XmlMetaModel {
|
|
||||||
|
|
||||||
String title;
|
|
||||||
String author;
|
|
||||||
String description;
|
|
||||||
// Date created;
|
|
||||||
// Date updated;
|
|
||||||
String defaultBranch;
|
|
||||||
ArrayList<XmlMetaPageModel> pages;
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
|
|
||||||
public XmlMetaModel() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public XmlMetaModel(String title, String author, String description, String defaultBranch, ArrayList<XmlMetaPageModel> pages) {
|
|
||||||
this.title = title;
|
|
||||||
this.author = author;
|
|
||||||
this.description = description;
|
|
||||||
this.defaultBranch = defaultBranch;
|
|
||||||
this.pages = pages;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Getter
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAuthor() {
|
|
||||||
return author;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDefaultBranch() {
|
|
||||||
return defaultBranch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<XmlMetaPageModel> getPages() {
|
|
||||||
return pages;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setter
|
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAuthor(String author) {
|
|
||||||
this.author = author;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultBranch(String defaultBranch) {
|
|
||||||
this.defaultBranch = defaultBranch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPages(ArrayList<XmlMetaPageModel> pages) {
|
|
||||||
this.pages = pages;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Public Methods
|
|
||||||
|
|
||||||
public void addPage(XmlMetaPageModel page) {
|
|
||||||
this.pages.add(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addPageAfterIndex(int index, XmlMetaPageModel page) {
|
|
||||||
this.pages.add(index, page);
|
|
||||||
|
|
||||||
//Update index
|
|
||||||
this.updateIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removePage(XmlMetaPageModel page) {
|
|
||||||
this.pages.remove(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removePageAtIndex(int index) {
|
|
||||||
this.pages.remove(index);
|
|
||||||
|
|
||||||
//Update index
|
|
||||||
this.updateIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Internal Methods
|
|
||||||
private void updateIndex() { // TODO-rca: 効率悪そう
|
|
||||||
for (int i = 0; i < this.pages.size(); i++) {
|
|
||||||
this.pages.get(i).setIndex(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package one.nem.lacerta.processor.model;
|
|
||||||
|
|
||||||
public class XmlMetaPageModel {
|
|
||||||
|
|
||||||
int index;
|
|
||||||
String filename;
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
|
|
||||||
public XmlMetaPageModel() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public XmlMetaPageModel(int index, String filename) {
|
|
||||||
this.index = index;
|
|
||||||
this.filename = filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getter
|
|
||||||
|
|
||||||
public int getIndex() {
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFilename() {
|
|
||||||
return filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setter
|
|
||||||
|
|
||||||
public void setIndex(int index) {
|
|
||||||
this.index = index;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFilename(String filename) {
|
|
||||||
this.filename = filename;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package one.nem.lacerta.processor.module;
|
|
||||||
|
|
||||||
public class DocumentProcessorModule {
|
|
||||||
}
|
|
||||||
Whitespace-only changes.
Whitespace-only changes.
@@ -1,4 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<!-- TODO: Remove or change this placeholder text -->
|
|
||||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
|
||||||
</resources>
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package one.nem.lacerta.source.file;
|
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface FileManager {
|
|
||||||
|
|
||||||
Path getRootDir();
|
|
||||||
void changeDir(String dirName); //cd
|
|
||||||
void backDir(); //cd ..
|
|
||||||
void backRootDir(); //cd /
|
|
||||||
List<Path> getList();
|
|
||||||
void createDir(String dirName);
|
|
||||||
void removeDir(String dirName);
|
|
||||||
|
|
||||||
void saveBitmapAtCurrent(Bitmap bitmap, String fileName);
|
|
||||||
Bitmap loadBitmap(Path path);
|
|
||||||
void removeBitmap(Path path);
|
|
||||||
|
|
||||||
// void saveFileAtCurrent(File file);
|
|
||||||
// File getFile(Path path);
|
|
||||||
// void removeFile(Path path);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package one.nem.lacerta.source.file.factory;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import dagger.assisted.AssistedFactory;
|
|
||||||
import one.nem.lacerta.source.file.impl.FileManagerImpl;
|
|
||||||
|
|
||||||
@AssistedFactory
|
|
||||||
public interface FileManagerFactory {
|
|
||||||
FileManagerImpl create(Path rootDir);
|
|
||||||
}
|
|
||||||
Whitespace-only changes.
@@ -1,130 +0,0 @@
|
|||||||
package one.nem.lacerta.source.file.impl;
|
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.DirectoryStream;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import dagger.assisted.Assisted;
|
|
||||||
import dagger.assisted.AssistedInject;
|
|
||||||
import one.nem.lacerta.source.file.FileManager;
|
|
||||||
|
|
||||||
public class FileManagerImpl implements FileManager {
|
|
||||||
|
|
||||||
// RootDir
|
|
||||||
private Path rootDir;
|
|
||||||
|
|
||||||
// CurrentDir
|
|
||||||
private Path currentDir;
|
|
||||||
|
|
||||||
// Internal Methods
|
|
||||||
private Path convertPath(String path) {
|
|
||||||
Path convertedPath = currentDir.resolve(path);
|
|
||||||
if (convertedPath.startsWith(rootDir)) { // 異常なパスの場合はnullを返す // TODO-rca: エラーハンドリング
|
|
||||||
return convertedPath;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@AssistedInject
|
|
||||||
public FileManagerImpl(@Assisted Path rootDir) {
|
|
||||||
this.rootDir = rootDir;
|
|
||||||
this.currentDir = rootDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Path getRootDir() {
|
|
||||||
return rootDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void changeDir(String dirName) {
|
|
||||||
this.currentDir = rootDir.resolve(dirName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void backDir() {
|
|
||||||
this.currentDir = currentDir.getParent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void backRootDir() {
|
|
||||||
this.currentDir = rootDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Path> getList() {
|
|
||||||
List<Path> list = new ArrayList<>();
|
|
||||||
try (DirectoryStream<Path> stream = Files.newDirectoryStream(currentDir)) {
|
|
||||||
for (Path entry : stream) { // TODO-rca: エラーハンドリング, 効率化
|
|
||||||
list.add(entry);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void createDir(String dirName) {
|
|
||||||
currentDir.resolve(dirName).toFile().mkdir(); // TODO-rca: エラーハンドリング
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeDir(String dirName) {
|
|
||||||
currentDir.resolve(dirName).toFile().delete(); // TODO-rca: エラーハンドリング
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveBitmapAtCurrent(Bitmap bitmap, String fileName) { // TODO-rca: ファイル形式を変更できるようにする?
|
|
||||||
try {
|
|
||||||
File file = currentDir.resolve(fileName).toFile();
|
|
||||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, Files.newOutputStream(file.toPath()));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Bitmap loadBitmap(Path path) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeBitmap(Path path) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void saveFileAtCurrent(File file) {
|
|
||||||
// try {
|
|
||||||
// Files.copy(file.toPath(), currentDir.resolve(file.getName()));
|
|
||||||
// } catch (IOException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public File getFile(Path path) {
|
|
||||||
// // ファイルを取得する
|
|
||||||
// return path.toFile();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void removeFile(Path path) {
|
|
||||||
// // ファイルを削除する
|
|
||||||
// if (path.toFile().exists()) {
|
|
||||||
// path.toFile().delete(); // Resultを返す?
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
||||||
Whitespace-only changes.
@@ -1,20 +0,0 @@
|
|||||||
package one.nem.lacerta.source.file.module;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import dagger.assisted.Assisted;
|
|
||||||
import dagger.assisted.AssistedInject;
|
|
||||||
|
|
||||||
public class FileManagerModule {
|
|
||||||
|
|
||||||
private final Path rootDir;
|
|
||||||
|
|
||||||
@AssistedInject
|
|
||||||
public FileManagerModule(@Assisted Path rootDir) {
|
|
||||||
this.rootDir = rootDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Path getRootDir() {
|
|
||||||
return rootDir;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Whitespace-only changes.
Reference in new issue
Block a user