From 28b958fc162bb9448907e3ed9c6d2eb69455565a Mon Sep 17 00:00:00 2001 From: Akshay Nandwana Date: Tue, 22 Oct 2024 13:38:06 +0530 Subject: [PATCH 1/7] added landscape support --- .../DataSubmissionConfirmationDialog.kt | 87 ++++++++++++------- 1 file changed, 58 insertions(+), 29 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt index 2a0218f599..fbfbacd9fe 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt @@ -15,8 +15,11 @@ */ package com.google.android.ground.ui.datacollection +import android.content.res.Configuration import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ColumnScope +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding @@ -31,6 +34,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign @@ -52,41 +56,66 @@ fun DataSubmissionConfirmationDialog(onDismiss: () -> Unit) { shape = RoundedCornerShape(16.dp), tonalElevation = 8.dp, ) { - Column( - modifier = Modifier.padding(16.dp), - horizontalAlignment = Alignment.CenterHorizontally, - ) { - Image( - painter = painterResource(id = R.drawable.data_submitted), - contentDescription = stringResource(R.string.data_submitted_image), - contentScale = ContentScale.Fit, - ) - - Spacer(modifier = Modifier.height(12.dp)) - - Text( - text = stringResource(R.string.data_collection_complete), - style = MaterialTheme.typography.titleLarge, - textAlign = TextAlign.Center, - ) - - Spacer(modifier = Modifier.height(8.dp)) - - Text( - text = stringResource(R.string.data_collection_complete_details), - style = MaterialTheme.typography.bodyMedium, - textAlign = TextAlign.Center, - ) - - Spacer(modifier = Modifier.height(12.dp)) - - OutlinedButton(onClick = { onDismiss() }) { Text(stringResource(id = R.string.close)) } + val configuration = LocalConfiguration.current + when (configuration.orientation) { + Configuration.ORIENTATION_LANDSCAPE -> { + Row(verticalAlignment = Alignment.CenterVertically) { + DataCollectionThumbnail(modifier = Modifier.weight(1f)) + Column( + modifier = Modifier.padding(16.dp).weight(1f), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + DetailColumn(onDismiss) + } + } + } + else -> { + Column( + modifier = Modifier.padding(16.dp), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + DataCollectionThumbnail() + Spacer(modifier = Modifier.height(12.dp)) + DetailColumn(onDismiss) + } + } } } } } @Composable +private fun DataCollectionThumbnail(modifier: Modifier = Modifier) { + Image( + modifier = modifier, + painter = painterResource(id = R.drawable.data_submitted), + contentDescription = stringResource(R.string.data_submitted_image), + contentScale = ContentScale.Fit, + ) +} + +@Composable +private fun ColumnScope.DetailColumn(onDismiss: () -> Unit) { + Text( + text = stringResource(R.string.data_collection_complete), + style = MaterialTheme.typography.titleLarge, + textAlign = TextAlign.Center, + ) + Spacer(modifier = Modifier.height(8.dp)) + Text( + text = stringResource(R.string.data_collection_complete_details), + style = MaterialTheme.typography.bodyMedium, + textAlign = TextAlign.Center, + ) + Spacer(modifier = Modifier.height(12.dp)) + OutlinedButton(onClick = { onDismiss() }) { Text(stringResource(id = R.string.close)) } +} + +@Composable +@Preview( + showSystemUi = true, + device = "spec:width=411dp,height=891dp,dpi=420,isRound=false,chinSize=0dp,orientation=landscape", +) @Preview fun DataSubmissionConfirmationDialogPreview() { AppTheme { DataSubmissionConfirmationDialog {} } From ea0f67e5fc9d75e4030cfae904529328a5d39201 Mon Sep 17 00:00:00 2001 From: Akshay Nandwana Date: Thu, 24 Oct 2024 09:56:04 +0530 Subject: [PATCH 2/7] landscape fixed --- .../DataSubmissionConfirmationDialog.kt | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt index fbfbacd9fe..9e3cc1c582 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt @@ -17,6 +17,7 @@ package com.google.android.ground.ui.datacollection import android.content.res.Configuration import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.Row @@ -37,7 +38,6 @@ import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog @@ -57,27 +57,25 @@ fun DataSubmissionConfirmationDialog(onDismiss: () -> Unit) { tonalElevation = 8.dp, ) { val configuration = LocalConfiguration.current - when (configuration.orientation) { - Configuration.ORIENTATION_LANDSCAPE -> { + if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) { + Column { Row(verticalAlignment = Alignment.CenterVertically) { DataCollectionThumbnail(modifier = Modifier.weight(1f)) Column( - modifier = Modifier.padding(16.dp).weight(1f), - horizontalAlignment = Alignment.CenterHorizontally, + modifier = Modifier.padding(start = 16.dp, end = 16.dp, top = 16.dp).weight(2f), + verticalArrangement = Arrangement.Center, ) { - DetailColumn(onDismiss) + DetailColumn() } } + CloseButton(modifier = Modifier.padding(bottom = 16.dp, end = 16.dp), onDismiss) } - else -> { - Column( - modifier = Modifier.padding(16.dp), - horizontalAlignment = Alignment.CenterHorizontally, - ) { - DataCollectionThumbnail() - Spacer(modifier = Modifier.height(12.dp)) - DetailColumn(onDismiss) - } + } else { + Column(modifier = Modifier.padding(16.dp)) { + DataCollectionThumbnail() + DetailColumn() + Spacer(modifier = Modifier.height(12.dp)) + CloseButton(onDismiss = onDismiss) } } } @@ -95,27 +93,27 @@ private fun DataCollectionThumbnail(modifier: Modifier = Modifier) { } @Composable -private fun ColumnScope.DetailColumn(onDismiss: () -> Unit) { +private fun ColumnScope.DetailColumn() { Text( text = stringResource(R.string.data_collection_complete), style = MaterialTheme.typography.titleLarge, - textAlign = TextAlign.Center, ) Spacer(modifier = Modifier.height(8.dp)) Text( text = stringResource(R.string.data_collection_complete_details), style = MaterialTheme.typography.bodyMedium, - textAlign = TextAlign.Center, ) - Spacer(modifier = Modifier.height(12.dp)) - OutlinedButton(onClick = { onDismiss() }) { Text(stringResource(id = R.string.close)) } } @Composable -@Preview( - showSystemUi = true, - device = "spec:width=411dp,height=891dp,dpi=420,isRound=false,chinSize=0dp,orientation=landscape", -) +private fun ColumnScope.CloseButton(modifier: Modifier = Modifier, onDismiss: () -> Unit) { + OutlinedButton(modifier = modifier.align(Alignment.End), onClick = { onDismiss() }) { + Text(stringResource(id = R.string.close)) + } +} + +@Composable +@Preview(showBackground = false, heightDp = 360, widthDp = 800) @Preview fun DataSubmissionConfirmationDialogPreview() { AppTheme { DataSubmissionConfirmationDialog {} } From baccfa96599034e407497303e66b6b0dc6557f43 Mon Sep 17 00:00:00 2001 From: Akshay Nandwana Date: Sun, 27 Oct 2024 07:35:33 +0530 Subject: [PATCH 3/7] space fix --- .../ui/datacollection/DataSubmissionConfirmationDialog.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt index 9e3cc1c582..928efaff94 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt @@ -62,16 +62,16 @@ fun DataSubmissionConfirmationDialog(onDismiss: () -> Unit) { Row(verticalAlignment = Alignment.CenterVertically) { DataCollectionThumbnail(modifier = Modifier.weight(1f)) Column( - modifier = Modifier.padding(start = 16.dp, end = 16.dp, top = 16.dp).weight(2f), + modifier = Modifier.padding(start = 16.dp, end = 24.dp, top = 16.dp).weight(2f), verticalArrangement = Arrangement.Center, ) { DetailColumn() } } - CloseButton(modifier = Modifier.padding(bottom = 16.dp, end = 16.dp), onDismiss) + CloseButton(modifier = Modifier.padding(bottom = 24.dp, end = 24.dp), onDismiss) } } else { - Column(modifier = Modifier.padding(16.dp)) { + Column(modifier = Modifier.padding(horizontal = 24.dp, vertical = 16.dp)) { DataCollectionThumbnail() DetailColumn() Spacer(modifier = Modifier.height(12.dp)) From 50f2ea5b620ca2767120b49bd2b0e859c732558e Mon Sep 17 00:00:00 2001 From: Akshay Nandwana Date: Sun, 27 Oct 2024 07:52:47 +0530 Subject: [PATCH 4/7] nit fix --- .../DataSubmissionConfirmationDialog.kt | 26 ++++++++++++++++--- .../google/android/ground/ui/theme/Theme.kt | 8 ++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt index 928efaff94..29cbdbdbbf 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt @@ -16,6 +16,7 @@ package com.google.android.ground.ui.datacollection import android.content.res.Configuration +import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -40,10 +41,15 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.DialogProperties import com.google.android.ground.R import com.google.android.ground.ui.theme.AppTheme +import com.google.android.ground.ui.theme.manropeFont +import com.google.android.ground.ui.theme.md_theme_light_onBackground +import com.google.android.ground.ui.theme.md_theme_light_onSurfaceVariant +import com.google.android.ground.ui.theme.md_theme_light_outline @Composable fun DataSubmissionConfirmationDialog(onDismiss: () -> Unit) { @@ -97,18 +103,32 @@ private fun ColumnScope.DetailColumn() { Text( text = stringResource(R.string.data_collection_complete), style = MaterialTheme.typography.titleLarge, + color = md_theme_light_onBackground, + lineHeight = 28.sp, ) Spacer(modifier = Modifier.height(8.dp)) Text( text = stringResource(R.string.data_collection_complete_details), - style = MaterialTheme.typography.bodyMedium, + fontSize = 16.sp, + lineHeight = 24.sp, + color = md_theme_light_onSurfaceVariant, + fontFamily = manropeFont, ) } @Composable private fun ColumnScope.CloseButton(modifier: Modifier = Modifier, onDismiss: () -> Unit) { - OutlinedButton(modifier = modifier.align(Alignment.End), onClick = { onDismiss() }) { - Text(stringResource(id = R.string.close)) + OutlinedButton( + modifier = modifier.align(Alignment.End), + border = BorderStroke(width = 1.dp, color = md_theme_light_outline), + onClick = { onDismiss() }, + ) { + Text( + stringResource(id = R.string.close), + fontSize = 14.sp, + lineHeight = 20.sp, + fontFamily = manropeFont, + ) } } diff --git a/ground/src/main/java/com/google/android/ground/ui/theme/Theme.kt b/ground/src/main/java/com/google/android/ground/ui/theme/Theme.kt index 29a759cdff..c910805602 100644 --- a/ground/src/main/java/com/google/android/ground/ui/theme/Theme.kt +++ b/ground/src/main/java/com/google/android/ground/ui/theme/Theme.kt @@ -20,6 +20,10 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.darkColorScheme import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable +import androidx.compose.ui.text.font.Font +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import com.google.android.ground.R private val LightColors = lightColorScheme( @@ -87,6 +91,10 @@ private val DarkColors = scrim = md_theme_dark_scrim, ) +val manropeFont = FontFamily(Font(R.font.manrope_medium, FontWeight.Normal)) + +val googleSansFont = FontFamily(Font(R.font.google_sans, FontWeight.Normal)) + @Composable fun AppTheme(useDarkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) { val colors = From 1a8253a3a3b41d18e03c6da575b52d1472b168cb Mon Sep 17 00:00:00 2001 From: Akshay Nandwana Date: Sun, 27 Oct 2024 07:53:56 +0530 Subject: [PATCH 5/7] remove unused --- .../src/main/java/com/google/android/ground/ui/theme/Theme.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/theme/Theme.kt b/ground/src/main/java/com/google/android/ground/ui/theme/Theme.kt index c910805602..ec257a6691 100644 --- a/ground/src/main/java/com/google/android/ground/ui/theme/Theme.kt +++ b/ground/src/main/java/com/google/android/ground/ui/theme/Theme.kt @@ -93,8 +93,6 @@ private val DarkColors = val manropeFont = FontFamily(Font(R.font.manrope_medium, FontWeight.Normal)) -val googleSansFont = FontFamily(Font(R.font.google_sans, FontWeight.Normal)) - @Composable fun AppTheme(useDarkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) { val colors = From 9a3e0c3126c560a45b3b06cae4c1a1a9d3e37b1b Mon Sep 17 00:00:00 2001 From: Akshay Nandwana Date: Mon, 28 Oct 2024 12:08:08 +0530 Subject: [PATCH 6/7] color fixed --- .../ui/datacollection/DataSubmissionConfirmationDialog.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt index 29cbdbdbbf..31fd77e40c 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt @@ -48,8 +48,6 @@ import com.google.android.ground.R import com.google.android.ground.ui.theme.AppTheme import com.google.android.ground.ui.theme.manropeFont import com.google.android.ground.ui.theme.md_theme_light_onBackground -import com.google.android.ground.ui.theme.md_theme_light_onSurfaceVariant -import com.google.android.ground.ui.theme.md_theme_light_outline @Composable fun DataSubmissionConfirmationDialog(onDismiss: () -> Unit) { @@ -111,7 +109,7 @@ private fun ColumnScope.DetailColumn() { text = stringResource(R.string.data_collection_complete_details), fontSize = 16.sp, lineHeight = 24.sp, - color = md_theme_light_onSurfaceVariant, + color = MaterialTheme.colorScheme.onSurfaceVariant, fontFamily = manropeFont, ) } @@ -120,7 +118,7 @@ private fun ColumnScope.DetailColumn() { private fun ColumnScope.CloseButton(modifier: Modifier = Modifier, onDismiss: () -> Unit) { OutlinedButton( modifier = modifier.align(Alignment.End), - border = BorderStroke(width = 1.dp, color = md_theme_light_outline), + border = BorderStroke(width = 1.dp, color = MaterialTheme.colorScheme.outline), onClick = { onDismiss() }, ) { Text( From 054f75bb4e3fe20fb4889f55295d11ba3625c758 Mon Sep 17 00:00:00 2001 From: Akshay Nandwana Date: Mon, 28 Oct 2024 12:37:38 +0530 Subject: [PATCH 7/7] font fixes --- .../datacollection/DataSubmissionConfirmationDialog.kt | 10 +++++----- .../java/com/google/android/ground/ui/theme/Theme.kt | 6 ------ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt index 31fd77e40c..c7fd31e296 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt @@ -39,6 +39,8 @@ import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.Font +import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -46,8 +48,6 @@ import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.DialogProperties import com.google.android.ground.R import com.google.android.ground.ui.theme.AppTheme -import com.google.android.ground.ui.theme.manropeFont -import com.google.android.ground.ui.theme.md_theme_light_onBackground @Composable fun DataSubmissionConfirmationDialog(onDismiss: () -> Unit) { @@ -101,7 +101,7 @@ private fun ColumnScope.DetailColumn() { Text( text = stringResource(R.string.data_collection_complete), style = MaterialTheme.typography.titleLarge, - color = md_theme_light_onBackground, + color = MaterialTheme.colorScheme.onBackground, lineHeight = 28.sp, ) Spacer(modifier = Modifier.height(8.dp)) @@ -110,7 +110,7 @@ private fun ColumnScope.DetailColumn() { fontSize = 16.sp, lineHeight = 24.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, - fontFamily = manropeFont, + fontFamily = FontFamily(Font(R.font.text_500)), ) } @@ -125,7 +125,7 @@ private fun ColumnScope.CloseButton(modifier: Modifier = Modifier, onDismiss: () stringResource(id = R.string.close), fontSize = 14.sp, lineHeight = 20.sp, - fontFamily = manropeFont, + fontFamily = FontFamily(Font(R.font.text_500)), ) } } diff --git a/ground/src/main/java/com/google/android/ground/ui/theme/Theme.kt b/ground/src/main/java/com/google/android/ground/ui/theme/Theme.kt index ec257a6691..29a759cdff 100644 --- a/ground/src/main/java/com/google/android/ground/ui/theme/Theme.kt +++ b/ground/src/main/java/com/google/android/ground/ui/theme/Theme.kt @@ -20,10 +20,6 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.darkColorScheme import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable -import androidx.compose.ui.text.font.Font -import androidx.compose.ui.text.font.FontFamily -import androidx.compose.ui.text.font.FontWeight -import com.google.android.ground.R private val LightColors = lightColorScheme( @@ -91,8 +87,6 @@ private val DarkColors = scrim = md_theme_dark_scrim, ) -val manropeFont = FontFamily(Font(R.font.manrope_medium, FontWeight.Normal)) - @Composable fun AppTheme(useDarkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) { val colors =