properly pick either the dark or light dialog theme
This commit is contained in:
parent
dbd662d0c2
commit
566646a1b9
|
@ -11,6 +11,7 @@ import android.view.WindowManager
|
||||||
import android.widget.AdapterView
|
import android.widget.AdapterView
|
||||||
import com.simplemobiletools.calendar.R
|
import com.simplemobiletools.calendar.R
|
||||||
import com.simplemobiletools.calendar.extensions.beVisibleIf
|
import com.simplemobiletools.calendar.extensions.beVisibleIf
|
||||||
|
import com.simplemobiletools.calendar.extensions.getAppropriateTheme
|
||||||
import com.simplemobiletools.calendar.extensions.scheduleNotification
|
import com.simplemobiletools.calendar.extensions.scheduleNotification
|
||||||
import com.simplemobiletools.calendar.helpers.*
|
import com.simplemobiletools.calendar.helpers.*
|
||||||
import com.simplemobiletools.calendar.models.Event
|
import com.simplemobiletools.calendar.models.Event
|
||||||
|
@ -35,7 +36,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
setContentView(R.layout.activity_event)
|
setContentView(R.layout.activity_event)
|
||||||
|
|
||||||
val intent = intent ?: return
|
val intent = intent ?: return
|
||||||
mDialogTheme = if (config.backgroundColor.getContrastColor() == Color.WHITE) R.style.DialogTheme_Dark else R.style.DialogTheme
|
mDialogTheme = getAppropriateTheme()
|
||||||
|
|
||||||
mWasReminderInit = false
|
mWasReminderInit = false
|
||||||
val eventId = intent.getIntExtra(EVENT_ID, 0)
|
val eventId = intent.getIntExtra(EVENT_ID, 0)
|
||||||
|
|
|
@ -6,12 +6,14 @@ import android.appwidget.AppWidgetManager
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.graphics.Color
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import com.simplemobiletools.calendar.R
|
import com.simplemobiletools.calendar.R
|
||||||
import com.simplemobiletools.calendar.helpers.*
|
import com.simplemobiletools.calendar.helpers.*
|
||||||
import com.simplemobiletools.calendar.models.Event
|
import com.simplemobiletools.calendar.models.Event
|
||||||
import com.simplemobiletools.calendar.receivers.NotificationReceiver
|
import com.simplemobiletools.calendar.receivers.NotificationReceiver
|
||||||
|
import com.simplemobiletools.commons.extensions.getContrastColor
|
||||||
|
|
||||||
fun Context.updateWidgets() {
|
fun Context.updateWidgets() {
|
||||||
val widgetsCnt = AppWidgetManager.getInstance(this).getAppWidgetIds(ComponentName(this, MyWidgetMonthlyProvider::class.java))
|
val widgetsCnt = AppWidgetManager.getInstance(this).getAppWidgetIds(ComponentName(this, MyWidgetMonthlyProvider::class.java))
|
||||||
|
@ -91,3 +93,7 @@ private fun getNotificationIntent(context: Context, eventId: Int): PendingIntent
|
||||||
intent.putExtra(EVENT_ID, eventId)
|
intent.putExtra(EVENT_ID, eventId)
|
||||||
return PendingIntent.getBroadcast(context, eventId, intent, PendingIntent.FLAG_UPDATE_CURRENT)
|
return PendingIntent.getBroadcast(context, eventId, intent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Context.getAppropriateTheme(): Int {
|
||||||
|
return if (Config.newInstance(this).backgroundColor.getContrastColor() == Color.WHITE) R.style.DialogTheme_Dark else R.style.DialogTheme
|
||||||
|
}
|
||||||
|
|
|
@ -15,14 +15,17 @@ import com.simplemobiletools.calendar.R
|
||||||
import com.simplemobiletools.calendar.activities.EventActivity
|
import com.simplemobiletools.calendar.activities.EventActivity
|
||||||
import com.simplemobiletools.calendar.activities.SimpleActivity
|
import com.simplemobiletools.calendar.activities.SimpleActivity
|
||||||
import com.simplemobiletools.calendar.adapters.DayEventsAdapter
|
import com.simplemobiletools.calendar.adapters.DayEventsAdapter
|
||||||
|
import com.simplemobiletools.calendar.extensions.getAppropriateTheme
|
||||||
import com.simplemobiletools.calendar.helpers.*
|
import com.simplemobiletools.calendar.helpers.*
|
||||||
import com.simplemobiletools.calendar.helpers.Formatter
|
import com.simplemobiletools.calendar.helpers.Formatter
|
||||||
import com.simplemobiletools.calendar.interfaces.NavigationListener
|
import com.simplemobiletools.calendar.interfaces.NavigationListener
|
||||||
import com.simplemobiletools.calendar.models.Event
|
import com.simplemobiletools.calendar.models.Event
|
||||||
import com.simplemobiletools.commons.extensions.adjustAlpha
|
import com.simplemobiletools.commons.extensions.adjustAlpha
|
||||||
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.views.RecyclerViewDivider
|
import com.simplemobiletools.commons.views.RecyclerViewDivider
|
||||||
import kotlinx.android.synthetic.main.fragment_day.view.*
|
import kotlinx.android.synthetic.main.fragment_day.view.*
|
||||||
import kotlinx.android.synthetic.main.top_navigation.view.*
|
import kotlinx.android.synthetic.main.top_navigation.view.*
|
||||||
|
import org.joda.time.DateTime
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.comparisons.compareBy
|
import kotlin.comparisons.compareBy
|
||||||
|
|
||||||
|
@ -85,28 +88,29 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DBHelper.GetEvents
|
||||||
}
|
}
|
||||||
|
|
||||||
fun pickDay() {
|
fun pickDay() {
|
||||||
val alertDialog = AlertDialog.Builder(context)
|
activity.setTheme(context.getAppropriateTheme())
|
||||||
val view = getLayoutInflater(arguments).inflate(R.layout.date_picker, null)
|
val view = getLayoutInflater(arguments).inflate(R.layout.date_picker, null)
|
||||||
val datePicker = view.findViewById(R.id.date_picker) as DatePicker
|
val datePicker = view.findViewById(R.id.date_picker) as DatePicker
|
||||||
|
|
||||||
val dateTime = Formatter.getDateTimeFromCode(mDayCode)
|
val dateTime = Formatter.getDateTimeFromCode(mDayCode)
|
||||||
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, dateTime.dayOfMonth, null)
|
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, dateTime.dayOfMonth, null)
|
||||||
|
|
||||||
alertDialog.apply {
|
AlertDialog.Builder(context)
|
||||||
setView(view)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
setNegativeButton(R.string.cancel, null)
|
.setPositiveButton(R.string.ok) { dialog, which -> positivePressed(dateTime, datePicker) }
|
||||||
setPositiveButton(R.string.ok) { dialog, id ->
|
.create().apply {
|
||||||
val month = datePicker.month + 1
|
context.setupDialogStuff(view, this)
|
||||||
val year = datePicker.year
|
|
||||||
val day = datePicker.dayOfMonth
|
|
||||||
val newDateTime = dateTime.withDate(year, month, day)
|
|
||||||
mListener?.goToDateTime(newDateTime)
|
|
||||||
}
|
|
||||||
|
|
||||||
show()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun positivePressed(dateTime: DateTime, datePicker: DatePicker) {
|
||||||
|
val month = datePicker.month + 1
|
||||||
|
val year = datePicker.year
|
||||||
|
val day = datePicker.dayOfMonth
|
||||||
|
val newDateTime = dateTime.withDate(year, month, day)
|
||||||
|
mListener?.goToDateTime(newDateTime)
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkEvents() {
|
private fun checkEvents() {
|
||||||
val startTS = Formatter.getDayStartTS(mDayCode)
|
val startTS = Formatter.getDayStartTS(mDayCode)
|
||||||
val endTS = Formatter.getDayEndTS(mDayCode)
|
val endTS = Formatter.getDayEndTS(mDayCode)
|
||||||
|
|
|
@ -16,11 +16,13 @@ import com.simplemobiletools.calendar.MonthlyCalendarImpl
|
||||||
import com.simplemobiletools.calendar.R
|
import com.simplemobiletools.calendar.R
|
||||||
import com.simplemobiletools.calendar.activities.DayActivity
|
import com.simplemobiletools.calendar.activities.DayActivity
|
||||||
import com.simplemobiletools.calendar.extensions.beVisibleIf
|
import com.simplemobiletools.calendar.extensions.beVisibleIf
|
||||||
|
import com.simplemobiletools.calendar.extensions.getAppropriateTheme
|
||||||
import com.simplemobiletools.calendar.helpers.*
|
import com.simplemobiletools.calendar.helpers.*
|
||||||
import com.simplemobiletools.calendar.interfaces.MonthlyCalendar
|
import com.simplemobiletools.calendar.interfaces.MonthlyCalendar
|
||||||
import com.simplemobiletools.calendar.interfaces.NavigationListener
|
import com.simplemobiletools.calendar.interfaces.NavigationListener
|
||||||
import com.simplemobiletools.calendar.models.Day
|
import com.simplemobiletools.calendar.models.Day
|
||||||
import com.simplemobiletools.commons.extensions.adjustAlpha
|
import com.simplemobiletools.commons.extensions.adjustAlpha
|
||||||
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import kotlinx.android.synthetic.main.first_row.*
|
import kotlinx.android.synthetic.main.first_row.*
|
||||||
import kotlinx.android.synthetic.main.fragment_month.view.*
|
import kotlinx.android.synthetic.main.fragment_month.view.*
|
||||||
import kotlinx.android.synthetic.main.top_navigation.view.*
|
import kotlinx.android.synthetic.main.top_navigation.view.*
|
||||||
|
@ -120,7 +122,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showMonthDialog() {
|
fun showMonthDialog() {
|
||||||
val alertDialog = AlertDialog.Builder(context)
|
activity.setTheme(context.getAppropriateTheme())
|
||||||
val view = getLayoutInflater(arguments).inflate(R.layout.date_picker, null)
|
val view = getLayoutInflater(arguments).inflate(R.layout.date_picker, null)
|
||||||
val datePicker = view.findViewById(R.id.date_picker) as DatePicker
|
val datePicker = view.findViewById(R.id.date_picker) as DatePicker
|
||||||
datePicker.findViewById(Resources.getSystem().getIdentifier("day", "id", "android")).visibility = View.GONE
|
datePicker.findViewById(Resources.getSystem().getIdentifier("day", "id", "android")).visibility = View.GONE
|
||||||
|
@ -128,20 +130,21 @@ class MonthFragment : Fragment(), MonthlyCalendar {
|
||||||
val dateTime = DateTime(mCalendar.mTargetDate.toString())
|
val dateTime = DateTime(mCalendar.mTargetDate.toString())
|
||||||
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, 1, null)
|
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, 1, null)
|
||||||
|
|
||||||
alertDialog.apply {
|
AlertDialog.Builder(context)
|
||||||
setView(view)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
setNegativeButton(R.string.cancel, null)
|
.setPositiveButton(R.string.ok) { dialog, which -> positivePressed(dateTime, datePicker) }
|
||||||
setPositiveButton(R.string.ok) { dialog, id ->
|
.create().apply {
|
||||||
val month = datePicker.month + 1
|
context.setupDialogStuff(view, this)
|
||||||
val year = datePicker.year
|
|
||||||
val newDateTime = dateTime.withDate(year, month, 1)
|
|
||||||
mListener?.goToDateTime(newDateTime)
|
|
||||||
}
|
|
||||||
|
|
||||||
show()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun positivePressed(dateTime: DateTime, datePicker: DatePicker) {
|
||||||
|
val month = datePicker.month + 1
|
||||||
|
val year = datePicker.year
|
||||||
|
val newDateTime = dateTime.withDate(year, month, 1)
|
||||||
|
mListener?.goToDateTime(newDateTime)
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupLabels() {
|
private fun setupLabels() {
|
||||||
val letters = letterIDs
|
val letters = letterIDs
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue