OK cancel button color

This commit is contained in:
osodebailar 2022-04-19 22:36:12 +02:00
parent a49ed949fc
commit b0e0feb29a
5 changed files with 32 additions and 3 deletions

View file

@ -151,6 +151,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
binding.date.setOnClickListener {
MaterialDatePicker.Builder.datePicker()
.setSelection(dateUtil.timeStampToUtcDateMilis(overviewData.fromTime))
.setTheme(R.style.DatePicker)
.build()
.apply {
addOnPositiveButtonClickListener { selection ->

View file

@ -3,11 +3,11 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import android.content.Context
import android.graphics.Typeface
import android.text.format.DateFormat
import android.view.ContextThemeWrapper
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import android.view.ContextThemeWrapper
import androidx.fragment.app.FragmentManager
import com.google.android.material.datepicker.MaterialDatePicker
import com.google.android.material.timepicker.MaterialTimePicker
@ -39,6 +39,7 @@ class InputDateTime(private val rh: ResourceHelper, private val dateUtil: DateUt
setOnClickListener {
getFragmentManager(root.context)?.let { fm ->
MaterialDatePicker.Builder.datePicker()
.setTheme(R.style.DatePicker)
.setSelection(dateUtil.timeStampToUtcDateMilis(value))
.build()
.apply {
@ -60,6 +61,7 @@ class InputDateTime(private val rh: ResourceHelper, private val dateUtil: DateUt
val cal = Calendar.getInstance().apply { timeInMillis = value }
val clockFormat = if (DateFormat.is24HourFormat(context)) TimeFormat.CLOCK_24H else TimeFormat.CLOCK_12H
val timePicker = MaterialTimePicker.Builder()
.setTheme(R.style.TimePicker)
.setTimeFormat(clockFormat)
.setHour(cal.get(Calendar.HOUR_OF_DAY))
.setMinute(cal.get(Calendar.MINUTE))
@ -78,9 +80,9 @@ class InputDateTime(private val rh: ResourceHelper, private val dateUtil: DateUt
private fun getFragmentManager(context: Context?): FragmentManager? {
return when (context) {
is AppCompatActivity -> context.supportFragmentManager
is AppCompatActivity -> context.supportFragmentManager
is ContextThemeWrapper -> getFragmentManager(context.baseContext)
else -> null
else -> null
}
}
}

View file

@ -83,6 +83,7 @@ abstract class DialogFragmentWithDate : DaggerDialogFragment() {
eventDateView?.setOnClickListener {
val selection = dateUtil.timeStampToUtcDateMilis(eventTime)
MaterialDatePicker.Builder.datePicker()
.setTheme(R.style.DatePicker)
.setSelection(selection)
.build()
.apply {
@ -105,6 +106,7 @@ abstract class DialogFragmentWithDate : DaggerDialogFragment() {
.setTimeFormat(clockFormat)
.setHour(cal.get(Calendar.HOUR_OF_DAY))
.setMinute(cal.get(Calendar.MINUTE))
.setTheme(R.style.TimePicker)
.build()
timePicker.addOnPositiveButtonClickListener {
// Randomize seconds to prevent creating record of the same time, if user choose time manually

View file

@ -239,6 +239,8 @@
<item name="separatorColor">@color/sphere_plastic_grey</item>
<item name="isCompletedColor">@color/isCompleted</item>
<item name="isNotCompletedColor">@color/isNotCompleted</item>
<item name="materialCalendarStyle">@style/DatePicker</item>
<item name="materialTimePickerStyle">@style/DatePicker</item>
</style>
<style name="Aaps_ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar">
@ -269,6 +271,17 @@
<item name="dialogTitleBackground">@color/dialog_title_background</item>
</style>
<!-- Style for Material Date Picker -->
<style name="DatePicker" parent="@style/ThemeOverlay.MaterialComponents.MaterialCalendar">
<item name="buttonBarPositiveButtonStyle">@style/PickerTextButton</item>
<item name="buttonBarNegativeButtonStyle">@style/PickerTextButton</item>
</style>
<!-- Style for Material Time Picker -->
<style name="TimePicker" parent="ThemeOverlay.MaterialComponents.TimePicker">
<item name="buttonStyle">@style/PickerTextButton</item>
</style>
<!-- Buttons from MaterialDateTimePicker, Dialogs ... -->
<dimen name="material_button_height">48dp</dimen>
<dimen name="material_button_text_size">14sp</dimen>

View file

@ -272,6 +272,17 @@
<item name="dialogTitleBackground">@color/dialog_title_background</item>
</style>
<!-- Style for Material Date Picker -->
<style name="DatePicker" parent="@style/ThemeOverlay.MaterialComponents.MaterialCalendar">
<item name="buttonBarPositiveButtonStyle">@style/PickerTextButton</item>
<item name="buttonBarNegativeButtonStyle">@style/PickerTextButton</item>
</style>
<!-- Style for Material Time Picker -->
<style name="TimePicker" parent="ThemeOverlay.MaterialComponents.TimePicker">
<item name="buttonStyle">@style/PickerTextButton</item>
</style>
<!-- Buttons from MaterialDateTimePicker, Dialogs ... -->
<dimen name="material_button_height">48dp</dimen>
<dimen name="material_button_text_size">14sp</dimen>