モジュール構成変更

This commit is contained in:
r-ca 2023-12-14 03:33:56 +09:00
parent 08fafcfced
commit 0613c8284a
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9
23 changed files with 2 additions and 515 deletions

View File

@ -1,28 +0,0 @@
package one.nem.lacerta.data.impl;
import java.nio.file.Path;
import javax.inject.Inject;
import one.nem.lacerta.data.repository.Commons;
import one.nem.lacerta.utils.repository.DeviceInfoUtils;
public class CommonsImpl implements Commons{
@Inject
public CommonsImpl() {
}
@Inject
DeviceInfoUtils fileUtils;
public Path getExternalFilesDirPath(String type) {
return fileUtils.getExternalFilesDirPath(type);
}
public Path getExternalFilesDirPath() {
return fileUtils.getExternalFilesDirPath();
}
}

View File

@ -1,27 +0,0 @@
package one.nem.lacerta.data.impl;
import org.eclipse.jgit.lib.Repository;
import javax.inject.Inject;
import one.nem.lacerta.data.repository.DebugFunc;
import one.nem.lacerta.source.jgit.RepoUtils;
public class DebugFuncImpl implements DebugFunc {
@Inject
public DebugFuncImpl() {
}
@Inject
RepoUtils repoUtils;
public Repository getOrCreateRepositoryById(String id) {
Repository repo = repoUtils.getRepo(id); // TODO-rca: リポジトリの存在確認をもうすこしなんとかする
if (repo == null) {
repo = repoUtils.createRepo(id);
}
// Repository repo = repoUtils.createRepo(id); // debug
return repo;
}
}

View File

@ -1,26 +0,0 @@
package one.nem.lacerta.data.impl;
import android.os.Build;
import one.nem.lacerta.data.repository.DeviceMeta;
import one.nem.lacerta.data.model.DeviceMetaModel;
import javax.inject.Inject;
public class DeviceMetaImpl implements DeviceMeta{
@Inject
public DeviceMetaImpl() {
}
public DeviceMetaModel getDeviceMeta() {
DeviceMetaModel deviceMetaModel = new DeviceMetaModel(
Build.MANUFACTURER,
Build.MODEL,
Build.VERSION.RELEASE,
Build.VERSION.SDK_INT
);
return deviceMetaModel;
}
}

View File

@ -1,24 +0,0 @@
package one.nem.lacerta.data.impl;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import one.nem.lacerta.data.model.documents.DocumentMeta;
import one.nem.lacerta.data.repository.Documents;
public class DocumentsImpl implements Documents {
@Inject
public DocumentsImpl() {
}
public ArrayList<DocumentMeta> getRecentDocuments(int limit) {
return null; // TODO-rca:
}
public ArrayList<DocumentMeta> getStarredDocuments(int limit) {
return null; // TODO-rca:
}
}

View File

@ -1,26 +0,0 @@
package one.nem.lacerta.data.impl;
import android.content.Context;
import android.content.SharedPreferences;
import javax.inject.Inject;
import dagger.hilt.android.qualifiers.ApplicationContext;
import one.nem.lacerta.data.repository.SharedPref;
import one.nem.lacerta.data.model.shared_pref.enums.SharedPrefType;
public class SharedPrefImpl implements SharedPref{
private final Context applicationContext;
@Inject
public SharedPrefImpl(@ApplicationContext Context applicationContext) {
this.applicationContext = applicationContext;
}
@Override
public SharedPreferences getSharedPreferencesByTag(SharedPrefType sharedPrefType) {
return applicationContext.getSharedPreferences(sharedPrefType.getTag(), Context.MODE_PRIVATE);
}
}

View File

@ -1,56 +0,0 @@
package one.nem.lacerta.data.impl.stub;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import java.util.Date;
import javax.inject.Inject;
import one.nem.lacerta.data.model.documents.DocumentMeta;
import one.nem.lacerta.data.model.documents.enums.DocumentType;
import one.nem.lacerta.data.repository.Documents;
public class DocumentsImpl implements Documents {
@Inject
public DocumentsImpl() {
}
public ArrayList<DocumentMeta> getRecentDocuments(int limit) { // Generate dummy data
ArrayList<DocumentMeta> documentMetaList = new ArrayList<>();
for (int i = 0; i < limit; i++) {
DocumentMeta documentMeta = new DocumentMeta();
documentMeta.id = UUID.randomUUID().toString();
documentMeta.name = "Document " + i;
documentMeta.created = new Date();
documentMeta.type = new Random(i).nextInt()/2 == 0 ? DocumentType.OTHER : DocumentType.NOTEBOOK;
documentMeta.tags = new String[] {"tag1", "tag2", "tag3"};
documentMeta.categories = new String[] {"category1", "category2", "category3"};
documentMetaList.add(documentMeta);
}
return documentMetaList;
}
public ArrayList<DocumentMeta> getStarredDocuments(int limit) { // Generate dummy data
ArrayList<DocumentMeta> documentMetaList = new ArrayList<>();
for (int i = 0; i < limit; i++) {
DocumentMeta documentMeta = new DocumentMeta();
documentMeta.id = UUID.randomUUID().toString();
documentMeta.name = "Document " + i;
documentMeta.created = new Date();
documentMeta.type = new Random(i).nextInt()/2 == 0 ? DocumentType.OTHER : DocumentType.NOTEBOOK;
documentMeta.tags = new String[] {"tag1", "tag2", "tag3"};
documentMeta.categories = new String[] {"category1", "category2", "category3"};
documentMetaList.add(documentMeta);
}
return documentMetaList;
}
}

View File

@ -1,34 +0,0 @@
package one.nem.lacerta.data.model;
public class DeviceMetaModel {
private String DeviceManufacturer;
private String DeviceModel;
private String AndroidVersion;
private int AndroidApiLevel;
public DeviceMetaModel(String DeviceManufacturer, String DeviceModel, String AndroidVersion, int AndroidApiLevel) {
this.DeviceManufacturer = DeviceManufacturer;
this.DeviceModel = DeviceModel;
this.AndroidVersion = AndroidVersion;
this.AndroidApiLevel = AndroidApiLevel;
}
// Getters
// TODO-rca: ボイラープレートコードなので削減する
public String getDeviceManufacturer() {
return DeviceManufacturer;
}
public String getDeviceModel() {
return DeviceModel;
}
public String getAndroidVersion() {
return AndroidVersion;
}
public int getAndroidApiLevel() {
return AndroidApiLevel;
}
}

View File

@ -1,8 +0,0 @@
package one.nem.lacerta.data.model.documents;
public class DocumentDetail {
// ドキュメントの詳細情報
private DocumentMeta documentMeta;
// TODO-rca: ドキュメントの詳細情報を格納するフィールドを追加する
}

View File

@ -1,107 +0,0 @@
package one.nem.lacerta.data.model.documents;
import java.util.Date;
import one.nem.lacerta.data.model.documents.enums.DocumentType;
// TODO-rca: Dateをデバイスのロケールに合わせてStringに変換するメソッドを実装する?
public class DocumentMeta {
// ドキュメントのメタ情報
public String id; // ドキュメントの内部ID(UUIDv4?)
public String name; // ドキュメントの名前
public DocumentType type; // ドキュメントの種類
public Date created; // ドキュメントの作成日時
public String[] tags; // ドキュメントのタグ
public String[] categories; // ドキュメントのカテゴリ
public DocumentMeta(String id, String name, Date created, DocumentType type, String[] tags, String[] categories) {
this.id = id;
this.name = name;
this.created = created;
this.type = type;
this.tags = tags;
this.categories = categories;
}
public DocumentMeta() {
this.id = "";
this.name = "";
this.created = new Date();
this.type = DocumentType.OTHER;
this.tags = new String[0];
this.categories = new String[0];
}
// TODO-rca: ボイラープレートコードなので削減する
// Getter
public String getId() {
return id;
}
public String getName() {
return name;
}
public Date getCreated() {
return created;
}
public DocumentType getType() {
return type;
}
public String[] getTags() {
return tags;
}
public String[] getCategories() {
return categories;
}
// Setter
public void setId(String id) {
this.id = id;
}
public void setName(String name) {
if (name == null) {
this.name = "";
} else {
this.name = name;
}
}
public void setCreated(Date created) {
if (created == null) {
this.created = new Date();
} else {
this.created = created;
}
}
public void setType(DocumentType type) {
if (type == null) {
this.type = DocumentType.OTHER;
} else {
this.type = type;
}
}
public void setTags(String[] tags) {
if (tags == null) {
this.tags = new String[0];
} else {
this.tags = tags;
}
}
public void setCategories(String[] categories) {
if (categories == null) {
this.categories = new String[0];
} else {
this.categories = categories;
}
}
}

View File

@ -1,21 +0,0 @@
package one.nem.lacerta.data.model.documents.enums;
public enum DocumentType {
// ドキュメントの種類
// TODO: ユーザーがドキュメントの種類を追加できるようにする
// テキスト
TEXTBOOK,
// ノート
NOTEBOOK,
// ワークブック
WORKBOOK,
// レシート
RECEIPT,
// チケット
TICKET,
// メモ
MEMO,
// その他
OTHER
}

View File

@ -1,17 +0,0 @@
package one.nem.lacerta.data.model.shared_pref.enums;
public enum SharedPrefType {
COMMON("common"),
USERDATA("userdata");
private String tag;
SharedPrefType(String tag) {
this.tag = tag;
}
public String getTag() {
return tag;
}
}

View File

@ -1,16 +0,0 @@
package one.nem.lacerta.data.module;
import dagger.Binds;
import dagger.Module;
import dagger.hilt.InstallIn;
import dagger.hilt.components.SingletonComponent;
import one.nem.lacerta.data.repository.Commons;
import one.nem.lacerta.data.impl.CommonsImpl;
@Module
@InstallIn(SingletonComponent.class)
abstract class CommonsModule {
@Binds
public abstract Commons bindCommons(CommonsImpl commonsImpl);
}

View File

@ -1,16 +0,0 @@
package one.nem.lacerta.data.module;
import dagger.Binds;
import dagger.Module;
import dagger.hilt.InstallIn;
import dagger.hilt.components.SingletonComponent;
import one.nem.lacerta.data.repository.DebugFunc;
import one.nem.lacerta.data.impl.DebugFuncImpl;
@Module
@InstallIn(SingletonComponent.class)
abstract class DebugFuncModule {
@Binds
public abstract DebugFunc bindDebugFunc(DebugFuncImpl debugFuncImpl);
}

View File

@ -1,19 +0,0 @@
package one.nem.lacerta.data.module;
import one.nem.lacerta.data.impl.DeviceMetaImpl;
import one.nem.lacerta.data.repository.DeviceMeta;
import dagger.Binds;
import dagger.Module;
import dagger.hilt.InstallIn;
// Singleton
import dagger.hilt.components.SingletonComponent;
@Module
@InstallIn(SingletonComponent.class)
abstract class DeviceMetaModule {
@Binds
public abstract DeviceMeta bindDeviceMeta(DeviceMetaImpl deviceMetaImpl);
}

View File

@ -1,18 +0,0 @@
package one.nem.lacerta.data.module;
import dagger.Binds;
import dagger.Module;
import dagger.hilt.InstallIn;
import dagger.hilt.components.SingletonComponent;
import one.nem.lacerta.data.repository.Documents;
import one.nem.lacerta.data.impl.DocumentsImpl;
@Module
@InstallIn(SingletonComponent.class)
abstract public class DocumentsModule {
@Binds
public abstract Documents bindDocuments(DocumentsImpl documentsImpl);
}

View File

@ -1,19 +0,0 @@
package one.nem.lacerta.data.module;
import android.content.Context;
import android.content.SharedPreferences;
import dagger.Binds;
import dagger.Module;
import dagger.hilt.InstallIn;
import dagger.hilt.components.SingletonComponent;
import one.nem.lacerta.data.impl.SharedPrefImpl;
import one.nem.lacerta.data.repository.SharedPref;
@Module
@InstallIn(SingletonComponent.class)
abstract public class SharedPrefModule {
@Binds
public abstract SharedPref bindSharedPref(SharedPrefImpl sharedPrefImpl);
}

View File

@ -1,11 +0,0 @@
package one.nem.lacerta.data.repository;
import java.nio.file.Path;
public interface Commons {
Path getExternalFilesDirPath(String type);
Path getExternalFilesDirPath();
}

View File

@ -1,9 +0,0 @@
package one.nem.lacerta.data.repository;
import org.eclipse.jgit.lib.Repository;
public interface DebugFunc {
Repository getOrCreateRepositoryById(String id);
}

View File

@ -1,7 +0,0 @@
package one.nem.lacerta.data.repository;
import one.nem.lacerta.data.model.DeviceMetaModel;
public interface DeviceMeta {
DeviceMetaModel getDeviceMeta();
}

View File

@ -1,15 +0,0 @@
package one.nem.lacerta.data.repository;
import java.util.ArrayList;
import java.util.List;
import one.nem.lacerta.data.model.documents.DocumentDetail;
import one.nem.lacerta.data.model.documents.DocumentMeta;
public interface Documents {
ArrayList<DocumentMeta> getRecentDocuments(int limit);
ArrayList<DocumentMeta> getStarredDocuments(int limit);
}

View File

@ -1,11 +0,0 @@
package one.nem.lacerta.data.repository;
import android.content.SharedPreferences;
import one.nem.lacerta.data.model.shared_pref.enums.SharedPrefType;
public interface SharedPref {
// タグのTypoを防ぐ為にEnumで管理して取得させるやつ
SharedPreferences getSharedPreferencesByTag(SharedPrefType sharedPrefType);
}

View File

@ -1,4 +1,6 @@
package one.nem.lacerta.source.jgit.repository;
public interface JGitUtils {
}