always use proper theme at date pickers
This commit is contained in:
parent
466d0cbf32
commit
0987940192
|
@ -15,7 +15,6 @@ import com.simplemobiletools.calendar.pro.helpers.DAY_CODE
|
|||
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.pro.interfaces.NavigationListener
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.getDatePickerDialogTheme
|
||||
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.views.MyViewPager
|
||||
|
@ -104,8 +103,11 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
|
|||
}
|
||||
|
||||
override fun showGoToDateDialog() {
|
||||
requireActivity().setTheme(requireContext().getDatePickerDialogTheme())
|
||||
val view = layoutInflater.inflate(R.layout.date_picker, null)
|
||||
if (activity == null) {
|
||||
return
|
||||
}
|
||||
|
||||
val view = layoutInflater.inflate(getDatePickerDialogStyle(), null)
|
||||
val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
|
||||
|
||||
val dateTime = getCurrentDate()!!
|
||||
|
|
|
@ -16,7 +16,10 @@ import com.simplemobiletools.calendar.pro.helpers.DAY_CODE
|
|||
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.pro.helpers.MONTHLY_DAILY_VIEW
|
||||
import com.simplemobiletools.calendar.pro.interfaces.NavigationListener
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.extensions.beGone
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.views.MyViewPager
|
||||
import kotlinx.android.synthetic.main.fragment_months_days_holder.view.*
|
||||
import org.joda.time.DateTime
|
||||
|
@ -103,8 +106,11 @@ class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener {
|
|||
}
|
||||
|
||||
override fun showGoToDateDialog() {
|
||||
requireActivity().setTheme(requireContext().getDatePickerDialogTheme())
|
||||
val view = layoutInflater.inflate(R.layout.date_picker, null)
|
||||
if (activity == null) {
|
||||
return
|
||||
}
|
||||
|
||||
val view = layoutInflater.inflate(getDatePickerDialogStyle(), null)
|
||||
val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
|
||||
datePicker.findViewById<View>(Resources.getSystem().getIdentifier("day", "id", "android")).beGone()
|
||||
|
||||
|
|
|
@ -16,7 +16,10 @@ import com.simplemobiletools.calendar.pro.helpers.DAY_CODE
|
|||
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.pro.helpers.MONTHLY_VIEW
|
||||
import com.simplemobiletools.calendar.pro.interfaces.NavigationListener
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.extensions.beGone
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.views.MyViewPager
|
||||
import kotlinx.android.synthetic.main.fragment_months_holder.view.*
|
||||
import org.joda.time.DateTime
|
||||
|
@ -103,8 +106,11 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
|
|||
}
|
||||
|
||||
override fun showGoToDateDialog() {
|
||||
requireActivity().setTheme(requireContext().getDatePickerDialogTheme())
|
||||
val view = layoutInflater.inflate(R.layout.date_picker, null)
|
||||
if (activity == null) {
|
||||
return
|
||||
}
|
||||
|
||||
val view = layoutInflater.inflate(getDatePickerDialogStyle(), null)
|
||||
val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
|
||||
datePicker.findViewById<View>(Resources.getSystem().getIdentifier("day", "id", "android")).beGone()
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package com.simplemobiletools.calendar.pro.fragments
|
||||
|
||||
import android.graphics.Color
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.commons.extensions.getContrastColor
|
||||
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
|
||||
import org.joda.time.DateTime
|
||||
|
||||
abstract class MyFragmentHolder : Fragment() {
|
||||
|
@ -19,4 +23,12 @@ abstract class MyFragmentHolder : Fragment() {
|
|||
abstract fun printView()
|
||||
|
||||
abstract fun getCurrentDate(): DateTime?
|
||||
|
||||
fun getDatePickerDialogStyle(): Int {
|
||||
return if (requireActivity().getProperBackgroundColor().getContrastColor() == Color.WHITE) {
|
||||
R.layout.date_picker_dark
|
||||
} else {
|
||||
R.layout.date_picker_light
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,8 +170,11 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
|
|||
}
|
||||
|
||||
override fun showGoToDateDialog() {
|
||||
requireActivity().setTheme(requireContext().getDatePickerDialogTheme())
|
||||
val view = layoutInflater.inflate(R.layout.date_picker, null)
|
||||
if (activity == null) {
|
||||
return
|
||||
}
|
||||
|
||||
val view = layoutInflater.inflate(getDatePickerDialogStyle(), null)
|
||||
val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
|
||||
|
||||
val dateTime = getCurrentDate()!!
|
||||
|
|
|
@ -15,11 +15,13 @@ import com.simplemobiletools.calendar.pro.helpers.Formatter
|
|||
import com.simplemobiletools.calendar.pro.helpers.YEARLY_VIEW
|
||||
import com.simplemobiletools.calendar.pro.helpers.YEAR_TO_OPEN
|
||||
import com.simplemobiletools.calendar.pro.interfaces.NavigationListener
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.extensions.beGone
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.views.MyViewPager
|
||||
import kotlinx.android.synthetic.main.fragment_years_holder.view.*
|
||||
import org.joda.time.DateTime
|
||||
import kotlin.text.toInt
|
||||
|
||||
class YearFragmentsHolder : MyFragmentHolder(), NavigationListener {
|
||||
private val PREFILLED_YEARS = 61
|
||||
|
@ -95,8 +97,11 @@ class YearFragmentsHolder : MyFragmentHolder(), NavigationListener {
|
|||
}
|
||||
|
||||
override fun showGoToDateDialog() {
|
||||
requireActivity().setTheme(requireContext().getDatePickerDialogTheme())
|
||||
val view = layoutInflater.inflate(R.layout.date_picker, null)
|
||||
if (activity == null) {
|
||||
return
|
||||
}
|
||||
|
||||
val view = layoutInflater.inflate(getDatePickerDialogStyle(), null)
|
||||
val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
|
||||
datePicker.findViewById<View>(Resources.getSystem().getIdentifier("day", "id", "android")).beGone()
|
||||
datePicker.findViewById<View>(Resources.getSystem().getIdentifier("month", "id", "android")).beGone()
|
||||
|
|
|
@ -4,4 +4,5 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:calendarViewShown="false"
|
||||
android:datePickerMode="spinner" />
|
||||
android:datePickerMode="spinner"
|
||||
android:theme="@style/DatePickerDarkStyle" />
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<DatePicker xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/date_picker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:calendarViewShown="false"
|
||||
android:datePickerMode="spinner"
|
||||
android:theme="@style/DatePickerLightStyle" />
|
|
@ -29,4 +29,12 @@
|
|||
<style name="MonthStyle">
|
||||
<item name="android:background">?android:attr/selectableItemBackground</item>
|
||||
</style>
|
||||
|
||||
<style name="DatePickerLightStyle">
|
||||
<item name="android:textColorPrimary">@color/theme_light_text_color</item>
|
||||
</style>
|
||||
|
||||
<style name="DatePickerDarkStyle">
|
||||
<item name="android:textColorPrimary">@color/theme_dark_text_color</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue