diff options
author | Aditya Wasan <adityawasan55@gmail.com> | 2021-05-22 19:48:30 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2021-05-22 20:05:56 +0530 |
commit | a2741cd871d91758950848ef5ae123bbc5b1d6b7 (patch) | |
tree | c089bf356df19e0f8162f92e44f183d8d0a35fdf /app/src/main/java | |
parent | d9d18069abeccea795d82f917ed2b56f8199d406 (diff) |
docs: Document qualifiers
Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
Diffstat (limited to 'app/src/main/java')
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 |