From 1e68e97b25b3f9ab640b8697537b1ab1fe921dfe Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Fri, 5 May 2023 00:47:11 +0530 Subject: refactor: make `PreferenceModule` codestyle consistent --- .../injection/prefs/PreferenceModule.kt | 25 +++++++--------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/app/passwordstore/injection/prefs/PreferenceModule.kt b/app/src/main/java/app/passwordstore/injection/prefs/PreferenceModule.kt index 072bf031..797c7563 100644 --- a/app/src/main/java/app/passwordstore/injection/prefs/PreferenceModule.kt +++ b/app/src/main/java/app/passwordstore/injection/prefs/PreferenceModule.kt @@ -17,10 +17,7 @@ import dagger.hilt.components.SingletonComponent @InstallIn(SingletonComponent::class) class PreferenceModule { - private fun provideBaseEncryptedPreferences( - context: Context, - fileName: String - ): SharedPreferences { + private fun createEncryptedPreferences(context: Context, fileName: String): SharedPreferences { val masterKeyAlias = MasterKey.Builder(context).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build() return EncryptedSharedPreferences.create( @@ -34,27 +31,21 @@ class PreferenceModule { @[Provides PasswordGeneratorPreferences Reusable] fun providePwgenPreferences(@ApplicationContext context: Context): SharedPreferences { - return provideBaseEncryptedPreferences(context, "pwgen_preferences") + return createEncryptedPreferences(context, "pwgen_preferences") } - @Provides - @SettingsPreferences - @Reusable + @[Provides SettingsPreferences Reusable] fun provideSettingsPreferences(@ApplicationContext context: Context): SharedPreferences { return context.getSharedPreferences("${BuildConfig.APPLICATION_ID}_preferences", MODE_PRIVATE) } - @Provides - @GitPreferences - @Reusable - fun provideEncryptedPreferences(@ApplicationContext context: Context): SharedPreferences { - return provideBaseEncryptedPreferences(context, "git_operation") + @[Provides GitPreferences Reusable] + fun provideGitPreferences(@ApplicationContext context: Context): SharedPreferences { + return createEncryptedPreferences(context, "git_operation") } - @Provides - @ProxyPreferences - @Reusable + @[Provides ProxyPreferences Reusable] fun provideProxyPreferences(@ApplicationContext context: Context): SharedPreferences { - return provideBaseEncryptedPreferences(context, "http_proxy") + return createEncryptedPreferences(context, "http_proxy") } } -- cgit v1.2.3