refactor: make PreferenceModule codestyle consistent

This commit is contained in:
Harsh Shandilya 2023-05-05 00:47:11 +05:30
parent a188ad3f72
commit 1e68e97b25
No known key found for this signature in database

View file

@ -17,10 +17,7 @@ import dagger.hilt.components.SingletonComponent
@InstallIn(SingletonComponent::class) @InstallIn(SingletonComponent::class)
class PreferenceModule { class PreferenceModule {
private fun provideBaseEncryptedPreferences( private fun createEncryptedPreferences(context: Context, fileName: String): SharedPreferences {
context: Context,
fileName: String
): SharedPreferences {
val masterKeyAlias = val masterKeyAlias =
MasterKey.Builder(context).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build() MasterKey.Builder(context).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build()
return EncryptedSharedPreferences.create( return EncryptedSharedPreferences.create(
@ -34,27 +31,21 @@ class PreferenceModule {
@[Provides PasswordGeneratorPreferences Reusable] @[Provides PasswordGeneratorPreferences Reusable]
fun providePwgenPreferences(@ApplicationContext context: Context): SharedPreferences { fun providePwgenPreferences(@ApplicationContext context: Context): SharedPreferences {
return provideBaseEncryptedPreferences(context, "pwgen_preferences") return createEncryptedPreferences(context, "pwgen_preferences")
} }
@Provides @[Provides SettingsPreferences Reusable]
@SettingsPreferences
@Reusable
fun provideSettingsPreferences(@ApplicationContext context: Context): SharedPreferences { fun provideSettingsPreferences(@ApplicationContext context: Context): SharedPreferences {
return context.getSharedPreferences("${BuildConfig.APPLICATION_ID}_preferences", MODE_PRIVATE) return context.getSharedPreferences("${BuildConfig.APPLICATION_ID}_preferences", MODE_PRIVATE)
} }
@Provides @[Provides GitPreferences Reusable]
@GitPreferences fun provideGitPreferences(@ApplicationContext context: Context): SharedPreferences {
@Reusable return createEncryptedPreferences(context, "git_operation")
fun provideEncryptedPreferences(@ApplicationContext context: Context): SharedPreferences {
return provideBaseEncryptedPreferences(context, "git_operation")
} }
@Provides @[Provides ProxyPreferences Reusable]
@ProxyPreferences
@Reusable
fun provideProxyPreferences(@ApplicationContext context: Context): SharedPreferences { fun provideProxyPreferences(@ApplicationContext context: Context): SharedPreferences {
return provideBaseEncryptedPreferences(context, "http_proxy") return createEncryptedPreferences(context, "http_proxy")
} }
} }