Compare commits

..
Author SHA1 Message Date
r-ca 1b85845499 Readme.mdに説明を追加 2024-01-11 10:59:36 +09:00
ろむねこ 523008ff3f Merge pull request #41 from lacerta-doc/improve/improve_debug_menu
デバッグメニューから不要になったアイテムを削除
2024-01-10 12:28:11 +09:00
r-ca 50c2b1dc4d リンクを削除 2024-01-10 12:23:17 +09:00
r-ca ae8f7ef1f1 ナビゲーショングラフから削除 2024-01-10 12:23:03 +09:00
r-ca 27766effc1 メタデータを表示するフラグメント, クラスを削除 2024-01-10 12:22:49 +09:00
r-ca f7fe8b35b1 メニューから削除 2024-01-10 12:11:29 +09:00
r-ca 87c4738f37 ナビゲーションから削除 2024-01-10 12:10:48 +09:00
r-ca 96bfca0550 レイアウト, クラス削除 2024-01-10 12:10:37 +09:00
ろむねこ 0140c0376b Merge pull request #34 from lacerta-doc/improve/remove_page_index
Indexの廃止
2024-01-09 17:26:14 +09:00
r-ca 89a3a179bd index廃止 2024-01-09 17:23:56 +09:00
r-ca ff905d9280 index廃止 2024-01-09 17:23:08 +09:00
r-ca 4b0ea02f16 cleanup 2024-01-09 17:22:23 +09:00
r-ca ca37a97e2f Indexを廃止 2024-01-09 17:21:00 +09:00
ろむねこ 217f096a38 Merge pull request #33 from lacerta-doc/feature/add_doc_proc_missing
DocumentProcessorの不足しているメソッドを実装する(1)
2024-01-09 17:16:11 +09:00
r-ca 0c59c85b28 addNewPageBeforeIndex実装 2024-01-09 17:12:13 +09:00
r-ca e3a5dee36c addNewPageAfterIndex実装 2024-01-09 17:07:37 +09:00
r-ca 1805cd7d73 WIP 2024-01-09 17:05:25 +09:00
r-ca 513a91b41e throws追加 2024-01-09 17:04:42 +09:00
ろむねこ 3f2534b1eb Merge pull request #30 from lacerta-doc/improve/improve_file_manager
FileManagerの修正
2024-01-09 16:26:20 +09:00
12 changed files with 59 additions and 270 deletions

No files matched your search

+38
View File
@@ -7,6 +7,44 @@ WIP
## メモ
- アイコン: Google Material Icons https://fonts.google.com/icons (Weight:300, Grade:0, Optical size: 24px)
## モジュール構成
### モジュール一覧
- `component` : コンポーネント
- `common` : 共通コンポーネント
- UIの中で共通で使う要素(メニューアイテムとか)
- `scanner` : スキャナー
- スキャナーの実装
- `viewer` : ビューワー
- ドキュメントビューワーの実装
- `data` : データ
- UIからデータを取得/保存するためのラッパーモジュール
- `Document` : ドキュメント関係
- WIP(JavaDocを参照してください, 余裕があったら追記します)
- `feature` : 機能モジュール(ナビゲーションからみた機能で分割)
- `common`: 共通機能
- 設定画面とか、どこからでも呼ばれうる画面
- `debug`: デバッグメニュー
- `home`: ホーム画面
- `library`: ライブラリ画面
- `scan`: スキャン画面
- `search`: 検索画面
- `model` : モデル
- データモデルをまとめたモジュール (WIP)
- `document` : ドキュメント
- `meta` : メタデータ
- `processor` : プロセッサ
- いくつかの処理をまとめたモジュール
- `DocumentProcessor` : ドキュメント処理(ドキュメントにページを追加したり更新したり)
- `shared` :
- 共有リソース
- `source` : ソース
- (バックエンドが使うのでとりあえず後回し、フロントから直接操作することは絶対にありません)
- `utils` : ユーティリティ
- ちょっとしたユーティリティをまとめたモジュール
- `LacertaLogger` : ロガー
- `XmlMetaParser` : XMLメタデータパーサー(フロントから直接操作することは絶対にありません)
## コーディング規則/推奨(WIP)
### 規則
- `// TODO`コメントには任意のsuffixを付ける
@@ -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;
}
}
@@ -1,39 +0,0 @@
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 DebugMenuMetaDataFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class DebugMenuMetaDataFragment extends Fragment {
public DebugMenuMetaDataFragment() {
// Required empty public constructor
}
public static DebugMenuMetaDataFragment newInstance() {
DebugMenuMetaDataFragment fragment = new DebugMenuMetaDataFragment();
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
return inflater.inflate(R.layout.fragment_debug_menu_meta_data, container, false);
}
}
@@ -48,10 +48,8 @@ public class DebugMenuTopFragment extends Fragment {
recyclerView.setLayoutManager(new androidx.recyclerview.widget.LinearLayoutManager(getContext()));
List<DebugMenuListItem> debugMenuListItems = new ArrayList<>();
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);
@@ -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>
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".DebugMenuMetaDataFragment">
<!-- TODO: Update blank fragment layout -->
</FrameLayout>
@@ -10,24 +10,13 @@
android:name="one.nem.lacerta.feature.debug.DebugMenuTopFragment"
android:label="fragment_debug_menu_top"
tools:layout="@layout/fragment_debug_menu_top" >
<action
android:id="@+id/action_debugMenuTopFragment_to_debugMenuMetaDataFragment"
app:destination="@id/debugMenuMetaDataFragment" />
<action
android:id="@+id/action_debugMenuTopFragment_to_debugMenuDocumentTesterTopFragment"
app:destination="@id/debugMenuDocumentTesterTopFragment" />
<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"
android:name="one.nem.lacerta.feature.debug.DebugMenuMetaDataFragment"
android:label="fragment_debug_menu_meta_data"
tools:layout="@layout/fragment_debug_menu_meta_data" />
<fragment
android:id="@+id/debugMenuDocumentTesterTopFragment"
android:name="one.nem.lacerta.feature.debug.DebugMenuDocumentTesterTopFragment"
@@ -54,9 +43,4 @@
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>
@@ -70,35 +70,4 @@ public class XmlMetaModel {
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);
}
}
}
@@ -2,7 +2,6 @@ package one.nem.lacerta.model.document.internal;
public class XmlMetaPageModel {
int index;
String filename;
// Constructor
@@ -10,27 +9,18 @@ public class XmlMetaPageModel {
public XmlMetaPageModel() {
}
public XmlMetaPageModel(int index, String filename) {
this.index = index;
public XmlMetaPageModel(String filename) {
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;
}
@@ -7,9 +7,9 @@ public interface DocumentProcessor {
// ページ操作
void addNewPageToLast(Bitmap bitmap) throws Exception;
void addNewPagesToLast(Bitmap[] bitmaps) throws Exception;
void addNewPageAfterIndex(Bitmap bitmap, int index);
void addNewPageBeforeIndex(Bitmap bitmap, int index);
void removePageAtIndex(int index);
void addNewPageAfterIndex(Bitmap bitmap, int index) throws Exception;
void addNewPageBeforeIndex(Bitmap bitmap, int index) throws Exception;
void removePageAtIndex(int index) throws Exception;
// 更新
void updatePageAtIndex(Bitmap bitmap, int index);
@@ -102,11 +102,10 @@ public class DocumentProcessorImpl implements DocumentProcessor{
XmlMetaPageModel xmlMetaPageModel = new XmlMetaPageModel();
xmlMetaPageModel.setFilename(filename);
xmlMetaPageModel.setIndex(xmlMetaModel.getPages().size() + 1);
xmlMetaModel.getPages().add(xmlMetaPageModel);
logger.info("addNewPageToLast", "finished");
logger.info("addNewPageToLast", "filename: " + filename + ", index: " + xmlMetaPageModel.getIndex());
logger.info("addNewPageToLast", "filename: " + filename);
}
@Override
@@ -119,13 +118,27 @@ public class DocumentProcessorImpl implements DocumentProcessor{
}
@Override
public void addNewPageAfterIndex(Bitmap bitmap, int index) {
public void addNewPageAfterIndex(Bitmap bitmap, int index) throws Exception {
logger.debug("addNewPageAfterIndex", "called");
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
this.fileManager.getNewInstance().createDirectoryIfNotExist(DEFAULT_SAVE_DIR).resolve(DEFAULT_SAVE_DIR).saveBitmap(bitmap, filename);
XmlMetaPageModel xmlMetaPageModel = new XmlMetaPageModel();
xmlMetaPageModel.setFilename(filename);
xmlMetaModel.getPages().add(index, xmlMetaPageModel);
}
@Override
public void addNewPageBeforeIndex(Bitmap bitmap, int index) {
public void addNewPageBeforeIndex(Bitmap bitmap, int index) throws Exception {
logger.debug("addNewPageBeforeIndex", "called");
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
this.fileManager.getNewInstance().createDirectoryIfNotExist(DEFAULT_SAVE_DIR).resolve(DEFAULT_SAVE_DIR).saveBitmap(bitmap, filename);
XmlMetaPageModel xmlMetaPageModel = new XmlMetaPageModel();
xmlMetaPageModel.setFilename(filename);
xmlMetaModel.getPages().add(index - 1, xmlMetaPageModel);
}
@Override
@@ -41,7 +41,6 @@ public class XmlMetaParserImpl implements XmlMetaParser{
for(int i = 0; i < rootElement.getElementsByTagName("pages").getLength(); i++) {
Element pageElement = (Element) rootElement.getElementsByTagName("page").item(i);
XmlMetaPageModel page = new XmlMetaPageModel();
page.setIndex(Integer.parseInt(pageElement.getElementsByTagName("index").item(0).getTextContent()));
page.setFilename(pageElement.getElementsByTagName("filename").item(0).getTextContent());
pages.add(page);
}
@@ -73,7 +72,6 @@ public class XmlMetaParserImpl implements XmlMetaParser{
Element pagesElement = document.createElement("pages");
for(XmlMetaPageModel page : meta.getPages()) {
Element pageElement = document.createElement("page");
appendElement(document, pageElement, "index", String.valueOf(page.getIndex()));
appendElement(document, pageElement, "filename", page.getFilename());
pagesElement.appendChild(pageElement);
}