mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-19 07:15:25 +02:00
feat: Add forceExactMaxDuration option to AppSettings
This commit is contained in:
parent
5620ff9625
commit
07494cba98
@ -35,6 +35,7 @@ data class AudioRecorderSettings(
|
|||||||
val maxDuration: Long = 30 * 60 * 1000L,
|
val maxDuration: Long = 30 * 60 * 1000L,
|
||||||
// 60 seconds
|
// 60 seconds
|
||||||
val intervalDuration: Long = 60 * 1000L,
|
val intervalDuration: Long = 60 * 1000L,
|
||||||
|
val forceExactMaxDuration: Boolean = true,
|
||||||
// 320 Kbps
|
// 320 Kbps
|
||||||
val bitRate: Int = 320000,
|
val bitRate: Int = 320000,
|
||||||
val samplingRate: Int? = null,
|
val samplingRate: Int? = null,
|
||||||
@ -122,6 +123,10 @@ data class AudioRecorderSettings(
|
|||||||
return copy(maxDuration = duration)
|
return copy(maxDuration = duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setForceExactMaxDuration(forceExactMaxDuration: Boolean): AudioRecorderSettings {
|
||||||
|
return copy(forceExactMaxDuration = forceExactMaxDuration)
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun getDefaultInstance(): AudioRecorderSettings = AudioRecorderSettings()
|
fun getDefaultInstance(): AudioRecorderSettings = AudioRecorderSettings()
|
||||||
val EXAMPLE_MAX_DURATIONS = listOf(
|
val EXAMPLE_MAX_DURATIONS = listOf(
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
package app.myzel394.locationtest.ui.components.SettingsScreen.atoms
|
||||||
|
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.GraphicEq
|
||||||
|
import androidx.compose.material.icons.filled.Memory
|
||||||
|
import androidx.compose.material3.ButtonDefaults
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Switch
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.collectAsState
|
||||||
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import app.myzel394.locationtest.dataStore
|
||||||
|
import app.myzel394.locationtest.db.AppSettings
|
||||||
|
import app.myzel394.locationtest.db.AudioRecorderSettings
|
||||||
|
import app.myzel394.locationtest.ui.components.atoms.ExampleListRoulette
|
||||||
|
import app.myzel394.locationtest.ui.components.atoms.SettingsTile
|
||||||
|
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ForceExactMaxDurationTile() {
|
||||||
|
val scope = rememberCoroutineScope()
|
||||||
|
val showDialog = rememberUseCaseState()
|
||||||
|
val dataStore = LocalContext.current.dataStore
|
||||||
|
val settings = dataStore
|
||||||
|
.data
|
||||||
|
.collectAsState(initial = AppSettings.getDefaultInstance())
|
||||||
|
.value
|
||||||
|
|
||||||
|
fun updateValue(forceExactMaxDuration: Boolean) {
|
||||||
|
scope.launch {
|
||||||
|
dataStore.updateData {
|
||||||
|
it.setAudioRecorderSettings(
|
||||||
|
it.audioRecorderSettings.setForceExactMaxDuration(forceExactMaxDuration)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SettingsTile(
|
||||||
|
title = "Force exact duration",
|
||||||
|
description = "Force to strip the output file to be the exactly specified duration. If this is disabled, the output file may be a bit longer due to batches of audio samples being encoded together.",
|
||||||
|
leading = {
|
||||||
|
Icon(
|
||||||
|
Icons.Default.GraphicEq,
|
||||||
|
contentDescription = null,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
trailing = {
|
||||||
|
Switch(
|
||||||
|
checked = settings.audioRecorderSettings.forceExactMaxDuration,
|
||||||
|
onCheckedChange = ::updateValue,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
@ -40,6 +40,7 @@ import app.myzel394.locationtest.db.AppSettings
|
|||||||
import app.myzel394.locationtest.db.AudioRecorderSettings
|
import app.myzel394.locationtest.db.AudioRecorderSettings
|
||||||
import app.myzel394.locationtest.ui.components.SettingsScreen.atoms.BitrateTile
|
import app.myzel394.locationtest.ui.components.SettingsScreen.atoms.BitrateTile
|
||||||
import app.myzel394.locationtest.ui.components.SettingsScreen.atoms.EncoderTile
|
import app.myzel394.locationtest.ui.components.SettingsScreen.atoms.EncoderTile
|
||||||
|
import app.myzel394.locationtest.ui.components.SettingsScreen.atoms.ForceExactMaxDurationTile
|
||||||
import app.myzel394.locationtest.ui.components.SettingsScreen.atoms.IntervalDurationTile
|
import app.myzel394.locationtest.ui.components.SettingsScreen.atoms.IntervalDurationTile
|
||||||
import app.myzel394.locationtest.ui.components.SettingsScreen.atoms.MaxDurationTile
|
import app.myzel394.locationtest.ui.components.SettingsScreen.atoms.MaxDurationTile
|
||||||
import app.myzel394.locationtest.ui.components.SettingsScreen.atoms.OutputFormatTile
|
import app.myzel394.locationtest.ui.components.SettingsScreen.atoms.OutputFormatTile
|
||||||
@ -110,6 +111,7 @@ fun SettingsScreen(
|
|||||||
)
|
)
|
||||||
MaxDurationTile()
|
MaxDurationTile()
|
||||||
IntervalDurationTile()
|
IntervalDurationTile()
|
||||||
|
ForceExactMaxDurationTile()
|
||||||
AnimatedVisibility(visible = settings.showAdvancedSettings) {
|
AnimatedVisibility(visible = settings.showAdvancedSettings) {
|
||||||
Column {
|
Column {
|
||||||
Divider(
|
Divider(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user