allow changing the Period used for displaying past events
This commit is contained in:
parent
57f246c52a
commit
9812bf56a7
|
@ -223,17 +223,19 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupDisplayPastEvents() {
|
||||
updatePastEventsText()
|
||||
var displayPastEvents = config.displayPastEvents
|
||||
updatePastEventsText(displayPastEvents)
|
||||
settings_display_past_events_holder.setOnClickListener {
|
||||
CustomEventReminderDialog(this) {
|
||||
CustomEventReminderDialog(this, displayPastEvents) {
|
||||
displayPastEvents = it
|
||||
config.displayPastEvents = it
|
||||
updatePastEventsText()
|
||||
updatePastEventsText(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updatePastEventsText() {
|
||||
settings_display_past_events.text = getDisplayPastEventsText(config.displayPastEvents)
|
||||
private fun updatePastEventsText(displayPastEvents: Int) {
|
||||
settings_display_past_events.text = getDisplayPastEventsText(displayPastEvents)
|
||||
}
|
||||
|
||||
private fun getDisplayPastEventsText(displayPastEvents: Int): String {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.simplemobiletools.calendar.dialogs
|
|||
|
||||
import android.app.Activity
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import com.simplemobiletools.calendar.R
|
||||
|
@ -10,13 +11,24 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff
|
|||
import com.simplemobiletools.commons.extensions.value
|
||||
import kotlinx.android.synthetic.main.dialog_custom_event_reminder.view.*
|
||||
|
||||
class CustomEventReminderDialog(val activity: Activity, val callback: (minutes: Int) -> Unit) : AlertDialog.Builder(activity) {
|
||||
class CustomEventReminderDialog(val activity: Activity, val selectedMinutes: Int = 0, val callback: (minutes: Int) -> Unit) : AlertDialog.Builder(activity) {
|
||||
var dialog: AlertDialog
|
||||
var view = activity.layoutInflater.inflate(R.layout.dialog_custom_event_reminder, null) as ViewGroup
|
||||
var view: View = (activity.layoutInflater.inflate(R.layout.dialog_custom_event_reminder, null) as ViewGroup).apply {
|
||||
if (selectedMinutes == 0) {
|
||||
dialog_radio_view.check(R.id.dialog_radio_minutes)
|
||||
} else if (selectedMinutes % 1440 == 0) {
|
||||
dialog_radio_view.check(R.id.dialog_radio_days)
|
||||
dialog_custom_reminder_value.setText((selectedMinutes / 1440).toString())
|
||||
} else if (selectedMinutes % 60 == 0) {
|
||||
dialog_radio_view.check(R.id.dialog_radio_hours)
|
||||
dialog_custom_reminder_value.setText((selectedMinutes / 60).toString())
|
||||
} else {
|
||||
dialog_radio_view.check(R.id.dialog_radio_minutes)
|
||||
dialog_custom_reminder_value.setText(selectedMinutes.toString())
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
view.dialog_radio_view.check(R.id.dialog_radio_minutes)
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok, { dialogInterface, i -> confirmReminder() })
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
|
||||
<com.simplemobiletools.commons.views.MyEditText
|
||||
android:id="@+id/dialog_custom_reminder_value"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:digits="0123456789"
|
||||
android:ems="3"
|
||||
android:ems="6"
|
||||
android:inputType="number"
|
||||
android:maxLength="4"
|
||||
android:maxLength="5"
|
||||
android:textCursorDrawable="@null"/>
|
||||
|
||||
<RadioGroup
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
android:id="@+id/snooze_picker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="5"
|
||||
android:ems="6"
|
||||
android:inputType="number"
|
||||
android:maxLength="5"
|
||||
android:paddingTop="@dimen/normal_margin"/>
|
||||
|
|
Loading…
Reference in New Issue