mirror of https://github.com/tasks/tasks
New due date picker
parent
5078cd2d15
commit
84f0842449
@ -0,0 +1,264 @@
|
||||
package org.tasks.dialogs
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Activity.RESULT_OK
|
||||
import android.app.Dialog
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import butterknife.ButterKnife
|
||||
import butterknife.OnClick
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.todoroo.andlib.utility.AndroidUtilities
|
||||
import com.todoroo.andlib.utility.AndroidUtilities.atLeastMarshmallow
|
||||
import com.todoroo.andlib.utility.DateUtilities
|
||||
import com.todoroo.astrid.data.Task
|
||||
import org.tasks.R
|
||||
import org.tasks.databinding.DialogDateTimePickerBinding
|
||||
import org.tasks.date.DateTimeUtils.newDateTime
|
||||
import org.tasks.dialogs.MyDatePickerDialog.newDatePicker
|
||||
import org.tasks.dialogs.MyTimePickerDialog.newTimePicker
|
||||
import org.tasks.injection.DialogFragmentComponent
|
||||
import org.tasks.injection.InjectingBottomSheetDialogFragment
|
||||
import org.tasks.locale.Locale
|
||||
import org.tasks.preferences.Preferences
|
||||
import org.tasks.time.DateTime
|
||||
import org.threeten.bp.format.FormatStyle
|
||||
import javax.inject.Inject
|
||||
|
||||
class DateTimePicker : InjectingBottomSheetDialogFragment() {
|
||||
|
||||
@Inject lateinit var activity: Activity
|
||||
@Inject lateinit var preferences: Preferences
|
||||
@Inject lateinit var locale: Locale
|
||||
|
||||
lateinit var binding: DialogDateTimePickerBinding
|
||||
private var selected: DateTime? = null
|
||||
private val today = newDateTime().startOfDay()
|
||||
private val tomorrow = today.plusDays(1)
|
||||
private val nextWeek = today.plusDays(7)
|
||||
private var morning = 32401000
|
||||
private var afternoon = 46801000
|
||||
private var evening = 61201000
|
||||
private var night = 72001000
|
||||
|
||||
companion object {
|
||||
const val EXTRA_TIMESTAMP = "extra_timestamp"
|
||||
private const val EXTRA_SELECTED = "extra_selected"
|
||||
private const val REQUEST_TIME = 10101
|
||||
private const val REQUEST_DATE = 10102
|
||||
private const val FRAG_TAG_TIME_PICKER = "frag_tag_time_picker"
|
||||
private const val FRAG_TAG_DATE_PICKER = "frag_tag_date_picker"
|
||||
|
||||
fun newDateTimePicker(target: Fragment, rc: Int, current: Long): DateTimePicker {
|
||||
val bundle = Bundle()
|
||||
bundle.putLong(EXTRA_TIMESTAMP, current)
|
||||
val fragment = DateTimePicker()
|
||||
fragment.arguments = bundle
|
||||
fragment.setTargetFragment(target, rc)
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
binding = DialogDateTimePickerBinding.inflate(inflater)
|
||||
if (AndroidUtilities.preMarshmallow()) {
|
||||
binding.shortcuts.pickDateButton.visibility = View.VISIBLE
|
||||
}
|
||||
morning = preferences.dateShortcutMorning + 1000
|
||||
afternoon = preferences.dateShortcutAfternoon + 1000
|
||||
evening = preferences.dateShortcutEvening + 1000
|
||||
night = preferences.dateShortcutNight + 1000
|
||||
binding.shortcuts.morningButton.text = DateUtilities.getTimeString(context, newDateTime().withMillisOfDay(morning))
|
||||
binding.shortcuts.afternoonButton.text = DateUtilities.getTimeString(context, newDateTime().withMillisOfDay(afternoon))
|
||||
binding.shortcuts.eveningButton.text = DateUtilities.getTimeString(context, newDateTime().withMillisOfDay(evening))
|
||||
binding.shortcuts.nightButton.text = DateUtilities.getTimeString(context, newDateTime().withMillisOfDay(night))
|
||||
ButterKnife.bind(this, binding.root)
|
||||
binding.shortcuts.nextWeekButton.text =
|
||||
getString(R.string.next, DateUtilities.getWeekdayShort(newDateTime().plusWeeks(1), locale.locale))
|
||||
if (atLeastMarshmallow()) {
|
||||
binding.calendarView.setOnDateChangeListener { _, y, m, d ->
|
||||
selected = DateTime(y, m + 1, d, selected?.hourOfDay ?: 0, selected?.minuteOfHour
|
||||
?: 0, selected?.secondOfMinute ?: 0)
|
||||
returnDate(selected!!.millis)
|
||||
refreshButtons()
|
||||
}
|
||||
val firstDayOfWeek = preferences.firstDayOfWeek
|
||||
if (firstDayOfWeek in 1..7) {
|
||||
binding.calendarView.firstDayOfWeek = firstDayOfWeek
|
||||
}
|
||||
}
|
||||
val timestamp = savedInstanceState?.getLong(EXTRA_SELECTED, -1)
|
||||
?: arguments!!.getLong(EXTRA_TIMESTAMP)
|
||||
selected = if (timestamp > 0) DateTime(timestamp) else null
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
refreshButtons()
|
||||
}
|
||||
|
||||
private fun refreshButtons() {
|
||||
when (selected?.startOfDay()) {
|
||||
null -> binding.shortcuts.dateGroup.check(R.id.no_date_button)
|
||||
today -> binding.shortcuts.dateGroup.check(R.id.today_button)
|
||||
tomorrow -> binding.shortcuts.dateGroup.check(R.id.tomorrow_button)
|
||||
nextWeek -> binding.shortcuts.dateGroup.check(R.id.next_week_button)
|
||||
else -> {
|
||||
binding.shortcuts.dateGroup.check(R.id.current_date_selection)
|
||||
binding.shortcuts.currentDateSelection.visibility = View.VISIBLE
|
||||
binding.shortcuts.currentDateSelection.text =
|
||||
DateUtilities.getRelativeDay(context, selected!!.millis, locale.locale, FormatStyle.MEDIUM)
|
||||
}
|
||||
}
|
||||
if (Task.hasDueTime(selected?.millis ?: 0)) {
|
||||
when (selected?.millisOfDay) {
|
||||
morning -> binding.shortcuts.timeGroup.check(R.id.morning_button)
|
||||
afternoon -> binding.shortcuts.timeGroup.check(R.id.afternoon_button)
|
||||
evening -> binding.shortcuts.timeGroup.check(R.id.evening_button)
|
||||
night -> binding.shortcuts.timeGroup.check(R.id.night_button)
|
||||
else -> {
|
||||
binding.shortcuts.timeGroup.check(R.id.current_time_selection)
|
||||
binding.shortcuts.currentTimeSelection.visibility = View.VISIBLE
|
||||
binding.shortcuts.currentTimeSelection.text = DateUtilities.getTimeString(context, selected)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
binding.shortcuts.timeGroup.check(R.id.no_time)
|
||||
}
|
||||
if (atLeastMarshmallow() && selected != null) {
|
||||
binding.calendarView.setDate(selected!!.millis, false, true)
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.no_date_button)
|
||||
fun clearDate() = returnDate(0)
|
||||
|
||||
@OnClick(R.id.no_time)
|
||||
fun clearTime() = returnDate(selected?.startOfDay()?.millis ?: 0)
|
||||
|
||||
@OnClick(R.id.today_button)
|
||||
fun setToday() = returnDate(today.withMillisOfDay(selected?.millisOfDay ?: 0))
|
||||
|
||||
@OnClick(R.id.tomorrow_button)
|
||||
fun setTomorrow() = returnDate(tomorrow.withMillisOfDay(selected?.millisOfDay ?: 0))
|
||||
|
||||
@OnClick(R.id.next_week_button)
|
||||
fun setNextWeek() = returnDate(nextWeek.withMillisOfDay(selected?.millisOfDay ?: 0))
|
||||
|
||||
@OnClick(R.id.morning_button)
|
||||
fun setMorning() = returnSelectedTime(morning)
|
||||
|
||||
@OnClick(R.id.afternoon_button)
|
||||
fun setAfternoon() = returnSelectedTime(afternoon)
|
||||
|
||||
@OnClick(R.id.evening_button)
|
||||
fun setEvening() = returnSelectedTime(evening)
|
||||
|
||||
@OnClick(R.id.night_button)
|
||||
fun setNight() = returnSelectedTime(night)
|
||||
|
||||
@OnClick(R.id.current_date_selection)
|
||||
fun currentDate() = dismiss()
|
||||
|
||||
@OnClick(R.id.current_time_selection)
|
||||
fun currentTime() = dismiss()
|
||||
|
||||
@OnClick(R.id.pick_time_button)
|
||||
fun pickTime() {
|
||||
newTimePicker(this, REQUEST_TIME, selected?.millis ?: today.noon().millis)
|
||||
.show(parentFragmentManager, FRAG_TAG_TIME_PICKER)
|
||||
}
|
||||
|
||||
@OnClick(R.id.pick_date_button)
|
||||
fun pickDate() {
|
||||
newDatePicker(this, REQUEST_DATE, selected?.millis ?: today.millis)
|
||||
.show(parentFragmentManager, FRAG_TAG_DATE_PICKER)
|
||||
}
|
||||
|
||||
private fun returnSelectedTime(millisOfDay: Int) {
|
||||
if (selected == null) {
|
||||
selected = today.withMillisOfDay(millisOfDay)
|
||||
if (selected!!.isBeforeNow) {
|
||||
selected = selected!!.plusDays(1)
|
||||
}
|
||||
} else {
|
||||
selected = selected!!.withMillisOfDay(millisOfDay)
|
||||
}
|
||||
returnDate(selected!!.millis)
|
||||
}
|
||||
|
||||
private fun returnDate(dt: DateTime? = selected) = returnDate(dt?.millis ?: 0)
|
||||
|
||||
private fun returnDate(date: Long? = selected?.millis) {
|
||||
selected = if (date == null || date <= 0) null else DateTime(date)
|
||||
targetFragment?.onActivityResult(targetRequestCode, RESULT_OK, Intent().putExtra(EXTRA_TIMESTAMP, selected?.millis ?: 0))
|
||||
dismiss()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
|
||||
outState.putSerializable(EXTRA_SELECTED, selected?.millis)
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val bottomSheetDialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
|
||||
|
||||
bottomSheetDialog.setOnShowListener {
|
||||
val coordinator = (it as BottomSheetDialog)
|
||||
.findViewById<CoordinatorLayout>(com.google.android.material.R.id.coordinator)
|
||||
val containerLayout =
|
||||
it.findViewById<FrameLayout>(com.google.android.material.R.id.container)
|
||||
val buttons = bottomSheetDialog.layoutInflater.inflate(R.layout.dialog_date_time_picker_buttons, null)
|
||||
buttons.findViewById<View>(R.id.cancel_button).setOnClickListener { dismiss() }
|
||||
buttons.findViewById<View>(R.id.ok_button).setOnClickListener { dismiss() }
|
||||
buttons.layoutParams = FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM
|
||||
).apply {
|
||||
gravity = Gravity.BOTTOM
|
||||
}
|
||||
containerLayout!!.addView(buttons)
|
||||
|
||||
buttons.post {
|
||||
(coordinator!!.layoutParams as ViewGroup.MarginLayoutParams).apply {
|
||||
buttons.measure(
|
||||
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
|
||||
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
|
||||
)
|
||||
this.bottomMargin = buttons.measuredHeight
|
||||
containerLayout.requestLayout()
|
||||
}
|
||||
}
|
||||
}
|
||||
return bottomSheetDialog
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (requestCode == REQUEST_TIME) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
val timestamp = data!!.getLongExtra(MyTimePickerDialog.EXTRA_TIMESTAMP, today.millis)
|
||||
returnSelectedTime(newDateTime(timestamp).millisOfDay + 1000)
|
||||
}
|
||||
} else if (requestCode == REQUEST_DATE) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
val timestamp = data!!.getLongExtra(MyDatePickerDialog.EXTRA_TIMESTAMP, today.millis)
|
||||
returnDate(timestamp)
|
||||
}
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
}
|
||||
}
|
||||
|
||||
override fun inject(component: DialogFragmentComponent) = component.inject(this)
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import android.app.Activity;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
|
||||
public abstract class InjectingBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||
|
||||
private boolean injected;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
|
||||
if (!injected) {
|
||||
inject(((InjectingActivity) activity).getComponent().plus(new DialogFragmentModule(this)));
|
||||
injected = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void inject(DialogFragmentComponent component);
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M20,3h-1L19,1h-2v2L7,3L7,1L5,1v2L4,3c-1.1,0 -2,0.9 -2,2v16c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,5c0,-1.1 -0.9,-2 -2,-2zM20,21L4,21L4,10h16v11zM20,8L4,8L4,5h16v3z"/>
|
||||
</vector>
|
@ -0,0 +1,5 @@
|
||||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M16,5v8c0,1.1 -0.9,2 -2,2L8,15c-1.1,0 -2,-0.9 -2,-2L6,5h10m4,-2L4,3v10c0,2.21 1.79,4 4,4h6c2.21,0 4,-1.79 4,-4v-3h2c1.11,0 2,-0.89 2,-2L22,5c0,-1.11 -0.89,-2 -2,-2zM18,8L18,5h2v3h-2zM20,19L2,19v2h18v-2z"/>
|
||||
</vector>
|
@ -0,0 +1,5 @@
|
||||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M11,18.5l4,-4 -4,-4 -1,1 3,3 -3,3zM20,7h-4L16,5c0,-0.55 -0.22,-1.05 -0.59,-1.41C15.05,3.22 14.55,3 14,3h-4c-1.1,0 -2,0.9 -2,2v2L4,7c-1.1,0 -2,0.9 -2,2v11c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,9c0,-1.1 -0.9,-2 -2,-2zM10,5h4v2h-4L10,5zM20,20L4,20L4,9h16v11z"/>
|
||||
</vector>
|
@ -0,0 +1,6 @@
|
||||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M19.78,17.51c-2.47,0 -6.57,-1.33 -8.68,-5.43C8.77,7.57 10.6,3.6 11.63,2.01C6.27,2.2 1.98,6.59 1.98,12c0,0.14 0.02,0.28 0.02,0.42C2.61,12.16 3.28,12 3.98,12c0,0 0,0 0,0c0,-3.09 1.73,-5.77 4.3,-7.1C7.78,7.09 7.74,9.94 9.32,13c1.57,3.04 4.18,4.95 6.8,5.86c-1.23,0.74 -2.65,1.15 -4.13,1.15c-0.5,0 -1,-0.05 -1.48,-0.14c-0.37,0.7 -0.94,1.27 -1.64,1.64c0.98,0.32 2.03,0.5 3.11,0.5c3.5,0 6.58,-1.8 8.37,-4.52C20.18,17.5 19.98,17.51 19.78,17.51z"/>
|
||||
<path android:fillColor="#FF000000" android:pathData="M7,16l-0.18,0C6.4,14.84 5.3,14 4,14c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.62,0 2.49,0 3,0c1.1,0 2,-0.9 2,-2C9,16.9 8.1,16 7,16z"/>
|
||||
</vector>
|
@ -0,0 +1,5 @@
|
||||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M20,12c0,-1.1 -0.9,-2 -2,-2V7c0,-1.1 -0.9,-2 -2,-2H8C6.9,5 6,5.9 6,7v3c-1.1,0 -2,0.9 -2,2v5h1.33L6,19h1l0.67,-2h8.67L17,19h1l0.67,-2H20V12zM16,10h-3V7h3V10zM8,7h3v3H8V7zM6,12h12v3H6V12z"/>
|
||||
</vector>
|
@ -0,0 +1,5 @@
|
||||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M3,12H7A5,5 0,0 1,12 7A5,5 0,0 1,17 12H21A1,1 0,0 1,22 13A1,1 0,0 1,21 14H3A1,1 0,0 1,2 13A1,1 0,0 1,3 12M5,16H19A1,1 0,0 1,20 17A1,1 0,0 1,19 18H5A1,1 0,0 1,4 17A1,1 0,0 1,5 16M17,20A1,1 0,0 1,18 21A1,1 0,0 1,17 22H7A1,1 0,0 1,6 21A1,1 0,0 1,7 20H17M15,12A3,3 0,0 0,12 9A3,3 0,0 0,9 12H15M12,2L14.39,5.42C13.65,5.15 12.84,5 12,5C11.16,5 10.35,5.15 9.61,5.42L12,2M3.34,7L7.5,6.65C6.9,7.16 6.36,7.78 5.94,8.5C5.5,9.24 5.25,10 5.11,10.79L3.34,7M20.65,7L18.88,10.79C18.74,10 18.47,9.23 18.05,8.5C17.63,7.78 17.1,7.15 16.5,6.64L20.65,7Z"/>
|
||||
</vector>
|
@ -1,32 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/due_date"
|
||||
style="@style/TaskEditTextPrimary"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:hint="@string/no_due_date"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="DisableBaselineAlignment">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="100"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/due_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"/>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/due_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dp"
|
||||
android:background="@null"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/control_set_clear_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
android:textAlignment="viewStart" />
|
||||
|
@ -0,0 +1,159 @@
|
||||
<?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="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@id/guideline"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
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/pick_date_button"
|
||||
style="@style/DateTimeShortcuts"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/shortcut_pick_date"
|
||||
android:visibility="gone"
|
||||
app:icon="@drawable/ic_outline_today_24px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/next_week_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/pick_date_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.60" />
|
||||
|
||||
<com.google.android.material.button.MaterialButtonToggleGroup
|
||||
android:id="@+id/time_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintLeft_toRightOf="@id/guideline"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
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>
|
@ -0,0 +1,30 @@
|
||||
<?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"
|
||||
android:background="@color/dialog_background">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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"
|
||||
android:visibility="@integer/calendar_view_visible"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
@ -0,0 +1,45 @@
|
||||
<?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.MaterialComponents.Button.TextButton"
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:id="@+id/ok_button"
|
||||
android:text="@android:string/ok"
|
||||
android:layout_below="@id/divider"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:layout_below="@id/divider"
|
||||
android:id="@+id/cancel_button"
|
||||
android:text="@android:string/cancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toLeftOf="@id/ok_button"
|
||||
android:paddingEnd="@dimen/keyline_first"
|
||||
android:paddingRight="@dimen/keyline_first"
|
||||
android:layout_toStartOf="@id/ok_button" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
</FrameLayout>
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<integer name="calendar_view_visible">0</integer> <!-- View.VISIBLE -->
|
||||
</resources>
|
Loading…
Reference in New Issue