Android: Test button beside the sound pack picker

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-05 20:44:43 +00:00
co-authored by Claude Opus 5.5
parent 380ea5acd6
commit 2619d9ff3d
2 changed files with 14 additions and 3 deletions
@@ -5,6 +5,7 @@ import eu.lixko.ts3j.client.android.audio.AndroidAudioBackend
import eu.lixko.ts3j.client.android.audio.AudioRoute import eu.lixko.ts3j.client.android.audio.AudioRoute
import eu.lixko.ts3j.client.audio.AudioDevice import eu.lixko.ts3j.client.audio.AudioDevice
import eu.lixko.ts3j.client.config.Settings import eu.lixko.ts3j.client.config.Settings
import eu.lixko.ts3j.client.sound.SoundEvent
import eu.lixko.ts3j.client.sound.SoundNotifier import eu.lixko.ts3j.client.sound.SoundNotifier
import eu.lixko.ts3j.client.sound.SoundPack import eu.lixko.ts3j.client.sound.SoundPack
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
@@ -53,6 +54,8 @@ class AudioSetup internal constructor(private val context: Context, private val
settings.save() settings.save()
} }
fun playTestSound() = sounds.preview(SoundEvent.SPECIAL_SOUND_TEST)
/** Unpacks the packs the app ships with, when this version has not yet. */ /** Unpacks the packs the app ships with, when this version has not yet. */
fun installSoundPacks() { fun installSoundPacks() {
if (!SoundPackInstaller(context).install()) return if (!SoundPackInstaller(context).install()) return
@@ -7,6 +7,7 @@ import android.provider.Settings.canDrawOverlays
import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.Canvas import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
@@ -16,12 +17,14 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.CornerRadius import androidx.compose.ui.geometry.CornerRadius
import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Offset
@@ -156,11 +159,16 @@ fun SoundSettingsScreen(settings: Settings, sessions: SessionController, audio:
if (packs.isEmpty()) { if (packs.isEmpty()) {
Hint("This build of the app came without sound packs.") Hint("This build of the app came without sound packs.")
} else { } else {
Row(verticalAlignment = Alignment.CenterVertically) {
Box(Modifier.weight(1f)) {
Picker("Sound pack", packs.map { it.id() to it.name() }, pack) { id -> Picker("Sound pack", packs.map { it.id() to it.name() }, pack) { id ->
packs.firstOrNull { it.id() == id }?.let(audio::setSoundPack) packs.firstOrNull { it.id() == id }?.let(audio::setSoundPack)
pack = id pack = id
} }
} }
TextButton(audio::playTestSound, Modifier.padding(end = 8.dp)) { Text("Test") }
}
}
Level("Volume", settings.soundVolume.get().toFloat(), 0f..1f, { "${(it * 100).roundToInt()} %" }) { Level("Volume", settings.soundVolume.get().toFloat(), 0f..1f, { "${(it * 100).roundToInt()} %" }) {
change(settings.soundVolume, it.toDouble()) change(settings.soundVolume, it.toDouble())
} }