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 { binding.date.setOnClickListener {
MaterialDatePicker.Builder.datePicker() MaterialDatePicker.Builder.datePicker()
.setSelection(dateUtil.timeStampToUtcDateMilis(overviewData.fromTime)) .setSelection(dateUtil.timeStampToUtcDateMilis(overviewData.fromTime))
.setTheme(R.style.DatePicker)
.build() .build()
.apply { .apply {
addOnPositiveButtonClickListener { selection -> addOnPositiveButtonClickListener { selection ->

View file

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

View file

@ -83,6 +83,7 @@ abstract class DialogFragmentWithDate : DaggerDialogFragment() {
eventDateView?.setOnClickListener { eventDateView?.setOnClickListener {
val selection = dateUtil.timeStampToUtcDateMilis(eventTime) val selection = dateUtil.timeStampToUtcDateMilis(eventTime)
MaterialDatePicker.Builder.datePicker() MaterialDatePicker.Builder.datePicker()
.setTheme(R.style.DatePicker)
.setSelection(selection) .setSelection(selection)
.build() .build()
.apply { .apply {
@ -105,6 +106,7 @@ abstract class DialogFragmentWithDate : DaggerDialogFragment() {
.setTimeFormat(clockFormat) .setTimeFormat(clockFormat)
.setHour(cal.get(Calendar.HOUR_OF_DAY)) .setHour(cal.get(Calendar.HOUR_OF_DAY))
.setMinute(cal.get(Calendar.MINUTE)) .setMinute(cal.get(Calendar.MINUTE))
.setTheme(R.style.TimePicker)
.build() .build()
timePicker.addOnPositiveButtonClickListener { timePicker.addOnPositiveButtonClickListener {
// Randomize seconds to prevent creating record of the same time, if user choose time manually // 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="separatorColor">@color/sphere_plastic_grey</item>
<item name="isCompletedColor">@color/isCompleted</item> <item name="isCompletedColor">@color/isCompleted</item>
<item name="isNotCompletedColor">@color/isNotCompleted</item> <item name="isNotCompletedColor">@color/isNotCompleted</item>
<item name="materialCalendarStyle">@style/DatePicker</item>
<item name="materialTimePickerStyle">@style/DatePicker</item>
</style> </style>
<style name="Aaps_ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar"> <style name="Aaps_ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar">
@ -269,6 +271,17 @@
<item name="dialogTitleBackground">@color/dialog_title_background</item> <item name="dialogTitleBackground">@color/dialog_title_background</item>
</style> </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 ... --> <!-- Buttons from MaterialDateTimePicker, Dialogs ... -->
<dimen name="material_button_height">48dp</dimen> <dimen name="material_button_height">48dp</dimen>
<dimen name="material_button_text_size">14sp</dimen> <dimen name="material_button_text_size">14sp</dimen>

View file

@ -272,6 +272,17 @@
<item name="dialogTitleBackground">@color/dialog_title_background</item> <item name="dialogTitleBackground">@color/dialog_title_background</item>
</style> </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 ... --> <!-- Buttons from MaterialDateTimePicker, Dialogs ... -->
<dimen name="material_button_height">48dp</dimen> <dimen name="material_button_height">48dp</dimen>
<dimen name="material_button_text_size">14sp</dimen> <dimen name="material_button_text_size">14sp</dimen>