Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {

val kotlinVersion: String by rootProject.extra

val androidxCameraVersion = "1.5.3"
val androidxCameraVersion = "1.6.0"
val coilKtVersion = "2.7.0"
val daggerVersion = "2.59.2"
val emojiVersion = "1.6.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class BackgroundVoiceMessageCard(
}
}

private const val TITLE_SPACE = 0.8f

@Suppress("LongParameterList", "LongMethod")
@Composable
fun BackgroundVoiceMessageCardContent(
Expand Down Expand Up @@ -142,7 +144,7 @@ fun BackgroundVoiceMessageCardContent(

Box(
modifier = Modifier
.weight(0.8f)
.weight(TITLE_SPACE)
.align(Alignment.CenterVertically),
contentAlignment = Alignment.Center
) {
Expand Down
183 changes: 108 additions & 75 deletions app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimeCompose.kt
Original file line number Diff line number Diff line change
Expand Up @@ -306,75 +306,56 @@ class DateTimeCompose(val bundle: Bundle) {
}

@SuppressLint("UnusedBoxWithConstraintsScope")
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun ExpandedDateTimePickers() {
val todayMillis = LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli()
val currentYear = LocalDate.now().year
val selectableDates = object : SelectableDates {
override fun isSelectableDate(utcTimeMillis: Long): Boolean = utcTimeMillis >= todayMillis
override fun isSelectableYear(year: Int): Boolean = year >= currentYear
}
val datePickerState = rememberDatePickerState(selectableDates = selectableDates)
val now = LocalDateTime.now()
val timePickerState = rememberTimePickerState(
initialHour = now.hour,
initialMinute = now.minute,
is24Hour = DateFormat.is24HourFormat(LocalContext.current)
)
BoxWithConstraints(modifier = Modifier.requiredSizeIn(minWidth = 360.dp)) {
val scale = remember(maxWidth) { if (maxWidth < 360.dp) maxWidth / 360.dp else 1f }
DatePicker(
state = datePickerState,
modifier = Modifier.scale(scale),
colors = DatePickerDefaults.colors(containerColor = colorResource(R.color.bg_default))
)
}
Spacer(modifier = Modifier.height(16.dp))
TimePicker(state = timePickerState)
val date = datePickerState.selectedDateMillis?.let {
LocalDateTime.ofInstant(Instant.ofEpochMilli(it), ZoneOffset.UTC) // Google sends time in UTC
}
val newTime = if (date != null) {
LocalDateTime.of(date.year, date.month, date.dayOfMonth, timePickerState.hour, timePickerState.minute)
} else {
LocalDate.now().atTime(timePickerState.hour, timePickerState.minute)
}
setTime(newTime)
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun CollapsableDateTime(shouldDismiss: MutableState<Boolean>, isCollapsed: MutableState<Boolean>) {
GeneralIconButton(
icon = ImageVector.vectorResource(R.drawable.ic_date_range_24px),
label = stringResource(R.string.custom)
) { isCollapsed.value = !isCollapsed.value }
val scrollState = rememberScrollState()
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.verticalScroll(scrollState)
modifier = Modifier.verticalScroll(rememberScrollState())
) {
if (!isCollapsed.value) {
val todayMillis = LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli()
val currentYear = LocalDate.now().year
val selectableDates = object : SelectableDates {
override fun isSelectableDate(utcTimeMillis: Long): Boolean = utcTimeMillis >= todayMillis

override fun isSelectableYear(year: Int): Boolean = year >= currentYear
}

val datePickerState = rememberDatePickerState(
selectableDates = selectableDates
)
val now = LocalDateTime.now()
val timePickerState = rememberTimePickerState(
initialHour = now.hour,
initialMinute = now.minute,
is24Hour = DateFormat.is24HourFormat(LocalContext.current)
)

BoxWithConstraints(
modifier = Modifier
.requiredSizeIn(minWidth = 360.dp)
) {
val scale = remember(maxWidth) { if (maxWidth < 360.dp) maxWidth / 360.dp else 1f }

DatePicker(
state = datePickerState,
modifier = Modifier
.scale(scale),
colors = DatePickerDefaults.colors(
containerColor = colorResource(R.color.bg_default)
)
)
}

Spacer(modifier = Modifier.height(16.dp))

TimePicker(
state = timePickerState
)

val date = datePickerState.selectedDateMillis?.let {
val instant = Instant.ofEpochMilli(it)
LocalDateTime.ofInstant(instant, ZoneOffset.UTC) // Google sends time in UTC
}
if (date != null) {
val year = date.year
val month = date.month
val day = date.dayOfMonth
val hour = timePickerState.hour
val minute = timePickerState.minute
val newTime = LocalDateTime.of(year, month, day, hour, minute)
setTime(newTime)
} else {
val newTime = LocalDate.now().atTime(timePickerState.hour, timePickerState.minute)
setTime(newTime)
}
ExpandedDateTimePickers()
}
Submission(shouldDismiss)
}
Expand Down Expand Up @@ -429,6 +410,7 @@ private fun TimeOption(label: String, timeString: String, onClick: () -> Unit) {
}

@Preview(name = "Light Mode")
@Preview(name = "Dark Mode", uiMode = android.content.res.Configuration.UI_MODE_NIGHT_YES)
@Composable
fun GeneralIconButtonPreview(label: String = "Custom") {
val context = LocalContext.current
Expand All @@ -443,22 +425,15 @@ fun GeneralIconButtonPreview(label: String = "Custom") {
}
}

@Preview(
name = "Dark Mode",
uiMode = android.content.res.Configuration.UI_MODE_NIGHT_YES
)
@Composable
fun GeneralIconButtonDarkPreview() {
GeneralIconButtonPreview()
}

@Preview(name = "RTL / Arabic", locale = "ar")
@Composable
fun GeneralIconButtonRtlPreview() {
GeneralIconButtonPreview(label = "مخصص")
}

@Preview(name = "Light Mode")
@Preview(name = "Dark Mode", uiMode = android.content.res.Configuration.UI_MODE_NIGHT_YES)
@Preview(name = "RTL / Arabic", locale = "ar")
@Composable
fun TimeOptionPreview() {
val context = LocalContext.current
Expand All @@ -475,17 +450,75 @@ fun TimeOptionPreview() {
}
}

@Preview(
name = "Dark Mode",
uiMode = android.content.res.Configuration.UI_MODE_NIGHT_YES
)
@SuppressLint("UnusedBoxWithConstraintsScope")
@OptIn(ExperimentalMaterial3Api::class)
@Preview(name = "Light Mode")
@Preview(name = "Dark Mode", uiMode = android.content.res.Configuration.UI_MODE_NIGHT_YES)
@Preview(name = "RTL / Arabic", locale = "ar")
@Composable
fun TimeOptionDarkPreview() {
TimeOptionPreview()
fun ExpandedDateTimePickersPreview() {
val context = LocalContext.current
val colorScheme = ComposePreviewUtils.getInstance(context).viewThemeUtils.getColorScheme(context)
val todayMillis = LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli()
val currentYear = LocalDate.now().year
val selectableDates = object : SelectableDates {
override fun isSelectableDate(utcTimeMillis: Long): Boolean = utcTimeMillis >= todayMillis
override fun isSelectableYear(year: Int): Boolean = year >= currentYear
}
val datePickerState = rememberDatePickerState(selectableDates = selectableDates)
val now = LocalDateTime.now()
val timePickerState = rememberTimePickerState(
initialHour = now.hour,
initialMinute = now.minute,
is24Hour = DateFormat.is24HourFormat(context)
)
MaterialTheme(colorScheme = colorScheme) {
Surface {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.verticalScroll(rememberScrollState())
) {
BoxWithConstraints(modifier = Modifier.requiredSizeIn(minWidth = 360.dp)) {
val scale = remember(maxWidth) { if (maxWidth < 360.dp) maxWidth / 360.dp else 1f }
DatePicker(
state = datePickerState,
modifier = Modifier.scale(scale),
colors = DatePickerDefaults.colors(containerColor = colorResource(R.color.bg_default))
)
}
Spacer(modifier = Modifier.height(16.dp))
TimePicker(state = timePickerState)
}
}
}
}

@Preview(name = "Light Mode")
@Preview(name = "Dark Mode", uiMode = android.content.res.Configuration.UI_MODE_NIGHT_YES)
@Preview(name = "RTL / Arabic", locale = "ar")
@Composable
fun TimeOptionRtlPreview() {
TimeOptionPreview()
fun CollapsableDateTimePreview() {
val context = LocalContext.current
val colorScheme = ComposePreviewUtils.getInstance(context).viewThemeUtils.getColorScheme(context)
MaterialTheme(colorScheme = colorScheme) {
Surface {
Column(modifier = Modifier.padding(16.dp)) {
GeneralIconButton(
icon = ImageVector.vectorResource(R.drawable.ic_date_range_24px),
label = stringResource(R.string.custom)
) {}
Row(modifier = Modifier.fillMaxWidth()) {
TextButton(onClick = {}, modifier = Modifier.weight(HALF_WEIGHT)) {
Text(stringResource(R.string.nc_delete), color = Color.Red)
}
TextButton(onClick = {}, modifier = Modifier.weight(HALF_WEIGHT)) {
Text(stringResource(R.string.close))
}
TextButton(onClick = {}, modifier = Modifier.weight(HALF_WEIGHT)) {
Text(stringResource(R.string.set))
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion detekt.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: GPL-3.0-or-later
build:
maxIssues: 98
maxIssues: 97
weights:
# complexity: 2
# LongParameterList: 1
Expand Down
9 changes: 9 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<trusting group="androidx.databinding"/>
<trusting group="androidx.datastore"/>
<trusting group="androidx.media3"/>
<trusting group="^androidx[.]camera($|([.].*))" regex="true"/>
<trusting group="^androidx[.]compose($|([.].*))" regex="true"/>
<trusting group="^com[.]android($|([.].*))" regex="true"/>
</trusted-key>
Expand All @@ -56,6 +57,7 @@
<trusting group="androidx.camera.featurecombinationquery" name="featurecombinationquery" version="1.5.1"/>
<trusting group="androidx.camera.featurecombinationquery" name="featurecombinationquery" version="1.5.2"/>
<trusting group="androidx.camera.featurecombinationquery" name="featurecombinationquery" version="1.5.3"/>
<trusting group="androidx.camera.viewfinder"/>
<trusting group="androidx.collection"/>
<trusting group="androidx.compose.runtime"/>
<trusting group="androidx.constraintlayout"/>
Expand All @@ -75,6 +77,7 @@
<trusting group="androidx.sqlite"/>
<trusting group="androidx.swiperefreshlayout" name="swiperefreshlayout" version="1.2.0"/>
<trusting group="androidx.test"/>
<trusting group="androidx.tracing"/>
<trusting group="androidx.transition"/>
<trusting group="androidx.window"/>
<trusting group="androidx.work"/>
Expand Down Expand Up @@ -216,6 +219,7 @@
<trusted-key id="51BF0A126F41293F40F50A0B8CD7D660AE857DAD" group="com.getkeepsafe.relinker" name="relinker" version="1.4.5"/>
<trusted-key id="54861E21122471058A4B3B6B46EBE0B8AD0CCDE9" group="be.digitalia.compose.htmlconverter"/>
<trusted-key id="54A26BFDC7ECDD39BA4C123AC3BAB45F4AF71FAB" group="io.opencensus" name="opencensus-proto" version="0.2.0"/>
<trusted-key id="5658C10C3CE831EB53C53ED42D690312365E5A2A" group="io.github.kevincianfarini.alchemist"/>
<trusted-key id="5767F9CDE920750621875079A40E24B5B408DBD5" group="org.robolectric"/>
<trusted-key id="5897253BEA3046AEEA95A067E93671C7272B7B3F" group="org.jdom" name="jdom2" version="2.0.6"/>
<trusted-key id="5989BAF76217B843D66BE55B2D0E1FB8FE4B68B4" group="org.eclipse.jetty" name="jetty-bom" version="9.4.54.v20240208"/>
Expand Down Expand Up @@ -7967,6 +7971,11 @@
<sha256 value="d877d2e7f8ffcc62433e65c4468f2562cf2b00b63b6127a5415e7d012274cd26" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="androidx.media3" name="media3-muxer" version="1.9.0">
<artifact name="media3-muxer-1.9.0.module">
<sha256 value="e22678eed7457db37ceb4f14d96c761fa5055a114b4750892cf42b820a791428" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
</component>
<component group="androidx.media3" name="media3-ui" version="1.2.1">
<artifact name="media3-ui-1.2.1.aar">
<sha256 value="d20c0cfb29b9e412e1941fc26d856318d1af912848e3deb972856950f661cadf" origin="Generated by Gradle" reason="Artifact is not signed"/>
Expand Down
Loading