Repository navigation
feat(player): let viewers turn Next Up off #995
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
Open
Rhainland
wants to merge
21
commits into
Silo-Server:main
Choose a base branch
from
Rhainland:feat/next-up-off
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
6ad4de4
fix(player): time Up Next from the end of the file, not the credits m…
Rhainland 445ca87
fix(tv): keep returning the series page to the next episode from the …
Rhainland 9a0ef16
feat(player): let viewers turn Next Up off
Rhainland fa22e02
fix(settings): make a Show Next Up time this device's whole choice
Rhainland 4c481a2
fix(tv): leave a hand-opened Up Next without a countdown at the promp…
Quick104 c693acd
Merge branch 'review/fix-994' into review/fix-995
Quick104 85cf2c3
fix(player): keep a Show Next Up time and the final position when Off…
Quick104 f6fdb38
Merge branch 'main' into feat/next-up-off
Quick104 de577ed
fix(player): arm no Up Next once Next Up is off while the next episod…
Quick104 966f8d8
Merge main into feat/next-up-off
Quick104 635f5ec
chore(settings): re-vendor the settings contract from silo-server#450…
Quick104 3927ac8
fix(settings): drop the Next Up override marker a server without the …
Quick104 b48f48b
fix(player): honor Next Up Off in picture-in-picture and on a running…
Quick104 41e4931
fix(player): leave the player when the last thing holding it open aft…
Quick104 31647af
fix(player): close when Next Up turns off while the end screen waits …
Quick104 33ac5cb
fix(player): close when Next Up turns off while an automatic end card…
Quick104 67d1743
fix(player): clear an automatic Up Next card when Next Up turns off b…
Quick104 3bea593
fix(player): judge the end of playback by position as well as the end…
Quick104 7b762e7
fix(player): keep resumed playback open when Next Up turns off after …
Quick104 bb46caf
fix(player): forget the end when the system media controls seek away …
Quick104 9f9d2ae
test(tv): cover Next Up Off while the next-episode lookup waits
Quick104 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/settings/NextUpChoice.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package org.siloserver.silo.common.settings | ||
|
|
||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.res.pluralStringResource | ||
| import androidx.compose.ui.res.stringResource | ||
| import org.siloserver.silo.common.R | ||
|
|
||
| /** | ||
| * The Show Next Up picker: one control over `playback.next_up_enabled` and | ||
| * `playback.next_up_prompt_seconds`. A choice is the seconds before the end | ||
| * (0 = at end), or null for Off. | ||
| */ | ||
| object NextUpChoice { | ||
| private val promptSeconds: List<Int?> = listOf(0, 10, 30, 60, 120) | ||
|
|
||
| /** | ||
| * Off comes first while the server stores the setting, and while this | ||
| * device's last choice is Off and the server's manifest is not read yet, | ||
| * so that choice stays visible and can be changed. | ||
| */ | ||
| fun options(offSupported: Boolean, enabled: Boolean): List<Int?> = | ||
| if (offSupported || !enabled) listOf(null) + promptSeconds else promptSeconds | ||
|
|
||
| fun selected(enabled: Boolean, seconds: Int): Int? = if (enabled) seconds.coerceAtLeast(0) else null | ||
|
|
||
| /** | ||
| * Off leaves the seconds alone. A time writes both keys, so the picker's | ||
| * choice is this device's whole choice: one inherited half would follow a | ||
| * later profile change to Off, including one the server reports only after | ||
| * its manifest is read. The flusher holds the key while the manifest is | ||
| * unknown and drops it for a server that lacks it, so that server is never | ||
| * sent it. | ||
| */ | ||
| suspend fun apply(store: PlayerSettingsStore, choice: Int?) { | ||
| if (choice == null) { | ||
| store.setNextUpEnabled(false) | ||
| return | ||
| } | ||
| store.setNextUpEnabled(true) | ||
| store.setNextUpPromptSeconds(choice) | ||
| } | ||
| } | ||
|
|
||
| /** The phone and TV label for a [NextUpChoice] choice. */ | ||
| @Composable | ||
| fun nextUpChoiceLabel(choice: Int?): String = when { | ||
| choice == null -> stringResource(R.string.settings_off) | ||
| choice <= 0 -> stringResource(R.string.settings_nextUp_atEnd) | ||
| choice < 60 -> pluralStringResource(R.plurals.settings_nextUp_secondsBeforeEnd, choice, choice) | ||
| else -> (choice / 60).let { pluralStringResource(R.plurals.settings_nextUp_minutesBeforeEnd, it, it) } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/settings/NextUpChoiceTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package org.siloserver.silo.common.settings | ||
|
|
||
| import java.lang.reflect.Proxy | ||
| import kotlinx.coroutines.test.runTest | ||
| import kotlin.test.Test | ||
| import kotlin.test.assertEquals | ||
|
|
||
| class NextUpChoiceTest { | ||
| @Test | ||
| fun offIsOfferedWhereTheServerStoresItAndWhileASavedOffAwaitsTheManifest() { | ||
| val times = listOf(0, 10, 30, 60, 120) | ||
| assertEquals(listOf<Int?>(null) + times, NextUpChoice.options(offSupported = true, enabled = true)) | ||
| assertEquals(times, NextUpChoice.options(offSupported = false, enabled = true)) | ||
| // A saved Off before the manifest is read stays visible and selected. | ||
| assertEquals(listOf<Int?>(null) + times, NextUpChoice.options(offSupported = false, enabled = false)) | ||
| assertEquals(null, NextUpChoice.selected(enabled = false, seconds = 30)) | ||
| } | ||
|
|
||
| @Test | ||
| fun aTimeIsAChoiceOfBothKeys() = runTest { | ||
| // On already (inherited from the profile, or not yet known from the | ||
| // manifest): the time still writes On, so this device's choice survives | ||
| // the profile turning Next Up off later. | ||
| assertEquals(listOf("enabled=true", "seconds=10"), writes(10)) | ||
| assertEquals(listOf("enabled=true", "seconds=0"), writes(0)) | ||
| assertEquals(listOf("enabled=false"), writes(null)) | ||
| } | ||
|
|
||
| private suspend fun writes(choice: Int?): List<String> { | ||
| val calls = mutableListOf<String>() | ||
| val unused = Proxy.newProxyInstance( | ||
| PlayerSettingsStore::class.java.classLoader, | ||
| arrayOf(PlayerSettingsStore::class.java), | ||
| ) { _, method, _ -> throw UnsupportedOperationException(method.name) } as PlayerSettingsStore | ||
| val store = object : PlayerSettingsStore by unused { | ||
| override suspend fun setNextUpEnabled(value: Boolean) { calls += "enabled=$value" } | ||
| override suspend fun setNextUpPromptSeconds(value: Int) { calls += "seconds=$value" } | ||
| } | ||
| NextUpChoice.apply(store, choice) | ||
| return calls | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.