fix the theme at date and timepicker dialogs on android 7

This commit is contained in:
Tibor Kaputa 2016-12-09 09:40:50 +01:00
parent ff1f7162db
commit 1ba39edc37
3 changed files with 16 additions and 4 deletions

View File

@ -22,6 +22,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
private var mWasReminderInit = false
private var mWasEndDateSet = false
private var mWasEndTimeSet = false
private var mDialogTheme = 0
lateinit var mEventStartDateTime: DateTime
lateinit var mEventEndDateTime: DateTime
@ -32,6 +33,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
setContentView(R.layout.activity_event)
val intent = intent ?: return
mDialogTheme = if (mConfig.isDarkTheme) R.style.DialogTheme_Dark else R.style.DialogTheme
mWasReminderInit = false
val eventId = intent.getIntExtra(EVENT_ID, 0)
@ -303,21 +305,21 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
}
fun setupStartDate() {
DatePickerDialog(this, startDateSetListener, mEventStartDateTime.year, mEventStartDateTime.monthOfYear - 1,
DatePickerDialog(this, mDialogTheme, startDateSetListener, mEventStartDateTime.year, mEventStartDateTime.monthOfYear - 1,
mEventStartDateTime.dayOfMonth).show()
}
fun setupStartTime() {
TimePickerDialog(this, startTimeSetListener, mEventStartDateTime.hourOfDay, mEventStartDateTime.minuteOfHour, true).show()
TimePickerDialog(this, mDialogTheme, startTimeSetListener, mEventStartDateTime.hourOfDay, mEventStartDateTime.minuteOfHour, true).show()
}
fun setupEndDate() {
DatePickerDialog(this, endDateSetListener, mEventEndDateTime.year, mEventEndDateTime.monthOfYear - 1,
DatePickerDialog(this, mDialogTheme, endDateSetListener, mEventEndDateTime.year, mEventEndDateTime.monthOfYear - 1,
mEventEndDateTime.dayOfMonth).show()
}
fun setupEndTime() {
TimePickerDialog(this, endTimeSetListener, mEventEndDateTime.hourOfDay, mEventEndDateTime.minuteOfHour, true).show()
TimePickerDialog(this, mDialogTheme, endTimeSetListener, mEventEndDateTime.hourOfDay, mEventEndDateTime.minuteOfHour, true).show()
}
private val startDateSetListener = DatePickerDialog.OnDateSetListener { view, year, monthOfYear, dayOfMonth ->

View File

@ -8,4 +8,5 @@
<color name="activated_item_foreground">#44888888</color>
<color name="mediumGrey">#18000000</color>
<color name="divider_grey">#44cccccc</color>
<color name="dark_theme_dialog_background">#ff333333</color>
</resources>

View File

@ -56,6 +56,15 @@
<style name="MyAlertDialog.Dark" parent="Base.Theme.AppCompat.Dialog.Alert"/>
<style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">@color/colorPrimary</item>
</style>
<style name="DialogTheme.Dark" parent="Theme.AppCompat.Dialog">
<item name="android:windowBackground">@color/dark_theme_dialog_background</item>
<item name="colorAccent">@color/colorPrimary</item>
</style>
<style name="AppTheme.ActionBarStyle" parent="@style/Base.Widget.AppCompat.ActionBar">
<item name="background">@color/colorPrimary</item>
<item name="titleTextStyle">@style/AppTheme.ActionBar.TitleTextStyle</item>