mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05:26 +02:00
Merge pull request #43 from Myzel394/delete-recordings-immediately-and-fix-dir
Delete recordings immediately and fix dir
This commit is contained in:
commit
66a54d8adf
@ -1,4 +1,4 @@
|
||||
name: Build and publish app
|
||||
name: Build and publish app to Google Play
|
||||
|
||||
on:
|
||||
release:
|
||||
|
@ -1,110 +0,0 @@
|
||||
package app.myzel394.alibi.ui.components.AudioRecorder.atoms
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Memory
|
||||
import androidx.compose.material.icons.filled.Save
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.unit.dp
|
||||
import app.myzel394.alibi.R
|
||||
import app.myzel394.alibi.services.RecorderService
|
||||
import app.myzel394.alibi.ui.BIG_PRIMARY_BUTTON_SIZE
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
|
||||
@Composable
|
||||
fun SaveRecordingButton(
|
||||
modifier: Modifier = Modifier,
|
||||
service: RecorderService,
|
||||
onSaveFile: (File) -> Unit,
|
||||
label: String = stringResource(R.string.ui_audioRecorder_action_save_label),
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
var isProcessingAudio by remember { mutableStateOf(false) }
|
||||
|
||||
if (isProcessingAudio)
|
||||
AlertDialog(
|
||||
onDismissRequest = { },
|
||||
icon = {
|
||||
Icon(
|
||||
Icons.Default.Memory,
|
||||
contentDescription = null,
|
||||
)
|
||||
},
|
||||
title = {
|
||||
Text(
|
||||
stringResource(R.string.ui_audioRecorder_action_save_processing_dialog_title),
|
||||
)
|
||||
},
|
||||
text = {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Text(
|
||||
stringResource(R.string.ui_audioRecorder_action_save_processing_dialog_description),
|
||||
)
|
||||
Spacer(modifier = Modifier.height(32.dp))
|
||||
LinearProgressIndicator()
|
||||
}
|
||||
},
|
||||
confirmButton = {}
|
||||
)
|
||||
Button(
|
||||
modifier = Modifier
|
||||
.padding(16.dp)
|
||||
.fillMaxWidth()
|
||||
.height(BIG_PRIMARY_BUTTON_SIZE)
|
||||
.semantics {
|
||||
contentDescription = label
|
||||
}
|
||||
.then(modifier),
|
||||
onClick = {
|
||||
isProcessingAudio = true
|
||||
|
||||
scope.launch {
|
||||
try {
|
||||
} catch (error: Exception) {
|
||||
Log.getStackTraceString(error)
|
||||
} finally {
|
||||
isProcessingAudio = false
|
||||
}
|
||||
}
|
||||
},
|
||||
) {
|
||||
Icon(
|
||||
Icons.Default.Save,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(ButtonDefaults.IconSize),
|
||||
)
|
||||
Spacer(modifier = Modifier.width(ButtonDefaults.IconSpacing))
|
||||
Text(label)
|
||||
}
|
||||
}
|
@ -36,14 +36,12 @@ import kotlinx.coroutines.launch
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun BitrateTile() {
|
||||
fun BitrateTile(
|
||||
settings: AppSettings,
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val showDialog = rememberUseCaseState()
|
||||
val dataStore = LocalContext.current.dataStore
|
||||
val settings = dataStore
|
||||
.data
|
||||
.collectAsState(initial = AppSettings.getDefaultInstance())
|
||||
.value
|
||||
|
||||
fun updateValue(bitRate: Int) {
|
||||
scope.launch {
|
||||
|
@ -22,12 +22,9 @@ import app.myzel394.alibi.ui.enums.Screen
|
||||
@Composable
|
||||
fun CustomNotificationTile(
|
||||
navController: NavController,
|
||||
settings: AppSettings,
|
||||
) {
|
||||
val dataStore = LocalContext.current.dataStore
|
||||
val settings = dataStore
|
||||
.data
|
||||
.collectAsState(initial = AppSettings.getDefaultInstance())
|
||||
.value
|
||||
|
||||
val label = if (settings.notificationSettings == null)
|
||||
stringResource(R.string.ui_settings_option_customNotification_description_setup)
|
||||
|
@ -16,14 +16,12 @@ import app.myzel394.alibi.ui.components.atoms.SettingsTile
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@Composable
|
||||
fun DeleteRecordingsImmediatelyTile() {
|
||||
fun DeleteRecordingsImmediatelyTile(
|
||||
settings: AppSettings,
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
val dataStore = LocalContext.current.dataStore
|
||||
val settings = dataStore
|
||||
.data
|
||||
.collectAsState(initial = AppSettings.getDefaultInstance())
|
||||
.value
|
||||
|
||||
SettingsTile(
|
||||
title = stringResource(R.string.ui_settings_option_deleteRecordingsImmediately_title),
|
||||
|
@ -2,7 +2,6 @@ package app.myzel394.alibi.ui.components.SettingsScreen.atoms
|
||||
|
||||
import android.media.MediaRecorder
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.AudioFile
|
||||
import androidx.compose.material.icons.filled.Memory
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
@ -35,17 +34,15 @@ import kotlinx.coroutines.launch
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun EncoderTile(
|
||||
snackbarHostState: SnackbarHostState
|
||||
snackbarHostState: SnackbarHostState,
|
||||
settings: AppSettings,
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val showDialog = rememberUseCaseState()
|
||||
val dataStore = LocalContext.current.dataStore
|
||||
val settings = dataStore
|
||||
.data
|
||||
.collectAsState(initial = AppSettings.getDefaultInstance())
|
||||
.value
|
||||
|
||||
val updatedOutputFormatLabel = stringResource(R.string.ui_settings_option_encoder_extra_outputFormatChanged)
|
||||
val updatedOutputFormatLabel =
|
||||
stringResource(R.string.ui_settings_option_encoder_extra_outputFormatChanged)
|
||||
|
||||
fun updateValue(encoder: Int?) {
|
||||
scope.launch {
|
||||
@ -92,7 +89,7 @@ fun EncoderTile(
|
||||
selected = settings.audioRecorderSettings.encoder == index,
|
||||
)
|
||||
}.toList()
|
||||
) {index, option ->
|
||||
) { index, _ ->
|
||||
updateValue(index)
|
||||
},
|
||||
)
|
||||
|
@ -18,14 +18,11 @@ import kotlinx.coroutines.launch
|
||||
|
||||
|
||||
@Composable
|
||||
fun ForceExactMaxDurationTile() {
|
||||
fun ForceExactMaxDurationTile(
|
||||
settings: AppSettings,
|
||||
) {
|
||||
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 {
|
||||
|
@ -24,6 +24,7 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.core.os.LocaleListCompat
|
||||
import app.myzel394.alibi.R
|
||||
import app.myzel394.alibi.SUPPORTED_LOCALES
|
||||
import app.myzel394.alibi.db.AppSettings
|
||||
import app.myzel394.alibi.db.AudioRecorderSettings
|
||||
import app.myzel394.alibi.ui.components.atoms.SettingsTile
|
||||
import app.myzel394.alibi.ui.utils.IconResource
|
||||
|
@ -34,14 +34,12 @@ import kotlinx.coroutines.launch
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun IntervalDurationTile() {
|
||||
fun IntervalDurationTile(
|
||||
settings: AppSettings,
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val showDialog = rememberUseCaseState()
|
||||
val dataStore = LocalContext.current.dataStore
|
||||
val settings = dataStore
|
||||
.data
|
||||
.collectAsState(initial = AppSettings.getDefaultInstance())
|
||||
.value
|
||||
|
||||
fun updateValue(intervalDuration: Long) {
|
||||
scope.launch {
|
||||
|
@ -33,14 +33,12 @@ import kotlinx.coroutines.launch
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun MaxDurationTile() {
|
||||
fun MaxDurationTile(
|
||||
settings: AppSettings,
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val showDialog = rememberUseCaseState()
|
||||
val dataStore = LocalContext.current.dataStore
|
||||
val settings = dataStore
|
||||
.data
|
||||
.collectAsState(initial = AppSettings.getDefaultInstance())
|
||||
.value
|
||||
|
||||
fun updateValue(maxDuration: Long) {
|
||||
scope.launch {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package app.myzel394.alibi.ui.components.SettingsScreen.atoms
|
||||
|
||||
import android.media.MediaRecorder
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.AudioFile
|
||||
import androidx.compose.material3.Button
|
||||
@ -8,13 +7,8 @@ import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.SnackbarDuration
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.SnackbarVisuals
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
@ -35,14 +29,12 @@ import kotlinx.coroutines.launch
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun OutputFormatTile() {
|
||||
fun OutputFormatTile(
|
||||
settings: AppSettings,
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val showDialog = rememberUseCaseState()
|
||||
val dataStore = LocalContext.current.dataStore
|
||||
val settings = dataStore
|
||||
.data
|
||||
.collectAsState(initial = AppSettings.getDefaultInstance())
|
||||
.value
|
||||
val availableOptions = if (settings.audioRecorderSettings.encoder == null)
|
||||
AudioRecorderSettings.OUTPUT_FORMAT_INDEX_TEXT_MAP.keys.toTypedArray()
|
||||
else AudioRecorderSettings.ENCODER_SUPPORTED_OUTPUT_FORMATS_MAP[settings.audioRecorderSettings.encoder]!!
|
||||
@ -74,7 +66,7 @@ fun OutputFormatTile() {
|
||||
selected = settings.audioRecorderSettings.outputFormat == option,
|
||||
)
|
||||
}.toList()
|
||||
) {index, option ->
|
||||
) { index, _ ->
|
||||
updateValue(availableOptions[index])
|
||||
},
|
||||
)
|
||||
|
@ -36,14 +36,12 @@ import kotlinx.coroutines.launch
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun SamplingRateTile() {
|
||||
fun SamplingRateTile(
|
||||
settings: AppSettings,
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val showDialog = rememberUseCaseState()
|
||||
val dataStore = LocalContext.current.dataStore
|
||||
val settings = dataStore
|
||||
.data
|
||||
.collectAsState(initial = AppSettings.getDefaultInstance())
|
||||
.value
|
||||
|
||||
fun updateValue(samplingRate: Int?) {
|
||||
scope.launch {
|
||||
|
@ -19,13 +19,11 @@ import kotlinx.coroutines.launch
|
||||
|
||||
|
||||
@Composable
|
||||
fun ShowAllMicrophonesTile() {
|
||||
fun ShowAllMicrophonesTile(
|
||||
settings: AppSettings,
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val dataStore = LocalContext.current.dataStore
|
||||
val settings = dataStore
|
||||
.data
|
||||
.collectAsState(initial = AppSettings.getDefaultInstance())
|
||||
.value
|
||||
|
||||
fun updateValue(showAllMicrophones: Boolean) {
|
||||
scope.launch {
|
||||
|
@ -56,6 +56,7 @@ import app.myzel394.alibi.ui.components.SettingsScreen.atoms.ThemeSelector
|
||||
import app.myzel394.alibi.ui.components.atoms.GlobalSwitch
|
||||
import app.myzel394.alibi.ui.components.atoms.MessageBox
|
||||
import app.myzel394.alibi.ui.components.atoms.MessageType
|
||||
import app.myzel394.alibi.ui.effects.rememberSettings
|
||||
import app.myzel394.alibi.ui.models.AudioRecorderModel
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@ -114,10 +115,7 @@ fun SettingsScreen(
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val dataStore = LocalContext.current.dataStore
|
||||
val settings = dataStore
|
||||
.data
|
||||
.collectAsState(initial = AppSettings.getDefaultInstance())
|
||||
.value
|
||||
val settings = rememberSettings()
|
||||
|
||||
// Show alert
|
||||
if (audioRecorder.isInRecording)
|
||||
@ -145,12 +143,12 @@ fun SettingsScreen(
|
||||
}
|
||||
}
|
||||
)
|
||||
MaxDurationTile()
|
||||
IntervalDurationTile()
|
||||
ForceExactMaxDurationTile()
|
||||
MaxDurationTile(settings = settings)
|
||||
IntervalDurationTile(settings = settings)
|
||||
ForceExactMaxDurationTile(settings = settings)
|
||||
InAppLanguagePicker()
|
||||
DeleteRecordingsImmediatelyTile()
|
||||
CustomNotificationTile(navController = navController)
|
||||
DeleteRecordingsImmediatelyTile(settings = settings)
|
||||
CustomNotificationTile(navController = navController, settings = settings)
|
||||
AboutTile(navController = navController)
|
||||
AnimatedVisibility(visible = settings.showAdvancedSettings) {
|
||||
Column(
|
||||
@ -163,11 +161,11 @@ fun SettingsScreen(
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 32.dp)
|
||||
)
|
||||
ShowAllMicrophonesTile()
|
||||
BitrateTile()
|
||||
SamplingRateTile()
|
||||
EncoderTile(snackbarHostState = snackbarHostState)
|
||||
OutputFormatTile()
|
||||
ShowAllMicrophonesTile(settings = settings)
|
||||
BitrateTile(settings = settings)
|
||||
SamplingRateTile(settings = settings)
|
||||
EncoderTile(snackbarHostState = snackbarHostState, settings = settings)
|
||||
OutputFormatTile(settings = settings)
|
||||
}
|
||||
Divider(
|
||||
modifier = Modifier
|
||||
|
Loading…
x
Reference in New Issue
Block a user