updating commons with initial dialog updates
This commit is contained in:
parent
ae1c52adf8
commit
1d66fe8771
23 changed files with 143 additions and 147 deletions
|
@ -70,7 +70,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:11288f0e8c'
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:f8b1a5a510'
|
||||
implementation 'androidx.multidex:multidex:2.0.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||
|
|
|
@ -8,27 +8,25 @@ import com.simplemobiletools.calendar.pro.helpers.DAY
|
|||
import com.simplemobiletools.calendar.pro.helpers.MONTH
|
||||
import com.simplemobiletools.calendar.pro.helpers.WEEK
|
||||
import com.simplemobiletools.calendar.pro.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 com.simplemobiletools.commons.extensions.*
|
||||
import kotlinx.android.synthetic.main.dialog_custom_event_repeat_interval.view.*
|
||||
|
||||
class CustomEventRepeatIntervalDialog(val activity: Activity, val callback: (seconds: Int) -> Unit) {
|
||||
var dialog: AlertDialog
|
||||
var view = activity.layoutInflater.inflate(R.layout.dialog_custom_event_repeat_interval, null) as ViewGroup
|
||||
private var dialog: AlertDialog? = null
|
||||
private var view = activity.layoutInflater.inflate(R.layout.dialog_custom_event_repeat_interval, null) as ViewGroup
|
||||
|
||||
init {
|
||||
view.dialog_radio_view.check(R.id.dialog_radio_days)
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmRepeatInterval() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this) {
|
||||
showKeyboard(view.dialog_custom_repeat_interval_value)
|
||||
}
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmRepeatInterval() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
||||
dialog = alertDialog
|
||||
alertDialog.showKeyboard(view.dialog_custom_repeat_interval_value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun confirmRepeatInterval() {
|
||||
|
@ -37,7 +35,7 @@ class CustomEventRepeatIntervalDialog(val activity: Activity, val callback: (sec
|
|||
val days = Integer.valueOf(if (value.isEmpty()) "0" else value)
|
||||
callback(days * multiplier)
|
||||
activity.hideKeyboard()
|
||||
dialog.dismiss()
|
||||
dialog?.dismiss()
|
||||
}
|
||||
|
||||
private fun getMultiplier(id: Int) = when (id) {
|
||||
|
|
|
@ -4,28 +4,26 @@ import android.app.Activity
|
|||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
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 com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.DAY_SECONDS
|
||||
import com.simplemobiletools.commons.helpers.MONTH_SECONDS
|
||||
import com.simplemobiletools.commons.helpers.WEEK_SECONDS
|
||||
import kotlinx.android.synthetic.main.dialog_custom_period_picker.view.*
|
||||
|
||||
class CustomPeriodPickerDialog(val activity: Activity, val callback: (value: Int) -> Unit) {
|
||||
var dialog: AlertDialog
|
||||
var view = (activity.layoutInflater.inflate(R.layout.dialog_custom_period_picker, null) as ViewGroup)
|
||||
private var dialog: AlertDialog? = null
|
||||
private var view = (activity.layoutInflater.inflate(R.layout.dialog_custom_period_picker, null) as ViewGroup)
|
||||
|
||||
init {
|
||||
view.dialog_custom_period_value.setText("")
|
||||
view.dialog_radio_view.check(R.id.dialog_radio_days)
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmReminder() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this) {
|
||||
showKeyboard(view.dialog_custom_period_value)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
||||
dialog = alertDialog
|
||||
alertDialog.showKeyboard(view.dialog_custom_period_value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +46,6 @@ class CustomPeriodPickerDialog(val activity: Activity, val callback: (value: Int
|
|||
val period = calculatePeriod(Integer.valueOf(periodValue), type)
|
||||
callback(period)
|
||||
activity.hideKeyboard()
|
||||
dialog.dismiss()
|
||||
dialog?.dismiss()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.simplemobiletools.calendar.pro.helpers.DELETE_ALL_OCCURRENCES
|
|||
import com.simplemobiletools.calendar.pro.helpers.DELETE_FUTURE_OCCURRENCES
|
||||
import com.simplemobiletools.calendar.pro.helpers.DELETE_SELECTED_OCCURRENCE
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import kotlinx.android.synthetic.main.dialog_delete_event.view.*
|
||||
|
||||
|
@ -18,7 +19,7 @@ class DeleteEventDialog(
|
|||
isTask: Boolean = false,
|
||||
val callback: (deleteRule: Int) -> Unit
|
||||
) {
|
||||
val dialog: AlertDialog?
|
||||
private var dialog: AlertDialog? = null
|
||||
|
||||
init {
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_delete_event, null).apply {
|
||||
|
@ -39,11 +40,13 @@ class DeleteEventDialog(
|
|||
}
|
||||
}
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.yes) { dialog, which -> dialogConfirmed(view as ViewGroup) }
|
||||
.setNegativeButton(R.string.no, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
||||
dialog = alertDialog
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.app.Activity
|
|||
import android.widget.ImageView
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.extensions.config
|
||||
import com.simplemobiletools.calendar.pro.extensions.eventsHelper
|
||||
import com.simplemobiletools.calendar.pro.models.EventType
|
||||
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
|
||||
|
@ -13,7 +12,7 @@ import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
|||
import kotlinx.android.synthetic.main.dialog_event_type.view.*
|
||||
|
||||
class EditEventTypeDialog(val activity: Activity, var eventType: EventType? = null, val callback: (eventType: EventType) -> Unit) {
|
||||
var isNewEvent = eventType == null
|
||||
private var isNewEvent = eventType == null
|
||||
|
||||
init {
|
||||
if (eventType == null) {
|
||||
|
@ -40,15 +39,15 @@ class EditEventTypeDialog(val activity: Activity, var eventType: EventType? = nu
|
|||
}
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
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 {
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, if (isNewEvent) R.string.add_new_type else R.string.edit_type) { alertDialog ->
|
||||
alertDialog.showKeyboard(view.type_title)
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
ensureBackgroundThread {
|
||||
eventTypeConfirmed(view.type_title.value, this)
|
||||
eventTypeConfirmed(view.type_title.value, alertDialog)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,13 @@ import android.view.ViewGroup
|
|||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.hideKeyboard
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import kotlinx.android.synthetic.main.dialog_edit_repeating_event.view.*
|
||||
|
||||
class EditRepeatingEventDialog(val activity: SimpleActivity, val isTask: Boolean = false, val callback: (allOccurrences: Int) -> Unit) {
|
||||
var dialog: AlertDialog
|
||||
private var dialog: AlertDialog? = null
|
||||
|
||||
init {
|
||||
val view = (activity.layoutInflater.inflate(R.layout.dialog_edit_repeating_event, null) as ViewGroup).apply {
|
||||
|
@ -24,16 +25,17 @@ class EditRepeatingEventDialog(val activity: SimpleActivity, val isTask: Boolean
|
|||
}
|
||||
}
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this) {
|
||||
hideKeyboard()
|
||||
activity.getAlertDialogBuilder()
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
||||
dialog = alertDialog
|
||||
alertDialog.hideKeyboard()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendResult(allOccurrences: Int) {
|
||||
callback(allOccurrences)
|
||||
dialog.dismiss()
|
||||
dialog?.dismiss()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,14 +12,13 @@ import com.simplemobiletools.commons.extensions.*
|
|||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import kotlinx.android.synthetic.main.dialog_export_events.view.*
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
class ExportEventsDialog(
|
||||
val activity: SimpleActivity, val path: String, val hidePath: Boolean,
|
||||
val callback: (file: File, eventTypes: ArrayList<Long>) -> Unit
|
||||
) {
|
||||
private var realPath = if (path.isEmpty()) activity.internalStoragePath else path
|
||||
val config = activity.config
|
||||
private val config = activity.config
|
||||
|
||||
init {
|
||||
val view = (activity.layoutInflater.inflate(R.layout.dialog_export_events, null) as ViewGroup).apply {
|
||||
|
@ -54,12 +53,12 @@ class ExportEventsDialog(
|
|||
}
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.export_events) {
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, R.string.export_events) { alertDialog ->
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val filename = view.export_events_filename.value
|
||||
when {
|
||||
filename.isEmpty() -> activity.toast(R.string.empty_name)
|
||||
|
@ -76,7 +75,7 @@ class ExportEventsDialog(
|
|||
|
||||
val eventTypes = (view.export_events_types_list.adapter as FilterEventTypeAdapter).getSelectedItemsList()
|
||||
callback(file, eventTypes)
|
||||
dismiss()
|
||||
alertDialog.dismiss()
|
||||
}
|
||||
}
|
||||
else -> activity.toast(R.string.invalid_name)
|
||||
|
|
|
@ -6,11 +6,12 @@ import com.simplemobiletools.calendar.pro.activities.SimpleActivity
|
|||
import com.simplemobiletools.calendar.pro.adapters.FilterEventTypeAdapter
|
||||
import com.simplemobiletools.calendar.pro.extensions.config
|
||||
import com.simplemobiletools.calendar.pro.extensions.eventsHelper
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import kotlinx.android.synthetic.main.dialog_filter_event_types.view.*
|
||||
|
||||
class FilterEventTypesDialog(val activity: SimpleActivity, val callback: () -> Unit) {
|
||||
private lateinit var dialog: AlertDialog
|
||||
private var dialog: AlertDialog? = null
|
||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_filter_event_types, null)
|
||||
|
||||
init {
|
||||
|
@ -18,11 +19,13 @@ class FilterEventTypesDialog(val activity: SimpleActivity, val callback: () -> U
|
|||
val displayEventTypes = activity.config.displayEventTypes
|
||||
view.filter_event_types_list.adapter = FilterEventTypeAdapter(activity, it, displayEventTypes)
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmEventTypes() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
||||
dialog = alertDialog
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +36,6 @@ class FilterEventTypesDialog(val activity: SimpleActivity, val callback: () -> U
|
|||
activity.config.displayEventTypes = selectedItems
|
||||
callback()
|
||||
}
|
||||
dialog.dismiss()
|
||||
dialog?.dismiss()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,17 +13,14 @@ import com.simplemobiletools.calendar.pro.helpers.IcsImporter.ImportResult.IMPOR
|
|||
import com.simplemobiletools.calendar.pro.helpers.IcsImporter.ImportResult.IMPORT_OK
|
||||
import com.simplemobiletools.calendar.pro.helpers.IcsImporter.ImportResult.IMPORT_PARTIAL
|
||||
import com.simplemobiletools.calendar.pro.helpers.REGULAR_EVENT_TYPE_ID
|
||||
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
|
||||
import com.simplemobiletools.commons.extensions.setFillWithStroke
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import kotlinx.android.synthetic.main.dialog_import_events.view.*
|
||||
|
||||
class ImportEventsDialog(val activity: SimpleActivity, val path: String, val callback: (refreshView: Boolean) -> Unit) {
|
||||
var currEventTypeId = REGULAR_EVENT_TYPE_ID
|
||||
var currEventTypeCalDAVCalendarId = 0
|
||||
val config = activity.config
|
||||
private var currEventTypeId = REGULAR_EVENT_TYPE_ID
|
||||
private var currEventTypeCalDAVCalendarId = 0
|
||||
private val config = activity.config
|
||||
|
||||
init {
|
||||
ensureBackgroundThread {
|
||||
|
@ -70,19 +67,19 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal
|
|||
}
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.import_events) {
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(null)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, R.string.import_events) { alertDialog ->
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(null)
|
||||
activity.toast(R.string.importing)
|
||||
ensureBackgroundThread {
|
||||
val overrideFileEventTypes = view.import_events_checkbox.isChecked
|
||||
val result = IcsImporter(activity).importEvents(path, currEventTypeId, currEventTypeCalDAVCalendarId, overrideFileEventTypes)
|
||||
handleParseResult(result)
|
||||
dismiss()
|
||||
alertDialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,29 +6,31 @@ import android.net.Uri
|
|||
import android.provider.Settings
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.hideKeyboard
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.showErrorToast
|
||||
|
||||
class ReminderWarningDialog(val activity: Activity, val callback: () -> Unit) {
|
||||
var dialog: AlertDialog
|
||||
private var dialog: AlertDialog? = null
|
||||
|
||||
init {
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_reminder_warning, null)
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||
.setNeutralButton(R.string.settings, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, cancelOnTouchOutside = false)
|
||||
getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener {
|
||||
redirectToSettings()
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, cancelOnTouchOutside = false) { alertDialog ->
|
||||
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener {
|
||||
redirectToSettings()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun dialogConfirmed() {
|
||||
dialog.dismiss()
|
||||
dialog?.dismiss()
|
||||
callback()
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.simplemobiletools.calendar.pro.extensions.config
|
|||
import com.simplemobiletools.calendar.pro.extensions.seconds
|
||||
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.pro.helpers.getNowSeconds
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.getDatePickerDialogTheme
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.value
|
||||
|
@ -17,8 +18,8 @@ import org.joda.time.DateTime
|
|||
import java.util.*
|
||||
|
||||
class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Long, val startTS: Long, val callback: (repeatLimit: Long) -> Unit) {
|
||||
lateinit var dialog: AlertDialog
|
||||
var view: View
|
||||
private var dialog: AlertDialog? = null
|
||||
private var view: View
|
||||
|
||||
init {
|
||||
view = activity.layoutInflater.inflate(R.layout.dialog_repeat_limit_type_picker, null).apply {
|
||||
|
@ -26,7 +27,7 @@ class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Long,
|
|||
repeat_type_count.setOnClickListener { dialog_radio_view.check(R.id.repeat_type_x_times) }
|
||||
repeat_type_forever.setOnClickListener {
|
||||
callback(0)
|
||||
dialog.dismiss()
|
||||
dialog?.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,11 +39,12 @@ class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Long,
|
|||
|
||||
updateRepeatLimitText()
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmRepetition() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this) {
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
||||
dialog = alertDialog
|
||||
activity.currentFocus?.clearFocus()
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +81,7 @@ class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Long,
|
|||
callback(count.toLong())
|
||||
}
|
||||
}
|
||||
dialog.dismiss()
|
||||
dialog?.dismiss()
|
||||
}
|
||||
|
||||
private fun showRepetitionLimitDialog() {
|
||||
|
@ -101,6 +103,6 @@ class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Long,
|
|||
repeatLimitDateTime.seconds()
|
||||
}
|
||||
callback(repeatLimit)
|
||||
dialog.dismiss()
|
||||
dialog?.dismiss()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
package com.simplemobiletools.calendar.pro.dialogs
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.extensions.config
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||
import kotlinx.android.synthetic.main.dialog_vertical_linear_layout.view.*
|
||||
import java.util.*
|
||||
|
||||
class RepeatRuleWeeklyDialog(val activity: Activity, val curRepeatRule: Int, val callback: (repeatRule: Int) -> Unit) {
|
||||
val dialog: AlertDialog
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_vertical_linear_layout, null)
|
||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_vertical_linear_layout, null)
|
||||
|
||||
init {
|
||||
val days = activity.resources.getStringArray(R.array.week_days)
|
||||
|
@ -34,12 +32,12 @@ class RepeatRuleWeeklyDialog(val activity: Activity, val curRepeatRule: Int, val
|
|||
view.dialog_vertical_linear_layout.addView(it)
|
||||
}
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok, { dialog, which -> callback(getRepeatRuleSum()) })
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
}
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> callback(getRepeatRuleSum()) }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getRepeatRuleSum(): Int {
|
||||
|
|
|
@ -3,12 +3,12 @@ package com.simplemobiletools.calendar.pro.dialogs
|
|||
import android.text.TextUtils
|
||||
import android.view.ViewGroup
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
|
||||
import com.simplemobiletools.calendar.pro.extensions.calDAVHelper
|
||||
import com.simplemobiletools.calendar.pro.extensions.config
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||
import kotlinx.android.synthetic.main.calendar_item_account.view.*
|
||||
|
@ -17,7 +17,6 @@ import kotlinx.android.synthetic.main.dialog_select_calendars.view.*
|
|||
|
||||
class SelectCalendarsDialog(val activity: SimpleActivity, val callback: () -> Unit) {
|
||||
private var prevAccount = ""
|
||||
private var dialog: AlertDialog
|
||||
private var view = (activity.layoutInflater.inflate(R.layout.dialog_select_calendars, null) as ViewGroup)
|
||||
|
||||
init {
|
||||
|
@ -38,10 +37,10 @@ class SelectCalendarsDialog(val activity: SimpleActivity, val callback: () -> Un
|
|||
addCalendarItem(true, it.displayName, it.id, ids.contains(it.id))
|
||||
}
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmSelection() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, R.string.select_caldav_calendars)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,20 +7,16 @@ import android.widget.RadioButton
|
|||
import android.widget.RadioGroup
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.extensions.config
|
||||
import com.simplemobiletools.calendar.pro.extensions.eventsHelper
|
||||
import com.simplemobiletools.calendar.pro.helpers.STORED_LOCALLY_ONLY
|
||||
import com.simplemobiletools.calendar.pro.models.CalDAVCalendar
|
||||
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
|
||||
import com.simplemobiletools.commons.extensions.setFillWithStroke
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import kotlinx.android.synthetic.main.dialog_select_radio_group.view.*
|
||||
import kotlinx.android.synthetic.main.radio_button_with_color.view.*
|
||||
|
||||
class SelectEventCalendarDialog(val activity: Activity, val calendars: List<CalDAVCalendar>, val currCalendarId: Int, val callback: (id: Int) -> Unit) {
|
||||
private val dialog: AlertDialog?
|
||||
private var dialog: AlertDialog? = null
|
||||
private val radioGroup: RadioGroup
|
||||
private var wasInit = false
|
||||
|
||||
|
@ -46,9 +42,11 @@ class SelectEventCalendarDialog(val activity: Activity, val calendars: List<CalD
|
|||
}
|
||||
}
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
activity.getAlertDialogBuilder()
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
||||
dialog = alertDialog
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@ import android.widget.RadioGroup
|
|||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.extensions.calDAVHelper
|
||||
import com.simplemobiletools.calendar.pro.extensions.config
|
||||
import com.simplemobiletools.calendar.pro.models.EventType
|
||||
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
|
||||
import com.simplemobiletools.commons.extensions.setFillWithStroke
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
|
@ -17,7 +17,7 @@ import kotlinx.android.synthetic.main.dialog_select_event_type_color.view.*
|
|||
import kotlinx.android.synthetic.main.radio_button_with_color.view.*
|
||||
|
||||
class SelectEventTypeColorDialog(val activity: Activity, val eventType: EventType, val callback: (color: Int) -> Unit) {
|
||||
private val dialog: AlertDialog?
|
||||
private var dialog: AlertDialog? = null
|
||||
private val radioGroup: RadioGroup
|
||||
private var wasInit = false
|
||||
private val colors = activity.calDAVHelper.getAvailableCalDAVCalendarColors(eventType)
|
||||
|
@ -34,9 +34,11 @@ class SelectEventTypeColorDialog(val activity: Activity, val eventType: EventTyp
|
|||
}
|
||||
|
||||
wasInit = true
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
activity.getAlertDialogBuilder()
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
||||
dialog = alertDialog
|
||||
}
|
||||
|
||||
if (colors.isEmpty()) {
|
||||
showCustomColorPicker()
|
||||
|
|
|
@ -6,14 +6,12 @@ import android.view.ViewGroup
|
|||
import android.widget.RadioGroup
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.extensions.config
|
||||
import com.simplemobiletools.calendar.pro.extensions.eventsHelper
|
||||
import com.simplemobiletools.calendar.pro.models.EventType
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||
import kotlinx.android.synthetic.main.dialog_select_radio_group.view.*
|
||||
import kotlinx.android.synthetic.main.radio_button_with_color.view.*
|
||||
import java.util.*
|
||||
|
||||
class SelectEventTypeDialog(
|
||||
val activity: Activity, val currEventType: Long, val showCalDAVCalendars: Boolean, val showNewEventTypeOption: Boolean,
|
||||
|
@ -22,7 +20,7 @@ class SelectEventTypeDialog(
|
|||
private val NEW_EVENT_TYPE_ID = -2L
|
||||
private val LAST_USED_EVENT_TYPE_ID = -1L
|
||||
|
||||
private val dialog: AlertDialog?
|
||||
private var dialog: AlertDialog? = null
|
||||
private val radioGroup: RadioGroup
|
||||
private var wasInit = false
|
||||
private var eventTypes = ArrayList<EventType>()
|
||||
|
@ -50,9 +48,11 @@ class SelectEventTypeDialog(
|
|||
}
|
||||
}
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
activity.getAlertDialogBuilder()
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
||||
dialog = alertDialog
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,12 @@ import com.simplemobiletools.calendar.pro.activities.SimpleActivity
|
|||
import com.simplemobiletools.calendar.pro.adapters.FilterEventTypeAdapter
|
||||
import com.simplemobiletools.calendar.pro.extensions.config
|
||||
import com.simplemobiletools.calendar.pro.extensions.eventsHelper
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import kotlinx.android.synthetic.main.dialog_filter_event_types.view.*
|
||||
|
||||
class SelectQuickFilterEventTypesDialog(val activity: SimpleActivity) {
|
||||
private lateinit var dialog: AlertDialog
|
||||
private var dialog: AlertDialog? = null
|
||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_filter_event_types, null)
|
||||
|
||||
init {
|
||||
|
@ -18,20 +19,25 @@ class SelectQuickFilterEventTypesDialog(val activity: SimpleActivity) {
|
|||
val quickFilterEventTypes = activity.config.quickFilterEventTypes
|
||||
view.filter_event_types_list.adapter = FilterEventTypeAdapter(activity, it, quickFilterEventTypes)
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmEventTypes() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
||||
dialog = alertDialog
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun confirmEventTypes() {
|
||||
val selectedItems = (view.filter_event_types_list.adapter as FilterEventTypeAdapter).getSelectedItemsList().map { it.toString() }.toHashSet()
|
||||
val selectedItems = (view.filter_event_types_list.adapter as FilterEventTypeAdapter).getSelectedItemsList().map {
|
||||
it.toString()
|
||||
}.toHashSet()
|
||||
|
||||
if (activity.config.quickFilterEventTypes != selectedItems) {
|
||||
activity.config.quickFilterEventTypes = selectedItems
|
||||
}
|
||||
dialog.dismiss()
|
||||
dialog?.dismiss()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.simplemobiletools.calendar.pro.dialogs
|
|||
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.extensions.config
|
||||
import com.simplemobiletools.calendar.pro.helpers.ANNIVERSARY_EVENT
|
||||
|
@ -69,10 +68,10 @@ class SetRemindersDialog(val activity: Activity, val eventType: Int, val callbac
|
|||
}
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, R.string.event_reminders)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.DatePicker
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.activities.MainActivity
|
||||
|
@ -15,10 +14,7 @@ import com.simplemobiletools.calendar.pro.helpers.DAILY_VIEW
|
|||
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.getDatePickerDialogTheme
|
||||
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.updateActionBarTitle
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.views.MyViewPager
|
||||
import kotlinx.android.synthetic.main.fragment_days_holder.view.*
|
||||
import org.joda.time.DateTime
|
||||
|
@ -113,10 +109,10 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
|
|||
val dateTime = getCurrentDate()!!
|
||||
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, dateTime.dayOfMonth, null)
|
||||
|
||||
AlertDialog.Builder(requireContext())
|
||||
activity?.getAlertDialogBuilder()!!
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> dateSelected(dateTime, datePicker) }
|
||||
.create().apply {
|
||||
.apply {
|
||||
activity?.setupDialogStuff(view, this)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.DatePicker
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.activities.MainActivity
|
||||
|
@ -113,10 +112,10 @@ class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener {
|
|||
val dateTime = getCurrentDate()!!
|
||||
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, 1, null)
|
||||
|
||||
AlertDialog.Builder(requireContext())
|
||||
activity?.getAlertDialogBuilder()!!
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> datePicked(dateTime, datePicker) }
|
||||
.create().apply {
|
||||
.apply {
|
||||
activity?.setupDialogStuff(view, this)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,12 +7,10 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.DatePicker
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.activities.MainActivity
|
||||
import com.simplemobiletools.calendar.pro.adapters.MyMonthPagerAdapter
|
||||
import com.simplemobiletools.calendar.pro.extensions.config
|
||||
import com.simplemobiletools.calendar.pro.extensions.getMonthCode
|
||||
import com.simplemobiletools.calendar.pro.helpers.DAY_CODE
|
||||
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
||||
|
@ -114,10 +112,10 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
|
|||
val dateTime = getCurrentDate()!!
|
||||
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, 1, null)
|
||||
|
||||
AlertDialog.Builder(requireContext())
|
||||
activity?.getAlertDialogBuilder()!!
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> datePicked(dateTime, datePicker) }
|
||||
.create().apply {
|
||||
.apply {
|
||||
activity?.setupDialogStuff(view, this)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import android.view.ViewGroup
|
|||
import android.widget.DatePicker
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
|
@ -185,10 +184,10 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
|
|||
val dateTime = getCurrentDate()!!
|
||||
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, dateTime.dayOfMonth, null)
|
||||
|
||||
AlertDialog.Builder(requireContext())
|
||||
activity?.getAlertDialogBuilder()!!
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> dateSelected(dateTime, datePicker) }
|
||||
.create().apply {
|
||||
.apply {
|
||||
activity?.setupDialogStuff(view, this)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.DatePicker
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.activities.MainActivity
|
||||
|
@ -101,10 +100,10 @@ class YearFragmentsHolder : MyFragmentHolder() {
|
|||
val dateTime = DateTime(Formatter.getDateTimeFromCode("${currentYear}0523").toString())
|
||||
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, 1, null)
|
||||
|
||||
AlertDialog.Builder(requireContext())
|
||||
activity?.getAlertDialogBuilder()!!
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> datePicked(datePicker) }
|
||||
.create().apply {
|
||||
.apply {
|
||||
activity?.setupDialogStuff(view, this)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue