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:
commit
47bd050bb9
|
@ -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 ->
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
<!---Nightscout client TitelColor -->
|
||||
<item name="nsTitleColor">@color/defaulttext</item>
|
||||
</style>
|
||||
|
@ -271,6 +273,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>
|
||||
|
|
|
@ -274,6 +274,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>
|
||||
|
|
Loading…
Reference in a new issue