docs: Document qualifiers
Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
This commit is contained in:
parent
d9d18069ab
commit
a2741cd871
4 changed files with 26 additions and 0 deletions
|
@ -11,6 +11,14 @@ import dagger.hilt.components.SingletonComponent
|
||||||
@InstallIn(SingletonComponent::class)
|
@InstallIn(SingletonComponent::class)
|
||||||
class ContextModule {
|
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
|
@Provides
|
||||||
@FilesDirPath
|
@FilesDirPath
|
||||||
fun providesFilesDirPath(@ApplicationContext context: Context): String {
|
fun providesFilesDirPath(@ApplicationContext context: Context): String {
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
package dev.msfjarvis.aps.injection.context
|
package dev.msfjarvis.aps.injection.context
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import dev.msfjarvis.aps.util.settings.GitSettings
|
||||||
import javax.inject.Qualifier
|
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
|
@Qualifier @Retention(AnnotationRetention.RUNTIME) annotation class FilesDirPath
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
package dev.msfjarvis.aps.injection.prefs
|
package dev.msfjarvis.aps.injection.prefs
|
||||||
|
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import dev.msfjarvis.aps.util.settings.GitSettings
|
||||||
import javax.inject.Qualifier
|
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
|
@Qualifier @Retention(AnnotationRetention.RUNTIME) annotation class GitPreferences
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
package dev.msfjarvis.aps.injection.prefs
|
package dev.msfjarvis.aps.injection.prefs
|
||||||
|
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import dev.msfjarvis.aps.util.settings.GitSettings
|
||||||
import javax.inject.Qualifier
|
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
|
@Qualifier @Retention(AnnotationRetention.RUNTIME) annotation class ProxyPreferences
|
||||||
|
|
Loading…
Reference in a new issue