Compare commits

...
Author SHA1 Message Date
r-ca 4235030986 外部リソースを使うように 2024-01-19 15:27:51 +09:00
r-ca c60fedeb87 WIP 2024-01-19 15:26:57 +09:00
r-ca 2f18134581 WIP 2024-01-19 15:25:28 +09:00
ろむねこ 4101f75685 Merge pull request #81 from lacerta-doc/refactor/refactor1
リファクタリング
2024-01-19 15:20:52 +09:00
r-ca 184771c92d リソースを切り出す準備 2024-01-19 15:19:15 +09:00
r-ca 3e12f1222b ナビゲーションの並び順を変更 2024-01-19 15:17:44 +09:00
r-ca 29f2749cb7 整形 2024-01-19 15:16:20 +09:00
r-ca 244b2fb123 リファクタリング 2024-01-19 15:15:46 +09:00
r-ca 725d541316 リファクタリング 2024-01-19 15:14:08 +09:00
r-ca fc712a131a Revert "utilsを依存関係に追加, LoggerをInject"
This reverts commit 42eb3d4c80.
2024-01-19 15:07:35 +09:00
r-ca cc7b0dc5d1 Revert "utilsを依存関係に追加, LoggerをInject"
This reverts commit 169a6c6e0a.
2024-01-19 15:07:34 +09:00
r-ca 169a6c6e0a utilsを依存関係に追加, LoggerをInject 2024-01-19 15:07:27 +09:00
r-ca 42eb3d4c80 utilsを依存関係に追加, LoggerをInject 2024-01-19 15:07:23 +09:00
r-ca 1c87b73a5b テスト用に設置していたトーストを削除 2024-01-19 15:05:44 +09:00
ろむねこ 46f119b531 Merge pull request #80 from lacerta-doc/improve/bottom_nav_color
システムナビゲーションの色をUIにあわせるようにした
2024-01-19 15:02:32 +09:00
r-ca def799bbe6 APIレベル27以上でシステムナビゲーションのアイコン色を適切に変更できるようにした 2024-01-19 15:01:20 +09:00
r-ca defc051436 システムナビゲーションの背景をボトムナビゲーションと同じに 2024-01-19 14:56:44 +09:00
r-ca de9b68de87 Revert "依存関係追加"
This reverts commit 802e4cc75a.
2024-01-19 14:50:20 +09:00
r-ca 802e4cc75a 依存関係追加 2024-01-19 14:48:17 +09:00
ろむねこ abc91b79ee Merge pull request #79 from lacerta-doc/feature/search/add_ui
Feature/search/add UI
2024-01-19 14:24:03 +09:00
r-ca 475c511d32 hotfix 2024-01-18 18:23:14 +09:00
r-ca 474d6417c9 hotfix: Adapterの初期化処理修正 2024-01-18 18:22:10 +09:00
r-ca c7e141b892 hotfix: 型の変更に追従 2024-01-18 18:21:01 +09:00
ろむねこ 3d2cc5ac05 Merge pull request #78 from lacerta-doc/feature/home/add_document_history
ドキュメント履歴をホームに追加
2024-01-18 18:19:49 +09:00
r-ca 73c310ee01 hotfix: 型の変更に追従 2024-01-18 18:16:44 +09:00
ろむねこ 5c3d811979 Merge pull request #77 from lacerta-doc/feature/lacerta_library_recent
Feature/lacerta library recent
2024-01-18 18:12:18 +09:00
ろむねこ f5bc740f58 Merge pull request #76 from lacerta-doc/feature/scan_and_save_document
Feature/scan and save document
2024-01-18 18:11:21 +09:00
Fuchimoto1234 71f9be77cd fix 2024-01-17 12:58:25 +09:00
r-ca e0d63122bd getRecentDocument実装 2024-01-17 12:52:13 +09:00
r-ca 1c3fdf921d Dao追加 2024-01-17 12:52:05 +09:00
Fuchimoto1234 d07e63f534 Merge branch 'develop' into feature/home/add_document_history
# Conflicts:
#	data/src/main/java/one/nem/lacerta/data/Document.java
#	data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java
2024-01-17 12:42:55 +09:00
Fuchimoto1234 5160411c76 fix 2024-01-17 12:41:31 +09:00
Fuchimoto1234 20d30e338e wip 2024-01-17 12:35:30 +09:00
r-ca 3be6185c21 getRecentDocumentの戻り値を変更 2024-01-17 12:15:47 +09:00
r-ca c82952f397 スキーマ更新, Dao更新 2024-01-17 12:11:12 +09:00
r-ca 8c9dc14f16 DBスキーマアップデート 2024-01-17 12:09:27 +09:00
r-ca d22644e37a 依存関係に追加 2024-01-17 12:08:54 +09:00
r-ca c80576d046 修正 2024-01-17 12:08:45 +09:00
r-ca b7cb4369d1 クエリ追加 2024-01-17 12:08:24 +09:00
r-ca 2cfab24c76 Injection追加 2024-01-17 12:07:28 +09:00
r-ca 55b34d964c Folderをデータベースに保存するように WIP 2024-01-17 12:07:18 +09:00
r-ca 744a2bef65 actionを追加するように WIP 2024-01-17 11:25:41 +09:00
r-ca 74becab37b デバッグ用のログポイント追加 2024-01-17 11:09:33 +09:00
r-ca 58d6ae17c6 タイミングの都合でエラーが出るのでloggerを使わないように 2024-01-17 11:07:54 +09:00
r-ca dea5f240f0 ドキュメント新規保存のロジックを実装 WIP 2024-01-17 11:05:25 +09:00
r-ca 119771a7f9 コメント追加, デバッグ用の実装を追加 2024-01-17 11:00:20 +09:00
r-ca b6a30d5cbf Document実装 2024-01-17 10:57:08 +09:00
r-ca 2ec4b96c14 Vcs変更 2024-01-17 10:55:39 +09:00
r-ca 151911d0b2 バージョンコード更新 2024-01-17 10:46:55 +09:00
r-ca d832438f8f Vcs実装 2024-01-17 10:46:31 +09:00
r-ca 0487553f3b Dao追加 2024-01-17 10:40:01 +09:00
r-ca 678c9730ef Dao追加 2024-01-17 10:39:17 +09:00
r-ca e1b43a5f22 EntityにisIncludedを追加 2024-01-17 10:37:42 +09:00
r-ca d384347e0a Merge branch 'develop' into feature/scan_and_save_document 2024-01-17 10:31:28 +09:00
r-ca a61c044391 新ドキュメントを生成できるように 2024-01-16 12:36:28 +09:00
r-ca bc19dd22d8 DocumentMetaにコンストラクタを追加 2024-01-16 12:35:19 +09:00
Fuchimoto1234 a5efab5838 アイテムのレイアウトを作成 2023-12-20 10:00:16 +09:00
Fuchimoto1234 f186064f6e 途中 2023-12-19 12:56:31 +09:00
Fuchimoto1234 59a35cbb4a 依存関係追加 2023-12-19 10:36:27 +09:00
Fuchimoto1234 a78e60416d 依存関係追加 2023-12-19 10:34:31 +09:00
Fuchimoto1234 ac5a950ce3 依存関係追加 2023-12-18 15:16:57 +09:00
37 changed files with 604 additions and 79 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
+9 -24
View File
@@ -59,30 +59,6 @@ dependencies {
androidTestImplementation libs.androidx.test.ext.junit
androidTestImplementation libs.androidx.test.espresso.core
// 内部モジュール
// Feature
implementation project(':feature:home')
implementation project(':feature:search')
implementation project(':feature:library')
implementation project(':feature:scan')
implementation project(':feature:debug') // デバッグメニュー
// // Component
// implementation project(':component:common')
// implementation project(':component:scanner')
// implementation project(':component:viewer')
// // Data
// implementation project(':data:repository')
//
// // Source
// implementation project(':data:source:database')
// implementation project(':data:source:preference')
//
implementation project(':data')
implementation project(':shared:ui')
// Hilt (DI)
implementation libs.com.google.dagger.hilt.android
annotationProcessor libs.com.google.dagger.hilt.compiler
@@ -92,4 +68,13 @@ dependencies {
implementation libs.navigation.ui
implementation libs.navigation.dynamic.features.fragment
// Feature
implementation project(':feature:home')
implementation project(':feature:search')
implementation project(':feature:library')
implementation project(':feature:scan')
implementation project(':feature:debug') // デバッグメニュー
implementation project(':data')
implementation project(':shared:ui')
}
@@ -1,6 +1,7 @@
package one.nem.lacerta;
import android.app.Application;
import android.util.Log;
import com.google.android.material.color.DynamicColors;
@@ -12,7 +13,13 @@ public class LacertaApplication extends Application {
public void onCreate() {
super.onCreate();
// DynamicColorを有効化
DynamicColors.applyToActivitiesIfAvailable(this);
if (DynamicColors.isDynamicColorAvailable()) {
Log.d("DynamicColors", "DynamicColors is available. Applying to activities...");
DynamicColors.applyToActivitiesIfAvailable(this);
} else {
Log.d("DynamicColors", "DynamicColors is not available.");
}
}
}
@@ -1,12 +1,15 @@
package one.nem.lacerta;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentManager;
import androidx.navigation.NavController;
import androidx.navigation.fragment.NavHostFragment;
import androidx.navigation.ui.NavigationUI;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import com.google.android.material.bottomnavigation.BottomNavigationView;
@@ -25,16 +28,23 @@ public class MainActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Debug
FragmentManager supportFragmentManager = getSupportFragmentManager();
// Init navigation
try {
FragmentManager supportFragmentManager = getSupportFragmentManager();
NavHostFragment navHostFragment = (NavHostFragment) supportFragmentManager.findFragmentById(R.id.nav_host_fragment);
assert navHostFragment != null;
NavController navController = navHostFragment.getNavController();
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav);
NavigationUI.setupWithNavController(bottomNavigationView, navController);
}
catch (Exception e) {
Log.e("Init", "Failed to init navigation");
Log.e("Init", "Searchable Error code: " + "894b5941-3bc0-46fe-b752-0dbc88be29a8");
Toast.makeText(this, "Failed to init navigation", Toast.LENGTH_LONG).show();
finish(); // Exit app
}
NavHostFragment navHostFragment = (NavHostFragment) supportFragmentManager.findFragmentById(R.id.nav_host_fragment);
NavController navController = navHostFragment.getNavController();
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav);
NavigationUI.setupWithNavController(bottomNavigationView, navController);
Toast.makeText(this, "testMessage", Toast.LENGTH_SHORT).show();
// Set navigation bar color
getWindow().setNavigationBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurfaceVariant));
}
}
}
+8 -9
View File
@@ -4,22 +4,21 @@
<item
android:id="@id/feature_home_navigation"
android:icon="@drawable/home_24px"
android:title="Home"/>
<item
android:id="@id/feature_library_navigation"
android:icon="@drawable/folder_24px"
android:title="Library"/>
android:title="@string/home_title"/>
<item
android:id="@id/feature_search_navigation"
android:icon="@drawable/search_24px"
android:title="Search"/>
android:title="@string/search_title"/>
<item
android:id="@id/feature_library_navigation"
android:icon="@drawable/folder_24px"
android:title="@string/library_title"/>
<item
android:id="@id/feature_debug_navigation"
android:icon="@drawable/developer_mode_24px"
android:title="Debug menu"/>
android:title="@string/debug_menu_title"/>
</menu>
@@ -26,8 +26,12 @@ import java.util.Objects;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.model.document.DocumentDetail;
import one.nem.lacerta.model.document.DocumentMeta;
import one.nem.lacerta.processor.factory.DocumentProcessorFactory;
import one.nem.lacerta.utils.LacertaLogger;
import one.nem.lacerta.data.Document;
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
@AndroidEntryPoint
public class ScannerManagerActivity extends AppCompatActivity {
@@ -40,6 +44,11 @@ public class ScannerManagerActivity extends AppCompatActivity {
@Inject
Document document;
@Inject
DocumentProcessorFactory documentProcessorFactory;
@Inject
LacertaVcsFactory lacertaVcsFactory;
// Variables
private ArrayList<Bitmap> croppedImages = new ArrayList<>();
@@ -143,7 +152,21 @@ public class ScannerManagerActivity extends AppCompatActivity {
private void saveNewDocument() {
logger.debug(TAG, "saveNewDocument");
DocumentMeta documentMeta = new DocumentMeta("Untitled"); // TODO-rca: デフォルトタイトルを指定できるようにする
DocumentDetail documentDetail = document.createDocument(documentMeta);
Bitmap[] bitmaps = new Bitmap[this.croppedImages.size()];
this.croppedImages.toArray(bitmaps);
try {
documentProcessorFactory.create(documentDetail).addNewPagesToLast(bitmaps);
Toast.makeText(this, "Saved.", Toast.LENGTH_SHORT).show();
lacertaVcsFactory.create(documentDetail.getMeta().getId()).generateRevisionAtCurrent("Initial commit");
lacertaVcsFactory.create(documentDetail.getMeta().getId()).printLog(); // Debug
lacertaVcsFactory.create(documentDetail.getMeta().getId()).printRev(); // Debug
finish();
} catch (Exception e) {
logger.error(TAG, "Error: " + e.getMessage());
logger.e_code("9dff2a28-20e8-4ccd-9d04-f0c7646faa6a");
}
}
private void insertToExistDocument() {
@@ -1,5 +1,8 @@
package one.nem.lacerta.data;
import java.util.ArrayList;
import one.nem.lacerta.model.ListItem;
import one.nem.lacerta.model.ListItemType;
import one.nem.lacerta.model.LibraryItemPage;
@@ -8,8 +11,8 @@ import one.nem.lacerta.model.document.DocumentDetail;
public interface LacertaLibrary {
// Get History
LibraryItemPage getRecentDocument(int limit);
LibraryItemPage getRecentDocument(int limit, int offset);
ArrayList<ListItem> getRecentDocument(int limit);
ArrayList<ListItem> getRecentDocument(int limit, int offset);
// Get Library page
LibraryItemPage getLibraryPage(int limit);
@@ -24,6 +24,7 @@ import one.nem.lacerta.utils.LacertaLogger;
// Lacerta/vcs
import one.nem.lacerta.vcs.LacertaVcs;
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
public class DocumentImpl implements Document {
@@ -36,14 +37,14 @@ public class DocumentImpl implements Document {
@Inject
LacertaDatabase database;
// @Inject
// LacertaVcs vcs;
@Inject
LacertaVcsFactory vcsFactory;
@Inject
public DocumentImpl() {
// Init
logger.debug(TAG, "called");
// logger.debug(TAG, "called");
}
@@ -69,7 +70,8 @@ public class DocumentImpl implements Document {
database.documentDao().insert(documentEntity);
// Vcs
// vcs.createDocument(meta.getId());
LacertaVcs vcs = vcsFactory.create(meta.getId());
vcs.createDocument(meta.getId());
return detail;
}
@@ -1,18 +1,48 @@
package one.nem.lacerta.data.impl;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.model.LibraryItemPage;
import one.nem.lacerta.model.ListItem;
import one.nem.lacerta.model.ListItemType;
import one.nem.lacerta.model.document.DocumentDetail;
import one.nem.lacerta.source.database.LacertaDatabase;
import one.nem.lacerta.source.database.common.DateTypeConverter;
import one.nem.lacerta.source.database.entity.DocumentEntity;
import one.nem.lacerta.utils.LacertaLogger;
public class LacertaLibraryImpl implements LacertaLibrary {
@Inject
LacertaLogger logger;
@Inject
LacertaDatabase database;
@Override
public LibraryItemPage getRecentDocument(int limit) {
return null;
public ArrayList<ListItem> getRecentDocument(int limit) {
List<DocumentEntity> documentEntities = database.documentDao().getRecentDocument(limit);
ArrayList<ListItem> listItems = new ArrayList<>();
for (DocumentEntity documentEntity : documentEntities) {
ListItem listItem = new ListItem();
listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT);
listItem.setTitle(documentEntity.title);
listItem.setDescription(DateFormat.getDateInstance().format(documentEntity.updatedAt));
listItem.setItemId(documentEntity.id);
listItems.add(listItem);
}
return listItems;
}
@Override
public LibraryItemPage getRecentDocument(int limit, int offset) {
return null;
public ArrayList<ListItem> getRecentDocument(int limit, int offset) {
return null; // TODO-rca: Implement
}
@Override
@@ -148,8 +148,8 @@ public class LacertaLibraryStubImpl implements LacertaLibrary {
* @return ページオブジェクト
*/
@Override
public LibraryItemPage getRecentDocument(int limit) {
return getRecentDocumentPage(limit);
public ArrayList<ListItem> getRecentDocument(int limit) {
return getRecentDocumentPage(limit).getListItems();
}
/**
@@ -159,8 +159,8 @@ public class LacertaLibraryStubImpl implements LacertaLibrary {
* @return ページオブジェクト
*/
@Override
public LibraryItemPage getRecentDocument(int limit, int offset) {
return getRecentDocumentPage(limit);
public ArrayList<ListItem> getRecentDocument(int limit, int offset) {
return getRecentDocumentPage(limit).getListItems();
}
/**
@@ -57,13 +57,13 @@ public class DebugMenuLibraryItemListPageFragment extends Fragment {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_debug_menu_library_item_list_page, container, false);
LibraryItemPage libraryItemPage = lacertaLibrary.getRecentDocument(10);
for (ListItem listItem : libraryItemPage.getListItems()) {
ArrayList<ListItem> listItems = lacertaLibrary.getRecentDocument(10);
for (ListItem listItem : listItems) {
System.out.println(listItem.getTitle());
}
RecyclerView recyclerView = view.findViewById(R.id.item_recycler_view);
recyclerView.setAdapter(new ItemAdapter(libraryItemPage.getListItems()));
recyclerView.setAdapter(new ItemAdapter(listItems));
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
@@ -23,4 +23,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/debug_menu_item_title" />
</androidx.constraintlayout.widget.ConstraintLayout>
+15
View File
@@ -1,4 +1,5 @@
plugins {
id 'com.google.dagger.hilt.android'
id 'com.android.library'
}
@@ -29,6 +30,8 @@ dependencies {
implementation libs.androidx.appcompat
implementation libs.com.google.android.material
implementation project(path: ':feature:debug')
implementation project(path: ':utils')
testImplementation libs.junit
androidTestImplementation libs.androidx.test.ext.junit
androidTestImplementation libs.androidx.test.espresso.core
@@ -38,6 +41,18 @@ dependencies {
implementation libs.navigation.ui
implementation libs.navigation.dynamic.features.fragment
// DI
implementation libs.com.google.dagger.hilt.android
annotationProcessor libs.com.google.dagger.hilt.compiler
// shared
implementation project(':shared:ui')
// DI
implementation project(':data')
//model
implementation project(':model')
implementation "androidx.recyclerview:recyclerview:1.3.2"
}
@@ -22,5 +22,7 @@ public class ExampleInstrumentedTest {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("one.nem.lacerta.feature.home.test", appContext.getPackageName());
}
}
@@ -1,20 +1,40 @@
package one.nem.lacerta.feature.home;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.data.Document;
import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.model.ListItem;
import one.nem.lacerta.model.document.DocumentMeta;
/**
* A simple {@link Fragment} subclass.
* Use the {@link HomeTopFragment#newInstance} factory method to
* create an instance of this fragment.
*/
@AndroidEntryPoint
public class HomeTopFragment extends Fragment {
@Inject
LacertaLibrary lacertaLibrary;
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
@@ -46,12 +66,15 @@ public class HomeTopFragment extends Fragment {
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@@ -59,6 +82,42 @@ public class HomeTopFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_home_top, container, false);
}
}
View view = inflater.inflate(R.layout.fragment_home_top, container, false);
// List<DocumentMeta> metas = document.getAllDocumentMetas(100);
ArrayList<ListItem> listItems = lacertaLibrary.getRecentDocument(100);
Log.d("docs", Integer.toString(listItems.size()));
RecyclerView recyclerView = view.findViewById(R.id.item_recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
MyAdapter myAdapter = new MyAdapter(listItems);
recyclerView.setAdapter(myAdapter);
return view;
}
String pageTitle;
String pageId;
ArrayList listItems;
String title;
String description;
String itemId;
}
@@ -0,0 +1,70 @@
package one.nem.lacerta.feature.home;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import one.nem.lacerta.model.ListItem;
import one.nem.lacerta.model.document.DocumentMeta;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyAdapterViewHolder> {
ArrayList<ListItem> listItems;
public MyAdapter(ArrayList<ListItem> listItems) {
this.listItems = listItems;
}
@NonNull
@Override
public MyAdapterViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_home_document, parent, false);
return new MyAdapterViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull MyAdapterViewHolder holder, int position) {
holder.title.setText(listItems.get(position).getTitle());
holder.description.setText(listItems.get(position).getDescription());
}
@Override
public int getItemCount() {
return listItems.size();
}
public class MyAdapterViewHolder extends RecyclerView.ViewHolder {
TextView title;
TextView description;
public MyAdapterViewHolder(@NonNull View itemView) {
super(itemView);
title = itemView.findViewById(R.id.debug_menu_item_title);
description = itemView.findViewById(R.id.debug_menu_item_description);
}
}
}
@@ -3,12 +3,19 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HomeTopFragment">
tools:context=".HomeTopFragment"
tools:ignore="ExtraText">
<!-- TODO: Update blank fragment layout -->
<TextView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/item_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
android:layout_height="match_parent">
</androidx.recyclerview.widget.RecyclerView>
</FrameLayout>
@@ -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"
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" />
<TextView
android:id="@+id/debug_menu_item_updated_at_home"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="14sp"
android:text="Updated at: aaaaaaaaaa"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="my_recycler_view" type="id" />
<item name="TITLE" type="id" />
<item name="textView" type="id" />
</resources>
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>
@@ -1,4 +1,5 @@
<resources>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="textview">TextView</string>
</resources>
@@ -25,6 +25,8 @@ import one.nem.lacerta.data.Document;
import one.nem.lacerta.model.document.DocumentMeta;
import one.nem.lacerta.model.document.tag.DocumentTag;
/**
* A simple {@link Fragment} subclass.
* Use the {@link LibraryTopFragment#newInstance} factory method to
@@ -73,4 +73,6 @@ public class DocumentDetail {
this.pages = pages;
}
}
}
@@ -48,6 +48,17 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
public DocumentMeta() {
}
public DocumentMeta(String title) {
this.id = UUID.randomUUID().toString();
this.title = title;
this.tags = new ArrayList<>();
this.author = ""; // TODO-rca: 作者のデフォルト値を設定できるようにする
this.defaultBranch = "main"; // TODO-rca: デフォルトブランチのデフォルト値を設定できるようにする
this.path = new PublicPath().getRoot();
this.updatedAt = new Date();
this.createdAt = new Date();
}
public DocumentMeta(String title, List<DocumentTag> tags, String author, String defaultBranch) {
this.id = UUID.randomUUID().toString();
this.title = title;
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Base.Theme.Lacerta" parent="Theme.Material3.DayNight.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorOnPrimary">@color/colorOnPrimary</item>
<item name="colorSecondary">@color/colorSecondary</item>
<item name="colorOnSecondary">@color/colorOnSecondary</item>
<item name="colorSurface">@color/colorSurface</item>
<item name="colorOnSurface">@color/colorOnSurface</item>
<item name="colorSurfaceVariant">@color/colorSurfaceVariant</item>
<item name="colorOnSurfaceVariant">@color/colorOnSurfaceVariant</item>
<item name="colorSurfaceInverse">@color/colorSurfaceInverse</item>
<item name="colorOnSurfaceInverse">@color/colorOnSurfaceInverse</item>
<item name="colorPrimaryInverse">@color/colorPrimaryInverse</item>
<item name="colorPrimaryContainer">@color/colorPrimaryContainer</item>
<item name="colorOnPrimaryContainer">@color/colorOnPrimaryContainer</item>
<item name="colorSecondaryContainer">@color/colorSecondaryContainer</item>
<item name="colorOnSecondaryContainer">@color/colorOnSecondaryContainer</item>
<item name="colorTertiary">@color/colorTertiary</item>
<item name="colorOnTertiary">@color/colorOnTertiary</item>
<item name="colorTertiaryContainer">@color/colorTertiaryContainer</item>
<item name="colorOnTertiaryContainer">@color/colorOnTertiaryContainer</item>
<item name="colorError">@color/colorError</item>
<item name="colorOnError">@color/colorOnError</item>
<item name="colorErrorContainer">@color/colorErrorContainer</item>
<item name="colorOnErrorContainer">@color/colorOnErrorContainer</item>
<item name="colorOutline">@color/colorOutline</item>
<item name="colorOnBackground">@color/colorOnBackground</item>
<item name="android:windowLightNavigationBar">false</item>
</style>
</resources>
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Base.Theme.Lacerta" parent="Theme.Material3.DayNight.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorOnPrimary">@color/colorOnPrimary</item>
<item name="colorSecondary">@color/colorSecondary</item>
<item name="colorOnSecondary">@color/colorOnSecondary</item>
<item name="colorSurface">@color/colorSurface</item>
<item name="colorOnSurface">@color/colorOnSurface</item>
<item name="colorSurfaceVariant">@color/colorSurfaceVariant</item>
<item name="colorOnSurfaceVariant">@color/colorOnSurfaceVariant</item>
<item name="colorSurfaceInverse">@color/colorSurfaceInverse</item>
<item name="colorOnSurfaceInverse">@color/colorOnSurfaceInverse</item>
<item name="colorPrimaryInverse">@color/colorPrimaryInverse</item>
<item name="colorPrimaryContainer">@color/colorPrimaryContainer</item>
<item name="colorOnPrimaryContainer">@color/colorOnPrimaryContainer</item>
<item name="colorSecondaryContainer">@color/colorSecondaryContainer</item>
<item name="colorOnSecondaryContainer">@color/colorOnSecondaryContainer</item>
<item name="colorTertiary">@color/colorTertiary</item>
<item name="colorOnTertiary">@color/colorOnTertiary</item>
<item name="colorTertiaryContainer">@color/colorTertiaryContainer</item>
<item name="colorOnTertiaryContainer">@color/colorOnTertiaryContainer</item>
<item name="colorError">@color/colorError</item>
<item name="colorOnError">@color/colorOnError</item>
<item name="colorErrorContainer">@color/colorErrorContainer</item>
<item name="colorOnErrorContainer">@color/colorOnErrorContainer</item>
<item name="colorOutline">@color/colorOutline</item>
<item name="colorOnBackground">@color/colorOnBackground</item>
<item name="android:windowLightNavigationBar">true</item>
</style>
</resources>
+18
View File
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- home -->
<string name="home_title">ホーム</string>
<!-- search -->
<string name="search_title">検索</string>
<!-- library -->
<string name="library_title">ライブラリ</string>
<!-- debug -->
<string name="debug_menu_title">デバッグメニュー</string>
<!-- common -->
</resources>
+1
View File
@@ -28,6 +28,7 @@
<item name="colorOutline">@color/colorOutline</item>
<item name="colorOnBackground">@color/colorOnBackground</item>
<item name="android:windowLightNavigationBar">true</item>
</style>
+3
View File
@@ -47,4 +47,7 @@ dependencies {
// Utils モジュール
implementation project(':utils')
// Model
implementation project(':model')
}
@@ -4,6 +4,8 @@ import androidx.room.Database;
import androidx.room.RoomDatabase;
// Entities
import one.nem.lacerta.source.database.dao.FolderDao;
import one.nem.lacerta.source.database.entity.FolderEntity;
import one.nem.lacerta.source.database.entity.TagEntity;
import one.nem.lacerta.source.database.entity.DocumentEntity;
import one.nem.lacerta.source.database.entity.LibraryEntity;
@@ -17,11 +19,12 @@ import one.nem.lacerta.source.database.dao.LibraryDao;
import one.nem.lacerta.source.database.dao.VcsRevDao;
import one.nem.lacerta.source.database.dao.VcsLogDao;
@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class, VcsRevEntity.class, VcsLogEntity.class}, version = 2)
@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class, VcsRevEntity.class, VcsLogEntity.class, FolderEntity.class}, version = 4)
public abstract class LacertaDatabase extends RoomDatabase {
public abstract TagDao tagDao();
public abstract DocumentDao documentDao();
public abstract LibraryDao libraryDao();
public abstract VcsRevDao vcsRevDao();
public abstract VcsLogDao vcsLogDao();
public abstract FolderDao folderDao();
}
@@ -28,6 +28,12 @@ public interface DocumentDao {
@Query("SELECT * FROM Document WHERE id IN (:ids)")
List<DocumentEntity> findByIds(List<String> ids);
@Query("SELECT * FROM Document WHERE public_path = :publicPath LIMIT :limit")
List<DocumentEntity> findByPublicPathWithLimit(String publicPath, int limit);
@Query("SELECT * FROM Document ORDER BY created_at DESC LIMIT :limit")
List<DocumentEntity> getRecentDocument(int limit);
// Insert
@Insert
void insert(DocumentEntity document);
@@ -0,0 +1,23 @@
package one.nem.lacerta.source.database.dao;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
import one.nem.lacerta.source.database.entity.FolderEntity;
@Dao
public interface FolderDao {
@Query("SELECT * FROM Folder WHERE id = :id")
FolderEntity findById(String id);
@Query("SELECT * FROM Folder WHERE public_path = :publicPath")
FolderEntity findByPublicPath(String publicPath);
@Insert
void insert(FolderEntity folderEntity);
@Insert
void insertAll(FolderEntity... folderEntities);
}
@@ -3,6 +3,7 @@ package one.nem.lacerta.source.database.dao;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;
import java.util.List;
@@ -24,6 +25,14 @@ public interface VcsLogDao {
@Query("SELECT * FROM vcs_log WHERE document_id = :documentId")
List<VcsLogEntity> findByDocumentId(String documentId);
@Query("SELECT * FROM vcs_log WHERE document_id = :documentId AND is_included = :isIncluded ORDER BY created_at")
List<VcsLogEntity> findByDocumentIdAndIncluded(String documentId, boolean isIncluded);
@Query("SELECT * FROM vcs_log WHERE document_id = :documentId AND branch_name = :branchName")
List<VcsLogEntity> findByDocumentIdAndBranchName(String documentId, String branchName);
@Query("SELECT * FROM vcs_log WHERE document_id = :documentId AND branch_name = :branchName AND is_included = :isIncluded ORDER BY created_at")
List<VcsLogEntity> findByDocumentIdAndBranchNameAndIncluded(String documentId, String branchName, boolean isIncluded);
// Insert
@Insert
@@ -35,5 +44,12 @@ public interface VcsLogDao {
@Insert
void insert(VcsLogEntity vcsLog);
// TODO-rca: Update, Deleteが必要か検討
@Update
void update(VcsLogEntity vcsLog);
@Update
void updateAll(VcsLogEntity... vcsLogs);
@Update
void updateAll(List<VcsLogEntity> vcsLogs);
}
@@ -0,0 +1,22 @@
package one.nem.lacerta.source.database.entity;
import androidx.annotation.NonNull;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
@Entity(tableName = "folder")
public class FolderEntity {
@PrimaryKey
@ColumnInfo(name = "id")
@NonNull
public String id; // フォルダID
@ColumnInfo(name = "title")
public String name; // フォルダ名
@ColumnInfo(name = "public_path")
public String publicPath; // 公開パス
}
@@ -45,4 +45,10 @@ public class VcsLogEntity {
*/
@ColumnInfo(name = "action")
public String action;
/**
* Revに含まれてるかどうか
*/
@ColumnInfo(name = "is_included")
public boolean isIncluded;
}
@@ -11,7 +11,12 @@ public interface LacertaVcs {
public void createDocument(String documentId);
public void generateRevisionAtCurrent(String message);
// debug
public void printLog();
public void printRev();
}
@@ -1,5 +1,7 @@
package one.nem.lacerta.vcs.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.inject.Inject;
@@ -8,8 +10,12 @@ import dagger.assisted.Assisted;
import dagger.assisted.AssistedInject;
import one.nem.lacerta.source.database.LacertaDatabase;
import one.nem.lacerta.source.database.entity.VcsLogEntity;
import one.nem.lacerta.source.database.entity.VcsRevEntity;
import one.nem.lacerta.utils.LacertaLogger;
import one.nem.lacerta.vcs.ActionType;
import one.nem.lacerta.vcs.LacertaVcs;
import one.nem.lacerta.vcs.internal.JsonUtils;
import one.nem.lacerta.vcs.model.action.InsertPage;
public class LacertaVcsImpl implements LacertaVcs {
@@ -38,12 +44,17 @@ public class LacertaVcsImpl implements LacertaVcs {
@Override
public void insertPage(int index, String fileName) {
logger.debug(TAG, "insertPage");
// InsertPage
InsertPage insertPage = new InsertPage(index, fileName);
insertPage.setActionType(ActionType.INSERT_PAGE);
VcsLogEntity vcsLogEntity = new VcsLogEntity();
vcsLogEntity.id = UUID.randomUUID().toString();
vcsLogEntity.documentId = documentId;
vcsLogEntity.branchName = "master";
vcsLogEntity.createdAt = new java.util.Date();
vcsLogEntity.action = "placeholder";
vcsLogEntity.action = JsonUtils.toJson(insertPage);
database.vcsLogDao().insert(vcsLogEntity);
}
@@ -54,7 +65,61 @@ public class LacertaVcsImpl implements LacertaVcs {
@Override
public void createDocument(String documentId) {
logger.debug(TAG, "createDocument");
VcsLogEntity vcsLogEntity = new VcsLogEntity();
vcsLogEntity.id = UUID.randomUUID().toString();
vcsLogEntity.documentId = documentId;
vcsLogEntity.branchName = "master";
vcsLogEntity.createdAt = new java.util.Date();
vcsLogEntity.action = "ph-createDocument";
database.vcsLogDao().insert(vcsLogEntity);
}
// Internal
private ArrayList<VcsLogEntity> getNonIncludedVcsLogEntities() {
return new ArrayList<>(database.vcsLogDao().findByDocumentIdAndIncluded(documentId, false));
}
private ArrayList<VcsLogEntity> getNonIncludedVcsLogEntities(String branchName) {
return new ArrayList<>(database.vcsLogDao().findByDocumentIdAndBranchNameAndIncluded(documentId, branchName, false));
}
private void setIncludedVcsLogEntities(ArrayList<VcsLogEntity> vcsLogEntities) {
vcsLogEntities.forEach(vcsLogEntity -> {
vcsLogEntity.isIncluded = true;
database.vcsLogDao().update(vcsLogEntity);
});
logger.debug(TAG, "setIncludedVcsLogEntities updated: " + vcsLogEntities.size() + " entities");
}
@Override
public void generateRevisionAtCurrent(String message) {
logger.debug(TAG, "generateRevisionAtCurrent");
// TODO-rca: ブランチを考慮する
ArrayList<VcsLogEntity> vcsLogEntities = getNonIncludedVcsLogEntities();
ArrayList<String> logIds = new ArrayList<>();
vcsLogEntities.forEach(vcsLogEntity -> {
logIds.add(vcsLogEntity.id);
});
VcsRevEntity vcsRevEntity = new VcsRevEntity();
vcsRevEntity.id = UUID.randomUUID().toString();
vcsRevEntity.documentId = documentId;
vcsRevEntity.branchName = "master";
vcsRevEntity.createdAt = new java.util.Date();
vcsRevEntity.commitMessage = message;
vcsRevEntity.logIds = logIds;
database.vcsRevDao().insert(vcsRevEntity);
setIncludedVcsLogEntities(vcsLogEntities);
logger.debug(TAG, "generateRevisionAtCurrent finished");
logger.debug(TAG, "New revision inserted: " + vcsRevEntity.id);
}
@Override
@@ -62,6 +127,19 @@ public class LacertaVcsImpl implements LacertaVcs {
logger.debug(TAG, "printLog");
database.vcsLogDao().findAll().forEach(vcsLog -> {
logger.debug(TAG, vcsLog.id);
logger.debug(TAG, vcsLog.documentId + " " + vcsLog.branchName);
logger.debug(TAG, vcsLog.action);
});
}
@Override
public void printRev() {
logger.debug(TAG, "printRev");
database.vcsRevDao().findAll().forEach(vcsRev -> {
logger.debug(TAG, vcsRev.id);
logger.debug(TAG, vcsRev.documentId + " " + vcsRev.branchName);
logger.debug(TAG, vcsRev.commitMessage);
logger.debug(TAG, vcsRev.logIds.toString());
});
}
}