mirror of
https://github.com/Shabinder/SpotiFlyer.git
synced 2024-12-22 20:57:54 +01:00
Analytic Toggle Fixes
This commit is contained in:
parent
ab2fea910a
commit
9d445fe34b
@ -137,8 +137,9 @@ class MainActivity : ComponentActivity() {
|
||||
AnalyticsDialog(
|
||||
askForAnalyticsPermission,
|
||||
enableAnalytics = {
|
||||
// preferenceManager.toggleAnalytics(true)
|
||||
analyticsManager.giveConsent()
|
||||
preferenceManager.toggleAnalytics(true) {
|
||||
analyticsManager.giveConsent()
|
||||
}
|
||||
preferenceManager.firstLaunchDone()
|
||||
},
|
||||
dismissDialog = {
|
||||
|
@ -69,7 +69,9 @@ fun SpotiFlyerPreferenceContent(component: SpotiFlyerPreference) {
|
||||
title = "Preferred Audio Quality",
|
||||
value = model.preferredQuality.kbps + "KBPS"
|
||||
) { save ->
|
||||
val audioQualities = AudioQuality.values()
|
||||
val audioQualities = AudioQuality.values().toMutableList().apply {
|
||||
remove(AudioQuality.UNKNOWN)
|
||||
}
|
||||
|
||||
audioQualities.forEach { quality ->
|
||||
Row(
|
||||
|
@ -17,7 +17,10 @@ class PreferenceManager(
|
||||
|
||||
/* ANALYTICS */
|
||||
val isAnalyticsEnabled get() = getBooleanOrNull(ANALYTICS_KEY) ?: false
|
||||
fun toggleAnalytics(enabled: Boolean) = putBoolean(ANALYTICS_KEY, enabled)
|
||||
fun toggleAnalytics(enabled: Boolean,f: () -> Unit = {}) {
|
||||
putBoolean(ANALYTICS_KEY, enabled)
|
||||
f()
|
||||
}
|
||||
|
||||
/* DOWNLOAD DIRECTORY */
|
||||
val downloadDir get() = getStringOrNull(DIR_KEY)
|
||||
|
@ -38,7 +38,7 @@ internal class SpotiFlyerMainImpl(
|
||||
init {
|
||||
instanceKeeper.ensureNeverFrozen()
|
||||
lifecycle.doOnResume {
|
||||
store.accept(Intent.ToggleAnalytics(analyticsManager.isTracking()))
|
||||
store.accept(Intent.ToggleAnalytics(preferenceManager.isAnalyticsEnabled))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ internal class SpotiFlyerMainStoreProvider(dependencies: SpotiFlyerMain.Dependen
|
||||
|
||||
private inner class ExecutorImpl : SuspendExecutor<Intent, Unit, State, Result, Nothing>() {
|
||||
override suspend fun executeAction(action: Unit, getState: () -> State) {
|
||||
dispatch(Result.AnalyticsToggled(analyticsManager.isTracking()))
|
||||
dispatch(Result.AnalyticsToggled(preferenceManager.isAnalyticsEnabled))
|
||||
updates?.collect {
|
||||
dispatch(Result.ItemsLoaded(it))
|
||||
}
|
||||
@ -82,7 +82,9 @@ internal class SpotiFlyerMainStoreProvider(dependencies: SpotiFlyerMain.Dependen
|
||||
is Intent.SelectCategory -> dispatch(Result.CategoryChanged(intent.category))
|
||||
is Intent.ToggleAnalytics -> {
|
||||
dispatch(Result.AnalyticsToggled(intent.enabled))
|
||||
analyticsManager.giveConsent()
|
||||
preferenceManager.toggleAnalytics(intent.enabled) {
|
||||
if (intent.enabled) analyticsManager.giveConsent() else analyticsManager.revokeConsent()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ internal class SpotiFlyerPreferenceStoreProvider(
|
||||
|
||||
private inner class ExecutorImpl : SuspendExecutor<Intent, Unit, State, Result, Nothing>() {
|
||||
override suspend fun executeAction(action: Unit, getState: () -> State) {
|
||||
dispatch(Result.AnalyticsToggled(analyticsManager.isTracking()))
|
||||
dispatch(Result.AnalyticsToggled(preferenceManager.isAnalyticsEnabled))
|
||||
dispatch(Result.PreferredAudioQualityChanged(preferenceManager.audioQuality))
|
||||
dispatch(Result.DownloadPathSet(fileManager.defaultDir()))
|
||||
}
|
||||
@ -61,7 +61,9 @@ internal class SpotiFlyerPreferenceStoreProvider(
|
||||
is Intent.ShareApp -> methods.value.shareApp()
|
||||
is Intent.ToggleAnalytics -> {
|
||||
dispatch(Result.AnalyticsToggled(intent.enabled))
|
||||
preferenceManager.toggleAnalytics(intent.enabled)
|
||||
preferenceManager.toggleAnalytics(intent.enabled) {
|
||||
if (intent.enabled) analyticsManager.giveConsent() else analyticsManager.revokeConsent()
|
||||
}
|
||||
}
|
||||
is Intent.SetDownloadDirectory -> {
|
||||
dispatch(Result.DownloadPathSet(intent.path))
|
||||
|
Loading…
Reference in New Issue
Block a user