diff options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/prefs/sections')
6 files changed, 33 insertions, 48 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/BehaviourPrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/BehaviourPrefs.kt index 9d621048..8842d988 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/BehaviourPrefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/BehaviourPrefs.kt @@ -21,8 +21,7 @@ import ca.allanwang.kau.kpref.KPrefFactory import com.pitchedapps.frost.BuildConfig import com.pitchedapps.frost.prefs.OldPrefs import com.pitchedapps.frost.prefs.PrefsBase -import org.koin.core.component.KoinComponent -import org.koin.core.component.inject +import javax.inject.Inject interface BehaviourPrefs : PrefsBase { var biometricsEnabled: Boolean @@ -50,12 +49,10 @@ interface BehaviourPrefs : PrefsBase { var autoExpandTextBox: Boolean } -class BehaviourPrefsImpl( - factory: KPrefFactory -) : KPref("${BuildConfig.APPLICATION_ID}.prefs.behaviour", factory), - BehaviourPrefs, KoinComponent { - - private val oldPrefs: OldPrefs by inject() +class BehaviourPrefsImpl @Inject internal constructor( + factory: KPrefFactory, + oldPrefs: OldPrefs, +) : KPref("${BuildConfig.APPLICATION_ID}.prefs.behaviour", factory), BehaviourPrefs { override var biometricsEnabled: Boolean by kpref( "biometrics_enabled", diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/CorePrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/CorePrefs.kt index 6d3885cb..880a7225 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/CorePrefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/CorePrefs.kt @@ -21,8 +21,7 @@ import ca.allanwang.kau.kpref.KPrefFactory import com.pitchedapps.frost.BuildConfig import com.pitchedapps.frost.prefs.OldPrefs import com.pitchedapps.frost.prefs.PrefsBase -import org.koin.core.component.KoinComponent -import org.koin.core.component.inject +import javax.inject.Inject interface CorePrefs : PrefsBase { var lastLaunch: Long @@ -56,12 +55,10 @@ interface CorePrefs : PrefsBase { var messageScrollToBottom: Boolean } -class CorePrefsImpl( - factory: KPrefFactory -) : KPref("${BuildConfig.APPLICATION_ID}.prefs.core", factory), - CorePrefs, KoinComponent { - - private val oldPrefs: OldPrefs by inject() +class CorePrefsImpl @Inject internal constructor( + factory: KPrefFactory, + oldPrefs: OldPrefs, +) : KPref("${BuildConfig.APPLICATION_ID}.prefs.core", factory), CorePrefs { override var lastLaunch: Long by kpref("last_launch", oldPrefs.lastLaunch /* -1L */) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/FeedPrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/FeedPrefs.kt index 3fe2cfd8..00df9743 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/FeedPrefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/FeedPrefs.kt @@ -22,8 +22,7 @@ import com.pitchedapps.frost.BuildConfig import com.pitchedapps.frost.enums.MainActivityLayout import com.pitchedapps.frost.prefs.OldPrefs import com.pitchedapps.frost.prefs.PrefsBase -import org.koin.core.component.KoinComponent -import org.koin.core.component.inject +import javax.inject.Inject interface FeedPrefs : PrefsBase { var webTextScaling: Int @@ -51,12 +50,10 @@ interface FeedPrefs : PrefsBase { var showPostReactions: Boolean } -class FeedPrefsImpl( - factory: KPrefFactory -) : KPref("${BuildConfig.APPLICATION_ID}.prefs.feed", factory), - FeedPrefs, KoinComponent { - - private val oldPrefs: OldPrefs by inject() +class FeedPrefsImpl @Inject internal constructor( + factory: KPrefFactory, + oldPrefs: OldPrefs +) : KPref("${BuildConfig.APPLICATION_ID}.prefs.feed", factory), FeedPrefs { override var webTextScaling: Int by kpref("web_text_scaling", oldPrefs.webTextScaling /* 100 */) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/NotifPrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/NotifPrefs.kt index a9a6956f..5e34c105 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/NotifPrefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/NotifPrefs.kt @@ -21,8 +21,7 @@ import ca.allanwang.kau.kpref.KPrefFactory import com.pitchedapps.frost.BuildConfig import com.pitchedapps.frost.prefs.OldPrefs import com.pitchedapps.frost.prefs.PrefsBase -import org.koin.core.component.KoinComponent -import org.koin.core.component.inject +import javax.inject.Inject interface NotifPrefs : PrefsBase { var notificationKeywords: Set<String> @@ -48,12 +47,10 @@ interface NotifPrefs : PrefsBase { var notificationFreq: Long } -class NotifPrefsImpl( - factory: KPrefFactory -) : KPref("${BuildConfig.APPLICATION_ID}.prefs.notif", factory), - NotifPrefs, KoinComponent { - - private val oldPrefs: OldPrefs by inject() +class NotifPrefsImpl @Inject internal constructor( + factory: KPrefFactory, + oldPrefs: OldPrefs, +) : KPref("${BuildConfig.APPLICATION_ID}.prefs.notif", factory), NotifPrefs { override var notificationKeywords: Set<String> by kpref( "notification_keywords", diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ShowcasePrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ShowcasePrefs.kt index 516a14c5..dce8b898 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ShowcasePrefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ShowcasePrefs.kt @@ -20,6 +20,7 @@ import ca.allanwang.kau.kpref.KPref import ca.allanwang.kau.kpref.KPrefFactory import com.pitchedapps.frost.BuildConfig import com.pitchedapps.frost.prefs.PrefsBase +import javax.inject.Inject interface ShowcasePrefs : PrefsBase { /** @@ -35,10 +36,9 @@ interface ShowcasePrefs : PrefsBase { * * Showcase prefs that offer one time helpers to guide new users */ -class ShowcasePrefsImpl( +class ShowcasePrefsImpl @Inject internal constructor( factory: KPrefFactory -) : KPref("${BuildConfig.APPLICATION_ID}.showcase", factory), - ShowcasePrefs { +) : KPref("${BuildConfig.APPLICATION_ID}.showcase", factory), ShowcasePrefs { override val firstWebOverlay: Boolean by kprefSingle("first_web_overlay") diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt index 47496d6d..b024b2d3 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt @@ -19,11 +19,9 @@ package com.pitchedapps.frost.prefs.sections import ca.allanwang.kau.kpref.KPref import ca.allanwang.kau.kpref.KPrefFactory import com.pitchedapps.frost.BuildConfig -import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.OldPrefs import com.pitchedapps.frost.prefs.PrefsBase -import org.koin.core.component.KoinComponent -import org.koin.core.component.inject +import javax.inject.Inject interface ThemePrefs : PrefsBase { var theme: Int @@ -41,17 +39,16 @@ interface ThemePrefs : PrefsBase { var tintNavBar: Boolean } -class ThemePrefsImpl( - factory: KPrefFactory -) : KPref("${BuildConfig.APPLICATION_ID}.prefs.theme", factory), - ThemePrefs, KoinComponent { +class ThemePrefsImpl @Inject internal constructor( + factory: KPrefFactory, + oldPrefs: OldPrefs, +) : KPref("${BuildConfig.APPLICATION_ID}.prefs.theme", factory), ThemePrefs { - private val oldPrefs: OldPrefs by inject() - private val themeProvider: ThemeProvider by inject() - - override var theme: Int by kpref("theme", oldPrefs.theme /* 0 */) { - themeProvider.setTheme(it) - } + /** + * Note that this is purely for the pref storage. Updating themes should use + * ThemeProvider + */ + override var theme: Int by kpref("theme", oldPrefs.theme /* 0 */) override var customTextColor: Int by kpref( "color_text", |