Merge pull request #1644 from osodebailar/fix/marterial_date_time_picker_ok_cancel_color

Fix material date time picker ok cancel color
This commit is contained in:
Milos Kozak 2022-04-19 22:57:24 +02:00 committed by GitHub
commit 47bd050bb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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))

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>
<!---Nightscout client TitelColor --> <!---Nightscout client TitelColor -->
<item name="nsTitleColor">@color/defaulttext</item> <item name="nsTitleColor">@color/defaulttext</item>
</style> </style>
@ -271,6 +273,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

@ -274,6 +274,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>