rename CustomEventReminderDialog to CustomIntervalPickerDialog
This commit is contained in:
parent
6c438b5cc1
commit
0c28d4f5ed
8 changed files with 54 additions and 119 deletions
|
@ -9,7 +9,7 @@ import android.os.Parcelable
|
|||
import android.text.TextUtils
|
||||
import com.simplemobiletools.calendar.BuildConfig
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.dialogs.CustomEventReminderDialog
|
||||
import com.simplemobiletools.calendar.dialogs.CustomIntervalPickerDialog
|
||||
import com.simplemobiletools.calendar.dialogs.SelectCalendarsDialog
|
||||
import com.simplemobiletools.calendar.extensions.*
|
||||
import com.simplemobiletools.calendar.helpers.CalDAVHandler
|
||||
|
@ -336,7 +336,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
var displayPastEvents = config.displayPastEvents
|
||||
updatePastEventsText(displayPastEvents)
|
||||
settings_display_past_events_holder.setOnClickListener {
|
||||
CustomEventReminderDialog(this, displayPastEvents) {
|
||||
CustomIntervalPickerDialog(this, displayPastEvents) {
|
||||
displayPastEvents = it
|
||||
config.displayPastEvents = it
|
||||
updatePastEventsText(it)
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.simplemobiletools.calendar.dialogs
|
|||
import android.app.Activity
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.helpers.DAY
|
||||
import com.simplemobiletools.calendar.helpers.MONTH
|
||||
|
@ -11,6 +10,7 @@ import com.simplemobiletools.calendar.helpers.WEEK
|
|||
import com.simplemobiletools.calendar.helpers.YEAR
|
||||
import com.simplemobiletools.commons.extensions.hideKeyboard
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.showKeyboard
|
||||
import com.simplemobiletools.commons.extensions.value
|
||||
import kotlinx.android.synthetic.main.dialog_custom_event_repeat_interval.view.*
|
||||
|
||||
|
@ -25,9 +25,10 @@ class CustomEventRepeatIntervalDialog(val activity: Activity, val callback: (sec
|
|||
.setPositiveButton(R.string.ok, { dialogInterface, i -> confirmRepeatInterval() })
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
activity.setupDialogStuff(view, this)
|
||||
}
|
||||
activity.setupDialogStuff(view, this) {
|
||||
showKeyboard(view.dialog_custom_repeat_interval_value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun confirmRepeatInterval() {
|
||||
|
|
|
@ -3,21 +3,22 @@ package com.simplemobiletools.calendar.dialogs
|
|||
import android.app.Activity
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.helpers.DAY_MINUTES
|
||||
import com.simplemobiletools.commons.extensions.hideKeyboard
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.showKeyboard
|
||||
import com.simplemobiletools.commons.extensions.value
|
||||
import kotlinx.android.synthetic.main.dialog_custom_event_reminder.view.*
|
||||
|
||||
class CustomEventReminderDialog(val activity: Activity, val selectedMinutes: Int = 0, val callback: (minutes: Int) -> Unit) {
|
||||
class CustomIntervalPickerDialog(val activity: Activity, val selectedMinutes: Int = 0, val callback: (minutes: Int) -> Unit) {
|
||||
var dialog: AlertDialog
|
||||
var view = (activity.layoutInflater.inflate(R.layout.dialog_custom_event_reminder, null) as ViewGroup).apply {
|
||||
when {
|
||||
selectedMinutes == 0 -> dialog_radio_view.check(R.id.dialog_radio_minutes)
|
||||
selectedMinutes % 1440 == 0 -> {
|
||||
selectedMinutes % DAY_MINUTES == 0 -> {
|
||||
dialog_radio_view.check(R.id.dialog_radio_days)
|
||||
dialog_custom_reminder_value.setText((selectedMinutes / 1440).toString())
|
||||
dialog_custom_reminder_value.setText((selectedMinutes / DAY_MINUTES).toString())
|
||||
}
|
||||
selectedMinutes % 60 == 0 -> {
|
||||
dialog_radio_view.check(R.id.dialog_radio_hours)
|
||||
|
@ -35,9 +36,10 @@ class CustomEventReminderDialog(val activity: Activity, val selectedMinutes: Int
|
|||
.setPositiveButton(R.string.ok, { dialogInterface, i -> confirmReminder() })
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
activity.setupDialogStuff(view, this)
|
||||
}
|
||||
activity.setupDialogStuff(view, this) {
|
||||
showKeyboard(view.dialog_custom_reminder_value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun confirmReminder() {
|
|
@ -2,9 +2,9 @@ package com.simplemobiletools.calendar.dialogs
|
|||
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.activities.SimpleActivity
|
||||
import com.simplemobiletools.commons.extensions.hideKeyboard
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import kotlinx.android.synthetic.main.dialog_edit_repeating_event.view.*
|
||||
|
||||
|
@ -19,10 +19,10 @@ class EditRepeatingEventDialog(val activity: SimpleActivity, val callback: (allO
|
|||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this) {
|
||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
|
||||
}
|
||||
}
|
||||
activity.setupDialogStuff(view, this) {
|
||||
hideKeyboard()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendResult(allOccurrences: Boolean) {
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
package com.simplemobiletools.calendar.dialogs
|
||||
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.activities.SimpleActivity
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.value
|
||||
import kotlinx.android.synthetic.main.dialog_snooze_picker.view.*
|
||||
|
||||
class SnoozePickerDialog(val activity: SimpleActivity, val minutes: Int, val callback: (newMinutes: Int) -> Unit) {
|
||||
init {
|
||||
val view = (activity.layoutInflater.inflate(R.layout.dialog_snooze_picker, null) as ViewGroup).apply {
|
||||
snooze_picker_label.text = snooze_picker_label.text.toString().capitalize()
|
||||
snooze_picker.setText(minutes.toString())
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this) {
|
||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val value = view.snooze_picker.value
|
||||
val minutes = Integer.valueOf(if (value.isEmpty() || value == "0") "1" else value)
|
||||
callback(minutes)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,17 +2,13 @@ package com.simplemobiletools.calendar.dialogs
|
|||
|
||||
import android.app.Activity
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.WindowManager
|
||||
import android.widget.ImageView
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.extensions.config
|
||||
import com.simplemobiletools.calendar.extensions.dbHelper
|
||||
import com.simplemobiletools.calendar.models.EventType
|
||||
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
|
||||
import com.simplemobiletools.commons.extensions.setBackgroundWithStroke
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.value
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import kotlinx.android.synthetic.main.dialog_event_type.view.*
|
||||
|
||||
class UpdateEventTypeDialog(val activity: Activity, var eventType: EventType? = null, val callback: (eventType: EventType) -> Unit) {
|
||||
|
@ -44,42 +40,42 @@ class UpdateEventTypeDialog(val activity: Activity, var eventType: EventType? =
|
|||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
activity.setupDialogStuff(view, this, if (isNewEvent) R.string.add_new_type else R.string.edit_type) {
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val title = view.type_title.value
|
||||
val eventIdWithTitle = activity.dbHelper.getEventTypeIdWithTitle(title)
|
||||
var isEventTypeTitleTaken = isNewEvent && eventIdWithTitle != -1
|
||||
if (!isEventTypeTitleTaken)
|
||||
isEventTypeTitleTaken = !isNewEvent && eventType!!.id != eventIdWithTitle && eventIdWithTitle != -1
|
||||
activity.setupDialogStuff(view, this, if (isNewEvent) R.string.add_new_type else R.string.edit_type) {
|
||||
showKeyboard(view.type_title)
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val title = view.type_title.value
|
||||
val eventIdWithTitle = activity.dbHelper.getEventTypeIdWithTitle(title)
|
||||
var isEventTypeTitleTaken = isNewEvent && eventIdWithTitle != -1
|
||||
if (!isEventTypeTitleTaken)
|
||||
isEventTypeTitleTaken = !isNewEvent && eventType!!.id != eventIdWithTitle && eventIdWithTitle != -1
|
||||
|
||||
if (title.isEmpty()) {
|
||||
activity.toast(R.string.title_empty)
|
||||
return@setOnClickListener
|
||||
} else if (isEventTypeTitleTaken) {
|
||||
activity.toast(R.string.type_already_exists)
|
||||
return@setOnClickListener
|
||||
}
|
||||
if (title.isEmpty()) {
|
||||
activity.toast(R.string.title_empty)
|
||||
return@setOnClickListener
|
||||
} else if (isEventTypeTitleTaken) {
|
||||
activity.toast(R.string.type_already_exists)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
eventType!!.title = title
|
||||
if (eventType!!.caldavCalendarId != 0)
|
||||
eventType!!.caldavDisplayName = title
|
||||
eventType!!.title = title
|
||||
if (eventType!!.caldavCalendarId != 0)
|
||||
eventType!!.caldavDisplayName = title
|
||||
|
||||
eventType!!.id = if (isNewEvent) {
|
||||
activity.dbHelper.insertEventType(eventType!!)
|
||||
} else {
|
||||
activity.dbHelper.updateEventType(eventType!!)
|
||||
}
|
||||
eventType!!.id = if (isNewEvent) {
|
||||
activity.dbHelper.insertEventType(eventType!!)
|
||||
} else {
|
||||
activity.dbHelper.updateEventType(eventType!!)
|
||||
}
|
||||
|
||||
if (eventType!!.id != -1) {
|
||||
dismiss()
|
||||
callback(eventType!!)
|
||||
} else {
|
||||
activity.toast(R.string.editing_calendar_failed)
|
||||
if (eventType!!.id != -1) {
|
||||
dismiss()
|
||||
callback(eventType!!)
|
||||
} else {
|
||||
activity.toast(R.string.editing_calendar_failed)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupColor(view: ImageView) {
|
||||
|
|
|
@ -3,8 +3,8 @@ package com.simplemobiletools.calendar.extensions
|
|||
import android.app.Activity
|
||||
import com.simplemobiletools.calendar.BuildConfig
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.dialogs.CustomEventReminderDialog
|
||||
import com.simplemobiletools.calendar.dialogs.CustomEventRepeatIntervalDialog
|
||||
import com.simplemobiletools.calendar.dialogs.CustomIntervalPickerDialog
|
||||
import com.simplemobiletools.calendar.helpers.*
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
|
@ -75,7 +75,7 @@ fun Activity.showEventReminderDialog(curMinutes: Int, isSnoozePicker: Boolean =
|
|||
|
||||
RadioGroupDialog(this, items, selectedIndex, showOKButton = isSnoozePicker, cancelCallback = cancelCallback) {
|
||||
if (it == -2) {
|
||||
CustomEventReminderDialog(this) {
|
||||
CustomIntervalPickerDialog(this) {
|
||||
callback(it)
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/snooze_picker_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/big_margin"
|
||||
android:paddingRight="@dimen/big_margin"
|
||||
android:paddingTop="@dimen/big_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/snooze_picker_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textCapSentences"
|
||||
android:text="@string/minutes_raw"
|
||||
android:textSize="@dimen/smaller_text_size"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyEditText
|
||||
android:id="@+id/snooze_picker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="6"
|
||||
android:inputType="number"
|
||||
android:maxLength="5"
|
||||
android:paddingTop="@dimen/normal_margin"
|
||||
android:textSize="@dimen/normal_text_size"/>
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in a new issue