mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2026-11-08 03:47:36 +00:00
Compare commits
27
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b601b28f81 | ||
|
|
853ac1eca3 | ||
|
|
834bc35318 | ||
|
|
1e3a3262a4 | ||
|
|
8a57331d32 | ||
|
|
abdca108d4 | ||
|
|
8b66646e7d | ||
|
|
c9160a2df0 | ||
|
|
c5b0a33720 | ||
|
|
13f31017f7 | ||
|
|
e6778e6214 | ||
|
|
8faaf1e84a | ||
|
|
a81d79a972 | ||
|
|
1e2f48e0ae | ||
|
|
be7bd6b6fc | ||
|
|
16eb6d083e | ||
|
|
4de33b9550 | ||
|
|
b4d94954b9 | ||
|
|
526ab97706 | ||
|
|
6f0af7c4eb | ||
|
|
c6d85471c6 | ||
|
|
c5d7224b40 | ||
|
|
cc62529224 | ||
|
|
2d686ce776 | ||
|
|
61ed1bbf79 | ||
|
|
fd785d9334 | ||
|
|
1e1f014e59 |
No files matched your search
Generated
+1
-1
@@ -4,6 +4,7 @@
|
|||||||
<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">
|
||||||
@@ -25,7 +26,6 @@
|
|||||||
<option value="$PROJECT_DIR$/model" />
|
<option value="$PROJECT_DIR$/model" />
|
||||||
<option value="$PROJECT_DIR$/processor" />
|
<option value="$PROJECT_DIR$/processor" />
|
||||||
<option value="$PROJECT_DIR$/shared" />
|
<option value="$PROJECT_DIR$/shared" />
|
||||||
<option value="$PROJECT_DIR$/shared/icon" />
|
|
||||||
<option value="$PROJECT_DIR$/shared/ui" />
|
<option value="$PROJECT_DIR$/shared/ui" />
|
||||||
<option value="$PROJECT_DIR$/source" />
|
<option value="$PROJECT_DIR$/source" />
|
||||||
<option value="$PROJECT_DIR$/utils" />
|
<option value="$PROJECT_DIR$/utils" />
|
||||||
|
|||||||
Generated
-1
@@ -1,4 +1,3 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<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" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# 概要
|
||||||
|
<!-- PRの概要 -->
|
||||||
|
|
||||||
|
# 関連Issue
|
||||||
|
- #000 <!-- 関連するIssueを指定(なければ省略可) -->
|
||||||
|
|
||||||
|
# 詳細
|
||||||
|
<!-- 詳細 -->
|
||||||
|
|
||||||
|
# 影響箇所
|
||||||
|
<!-- 予想される影響箇所 -->
|
||||||
|
|
||||||
|
# チェック
|
||||||
|
<!-- 参考用, 全てにチェックがついている必要があるわけではありません -->
|
||||||
|
- [ ] 機能として完成している
|
||||||
|
- [ ] WIP(Work in progress: 作業中)
|
||||||
|
- [ ] 正常にビルド/起動ができる
|
||||||
|
- [ ] 既存の機能を壊していない
|
||||||
@@ -83,8 +83,6 @@ dependencies {
|
|||||||
|
|
||||||
implementation project(':shared:ui')
|
implementation project(':shared:ui')
|
||||||
|
|
||||||
implementation project(':shared:icon')
|
|
||||||
|
|
||||||
// Hilt (DI)
|
// Hilt (DI)
|
||||||
implementation libs.com.google.dagger.hilt.android
|
implementation libs.com.google.dagger.hilt.android
|
||||||
annotationProcessor libs.com.google.dagger.hilt.compiler
|
annotationProcessor libs.com.google.dagger.hilt.compiler
|
||||||
|
|||||||
@@ -11,6 +11,11 @@
|
|||||||
android:icon="@drawable/folder_24px"
|
android:icon="@drawable/folder_24px"
|
||||||
android:title="Library"/>
|
android:title="Library"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@id/feature_search_navigation"
|
||||||
|
android:icon="@drawable/search_24px"
|
||||||
|
android:title="Search"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@id/feature_debug_navigation"
|
android:id="@id/feature_debug_navigation"
|
||||||
android:icon="@drawable/developer_mode_24px"
|
android:icon="@drawable/developer_mode_24px"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<include app:graph="@navigation/feature_library_navigation" />
|
<include app:graph="@navigation/feature_library_navigation" />
|
||||||
|
|
||||||
<include app:graph="@navigation/feature_home_navigation" />
|
<include app:graph="@navigation/feature_home_navigation" />
|
||||||
|
<include app:graph="@navigation/feature_search_navigation" />
|
||||||
|
|
||||||
|
|
||||||
</navigation>
|
</navigation>
|
||||||
@@ -2,32 +2,27 @@ package one.nem.lacerta.data.impl;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
// Hilt
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
// Lacerta/data
|
||||||
import one.nem.lacerta.data.Document;
|
import one.nem.lacerta.data.Document;
|
||||||
|
|
||||||
|
// Lacerta/model
|
||||||
import one.nem.lacerta.model.PublicPath;
|
import one.nem.lacerta.model.PublicPath;
|
||||||
import one.nem.lacerta.model.document.DocumentMeta;
|
import one.nem.lacerta.model.document.DocumentMeta;
|
||||||
import one.nem.lacerta.model.document.DocumentDetail;
|
import one.nem.lacerta.model.document.DocumentDetail;
|
||||||
|
|
||||||
import one.nem.lacerta.model.document.path.DocumentPath;
|
// Lacerta/source
|
||||||
import one.nem.lacerta.model.document.tag.DocumentTag;
|
|
||||||
import one.nem.lacerta.source.database.LacertaDatabase;
|
import one.nem.lacerta.source.database.LacertaDatabase;
|
||||||
|
|
||||||
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
||||||
import one.nem.lacerta.source.database.entity.LibraryEntity;
|
|
||||||
import one.nem.lacerta.source.database.entity.TagEntity;
|
|
||||||
|
|
||||||
import one.nem.lacerta.source.database.entity.VcsLogEntity;
|
// Lacerta/utils
|
||||||
import one.nem.lacerta.vcs.ActionType;
|
|
||||||
import one.nem.lacerta.source.file.factory.FileManagerFactory;
|
|
||||||
import one.nem.lacerta.source.jgit.JGitRepository;
|
|
||||||
import one.nem.lacerta.utils.LacertaLogger;
|
import one.nem.lacerta.utils.LacertaLogger;
|
||||||
import one.nem.lacerta.utils.XmlMetaParser;
|
|
||||||
import one.nem.lacerta.utils.repository.DeviceInfoUtils;
|
// Lacerta/vcs
|
||||||
import one.nem.lacerta.vcs.LacertaVcs;
|
import one.nem.lacerta.vcs.LacertaVcs;
|
||||||
|
|
||||||
|
|
||||||
@@ -41,8 +36,8 @@ public class DocumentImpl implements Document {
|
|||||||
@Inject
|
@Inject
|
||||||
LacertaDatabase database;
|
LacertaDatabase database;
|
||||||
|
|
||||||
@Inject
|
// @Inject
|
||||||
LacertaVcs vcs;
|
// LacertaVcs vcs;
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -74,7 +69,7 @@ public class DocumentImpl implements Document {
|
|||||||
database.documentDao().insert(documentEntity);
|
database.documentDao().insert(documentEntity);
|
||||||
|
|
||||||
// Vcs
|
// Vcs
|
||||||
vcs.createDocument(meta.getId());
|
// vcs.createDocument(meta.getId());
|
||||||
|
|
||||||
return detail;
|
return detail;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<application>
|
|
||||||
<activity
|
|
||||||
android:name=".DebugMenuContainerActivity"
|
|
||||||
android:exported="false" />
|
|
||||||
</application>
|
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -27,9 +27,17 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
implementation libs.androidx.appcompat
|
||||||
implementation 'com.google.android.material:material:1.10.0'
|
implementation libs.com.google.android.material
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation libs.junit
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
androidTestImplementation libs.androidx.test.ext.junit
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
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>
|
||||||
@@ -3,27 +3,30 @@ package one.nem.lacerta.processor.impl;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
// Hilt
|
||||||
import dagger.assisted.Assisted;
|
import dagger.assisted.Assisted;
|
||||||
import dagger.assisted.AssistedInject;
|
import dagger.assisted.AssistedInject;
|
||||||
import one.nem.lacerta.model.document.internal.XmlMetaPageModel;
|
|
||||||
import one.nem.lacerta.processor.DocumentProcessor;
|
|
||||||
|
|
||||||
|
// Lacerta/model
|
||||||
import one.nem.lacerta.model.document.DocumentDetail;
|
import one.nem.lacerta.model.document.DocumentDetail;
|
||||||
|
|
||||||
import one.nem.lacerta.model.document.internal.XmlMetaModel;
|
import one.nem.lacerta.model.document.internal.XmlMetaModel;
|
||||||
|
|
||||||
import one.nem.lacerta.model.document.page.Page;
|
import one.nem.lacerta.model.document.page.Page;
|
||||||
|
|
||||||
|
// Lacerta/processor
|
||||||
|
import one.nem.lacerta.processor.DocumentProcessor;
|
||||||
|
|
||||||
|
// Lacerta/source
|
||||||
import one.nem.lacerta.source.file.FileManager;
|
import one.nem.lacerta.source.file.FileManager;
|
||||||
import one.nem.lacerta.source.file.factory.FileManagerFactory;
|
import one.nem.lacerta.source.file.factory.FileManagerFactory;
|
||||||
|
|
||||||
|
// Lacerta/utils
|
||||||
import one.nem.lacerta.utils.LacertaLogger;
|
import one.nem.lacerta.utils.LacertaLogger;
|
||||||
|
|
||||||
import one.nem.lacerta.utils.XmlMetaParser;
|
import one.nem.lacerta.utils.XmlMetaParser;
|
||||||
import one.nem.lacerta.utils.repository.DeviceInfoUtils;
|
import one.nem.lacerta.utils.repository.DeviceInfoUtils;
|
||||||
|
|
||||||
|
// Lacerta/vcs
|
||||||
import one.nem.lacerta.vcs.LacertaVcs;
|
import one.nem.lacerta.vcs.LacertaVcs;
|
||||||
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
|
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -30,5 +30,4 @@ include ':source'
|
|||||||
include ':model'
|
include ':model'
|
||||||
include ':processor'
|
include ':processor'
|
||||||
include ':shared:ui'
|
include ':shared:ui'
|
||||||
include ':shared:icon'
|
|
||||||
include ':vcs'
|
include ':vcs'
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package one.nem.lacerta.source.jgit;
|
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.Repository;
|
|
||||||
|
|
||||||
public interface ActionRepo {
|
|
||||||
|
|
||||||
// リポジトリをインスタンス変数に格納
|
|
||||||
void setRepository(Repository repository);
|
|
||||||
|
|
||||||
// リポジトリ取得
|
|
||||||
Repository getRepository();
|
|
||||||
|
|
||||||
// リポジトリ名取得
|
|
||||||
String getRepositoryName();
|
|
||||||
|
|
||||||
// ステージングされていないファイルの一覧を取得
|
|
||||||
String[] getUnstagedFiles();
|
|
||||||
|
|
||||||
// ステージングされているファイルの一覧を取得
|
|
||||||
String[] getStagedFiles();
|
|
||||||
|
|
||||||
// ファイルをステージング
|
|
||||||
void stageFile(String path);
|
|
||||||
|
|
||||||
// ファイルをアンステージング
|
|
||||||
void unstageFile(String path);
|
|
||||||
|
|
||||||
// ステージングされているファイルをコミット
|
|
||||||
void commit(String message);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package one.nem.lacerta.source.jgit;
|
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.Repository;
|
|
||||||
|
|
||||||
public interface JGitRepository {
|
|
||||||
|
|
||||||
// リポジトリ取得
|
|
||||||
Repository getRepository(String id);
|
|
||||||
// リポジトリ作成
|
|
||||||
Repository createRepository(String id);
|
|
||||||
// リポジトリ削除
|
|
||||||
void deleteRepository(String id);
|
|
||||||
// リポジトリ存在確認
|
|
||||||
boolean repositoryExists(String id);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
package one.nem.lacerta.source.jgit.impl;
|
|
||||||
|
|
||||||
import org.eclipse.jgit.api.Git;
|
|
||||||
import org.eclipse.jgit.lib.Repository;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import one.nem.lacerta.source.jgit.ActionRepo;
|
|
||||||
import one.nem.lacerta.utils.LacertaLogger;
|
|
||||||
|
|
||||||
public class ActionRepoImpl implements ActionRepo{
|
|
||||||
|
|
||||||
@Inject // Inject logger
|
|
||||||
LacertaLogger logger;
|
|
||||||
|
|
||||||
private final String TAG = "ActionRepoImpl";
|
|
||||||
|
|
||||||
Repository repository;
|
|
||||||
|
|
||||||
Git git;
|
|
||||||
|
|
||||||
// Internal method
|
|
||||||
private Git getGit() {
|
|
||||||
if (this.git == null) {
|
|
||||||
logger.debug(TAG, "getGit: git is null. Creating new Git instance");
|
|
||||||
this.git = new Git(repository);
|
|
||||||
}
|
|
||||||
return this.git;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRepository(Repository repository) {
|
|
||||||
this.repository = repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Repository getRepository() {
|
|
||||||
if (repository == null) {
|
|
||||||
logger.warn(TAG, "getRepository: repository is null. Throwing RuntimeException");
|
|
||||||
throw new RuntimeException("リポジトリが設定されていません");
|
|
||||||
}
|
|
||||||
return repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRepositoryName() {
|
|
||||||
return repository.getDirectory().getParentFile().getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] getUnstagedFiles() {
|
|
||||||
Git git = getGit();
|
|
||||||
try {
|
|
||||||
return git.status().call().getUntracked().toArray(new String[0]);
|
|
||||||
} catch (Exception e) { // TODO-rca: エラーハンドリング
|
|
||||||
logger.error(TAG, "getUnstagedFiles: " + e.getMessage());
|
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] getStagedFiles() {
|
|
||||||
Git git = getGit();
|
|
||||||
try {
|
|
||||||
return git.status().call().getAdded().toArray(new String[0]);
|
|
||||||
} catch (Exception e) { // TODO-rca: エラーハンドリング
|
|
||||||
logger.error(TAG, "getStagedFiles: " + e.getMessage());
|
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stageFile(String path) {
|
|
||||||
Git git = getGit();
|
|
||||||
try {
|
|
||||||
git.add().addFilepattern(path).call();
|
|
||||||
} catch (Exception e) { // TODO-rca: エラーハンドリング
|
|
||||||
logger.error(TAG, "stageFile: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unstageFile(String path) {
|
|
||||||
Git git = getGit();
|
|
||||||
try {
|
|
||||||
git.reset().addPath(path).call();
|
|
||||||
} catch (Exception e) { // TODO-rca: エラーハンドリング
|
|
||||||
logger.error(TAG, "unstageFile: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void commit(String message) {
|
|
||||||
Git git = getGit();
|
|
||||||
try {
|
|
||||||
git.commit().setMessage(message).call();
|
|
||||||
} catch (Exception e) { // TODO-rca: エラーハンドリング
|
|
||||||
logger.error(TAG, "commit: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package one.nem.lacerta.source.jgit.impl;
|
|
||||||
|
|
||||||
import one.nem.lacerta.source.jgit.JGitRepository;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import one.nem.lacerta.utils.repository.DeviceInfoUtils;
|
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.Repository;
|
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.RepositoryBuilder;
|
|
||||||
|
|
||||||
public class JGitRepositoryImpl implements JGitRepository {
|
|
||||||
|
|
||||||
private final DeviceInfoUtils deviceInfoUtils;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public JGitRepositoryImpl(DeviceInfoUtils deviceInfoUtils) {
|
|
||||||
this.deviceInfoUtils = deviceInfoUtils;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Repository getRepository(String id) {
|
|
||||||
RepositoryBuilder repositoryBuilder = new RepositoryBuilder();
|
|
||||||
repositoryBuilder.setGitDir(deviceInfoUtils.getExternalStorageDirectory().resolve(id).resolve(".git").toFile());
|
|
||||||
repositoryBuilder.setMustExist(true);
|
|
||||||
try {
|
|
||||||
return repositoryBuilder.build();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Repository createRepository(String id) {
|
|
||||||
RepositoryBuilder repositoryBuilder = new RepositoryBuilder();
|
|
||||||
repositoryBuilder.setGitDir(deviceInfoUtils.getExternalStorageDirectory().resolve(id).resolve(".git").toFile());
|
|
||||||
repositoryBuilder.setMustExist(false);
|
|
||||||
try {
|
|
||||||
return repositoryBuilder.build();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteRepository(String id) {
|
|
||||||
// TODO-rca: 未実装
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean repositoryExists(String id) {
|
|
||||||
return false; // TODO-rca: 未実装
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Whitespace-only changes.
@@ -1,15 +0,0 @@
|
|||||||
package one.nem.lacerta.source.jgit.module;
|
|
||||||
|
|
||||||
import dagger.Binds;
|
|
||||||
import dagger.Module;
|
|
||||||
import dagger.hilt.InstallIn;
|
|
||||||
import dagger.hilt.components.SingletonComponent;
|
|
||||||
import one.nem.lacerta.source.jgit.JGitRepository;
|
|
||||||
|
|
||||||
@Module
|
|
||||||
@InstallIn(SingletonComponent.class)
|
|
||||||
abstract public class JGitRepositoryModule {
|
|
||||||
|
|
||||||
@Binds
|
|
||||||
public abstract JGitRepository bindManageRepo(one.nem.lacerta.source.jgit.impl.JGitRepositoryImpl manageRepoImpl);
|
|
||||||
}
|
|
||||||
Whitespace-only changes.
Reference in new issue
Block a user