From 1fe99b2aa6e35f5c9eff4ce5b9cb1ccf1c2c022d Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Fri, 23 Feb 2024 21:30:44 +0100 Subject: [PATCH] feat: Add explanation to internal storage Signed-off-by: Myzel394 <50424412+Myzel394@users.noreply.github.com> --- .../SettingsScreen/Tiles/SaveFolderTile.kt | 79 ++++++++++++++++--- app/src/main/res/values/strings.xml | 1 + 2 files changed, 70 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/app/myzel394/alibi/ui/components/SettingsScreen/Tiles/SaveFolderTile.kt b/app/src/main/java/app/myzel394/alibi/ui/components/SettingsScreen/Tiles/SaveFolderTile.kt index dd3aed4..f9cbcae 100644 --- a/app/src/main/java/app/myzel394/alibi/ui/components/SettingsScreen/Tiles/SaveFolderTile.kt +++ b/app/src/main/java/app/myzel394/alibi/ui/components/SettingsScreen/Tiles/SaveFolderTile.kt @@ -4,8 +4,6 @@ import android.Manifest import android.content.Intent import android.net.Uri import android.os.Build -import android.os.Environment -import android.provider.MediaStore import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement @@ -21,10 +19,10 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.InsertDriveFile import androidx.compose.material.icons.filled.CameraAlt import androidx.compose.material.icons.filled.Cancel import androidx.compose.material.icons.filled.Folder -import androidx.compose.material.icons.filled.InsertDriveFile import androidx.compose.material.icons.filled.Lock import androidx.compose.material.icons.filled.Mic import androidx.compose.material.icons.filled.PermMedia @@ -147,19 +145,29 @@ fun SaveFolderTile( var showDCIMFolderHelpSheet by remember { mutableStateOf(false) } if (showDCIMFolderHelpSheet) { - MediaFoldersExplanationDialog( + DCIMFolderExplanationDialog( onDismiss = { showDCIMFolderHelpSheet = false } ) } + var showExplanationDialog by remember { mutableStateOf(false) } + + if (showExplanationDialog) { + InternalFolderExplanationDialog( + onDismiss = { + showExplanationDialog = false + } + ) + } + SettingsTile( title = stringResource(R.string.ui_settings_option_saveFolder_title), description = stringResource(R.string.ui_settings_option_saveFolder_explanation), leading = { Icon( - Icons.Default.InsertDriveFile, + Icons.AutoMirrored.Filled.InsertDriveFile, contentDescription = null, ) }, @@ -205,7 +213,25 @@ fun SaveFolderTile( val openFolder = rememberOpenUri() when (settings.saveFolder) { - null -> {} + null -> { + Button( + onClick = { + showExplanationDialog = true + }, + shape = MaterialTheme.shapes.small, + contentPadding = ButtonDefaults.TextButtonContentPadding, + colors = ButtonDefaults.filledTonalButtonColors( + contentColor = MaterialTheme.colorScheme.onTertiaryContainer, + containerColor = MaterialTheme.colorScheme.tertiaryContainer, + ), + ) { + Text( + stringResource(R.string.ui_settings_option_saveFolder_explainMediaFolder_label), + fontSize = MaterialTheme.typography.bodySmall.fontSize, + ) + } + } + RECORDER_MEDIA_SELECTED_VALUE -> { Button( onClick = { @@ -258,12 +284,9 @@ fun SaveFolderTile( } @Composable -fun MediaFoldersExplanationDialog( +fun DCIMFolderExplanationDialog( onDismiss: () -> Unit, ) { - val context = LocalContext.current - val openFolder = rememberOpenUri() - AlertDialog( onDismissRequest = onDismiss, icon = { @@ -363,6 +386,42 @@ fun MediaFoldersExplanationDialog( ) } +@Composable +fun InternalFolderExplanationDialog( + onDismiss: () -> Unit, +) { + AlertDialog( + onDismissRequest = onDismiss, + icon = { + Icon( + Icons.Default.Lock, + contentDescription = null, + ) + }, + title = { + Text(stringResource(R.string.ui_settings_option_saveFolder_explainMediaFolder_label)) + }, + confirmButton = { + Button(onClick = onDismiss) { + Text(stringResource(R.string.dialog_close_neutral_label)) + } + }, + text = { + Column( + modifier = Modifier.fillMaxWidth(), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.spacedBy(32.dp), + ) { + Text( + stringResource(R.string.ui_settings_option_saveFolder_explainInternalFolder_explanation), + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurface, + ) + } + } + ) +} + @OptIn(ExperimentalMaterial3Api::class) @Composable fun SelectionSheet( diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 30e14c1..57cff23 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -188,4 +188,5 @@ The final merged recordings will be saved in those folders. Each recording creates a subfolder to store the short batches in (\"%s\" for audio recordings, \"%s\" for video recordings). To view the individual batches, you may need to enable hidden files in the Files app. Tap on a folder to open it in the Files app Unknown + 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. \ No newline at end of file