mirror of https://github.com/tasks/tasks
Compose date time pickers
parent
2f42d0ad28
commit
33a7a0a53f
@ -0,0 +1,350 @@
|
||||
package org.tasks.compose.pickers
|
||||
|
||||
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
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.outlined.NextWeek
|
||||
import androidx.compose.material.icons.outlined.AccessTime
|
||||
import androidx.compose.material.icons.outlined.Block
|
||||
import androidx.compose.material.icons.outlined.CalendarViewWeek
|
||||
import androidx.compose.material.icons.outlined.Coffee
|
||||
import androidx.compose.material.icons.outlined.NightsStay
|
||||
import androidx.compose.material.icons.outlined.Schedule
|
||||
import androidx.compose.material.icons.outlined.Today
|
||||
import androidx.compose.material.icons.outlined.WbSunny
|
||||
import androidx.compose.material.icons.outlined.WbTwilight
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableLongStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.ColorFilter
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.tasks.R
|
||||
import org.tasks.date.DateTimeUtils.newDateTime
|
||||
import org.tasks.dialogs.DateTimePicker.Companion.MULTIPLE_DAYS
|
||||
import org.tasks.dialogs.DateTimePicker.Companion.MULTIPLE_TIMES
|
||||
import org.tasks.dialogs.DateTimePicker.Companion.NO_DAY
|
||||
import org.tasks.dialogs.DateTimePicker.Companion.NO_TIME
|
||||
import org.tasks.dialogs.StartDatePicker.Companion.DAY_BEFORE_DUE
|
||||
import org.tasks.dialogs.StartDatePicker.Companion.DUE_DATE
|
||||
import org.tasks.dialogs.StartDatePicker.Companion.DUE_TIME
|
||||
import org.tasks.dialogs.StartDatePicker.Companion.WEEK_BEFORE_DUE
|
||||
import org.tasks.extensions.Context.is24HourFormat
|
||||
import org.tasks.kmp.org.tasks.time.DateStyle
|
||||
import org.tasks.kmp.org.tasks.time.getFullDate
|
||||
import org.tasks.kmp.org.tasks.time.getRelativeDay
|
||||
import org.tasks.kmp.org.tasks.time.getTimeString
|
||||
import org.tasks.time.DateTimeUtils2.currentTimeMillis
|
||||
import org.tasks.time.minusDays
|
||||
import org.tasks.time.startOfDay
|
||||
import org.tasks.time.withMillisOfDay
|
||||
import java.util.Calendar.FRIDAY
|
||||
import java.util.Calendar.MONDAY
|
||||
import java.util.Calendar.SATURDAY
|
||||
import java.util.Calendar.SUNDAY
|
||||
import java.util.Calendar.THURSDAY
|
||||
import java.util.Calendar.TUESDAY
|
||||
import java.util.Calendar.WEDNESDAY
|
||||
|
||||
@Composable
|
||||
fun DatePickerShortcuts(
|
||||
dateShortcuts: @Composable ColumnScope.() -> Unit,
|
||||
timeShortcuts: @Composable ColumnScope.() -> Unit,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 16.dp)
|
||||
.fillMaxWidth(),
|
||||
) {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.Start,
|
||||
) {
|
||||
dateShortcuts()
|
||||
}
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
Column {
|
||||
timeShortcuts()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun StartDateShortcuts(
|
||||
selected: Long,
|
||||
selectedDay: (Long) -> Unit,
|
||||
selectedDayTime: (Long, Int) -> Unit,
|
||||
clearDate: () -> Unit,
|
||||
) {
|
||||
var custom by remember { mutableLongStateOf(0) }
|
||||
LaunchedEffect(selected) {
|
||||
custom = if (selected !in listOf(DUE_DATE, DUE_TIME, DAY_BEFORE_DUE, WEEK_BEFORE_DUE, NO_DAY)) {
|
||||
selected
|
||||
} else {
|
||||
custom
|
||||
}
|
||||
}
|
||||
|
||||
if (custom > 0 || custom == MULTIPLE_DAYS) {
|
||||
ShortcutButton(
|
||||
icon = Icons.Outlined.Today,
|
||||
text = if (custom == MULTIPLE_DAYS) {
|
||||
stringResource(R.string.date_picker_multiple)
|
||||
} else {
|
||||
remember(custom) {
|
||||
runBlocking {
|
||||
if (custom < currentTimeMillis().startOfDay().minusDays(1)) {
|
||||
getFullDate(custom, style = DateStyle.LONG)
|
||||
} else {
|
||||
getRelativeDay(custom, style = DateStyle.LONG)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
selected = selected == custom,
|
||||
onClick = { selectedDay(custom) },
|
||||
)
|
||||
}
|
||||
ShortcutButton(
|
||||
icon = Icons.Outlined.Today,
|
||||
text = stringResource(R.string.due_date),
|
||||
selected = selected == DUE_DATE,
|
||||
onClick = { selectedDay(DUE_DATE) },
|
||||
)
|
||||
ShortcutButton(
|
||||
icon = Icons.Outlined.Schedule,
|
||||
text = stringResource(R.string.due_time),
|
||||
selected = selected == DUE_TIME,
|
||||
onClick = { selectedDayTime(DUE_TIME, NO_TIME) },
|
||||
)
|
||||
ShortcutButton(
|
||||
icon = Icons.Outlined.WbSunny,
|
||||
text = stringResource(R.string.day_before_due),
|
||||
selected = selected == DAY_BEFORE_DUE,
|
||||
onClick = { selectedDay(DAY_BEFORE_DUE) },
|
||||
)
|
||||
ShortcutButton(
|
||||
icon = Icons.Outlined.CalendarViewWeek,
|
||||
text = stringResource(R.string.week_before_due),
|
||||
selected = selected == WEEK_BEFORE_DUE,
|
||||
onClick = { selectedDay(WEEK_BEFORE_DUE) },
|
||||
)
|
||||
ShortcutButton(
|
||||
icon = Icons.Outlined.Block,
|
||||
text = stringResource(R.string.no_date),
|
||||
selected = selected == NO_DAY,
|
||||
onClick = { clearDate() },
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun DueDateShortcuts(
|
||||
today: Long,
|
||||
tomorrow: Long,
|
||||
nextWeek: Long,
|
||||
selected: Long,
|
||||
showNoDate: Boolean,
|
||||
selectedDay: (Long) -> Unit,
|
||||
clearDate: () -> Unit,
|
||||
) {
|
||||
var custom by remember { mutableLongStateOf(0) }
|
||||
LaunchedEffect(selected) {
|
||||
custom = if (selected == MULTIPLE_DAYS || selected !in listOf(today, tomorrow, nextWeek, NO_DAY)) {
|
||||
selected
|
||||
} else {
|
||||
custom
|
||||
}
|
||||
}
|
||||
|
||||
if (custom > 0 || custom == MULTIPLE_DAYS) {
|
||||
ShortcutButton(
|
||||
icon = Icons.Outlined.Today,
|
||||
text = if (custom == MULTIPLE_DAYS) {
|
||||
stringResource(R.string.date_picker_multiple)
|
||||
} else {
|
||||
remember(custom) {
|
||||
runBlocking {
|
||||
if (custom < today.minusDays(1)) {
|
||||
getFullDate(custom, style = DateStyle.LONG)
|
||||
} else {
|
||||
getRelativeDay(custom, style = DateStyle.LONG)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
selected = selected == custom,
|
||||
onClick = { selectedDay(custom) },
|
||||
)
|
||||
}
|
||||
ShortcutButton(
|
||||
icon = Icons.Outlined.Today,
|
||||
text = stringResource(R.string.today),
|
||||
selected = selected == today,
|
||||
onClick = { selectedDay(today) },
|
||||
)
|
||||
ShortcutButton(
|
||||
icon = Icons.Outlined.WbSunny,
|
||||
text = stringResource(R.string.tomorrow),
|
||||
selected = selected == tomorrow,
|
||||
onClick = { selectedDay(tomorrow) },
|
||||
)
|
||||
ShortcutButton(
|
||||
icon = Icons.AutoMirrored.Outlined.NextWeek,
|
||||
text = stringResource(
|
||||
remember {
|
||||
when (newDateTime(nextWeek).dayOfWeek) {
|
||||
SUNDAY -> R.string.next_sunday
|
||||
MONDAY -> R.string.next_monday
|
||||
TUESDAY -> R.string.next_tuesday
|
||||
WEDNESDAY -> R.string.next_wednesday
|
||||
THURSDAY -> R.string.next_thursday
|
||||
FRIDAY -> R.string.next_friday
|
||||
SATURDAY -> R.string.next_saturday
|
||||
else -> throw IllegalArgumentException()
|
||||
}
|
||||
}
|
||||
),
|
||||
selected = selected == nextWeek,
|
||||
onClick = { selectedDay(nextWeek) },
|
||||
)
|
||||
if (showNoDate) {
|
||||
ShortcutButton(
|
||||
icon = Icons.Outlined.Block,
|
||||
text = stringResource(R.string.no_date),
|
||||
selected = selected == NO_DAY,
|
||||
onClick = { clearDate() },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun TimeShortcuts(
|
||||
day: Long,
|
||||
selected: Int,
|
||||
morning: Int,
|
||||
afternoon: Int,
|
||||
evening: Int,
|
||||
night: Int,
|
||||
selectedMillisOfDay: (Int) -> Unit,
|
||||
pickTime: () -> Unit,
|
||||
clearTime: () -> Unit,
|
||||
) {
|
||||
var custom by remember { mutableIntStateOf(0) }
|
||||
LaunchedEffect(selected) {
|
||||
custom = if (selected == MULTIPLE_TIMES || selected !in listOf(morning, afternoon, evening, night, NO_TIME)) {
|
||||
selected
|
||||
} else {
|
||||
custom
|
||||
}
|
||||
}
|
||||
|
||||
val is24HourFormat = LocalContext.current.is24HourFormat
|
||||
val now = remember { currentTimeMillis() }
|
||||
if (custom > 0 || custom == MULTIPLE_TIMES) {
|
||||
ShortcutButton(
|
||||
icon = Icons.Outlined.AccessTime,
|
||||
text = if (custom == MULTIPLE_TIMES) {
|
||||
stringResource(R.string.date_picker_multiple)
|
||||
} else {
|
||||
remember(custom) {
|
||||
getTimeString(now.withMillisOfDay(custom), is24HourFormat)
|
||||
}
|
||||
},
|
||||
selected = selected == custom,
|
||||
onClick = { selectedMillisOfDay(custom) },
|
||||
)
|
||||
}
|
||||
ShortcutButton(
|
||||
icon = Icons.Outlined.Coffee,
|
||||
text = remember {
|
||||
getTimeString(now.withMillisOfDay(morning), is24HourFormat)
|
||||
},
|
||||
selected = selected == morning,
|
||||
onClick = { selectedMillisOfDay(morning) },
|
||||
)
|
||||
ShortcutButton(
|
||||
icon = Icons.Outlined.WbSunny,
|
||||
text = remember {
|
||||
getTimeString(now.withMillisOfDay(afternoon), is24HourFormat)
|
||||
},
|
||||
selected = selected == afternoon,
|
||||
onClick = { selectedMillisOfDay(afternoon) },
|
||||
)
|
||||
ShortcutButton(
|
||||
icon = Icons.Outlined.WbTwilight,
|
||||
text = remember {
|
||||
getTimeString(now.withMillisOfDay(evening), is24HourFormat)
|
||||
},
|
||||
selected = selected == evening,
|
||||
onClick = { selectedMillisOfDay(evening) },
|
||||
)
|
||||
ShortcutButton(
|
||||
icon = Icons.Outlined.NightsStay,
|
||||
text = remember {
|
||||
getTimeString(now.withMillisOfDay(night), is24HourFormat)
|
||||
},
|
||||
selected = selected == night,
|
||||
onClick = { selectedMillisOfDay(night) },
|
||||
)
|
||||
ShortcutButton(
|
||||
icon = Icons.Outlined.AccessTime,
|
||||
text = stringResource(R.string.shortcut_pick_time),
|
||||
selected = false,
|
||||
onClick = { pickTime() },
|
||||
)
|
||||
ShortcutButton(
|
||||
icon = Icons.Outlined.Block,
|
||||
text = stringResource(R.string.no_time),
|
||||
selected = day != DUE_TIME && selected == NO_TIME,
|
||||
onClick = { clearTime() },
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ShortcutButton(
|
||||
icon: ImageVector,
|
||||
text: String,
|
||||
selected: Boolean,
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
val color =
|
||||
if (selected) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurface
|
||||
TextButton(
|
||||
onClick = { onClick() },
|
||||
colors = ButtonDefaults.textButtonColors(contentColor = color)
|
||||
) {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Image(
|
||||
imageVector = icon,
|
||||
contentDescription = null,
|
||||
colorFilter = ColorFilter.tint(color)
|
||||
)
|
||||
Text(
|
||||
text = text,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,139 @@
|
||||
package org.tasks.compose.pickers
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Keyboard
|
||||
import androidx.compose.material.icons.outlined.Schedule
|
||||
import androidx.compose.material3.BasicAlertDialog
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TimeInput
|
||||
import androidx.compose.material3.TimePicker
|
||||
import androidx.compose.material3.TimePickerDefaults
|
||||
import androidx.compose.material3.TimePickerLayoutType
|
||||
import androidx.compose.material3.rememberTimePickerState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import org.tasks.R
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun TimePickerDialog(
|
||||
millisOfDay: Int,
|
||||
is24Hour: Boolean,
|
||||
textInput: Boolean,
|
||||
selected: (Int) -> Unit,
|
||||
dismiss: () -> Unit,
|
||||
) {
|
||||
val state = rememberTimePickerState(
|
||||
initialHour = millisOfDay / (60 * 60_000),
|
||||
initialMinute = (millisOfDay / (60_000)) % 60,
|
||||
is24Hour = is24Hour
|
||||
)
|
||||
var showingTextInput by remember { mutableStateOf(textInput) }
|
||||
val layoutType = with(LocalConfiguration.current) {
|
||||
if (screenHeightDp < screenWidthDp) {
|
||||
TimePickerLayoutType.Horizontal
|
||||
} else {
|
||||
TimePickerLayoutType.Vertical
|
||||
}
|
||||
}
|
||||
BasicAlertDialog(
|
||||
onDismissRequest = { dismiss() },
|
||||
properties = DialogProperties(usePlatformDefaultWidth = layoutType == TimePickerLayoutType.Vertical)
|
||||
) {
|
||||
Surface(
|
||||
shape = RoundedCornerShape(28.0.dp),
|
||||
color = MaterialTheme.colorScheme.surface,
|
||||
) {
|
||||
Column(verticalArrangement = Arrangement.SpaceBetween) {
|
||||
// Wrap the content with a Box and Modifier.weight(1f) to ensure that any "confirm"
|
||||
// and "dismiss" buttons are not pushed out of view when running on small screens,
|
||||
// or when nesting a DateRangePicker.
|
||||
// Fill is false to support collapsing the dialog's height when switching to input
|
||||
// mode.
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 32.dp)
|
||||
.weight(1f, fill = false),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
if (showingTextInput) {
|
||||
TimeInput(
|
||||
state = state,
|
||||
colors = TimePickerDefaults.colors(
|
||||
timeSelectorSelectedContainerColor = MaterialTheme.colorScheme.primary,
|
||||
timeSelectorSelectedContentColor = MaterialTheme.colorScheme.onPrimary,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
TimePicker(
|
||||
state = state,
|
||||
layoutType = layoutType,
|
||||
colors = TimePickerDefaults.colors(
|
||||
timeSelectorSelectedContainerColor = MaterialTheme.colorScheme.primary,
|
||||
timeSelectorSelectedContentColor = MaterialTheme.colorScheme.onPrimary,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
// Buttons
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(start = 6.dp, bottom = 8.dp, end = 6.dp)
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
IconButton(
|
||||
onClick = { showingTextInput = !showingTextInput },
|
||||
) {
|
||||
Icon(
|
||||
imageVector = if (showingTextInput) {
|
||||
Icons.Outlined.Schedule
|
||||
} else {
|
||||
Icons.Outlined.Keyboard
|
||||
},
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
TextButton(onClick = dismiss) {
|
||||
Text(text = stringResource(id = R.string.cancel))
|
||||
}
|
||||
TextButton(
|
||||
onClick = {
|
||||
selected(state.hour * 60 * 60_000 + state.minute * 60_000)
|
||||
dismiss()
|
||||
}
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.ok))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:alpha="1.00" android:color="?attr/colorAccent" android:state_checkable="true" android:state_checked="true" android:state_enabled="true"/>
|
||||
<item android:alpha="0.60" android:color="?attr/colorOnSurface" android:state_checkable="true" android:state_checked="false" android:state_enabled="true"/>
|
||||
<item android:alpha="1.00" android:color="?attr/colorAccent" android:state_enabled="true"/>
|
||||
<item android:alpha="0.38" android:color="?attr/colorOnSurface"/>
|
||||
</selector>
|
||||
@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2020 The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="?attr/colorOnSecondary" android:state_selected="true" />
|
||||
<item android:color="?attr/colorOnSurface" />
|
||||
</selector>
|
||||
@ -1,148 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<com.google.android.material.button.MaterialButtonToggleGroup
|
||||
android:id="@+id/date_group"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/half_keyline_first"
|
||||
android:layout_marginBottom="@dimen/half_keyline_first"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@id/guideline"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_max="wrap"
|
||||
app:layout_constraintWidth_percent="0.5"
|
||||
app:singleSelection="true"
|
||||
android:layout_marginStart="16dp">
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/current_date_selection"
|
||||
style="@style/DateTimeShortcuts"
|
||||
tools:text="Nov 24, 2021"
|
||||
android:visibility="gone"
|
||||
app:icon="@drawable/ic_outline_today_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/today_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
android:text="@string/today"
|
||||
app:icon="@drawable/ic_calendar_today_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/tomorrow_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
android:text="@string/tomorrow"
|
||||
app:icon="@drawable/ic_outline_wb_sunny_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/today_button" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/next_week_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
tools:text="Next Thurs"
|
||||
app:icon="@drawable/ic_next_week_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tomorrow_button" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/no_date_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
android:text="@string/no_date"
|
||||
app:icon="@drawable/ic_outline_not_interested_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/next_week_button" />
|
||||
</com.google.android.material.button.MaterialButtonToggleGroup>
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/guideline"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintGuide_percent="0.5" />
|
||||
|
||||
<com.google.android.material.button.MaterialButtonToggleGroup
|
||||
android:id="@+id/time_group"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/half_keyline_first"
|
||||
android:layout_marginBottom="@dimen/half_keyline_first"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintLeft_toRightOf="@id/guideline"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_max="wrap"
|
||||
app:layout_constraintWidth_percent="0.5"
|
||||
app:selectionRequired="true"
|
||||
app:singleSelection="true"
|
||||
android:layout_marginEnd="16dp">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/current_time_selection"
|
||||
style="@style/DateTimeShortcuts"
|
||||
app:icon="@drawable/ic_outline_schedule_24px"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="08:15" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/morning_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
tools:text="9 AM"
|
||||
app:icon="@drawable/ic_local_cafe_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/afternoon_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
android:layout_marginTop="1dp"
|
||||
tools:text="1 PM"
|
||||
app:icon="@drawable/ic_outline_wb_sunny_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/morning_button" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/evening_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
tools:text="5 PM"
|
||||
app:icon="@drawable/ic_weather_sunset"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/afternoon_button" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/night_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
tools:text="8 PM"
|
||||
app:icon="@drawable/ic_nights_stay_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/evening_button" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/pick_time_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
android:text="@string/shortcut_pick_time"
|
||||
app:icon="@drawable/ic_outline_schedule_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/evening_button" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/no_time"
|
||||
style="@style/DateTimeShortcuts"
|
||||
android:text="@string/no_time"
|
||||
app:icon="@drawable/ic_outline_not_interested_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/night_button" />
|
||||
</com.google.android.material.button.MaterialButtonToggleGroup>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/dialog_background"
|
||||
android:paddingBottom="@dimen/keyline_first">
|
||||
|
||||
<include
|
||||
layout="@layout/date_time_picker_shortcuts"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/shortcuts" />
|
||||
|
||||
<CalendarView
|
||||
android:id="@+id/calendar_view"
|
||||
android:layout_below="@id/shortcuts"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
@ -1,43 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/dialog_background">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end">
|
||||
|
||||
<View
|
||||
style="@style/horizontal_divider"
|
||||
android:id="@+id/divider"
|
||||
android:background="@color/divider"
|
||||
android:layout_alignParentTop="true" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/Widget.Material3.Button.TextButton"
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:id="@+id/ok_button"
|
||||
android:text="@string/ok"
|
||||
android:layout_below="@id/divider"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/Widget.Material3.Button.TextButton"
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:layout_below="@id/divider"
|
||||
android:id="@+id/cancel_button"
|
||||
android:text="@string/cancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="@dimen/keyline_first"
|
||||
android:paddingEnd="@dimen/keyline_first"
|
||||
android:layout_toStartOf="@id/ok_button" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
</FrameLayout>
|
||||
@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/keyline_first">
|
||||
|
||||
<include
|
||||
layout="@layout/start_date_picker_shortcuts"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/shortcuts" />
|
||||
|
||||
<CalendarView
|
||||
android:id="@+id/calendar_view"
|
||||
android:layout_below="@id/shortcuts"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
@ -1,149 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<com.google.android.material.button.MaterialButtonToggleGroup
|
||||
android:id="@+id/date_group"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/half_keyline_first"
|
||||
android:layout_marginBottom="@dimen/half_keyline_first"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@id/guideline"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_max="wrap"
|
||||
app:layout_constraintWidth_percent="0.5"
|
||||
app:singleSelection="true"
|
||||
android:layout_marginStart="16dp">
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/current_date_selection"
|
||||
style="@style/DateTimeShortcuts"
|
||||
tools:text="Nov 24, 2021"
|
||||
android:visibility="gone"
|
||||
app:icon="@drawable/ic_outline_today_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/due_date_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
android:text="@string/due_date"
|
||||
app:icon="@drawable/ic_calendar_today_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/due_time_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
app:icon="@drawable/ic_outline_schedule_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:text="@string/due_time" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/day_before_due_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
android:text="@string/day_before_due"
|
||||
app:icon="@drawable/ic_outline_wb_sunny_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/due_date_button" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/week_before_due_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
app:icon="@drawable/ic_date_range_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/day_before_due_button"
|
||||
android:text="@string/week_before_due" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/no_date_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
android:text="@string/no_date"
|
||||
app:icon="@drawable/ic_outline_not_interested_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/week_before_due_button" />
|
||||
</com.google.android.material.button.MaterialButtonToggleGroup>
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/guideline"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintGuide_percent="0.5" />
|
||||
|
||||
<com.google.android.material.button.MaterialButtonToggleGroup
|
||||
android:id="@+id/time_group"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/half_keyline_first"
|
||||
android:layout_marginBottom="@dimen/half_keyline_first"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintLeft_toRightOf="@id/guideline"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_max="wrap"
|
||||
app:layout_constraintWidth_percent="0.5"
|
||||
app:selectionRequired="true"
|
||||
app:singleSelection="true"
|
||||
android:layout_marginEnd="16dp">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/current_time_selection"
|
||||
style="@style/DateTimeShortcuts"
|
||||
app:icon="@drawable/ic_outline_schedule_24px"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:visibility="visible"
|
||||
tools:text="08:15" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/morning_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
tools:text="9 AM"
|
||||
app:icon="@drawable/ic_local_cafe_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"/>
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/afternoon_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
android:layout_marginTop="1dp"
|
||||
tools:text="1 PM"
|
||||
app:icon="@drawable/ic_outline_wb_sunny_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"/>
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/evening_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
tools:text="5 PM"
|
||||
app:icon="@drawable/ic_weather_sunset"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/night_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
tools:text="8 PM"
|
||||
app:icon="@drawable/ic_nights_stay_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/pick_time_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
android:text="@string/shortcut_pick_time"
|
||||
app:icon="@drawable/ic_outline_schedule_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/no_time"
|
||||
style="@style/DateTimeShortcuts"
|
||||
android:text="@string/no_time"
|
||||
app:icon="@drawable/ic_outline_not_interested_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
</com.google.android.material.button.MaterialButtonToggleGroup>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Loading…
Reference in New Issue