mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-11-06 02:40:58 +01:00
Add settings for max days in next up (#850)
## Description Add a settings to set the maximum amount of time items can appear in Next Up. Options range from 7 days to a year, or no limit (current & default behavior) ### Related issues Closes #662 ### Testing Tested on the emulator and verified URLs, added unit tests ## Screenshots N/A, just a new slider bar setting ## AI or LLM usage None
This commit is contained in:
parent
63b37ef3f4
commit
e7da5ca007
11 changed files with 208 additions and 7 deletions
|
|
@ -186,6 +186,45 @@ sealed interface AppPreference<Pref, T> {
|
|||
summarizer = { value -> value?.toString() },
|
||||
)
|
||||
|
||||
val MaxDaysNextUpOptions = listOf(7, 14, 30, 60, 90, 180, 365)
|
||||
val MaxDaysNextUp =
|
||||
AppSliderPreference<AppPreferences>(
|
||||
title = R.string.max_days_next_up,
|
||||
defaultValue = -1,
|
||||
min = 0,
|
||||
// Max is "no limit" stored as -1
|
||||
max = MaxDaysNextUpOptions.lastIndex + 1L,
|
||||
interval = 1,
|
||||
getter = {
|
||||
MaxDaysNextUpOptions
|
||||
.indexOf(it.homePagePreferences.maxDaysNextUp)
|
||||
.takeIf { it in MaxDaysNextUpOptions.indices }
|
||||
?.toLong()
|
||||
?: MaxDaysNextUpOptions.size.toLong()
|
||||
},
|
||||
setter = { prefs, index ->
|
||||
prefs.updateHomePagePreferences {
|
||||
maxDaysNextUp = MaxDaysNextUpOptions.getOrNull(index.toInt()) ?: -1
|
||||
}
|
||||
},
|
||||
summarizer = { value ->
|
||||
if (value != null) {
|
||||
val v = MaxDaysNextUpOptions.getOrNull(value.toInt()) ?: -1
|
||||
if (v == -1) {
|
||||
WholphinApplication.instance.getString(R.string.no_limit)
|
||||
} else {
|
||||
WholphinApplication.instance.resources.getQuantityString(
|
||||
R.plurals.days,
|
||||
v,
|
||||
v.toString(),
|
||||
)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
val CombineContinueNext =
|
||||
AppSwitchPreference<AppPreferences>(
|
||||
title = R.string.combine_continue_next,
|
||||
|
|
@ -956,6 +995,7 @@ val basicPreferences =
|
|||
AppPreference.HomePageItems,
|
||||
AppPreference.CombineContinueNext,
|
||||
AppPreference.RewatchNextUp,
|
||||
AppPreference.MaxDaysNextUp,
|
||||
AppPreference.PlayThemeMusic,
|
||||
AppPreference.RememberSelectedTab,
|
||||
AppPreference.SubtitleStyle,
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ class AppPreferencesSerializer
|
|||
maxItemsPerRow = AppPreference.HomePageItems.defaultValue.toInt()
|
||||
enableRewatchingNextUp = AppPreference.RewatchNextUp.defaultValue
|
||||
combineContinueNext = AppPreference.CombineContinueNext.defaultValue
|
||||
maxDaysNextUp = AppPreference.MaxDaysNextUp.defaultValue.toInt()
|
||||
}.build()
|
||||
interfacePreferences =
|
||||
InterfacePreferences
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue