mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05:26 +02:00
feat: Add confirmation modal for saving current recording
Signed-off-by: Myzel394 <50424412+Myzel394@users.noreply.github.com>
This commit is contained in:
parent
cf72b91f69
commit
a39efe8f68
@ -0,0 +1,58 @@
|
|||||||
|
package app.myzel394.alibi.ui.components.RecorderScreen.atoms
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.ModalBottomSheet
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TextButton
|
||||||
|
import androidx.compose.material3.rememberModalBottomSheetState
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import app.myzel394.alibi.R
|
||||||
|
import app.myzel394.alibi.ui.SHEET_BOTTOM_OFFSET
|
||||||
|
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
|
@Composable
|
||||||
|
fun SaveCurrentNowModal(
|
||||||
|
onDismiss: () -> Unit,
|
||||||
|
onConfirm: () -> Unit,
|
||||||
|
) {
|
||||||
|
val sheetState = rememberModalBottomSheetState(true)
|
||||||
|
|
||||||
|
// Auto save on specific events
|
||||||
|
ModalBottomSheet(
|
||||||
|
onDismissRequest = onDismiss,
|
||||||
|
sheetState = sheetState,
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.spacedBy(16.dp),
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(bottom = SHEET_BOTTOM_OFFSET)
|
||||||
|
.padding(16.dp)
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
stringResource(R.string.ui_recorder_action_saveCurrent),
|
||||||
|
style = MaterialTheme.typography.headlineMedium,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
)
|
||||||
|
|
||||||
|
Text(
|
||||||
|
stringResource(R.string.ui_recorder_action_saveCurrent_explanation),
|
||||||
|
)
|
||||||
|
|
||||||
|
TextButton(onClick = onConfirm) {
|
||||||
|
Text(stringResource(R.string.ui_recorder_action_save_label))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -24,6 +24,7 @@ import androidx.compose.ui.platform.LocalContext
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import app.myzel394.alibi.dataStore
|
import app.myzel394.alibi.dataStore
|
||||||
import app.myzel394.alibi.ui.components.RecorderScreen.atoms.RealtimeAudioVisualizer
|
import app.myzel394.alibi.ui.components.RecorderScreen.atoms.RealtimeAudioVisualizer
|
||||||
|
import app.myzel394.alibi.ui.components.RecorderScreen.atoms.SaveCurrentNowModal
|
||||||
import app.myzel394.alibi.ui.components.RecorderScreen.molecules.MicrophoneStatus
|
import app.myzel394.alibi.ui.components.RecorderScreen.molecules.MicrophoneStatus
|
||||||
import app.myzel394.alibi.ui.components.RecorderScreen.molecules.RecordingControl
|
import app.myzel394.alibi.ui.components.RecorderScreen.molecules.RecordingControl
|
||||||
import app.myzel394.alibi.ui.components.RecorderScreen.molecules.RecordingStatus
|
import app.myzel394.alibi.ui.components.RecorderScreen.molecules.RecordingStatus
|
||||||
@ -123,6 +124,25 @@ fun _PrimitiveControls(audioRecorder: AudioRecorderModel) {
|
|||||||
val dataStore = context.dataStore
|
val dataStore = context.dataStore
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
|
var showConfirmSaveNow by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
if (showConfirmSaveNow) {
|
||||||
|
SaveCurrentNowModal(
|
||||||
|
onDismiss = {
|
||||||
|
showConfirmSaveNow = false
|
||||||
|
},
|
||||||
|
onConfirm = {
|
||||||
|
showConfirmSaveNow = false
|
||||||
|
|
||||||
|
scope.launch {
|
||||||
|
audioRecorder.recorderService!!.startNewCycle()
|
||||||
|
|
||||||
|
audioRecorder.onRecordingSave(false).join()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
RecordingControl(
|
RecordingControl(
|
||||||
isPaused = audioRecorder.isPaused,
|
isPaused = audioRecorder.isPaused,
|
||||||
recordingTime = audioRecorder.recordingTime,
|
recordingTime = audioRecorder.recordingTime,
|
||||||
@ -160,11 +180,7 @@ fun _PrimitiveControls(audioRecorder: AudioRecorderModel) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSaveCurrent = {
|
onSaveCurrent = {
|
||||||
scope.launch {
|
showConfirmSaveNow = true
|
||||||
audioRecorder.recorderService!!.startNewCycle()
|
|
||||||
|
|
||||||
audioRecorder.onRecordingSave(false).join()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -191,4 +191,6 @@
|
|||||||
<string name="ui_settings_option_saveFolder_explainInternalFolder_explanation">To protect your privacy, Alibi stores its batches into its own private, encrypted storage. This storage is only accessible by Alibi and can\'t be accessed by other apps or by a possible intruder. Once you save the recording, you will be asked where you want to save the recording to.</string>
|
<string name="ui_settings_option_saveFolder_explainInternalFolder_explanation">To protect your privacy, Alibi stores its batches into its own private, encrypted storage. This storage is only accessible by Alibi and can\'t be accessed by other apps or by a possible intruder. Once you save the recording, you will be asked where you want to save the recording to.</string>
|
||||||
<string name="ui_rotateDevice_portrait_label">Please rotate your device to portait mode</string>
|
<string name="ui_rotateDevice_portrait_label">Please rotate your device to portait mode</string>
|
||||||
<string name="goBack">Back</string>
|
<string name="goBack">Back</string>
|
||||||
|
<string name="ui_recorder_action_saveCurrent">Save now?</string>
|
||||||
|
<string name="ui_recorder_action_saveCurrent_explanation">You can save the current ongoing recording by pressing and holding down on the save button. The recording will continue in the background.</string>
|
||||||
</resources>
|
</resources>
|
Loading…
x
Reference in New Issue
Block a user