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(); + +}