From 119140a6bc2eb2d38f37381c5df293970dc5e985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Tue, 12 Dec 2023 11:00:26 +0900 Subject: [PATCH] =?UTF-8?q?InternalUtils=E3=81=AA=E3=83=A2=E3=82=B8?= =?UTF-8?q?=E3=83=A5=E3=83=BC=E3=83=AB=E3=81=AB=E7=A7=BB=E6=A4=8DWIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/data/utils/UtilsRepo.java | 1 - .../nem/lacerta/source/jgit/RepoUtils.java | 13 ++++++++- .../oen/nem/lacerta/utils/impl/UtilsImpl.java | 29 +++++++++++++++++++ .../nem/lacerta/utils/module/UtilsModule.java | 16 ++++++++++ .../lacerta/utils/repository/UtilsRepo.java | 11 +++++++ 5 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 utils/src/main/java/oen/nem/lacerta/utils/impl/UtilsImpl.java create mode 100644 utils/src/main/java/oen/nem/lacerta/utils/module/UtilsModule.java create mode 100644 utils/src/main/java/oen/nem/lacerta/utils/repository/UtilsRepo.java diff --git a/data/src/main/java/one/nem/lacerta/data/utils/UtilsRepo.java b/data/src/main/java/one/nem/lacerta/data/utils/UtilsRepo.java index f64108e2..d25e0c92 100644 --- a/data/src/main/java/one/nem/lacerta/data/utils/UtilsRepo.java +++ b/data/src/main/java/one/nem/lacerta/data/utils/UtilsRepo.java @@ -8,5 +8,4 @@ public interface UtilsRepo { Path getExternalFilesDirPath(); - } diff --git a/data/src/main/java/one/nem/lacerta/source/jgit/RepoUtils.java b/data/src/main/java/one/nem/lacerta/source/jgit/RepoUtils.java index e7d4ea9e..66ce2647 100644 --- a/data/src/main/java/one/nem/lacerta/source/jgit/RepoUtils.java +++ b/data/src/main/java/one/nem/lacerta/source/jgit/RepoUtils.java @@ -1,10 +1,21 @@ package one.nem.lacerta.source.jgit; +import org.eclipse.jgit.internal.storage.file.FileRepository; import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.storage.file.FileRepositoryBuilder; public class RepoUtils { // Internal Utils - public static String getRepoName(Repository repo) { + + public Repository createRepo(String id, ) { + Repository repository = FileRepositoryBuilder.create( + + ) + } + public Repository getRepo(String id) { + // WIP + } + public String getRepoName(Repository repo) { return repo.getDirectory().getParentFile().getName(); } diff --git a/utils/src/main/java/oen/nem/lacerta/utils/impl/UtilsImpl.java b/utils/src/main/java/oen/nem/lacerta/utils/impl/UtilsImpl.java new file mode 100644 index 00000000..a0854ff3 --- /dev/null +++ b/utils/src/main/java/oen/nem/lacerta/utils/impl/UtilsImpl.java @@ -0,0 +1,29 @@ +package oen.nem.lacerta.utils.impl; + +import android.content.Context; + +import java.nio.file.Path; +import java.util.Objects; + +import javax.inject.Inject; + +import dagger.hilt.android.qualifiers.ApplicationContext; +import one.nem.lacerta.data.utils.UtilsRepo; + +public class UtilsImpl implements UtilsRepo{ + + private final Context applicationContext; + + @Inject + public UtilsImpl(@ApplicationContext Context applicationContext) { + this.applicationContext = applicationContext; + } + + public Path getExternalFilesDirPath(String type) { + return Objects.requireNonNull(applicationContext.getExternalFilesDir(type)).toPath(); + } + + public Path getExternalFilesDirPath() { + return Objects.requireNonNull(applicationContext.getExternalFilesDir(null)).toPath(); + } +} diff --git a/utils/src/main/java/oen/nem/lacerta/utils/module/UtilsModule.java b/utils/src/main/java/oen/nem/lacerta/utils/module/UtilsModule.java new file mode 100644 index 00000000..a05e96c9 --- /dev/null +++ b/utils/src/main/java/oen/nem/lacerta/utils/module/UtilsModule.java @@ -0,0 +1,16 @@ +package oen.nem.lacerta.utils.module; + +import dagger.Binds; +import dagger.Module; +import dagger.hilt.InstallIn; +import dagger.hilt.components.SingletonComponent; +import one.nem.lacerta.data.utils.UtilsImpl; +import one.nem.lacerta.data.utils.UtilsRepo; + +@Module +@InstallIn(SingletonComponent.class) +abstract public class UtilsModule { + + @Binds + public abstract UtilsRepo bindUtils(UtilsImpl utilsImpl); +} diff --git a/utils/src/main/java/oen/nem/lacerta/utils/repository/UtilsRepo.java b/utils/src/main/java/oen/nem/lacerta/utils/repository/UtilsRepo.java new file mode 100644 index 00000000..14a81d61 --- /dev/null +++ b/utils/src/main/java/oen/nem/lacerta/utils/repository/UtilsRepo.java @@ -0,0 +1,11 @@ +package oen.nem.lacerta.utils.repository; + +import java.nio.file.Path; + +public interface UtilsRepo { + + Path getExternalFilesDirPath(String type); + + Path getExternalFilesDirPath(); + +}