aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/injection/context/ContextModule.kt8
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/injection/context/FilesDirPath.kt6
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/injection/prefs/GitPreferences.kt6
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/injection/prefs/ProxyPreferences.kt6
4 files changed, 26 insertions, 0 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/injection/context/ContextModule.kt b/app/src/main/java/dev/msfjarvis/aps/injection/context/ContextModule.kt
index 6399781e..0f1acac8 100644
--- a/app/src/main/java/dev/msfjarvis/aps/injection/context/ContextModule.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/injection/context/ContextModule.kt
@@ -11,6 +11,14 @@ import dagger.hilt.components.SingletonComponent
@InstallIn(SingletonComponent::class)
class ContextModule {
+ /**
+ * A method which provides the path of app-specific files directory. This is useful where we want
+ * to perform file operations but we do not want to depend on the [Context]. Injecting this in
+ * place of [Context] allows the method/class to be unit-tested without any mocks/fakes.
+ *
+ * @param context [ApplicationContext]
+ * @return the path of app-specific files directory.
+ */
@Provides
@FilesDirPath
fun providesFilesDirPath(@ApplicationContext context: Context): String {
diff --git a/app/src/main/java/dev/msfjarvis/aps/injection/context/FilesDirPath.kt b/app/src/main/java/dev/msfjarvis/aps/injection/context/FilesDirPath.kt
index ec747bfe..8ab96f59 100644
--- a/app/src/main/java/dev/msfjarvis/aps/injection/context/FilesDirPath.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/injection/context/FilesDirPath.kt
@@ -1,5 +1,11 @@
package dev.msfjarvis.aps.injection.context
+import android.content.Context
+import dev.msfjarvis.aps.util.settings.GitSettings
import javax.inject.Qualifier
+/**
+ * Qualifier for a string value that needs to be provided to the [GitSettings]. It points to
+ * `applicationContext.filesDir` and helps in removing the dependency on [Context].
+ */
@Qualifier @Retention(AnnotationRetention.RUNTIME) annotation class FilesDirPath
diff --git a/app/src/main/java/dev/msfjarvis/aps/injection/prefs/GitPreferences.kt b/app/src/main/java/dev/msfjarvis/aps/injection/prefs/GitPreferences.kt
index 749eea48..69de66f2 100644
--- a/app/src/main/java/dev/msfjarvis/aps/injection/prefs/GitPreferences.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/injection/prefs/GitPreferences.kt
@@ -1,5 +1,11 @@
package dev.msfjarvis.aps.injection.prefs
+import android.content.SharedPreferences
+import dev.msfjarvis.aps.util.settings.GitSettings
import javax.inject.Qualifier
+/**
+ * Qualifier for a [SharedPreferences] that needs to be provided to the [GitSettings]. It provides a
+ * [SharedPreferences] with the file name "git_operation" which stores the git settings.
+ */
@Qualifier @Retention(AnnotationRetention.RUNTIME) annotation class GitPreferences
diff --git a/app/src/main/java/dev/msfjarvis/aps/injection/prefs/ProxyPreferences.kt b/app/src/main/java/dev/msfjarvis/aps/injection/prefs/ProxyPreferences.kt
index 786087ad..67d6f4dc 100644
--- a/app/src/main/java/dev/msfjarvis/aps/injection/prefs/ProxyPreferences.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/injection/prefs/ProxyPreferences.kt
@@ -1,5 +1,11 @@
package dev.msfjarvis.aps.injection.prefs
+import android.content.SharedPreferences
+import dev.msfjarvis.aps.util.settings.GitSettings
import javax.inject.Qualifier
+/**
+ * Qualifier for a [SharedPreferences] that needs to be provided to the [GitSettings]. It provides a
+ * [SharedPreferences] with the file name "http_proxy" which stores all the http proxy settings.
+ */
@Qualifier @Retention(AnnotationRetention.RUNTIME) annotation class ProxyPreferences