aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/prefs
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2021-04-17 17:49:18 -0700
committerAllan Wang <me@allanwang.ca>2021-04-17 17:49:18 -0700
commitd96d1d06a7c1581b97c042f2a74e7cd5b1c2546e (patch)
tree60ad049189d448132d1b99ea041a8f80a83ffe22 /app/src/main/kotlin/com/pitchedapps/frost/prefs
parentcb2adc75d8e105adfdf0d5646c1a9b6d39c292f8 (diff)
downloadfrost-d96d1d06a7c1581b97c042f2a74e7cd5b1c2546e.tar.gz
frost-d96d1d06a7c1581b97c042f2a74e7cd5b1c2546e.tar.bz2
frost-d96d1d06a7c1581b97c042f2a74e7cd5b1c2546e.zip
Update theme providers and readd koin modules
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/prefs')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/prefs/OldPrefs.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt16
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/BehaviourPrefs.kt10
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/CorePrefs.kt10
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/FeedPrefs.kt10
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/NotifPrefs.kt10
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ShowcasePrefs.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt22
8 files changed, 33 insertions, 52 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/OldPrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/OldPrefs.kt
index 1abed8fb..cfd8edbd 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/OldPrefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/OldPrefs.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.enums.FeedSort
+import javax.inject.Inject
/**
* Created by Allan Wang on 2017-05-28.
@@ -29,7 +30,8 @@ import com.pitchedapps.frost.enums.FeedSort
* As of 2020-07-18, prefs have been split up into multiple folders
*/
@Deprecated(level = DeprecationLevel.WARNING, message = "Use pref segments")
-class OldPrefs(factory: KPrefFactory) : KPref("${BuildConfig.APPLICATION_ID}.prefs", factory) {
+class OldPrefs @Inject internal constructor(factory: KPrefFactory) :
+ KPref("${BuildConfig.APPLICATION_ID}.prefs", factory) {
var lastLaunch: Long by kpref("last_launch", -1L)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt
index 56a7cf9d..b76b8ead 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt
@@ -37,10 +37,10 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
-import javax.inject.Inject
-import javax.inject.Singleton
import org.koin.core.context.GlobalContext
import org.koin.dsl.module
+import javax.inject.Inject
+import javax.inject.Singleton
/**
* [Prefs] is no longer an actual pref, but we will expose the reset function as it is used elsewhere
@@ -62,12 +62,12 @@ interface Prefs :
fun get(): Prefs = GlobalContext.get().get()
fun module() = module {
- single<BehaviourPrefs> { BehaviourPrefsImpl(factory = get()) }
- single<CorePrefs> { CorePrefsImpl(factory = get()) }
- single<FeedPrefs> { FeedPrefsImpl(factory = get()) }
- single<NotifPrefs> { NotifPrefsImpl(factory = get()) }
- single<ThemePrefs> { ThemePrefsImpl(factory = get()) }
- single<ShowcasePrefs> { ShowcasePrefsImpl(factory = get()) }
+ single<BehaviourPrefs> { BehaviourPrefsImpl(get(), get()) }
+ single<CorePrefs> { CorePrefsImpl(get(), get()) }
+ single<FeedPrefs> { FeedPrefsImpl(get(), get()) }
+ single<NotifPrefs> { NotifPrefsImpl(get(), get()) }
+ single<ThemePrefs> { ThemePrefsImpl(get(), get()) }
+ single<ShowcasePrefs> { ShowcasePrefsImpl(get()) }
single<Prefs> {
PrefsImpl(
behaviourPrefs = get(),
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 aa40c0d2..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
@@ -22,8 +22,6 @@ import com.pitchedapps.frost.BuildConfig
import com.pitchedapps.frost.prefs.OldPrefs
import com.pitchedapps.frost.prefs.PrefsBase
import javax.inject.Inject
-import org.koin.core.component.KoinComponent
-import org.koin.core.component.inject
interface BehaviourPrefs : PrefsBase {
var biometricsEnabled: Boolean
@@ -52,11 +50,9 @@ interface BehaviourPrefs : PrefsBase {
}
class BehaviourPrefsImpl @Inject internal constructor(
- factory: KPrefFactory
-) : KPref("${BuildConfig.APPLICATION_ID}.prefs.behaviour", factory),
- BehaviourPrefs, KoinComponent {
-
- private val oldPrefs: OldPrefs by inject()
+ 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 13fa5729..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
@@ -22,8 +22,6 @@ import com.pitchedapps.frost.BuildConfig
import com.pitchedapps.frost.prefs.OldPrefs
import com.pitchedapps.frost.prefs.PrefsBase
import javax.inject.Inject
-import org.koin.core.component.KoinComponent
-import org.koin.core.component.inject
interface CorePrefs : PrefsBase {
var lastLaunch: Long
@@ -58,11 +56,9 @@ interface CorePrefs : PrefsBase {
}
class CorePrefsImpl @Inject internal constructor(
- factory: KPrefFactory
-) : KPref("${BuildConfig.APPLICATION_ID}.prefs.core", factory),
- CorePrefs, KoinComponent {
-
- private val oldPrefs: OldPrefs by inject()
+ 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 17e3bfac..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
@@ -23,8 +23,6 @@ import com.pitchedapps.frost.enums.MainActivityLayout
import com.pitchedapps.frost.prefs.OldPrefs
import com.pitchedapps.frost.prefs.PrefsBase
import javax.inject.Inject
-import org.koin.core.component.KoinComponent
-import org.koin.core.component.inject
interface FeedPrefs : PrefsBase {
var webTextScaling: Int
@@ -53,11 +51,9 @@ interface FeedPrefs : PrefsBase {
}
class FeedPrefsImpl @Inject internal constructor(
- factory: KPrefFactory
-) : KPref("${BuildConfig.APPLICATION_ID}.prefs.feed", factory),
- FeedPrefs, KoinComponent {
-
- private val oldPrefs: OldPrefs by inject()
+ 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 c33cd92e..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
@@ -22,8 +22,6 @@ import com.pitchedapps.frost.BuildConfig
import com.pitchedapps.frost.prefs.OldPrefs
import com.pitchedapps.frost.prefs.PrefsBase
import javax.inject.Inject
-import org.koin.core.component.KoinComponent
-import org.koin.core.component.inject
interface NotifPrefs : PrefsBase {
var notificationKeywords: Set<String>
@@ -50,11 +48,9 @@ interface NotifPrefs : PrefsBase {
}
class NotifPrefsImpl @Inject internal constructor(
- factory: KPrefFactory
-) : KPref("${BuildConfig.APPLICATION_ID}.prefs.notif", factory),
- NotifPrefs, KoinComponent {
-
- private val oldPrefs: OldPrefs by inject()
+ 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 d8a51e32..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
@@ -38,8 +38,7 @@ interface ShowcasePrefs : PrefsBase {
*/
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 126c3654..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,12 +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 javax.inject.Inject
-import org.koin.core.component.KoinComponent
-import org.koin.core.component.inject
interface ThemePrefs : PrefsBase {
var theme: Int
@@ -43,16 +40,15 @@ interface ThemePrefs : PrefsBase {
}
class ThemePrefsImpl @Inject internal constructor(
- factory: KPrefFactory
-) : KPref("${BuildConfig.APPLICATION_ID}.prefs.theme", factory),
- ThemePrefs, KoinComponent {
-
- 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)
- }
+ factory: KPrefFactory,
+ oldPrefs: OldPrefs,
+) : KPref("${BuildConfig.APPLICATION_ID}.prefs.theme", factory), ThemePrefs {
+
+ /**
+ * 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",