From 86382afc1be436d955a88b326b4925dee487435c Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Fri, 23 Feb 2024 23:18:52 +0100 Subject: [PATCH] feat: Add RotateDeviceToPortrait to CustomRecordingNotificationsScreen Signed-off-by: Myzel394 <50424412+Myzel394@users.noreply.github.com> --- .../atoms/RotateDeviceToPortrait.kt | 39 +++++++++ .../CustomRecordingNotificationsScreen.kt | 86 ++++++++++--------- app/src/main/res/values/strings.xml | 3 +- 3 files changed, 88 insertions(+), 40 deletions(-) create mode 100644 app/src/main/java/app/myzel394/alibi/ui/components/atoms/RotateDeviceToPortrait.kt diff --git a/app/src/main/java/app/myzel394/alibi/ui/components/atoms/RotateDeviceToPortrait.kt b/app/src/main/java/app/myzel394/alibi/ui/components/atoms/RotateDeviceToPortrait.kt new file mode 100644 index 0000000..232bde3 --- /dev/null +++ b/app/src/main/java/app/myzel394/alibi/ui/components/atoms/RotateDeviceToPortrait.kt @@ -0,0 +1,39 @@ +package app.myzel394.alibi.ui.components.atoms + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.widthIn +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Rotate90DegreesCw +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +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.unit.dp +import app.myzel394.alibi.R + +@Composable +fun RotateDeviceToPortrait( + modifier: Modifier = Modifier + .fillMaxWidth() + .widthIn(max = 300.dp), +) { + Column( + modifier = modifier, + verticalArrangement = Arrangement.spacedBy(16.dp), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Icon( + Icons.Default.Rotate90DegreesCw, + contentDescription = stringResource(R.string.ui_rotateDevice_portrait_label), + modifier = Modifier.size(48.dp), + tint = MaterialTheme.colorScheme.tertiary, + ) + Text(stringResource(R.string.ui_rotateDevice_portrait_label)) + } +} \ No newline at end of file diff --git a/app/src/main/java/app/myzel394/alibi/ui/screens/CustomRecordingNotificationsScreen.kt b/app/src/main/java/app/myzel394/alibi/ui/screens/CustomRecordingNotificationsScreen.kt index 3d119f9..ca71964 100644 --- a/app/src/main/java/app/myzel394/alibi/ui/screens/CustomRecordingNotificationsScreen.kt +++ b/app/src/main/java/app/myzel394/alibi/ui/screens/CustomRecordingNotificationsScreen.kt @@ -1,18 +1,11 @@ package app.myzel394.alibi.ui.screens -import androidx.compose.foundation.clickable -import androidx.compose.foundation.gestures.scrollable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column +import android.content.res.Configuration +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.LazyRow -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.IconButton @@ -29,22 +22,20 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.input.nestedscroll.nestedScroll +import androidx.compose.ui.platform.LocalConfiguration 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 androidx.navigation.NavController import app.myzel394.alibi.R import app.myzel394.alibi.dataStore import app.myzel394.alibi.db.AppSettings import app.myzel394.alibi.db.NotificationSettings import app.myzel394.alibi.ui.components.CustomRecordingNotificationsScreen.atoms.LandingElement -import app.myzel394.alibi.ui.components.CustomRecordingNotificationsScreen.atoms.NotificationPresetSelect -import app.myzel394.alibi.ui.components.CustomRecordingNotificationsScreen.molecules.EditNotificationInput import app.myzel394.alibi.ui.components.CustomRecordingNotificationsScreen.organisms.NotificationEditor +import app.myzel394.alibi.ui.components.atoms.RotateDeviceToPortrait import kotlinx.coroutines.launch @OptIn(ExperimentalMaterial3Api::class) @@ -81,7 +72,7 @@ fun CustomRecordingNotificationsScreen( navigationIcon = { IconButton(onClick = onBackNavigate) { Icon( - Icons.Default.ArrowBack, + Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back" ) } @@ -92,33 +83,50 @@ fun CustomRecordingNotificationsScreen( modifier = Modifier .nestedScroll(scrollBehavior.nestedScrollConnection) ) { padding -> - if (showEditor) { - val scope = rememberCoroutineScope() + val orientation = LocalConfiguration.current.orientation - NotificationEditor( - modifier = Modifier - .padding(padding) - .padding(vertical = 16.dp), - onNotificationChange = { notificationSettings -> - scope.launch { - dataStore.updateData { settings -> - settings.setNotificationSettings(notificationSettings.let { - if (it.preset == NotificationSettings.Preset.Default) - null - else - it - }) + when (orientation) { + Configuration.ORIENTATION_PORTRAIT -> { + if (showEditor) { + val scope = rememberCoroutineScope() + + NotificationEditor( + modifier = Modifier + .padding(padding) + .padding(vertical = 16.dp), + onNotificationChange = { notificationSettings -> + scope.launch { + dataStore.updateData { settings -> + settings.setNotificationSettings(notificationSettings.let { + if (it.preset == NotificationSettings.Preset.Default) + null + else + it + }) + } + } + onBackNavigate() } - } - onBackNavigate() + ) + } else { + LandingElement( + onOpenEditor = { + showEditor = true + } + ) } - ) - } else { - LandingElement( - onOpenEditor = { - showEditor = true + } + + else -> { + Box( + modifier = Modifier + .fillMaxSize() + .padding(padding), + contentAlignment = Alignment.Center, + ) { + RotateDeviceToPortrait() } - ) + } } } } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f17128b..73a1745 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,4 +1,4 @@ - + Alibi Cancel @@ -189,4 +189,5 @@ 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. + Please rotate your device to portait mode \ No newline at end of file