forked from ReVanced/revanced-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: switch to Preferences DataStore (ReVanced#60)
- Loading branch information
Showing
18 changed files
with
303 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 1 addition & 6 deletions
7
app/src/main/java/app/revanced/manager/di/PreferencesModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
package app.revanced.manager.di | ||
|
||
import android.content.Context | ||
import app.revanced.manager.domain.manager.PreferencesManager | ||
import org.koin.core.module.dsl.singleOf | ||
import org.koin.dsl.module | ||
|
||
val preferencesModule = module { | ||
fun providePreferences( | ||
context: Context | ||
) = PreferencesManager(context.getSharedPreferences("preferences", Context.MODE_PRIVATE)) | ||
|
||
singleOf(::providePreferences) | ||
singleOf(::PreferencesManager) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 10 additions & 13 deletions
23
app/src/main/java/app/revanced/manager/domain/manager/PreferencesManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
package app.revanced.manager.domain.manager | ||
|
||
import android.content.SharedPreferences | ||
import app.revanced.manager.domain.manager.base.BasePreferenceManager | ||
import android.content.Context | ||
import app.revanced.manager.domain.manager.base.BasePreferencesManager | ||
import app.revanced.manager.ui.theme.Theme | ||
|
||
/** | ||
* @author Hyperion Authors, zt64 | ||
*/ | ||
class PreferencesManager( | ||
sharedPreferences: SharedPreferences | ||
) : BasePreferenceManager(sharedPreferences) { | ||
var dynamicColor by booleanPreference("dynamic_color", true) | ||
var theme by enumPreference("theme", Theme.SYSTEM) | ||
context: Context | ||
) : BasePreferencesManager(context, "settings") { | ||
val dynamicColor = booleanPreference("dynamic_color", true) | ||
val theme = enumPreference("theme", Theme.SYSTEM) | ||
|
||
var allowExperimental by booleanPreference("allow_experimental", false) | ||
val allowExperimental = booleanPreference("allow_experimental", false) | ||
|
||
var preferSplits by booleanPreference("prefer_splits", false) | ||
val keystoreCommonName = stringPreference("keystore_cn", KeystoreManager.DEFAULT) | ||
val keystorePass = stringPreference("keystore_pass", KeystoreManager.DEFAULT) | ||
|
||
var keystoreCommonName by stringPreference("keystore_cn", KeystoreManager.DEFAULT) | ||
var keystorePass by stringPreference("keystore_pass", KeystoreManager.DEFAULT) | ||
val preferSplits = booleanPreference("prefer_splits", false) | ||
} |
Oops, something went wrong.