Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make auto add to up next settings a UserSetting #1240

Merged
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
404cdfa
Try new settings configuration with skip forward setting
mchowning Jul 27, 2023
3adc81c
Update skipBack setting to new structure
mchowning Jul 27, 2023
659f9c1
Update name to avoid conflicts with Kotlin base types
mchowning Jul 27, 2023
0a3a05d
Update stream setting to new setting structure
mchowning Jul 27, 2023
f8465c7
Remove UserSetting syncable parameter
mchowning Jul 27, 2023
60f58bf
Create abstract class for preferences from Strings
mchowning Jul 27, 2023
f5f9b24
Update up next swipe setting to UserSetting
mchowning Jul 27, 2023
3f441e3
Reduce subclassing in UserSettings
mchowning Jul 27, 2023
ca8acee
Convert podcast grouping to be a UserSetting
mchowning Jul 27, 2023
1b5edef
Make show archived a UserSetting
mchowning Jul 27, 2023
7cd9519
Make media control items a UserSetting
mchowning Jul 28, 2023
404af8e
Make keep-screen-awake a UserSetting
mchowning Jul 28, 2023
d041dbb
Make open-player-automatically a UserSetting
mchowning Jul 28, 2023
6bc5933
Make intelligent playback resumption a UserSetting
mchowning Jul 28, 2023
8fce686
Make auto-add-up-next a UserSetting
mchowning Jul 28, 2023
6c9a13e
Avoid need to override UserSetting::set in subclasses
mchowning Jul 28, 2023
208c42b
Make custom-media-controls-visibility a UserSetting
mchowning Jul 28, 2023
f8cf288
Fix PodcastManagerTest
mchowning Jul 28, 2023
39a7399
Expose StateFlow
mchowning Jul 28, 2023
1777871
Update comment
mchowning Jul 28, 2023
7e9af3e
Update global episode notification preference to be UserSetting
mchowning Jul 28, 2023
4014b95
Make notification sounds setting a UserSetting
mchowning Jul 29, 2023
e90881f
Make notification actions a UserSetting
mchowning Jul 31, 2023
3146309
Make notification vibrate preference a UserSetting
mchowning Jul 31, 2023
e706249
Add wrapper class for notification vibrate setting
mchowning Jul 31, 2023
805cc58
Use UserSetting to persist vibration preference
mchowning Jul 31, 2023
2d0407a
Make play over notification a UserSetting
mchowning Jul 31, 2023
c97d470
Make hidePlaybackNotification a UserSetting
mchowning Jul 31, 2023
ba49926
Remove unused constants
mchowning Jul 31, 2023
ea1d391
Remove unnecessary type parameter
mchowning Jul 31, 2023
e83a4ae
Remove constant since the UI and the persistence do not have to match
mchowning Jul 31, 2023
bc14443
Merge remote-tracking branch 'origin/feature/sync-settings-refactor' …
mchowning Aug 1, 2023
bd0160b
Make theme settings into UserSettings
mchowning Aug 1, 2023
4d708a3
Improve type safety around persisting theme preferences
mchowning Aug 1, 2023
84b0b4f
Make app icon preference a UserSetting
mchowning Aug 1, 2023
b932106
Make show artwork on lock screen a UserSetting
mchowning Aug 1, 2023
9cfc808
Make use embedded podcast artwork a UserSetting
mchowning Aug 1, 2023
4c47b50
Fix tests
mchowning Aug 1, 2023
6d044f5
Make auto archive after playing a UserSetting
mchowning Aug 2, 2023
27a6d33
Make auto archive inactive a UserSetting
mchowning Aug 2, 2023
46f5b4a
Make archive starred episodes a UserSetting
mchowning Aug 2, 2023
4b39acb
Fix AutoArchiveTest
mchowning Aug 3, 2023
2767f55
Return to mocking settings in PodcastManagerTest
mchowning Aug 3, 2023
4ac0b16
Update changelog
mchowning Aug 3, 2023
0367e74
Make auto add to up next limit a UserSetting
mchowning Aug 3, 2023
9e3be4f
Make up next limit behavior a UserSetting
mchowning Aug 4, 2023
4701b9a
Merge remote-tracking branch 'origin/feature/sync-settings-refactor' …
mchowning Aug 7, 2023
37e449f
Merge remote-tracking branch 'origin/feature/sync-settings-refactor' …
mchowning Aug 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Convert podcast grouping to be a UserSetting
mchowning committed Jul 27, 2023
commit ca8acee650f767cd2cc971bdab3cb5683e8135b2
Original file line number Diff line number Diff line change
@@ -171,7 +171,7 @@ class PlaybackSettingsFragment : BaseFragment() {
)

PodcastEpisodeGrouping(
saved = settings.defaultPodcastGroupingFlow.collectAsState().value,
saved = settings.podcastGroupingDefault.flow.collectAsState().value,
onSave = {
analyticsTracker.track(
AnalyticsEvent.SETTINGS_GENERAL_EPISODE_GROUPING_CHANGED,
@@ -185,7 +185,7 @@ class PlaybackSettingsFragment : BaseFragment() {
}
)
)
settings.setDefaultPodcastGrouping(it)
settings.podcastGroupingDefault.set(it)
showSetAllGroupingDialog(it)
}
)
Original file line number Diff line number Diff line change
@@ -301,7 +301,6 @@ interface Settings {
val autoAddUpNextLimitBehaviour: Observable<AutoAddUpNextLimitBehaviour>
val autoAddUpNextLimit: Observable<Int>

val defaultPodcastGroupingFlow: StateFlow<PodcastGrouping>
val defaultMediaNotificationControlsFlow: StateFlow<List<MediaNotificationControls>>
val defaultShowArchivedFlow: StateFlow<Boolean>
val intelligentPlaybackResumptionFlow: StateFlow<Boolean>
@@ -503,8 +502,7 @@ interface Settings {
fun getPeriodicSaveTimeMs(): Long
fun getPodcastSearchDebounceMs(): Long
fun getEpisodeSearchDebounceMs(): Long
fun defaultPodcastGrouping(): PodcastGrouping
fun setDefaultPodcastGrouping(podcastGrouping: PodcastGrouping)
val podcastGroupingDefault: UserSetting<PodcastGrouping>

fun getMarketingOptIn(): Boolean
fun setMarketingOptIn(value: Boolean)
Original file line number Diff line number Diff line change
@@ -86,7 +86,6 @@ class SettingsImpl @Inject constructor(
override val autoAddUpNextLimitBehaviour = BehaviorRelay.create<Settings.AutoAddUpNextLimitBehaviour>().apply { accept(getAutoAddUpNextLimitBehaviour()) }
override val autoAddUpNextLimit = BehaviorRelay.create<Int>().apply { accept(getAutoAddUpNextLimit()) }

override val defaultPodcastGroupingFlow = MutableStateFlow(defaultPodcastGrouping())
override val defaultMediaNotificationControlsFlow = MutableStateFlow(getMediaNotificationControlItems())
override val defaultShowArchivedFlow = MutableStateFlow(defaultShowArchived())
override val keepScreenAwakeFlow = MutableStateFlow(keepScreenAwake())
@@ -1080,14 +1079,15 @@ class SettingsImpl @Inject constructor(
defaultMediaNotificationControlsFlow.update { items.mapNotNull { MediaNotificationControls.itemForId(it) } }
}

override fun defaultPodcastGrouping(): PodcastGrouping {
val index = getInt("default_podcast_grouping", 0)
return PodcastGrouping.All.getOrNull(index) ?: PodcastGrouping.None
}

override fun setDefaultPodcastGrouping(podcastGrouping: PodcastGrouping) {
setInt("default_podcast_grouping", PodcastGrouping.All.indexOf(podcastGrouping))
defaultPodcastGroupingFlow.update { podcastGrouping }
override val podcastGroupingDefault = run {
val default = PodcastGrouping.None
UserSetting.PrefFromInt<PodcastGrouping>(
sharedPrefKey = "default_podcast_grouping",
defaultValue = default,
sharedPrefs = sharedPreferences,
fromInt = { PodcastGrouping.All.getOrNull(it) ?: default },
toInt = { PodcastGrouping.All.indexOf(it) }
)
}

override fun setCloudSortOrder(sortOrder: Settings.CloudSortOrder) {
Original file line number Diff line number Diff line change
@@ -129,7 +129,7 @@ class SubscribeManager @Inject constructor(
// set subscribed to true and update the sync status
val updateObservable = podcastDao.updateSubscribedRx(subscribed = true, uuid = podcastUuid)
.andThen(podcastDao.updateSyncStatusRx(syncStatus = if (sync) Podcast.SYNC_STATUS_NOT_SYNCED else Podcast.SYNC_STATUS_SYNCED, uuid = podcastUuid))
.andThen(Completable.fromAction { podcastDao.updateGrouping(PodcastGrouping.All.indexOf(settings.defaultPodcastGrouping()), podcastUuid) })
.andThen(Completable.fromAction { podcastDao.updateGrouping(PodcastGrouping.All.indexOf(settings.podcastGroupingDefault.flow.value), podcastUuid) })
.andThen(rxCompletable { podcastDao.updateShowArchived(podcastUuid, settings.defaultShowArchived()) })
// return the final podcast
val findObservable = podcastDao.findByUuidRx(podcastUuid)
@@ -143,7 +143,7 @@ class SubscribeManager @Inject constructor(
// mark sync status
podcast.syncStatus = if (sync) Podcast.SYNC_STATUS_NOT_SYNCED else Podcast.SYNC_STATUS_SYNCED
podcast.isSubscribed = subscribed
podcast.grouping = PodcastGrouping.All.indexOf(settings.defaultPodcastGrouping())
podcast.grouping = PodcastGrouping.All.indexOf(settings.podcastGroupingDefault.flow.value)
podcast.showArchived = settings.defaultShowArchived()
}
// add the podcast