Compare commits

..
Author SHA1 Message Date
Fuchimoto1234 b601b28f81 search UI 2024-01-19 12:49:33 +09:00
Fuchimoto1234 853ac1eca3 search UI 2024-01-19 12:42:04 +09:00
Fuchimoto1234 834bc35318 search UI 2024-01-19 12:30:17 +09:00
Fuchimoto1234 1e3a3262a4 search UI 2024-01-19 12:11:56 +09:00
r-ca 8a57331d32 メニューに検索を追加 2024-01-18 14:33:27 +09:00
r-ca abdca108d4 ナビゲーショングラフに追加 2024-01-18 14:32:57 +09:00
r-ca 8b66646e7d ナビゲーショングラフ作成 2024-01-18 14:32:36 +09:00
r-ca c9160a2df0 依存関係修正 2024-01-18 14:31:52 +09:00
r-ca c5b0a33720 Revert "ナビゲーショングラフ作成"
This reverts commit 13f31017f7.
2024-01-18 14:31:30 +09:00
r-ca 13f31017f7 ナビゲーショングラフ作成 2024-01-18 14:30:22 +09:00
r-ca e6778e6214 フラグメント作成 2024-01-18 14:29:29 +09:00
17 changed files with 214 additions and 155 deletions

No files matched your search

+1
View File
@@ -4,6 +4,7 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="jbr-17" />
<option name="modules">
-1
View File
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
@@ -11,6 +11,11 @@
android:icon="@drawable/folder_24px"
android:title="Library"/>
<item
android:id="@id/feature_search_navigation"
android:icon="@drawable/search_24px"
android:title="Search"/>
<item
android:id="@id/feature_debug_navigation"
android:icon="@drawable/developer_mode_24px"
+1
View File
@@ -9,6 +9,7 @@
<include app:graph="@navigation/feature_library_navigation" />
<include app:graph="@navigation/feature_home_navigation" />
<include app:graph="@navigation/feature_search_navigation" />
</navigation>
@@ -26,12 +26,8 @@ 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 {
@@ -44,11 +40,6 @@ public class ScannerManagerActivity extends AppCompatActivity {
@Inject
Document document;
@Inject
DocumentProcessorFactory documentProcessorFactory;
@Inject
LacertaVcsFactory lacertaVcsFactory;
// Variables
private ArrayList<Bitmap> croppedImages = new ArrayList<>();
@@ -152,21 +143,7 @@ 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() {
@@ -24,7 +24,6 @@ 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 {
@@ -37,14 +36,14 @@ public class DocumentImpl implements Document {
@Inject
LacertaDatabase database;
@Inject
LacertaVcsFactory vcsFactory;
// @Inject
// LacertaVcs vcs;
@Inject
public DocumentImpl() {
// Init
// logger.debug(TAG, "called");
logger.debug(TAG, "called");
}
@@ -70,8 +69,7 @@ public class DocumentImpl implements Document {
database.documentDao().insert(documentEntity);
// Vcs
LacertaVcs vcs = vcsFactory.create(meta.getId());
vcs.createDocument(meta.getId());
// vcs.createDocument(meta.getId());
return detail;
}
+13 -5
View File
@@ -27,9 +27,17 @@ android {
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.10.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation libs.androidx.appcompat
implementation libs.com.google.android.material
testImplementation libs.junit
androidTestImplementation libs.androidx.test.ext.junit
androidTestImplementation libs.androidx.test.espresso.core
// Navigation
implementation libs.navigation.fragment
implementation libs.navigation.ui
implementation libs.navigation.dynamic.features.fragment
// shared
implementation project(':shared:ui')
}
@@ -0,0 +1,142 @@
package one.nem.lacerta.feature.search;
import android.app.LauncherActivity;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SearchView;
import java.util.ArrayList;
/**
* A simple {@link Fragment} subclass.
* Use the {@link SearchTopFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class SearchTopFragment extends Fragment {
private static final String TAG = SearchTopFragment.class.getSimpleName();
private final SearchTopFragment self = this;
private SearchView searchView;
private String searchWord;
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
public SearchTopFragment() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment SearchTopFragment.
*/
// TODO: Rename and change types and number of parameters
public static SearchTopFragment newInstance(String param1, String param2) {
SearchTopFragment fragment = new SearchTopFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_search_top, container, false);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
this.searchView.setIconifiedByDefault(true);
this.searchView.setSubmitButtonEnabled(false);
if (!this.searchWord.equals("")) {
this.searchView.setQuery(this.searchWord, false);
} else {
String queryHint = self.getResources().getString(R.string.hello_blank_fragment);
this.searchView.setQueryHint(queryHint);
}
this.searchView.setOnQueryTextListener(self.onQueryTextListener);
}
private final SearchView.OnQueryTextListener onQueryTextListener = new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return self.setSearchWord(searchWord);
}
@Override
public boolean onQueryTextChange(String query) {
return false;
}
};
private boolean setSearchWord(String query) {
if (searchWord != null && !searchWord.equals("")) {
this.searchWord = searchWord;
}
this.searchView.setIconified(false);
this.searchView.onActionViewCollapsed();
this.searchView.clearFocus();
return false;
}
}
interface LacertaSearch {
ArrayList<LauncherActivity.ListItem> autoSearch(String query, int limit);
ArrayList<LauncherActivity.ListItem> autoSearch(String query, int limit, int offset);
}
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<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"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".SearchTopFragment">
<!-- TODO: Update blank fragment layout -->
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/Search_tool_bar"
android:layout_width="match_parent"
android:layout_height="69dp"
android:background="#E4E8EA"
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="" />
<SearchView
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/feature_search_navigation"
app:startDestination="@id/searchTopFragment">
<fragment
android:id="@+id/searchTopFragment"
android:name="one.nem.lacerta.feature.search.SearchTopFragment"
android:label="fragment_search_top"
tools:layout="@layout/fragment_search_top" />
</navigation>
@@ -0,0 +1,4 @@
<resources>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>
@@ -48,17 +48,6 @@ 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;
@@ -17,7 +17,7 @@ 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 = 3)
@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class, VcsRevEntity.class, VcsLogEntity.class}, version = 2)
public abstract class LacertaDatabase extends RoomDatabase {
public abstract TagDao tagDao();
public abstract DocumentDao documentDao();
@@ -3,7 +3,6 @@ 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;
@@ -25,14 +24,6 @@ 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
@@ -44,12 +35,5 @@ public interface VcsLogDao {
@Insert
void insert(VcsLogEntity vcsLog);
@Update
void update(VcsLogEntity vcsLog);
@Update
void updateAll(VcsLogEntity... vcsLogs);
@Update
void updateAll(List<VcsLogEntity> vcsLogs);
// TODO-rca: Update, Deleteが必要か検討
}
@@ -45,10 +45,4 @@ public class VcsLogEntity {
*/
@ColumnInfo(name = "action")
public String action;
/**
* Revに含まれてるかどうか
*/
@ColumnInfo(name = "is_included")
public boolean isIncluded;
}
@@ -11,12 +11,7 @@ public interface LacertaVcs {
public void createDocument(String documentId);
public void generateRevisionAtCurrent(String message);
// debug
public void printLog();
public void printRev();
}
@@ -1,7 +1,5 @@
package one.nem.lacerta.vcs.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.inject.Inject;
@@ -10,12 +8,8 @@ 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 {
@@ -44,17 +38,12 @@ 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 = JsonUtils.toJson(insertPage);
vcsLogEntity.action = "placeholder";
database.vcsLogDao().insert(vcsLogEntity);
}
@@ -65,61 +54,7 @@ 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
@@ -127,19 +62,6 @@ 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());
});
}
}