feat: Schlaf-Timer, Verlauf und PC-Schlaf-Timer/-Verlauf in der Fernsteuerung (1.9.0)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-15 11:58:13 +01:00
co-authored by Claude Opus 5.5
parent 341155bc6b
commit 7f55699657
13 changed files with 691 additions and 11 deletions
@@ -143,6 +143,9 @@ class PcRemoteActivity : AppCompatActivity(), PcSession.Listener {
findViewById<ImageButton>(R.id.listBack).setOnClickListener { closeList() }
findViewById<Button>(R.id.queueButton).setOnClickListener { openList(ListMode.QUEUE) }
findViewById<Button>(R.id.playlistsButton).setOnClickListener { openList(ListMode.PLAYLISTS) }
sleepButton = findViewById(R.id.sleepButton)
sleepButton.setOnClickListener { showPcSleepDialog() }
findViewById<Button>(R.id.historyButton).setOnClickListener { showPcHistory() }
findViewById<ImageButton>(R.id.previousButton).setOnClickListener { PcSession.send("previous") }
findViewById<ImageButton>(R.id.nextButton).setOnClickListener { PcSession.send("next") }
@@ -413,6 +416,7 @@ class PcRemoteActivity : AppCompatActivity(), PcSession.Listener {
findViewById<ImageButton>(R.id.shuffleButton).imageTintList = tint(R.color.text_muted)
tabYoutube.alpha = if (state.visibleTab == "youtube") 1f else 0.45f
tabMusic.alpha = if (state.visibleTab == "music") 1f else 0.45f
renderSleep(state.sleepTimer)
if (state.thumbnail != coverUrl) loadCover(state.thumbnail)
}
@@ -469,6 +473,57 @@ class PcRemoteActivity : AppCompatActivity(), PcSession.Listener {
loadList(mode, scrollToCurrent = true)
}
// ------------------------------------------------------------------ Schlaf-Timer und Verlauf am PC
private lateinit var sleepButton: Button
private fun renderSleep(seconds: Long?) {
sleepButton.text = when (seconds) {
null -> getString(R.string.pc_sleep)
-1L -> getString(R.string.sleep_end_short)
else -> SleepTimer.format(seconds)
}
sleepButton.compoundDrawableTintList = tint(if (seconds != null) R.color.brand_to else R.color.text)
}
private fun showPcSleepDialog() {
val minutes = SleepTimer.CHOICES
val labels = minutes.map { getString(R.string.sleep_minutes, it) } +
getString(R.string.sleep_end) + getString(R.string.sleep_off)
AlertDialog.Builder(this)
.setTitle(R.string.sleep_title)
.setItems(labels.toTypedArray()) { _, which ->
val value = when {
which < minutes.size -> minutes[which]
which == minutes.size -> -1
else -> 0
}
PcSession.request("sleep_timer", { put("value", value) }) { result ->
result.onFailure { error ->
val text = if (PcRemote.isUnknownCommand(error.message)) getString(R.string.pc_too_old)
else error.message ?: error.javaClass.simpleName
android.widget.Toast.makeText(this, text, android.widget.Toast.LENGTH_LONG).show()
}
}
}
.show()
}
private fun showPcHistory() {
PcSession.request("history", { put("value", 200) }) { result ->
if (isDestroyed) return@request
result.onSuccess { reply ->
HistoryDialog.show(this, getString(R.string.history_pc_title), PlayHistory.parsePcHistory(reply), onPick = { entry ->
PcSession.request("play_video", { put("video", entry.videoId) })
})
}.onFailure { error ->
val text = if (PcRemote.isUnknownCommand(error.message)) getString(R.string.pc_too_old)
else error.message ?: error.javaClass.simpleName
android.widget.Toast.makeText(this, text, android.widget.Toast.LENGTH_LONG).show()
}
}
}
private fun closeList() {
listMode = null
listPanel.visibility = View.GONE