mirror of
				https://github.com/SimpleMobileTools/Simple-Calendar.git
				synced 2025-06-05 21:59:17 +02:00 
			
		
		
		
	some code style updates at the dialogs
This commit is contained in:
		| @@ -10,7 +10,7 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff | |||||||
| import com.simplemobiletools.commons.extensions.value | import com.simplemobiletools.commons.extensions.value | ||||||
| import kotlinx.android.synthetic.main.dialog_custom_event_reminder.view.* | import kotlinx.android.synthetic.main.dialog_custom_event_reminder.view.* | ||||||
|  |  | ||||||
| class CustomEventReminderDialog(val activity: Activity, val selectedMinutes: Int = 0, val callback: (minutes: Int) -> Unit) : AlertDialog.Builder(activity) { | class CustomEventReminderDialog(val activity: Activity, val selectedMinutes: Int = 0, val callback: (minutes: Int) -> Unit) { | ||||||
|     var dialog: AlertDialog |     var dialog: AlertDialog | ||||||
|     var view = (activity.layoutInflater.inflate(R.layout.dialog_custom_event_reminder, null) as ViewGroup).apply { |     var view = (activity.layoutInflater.inflate(R.layout.dialog_custom_event_reminder, null) as ViewGroup).apply { | ||||||
|         if (selectedMinutes == 0) { |         if (selectedMinutes == 0) { | ||||||
| @@ -41,7 +41,7 @@ class CustomEventReminderDialog(val activity: Activity, val selectedMinutes: Int | |||||||
|         val value = view.dialog_custom_reminder_value.value |         val value = view.dialog_custom_reminder_value.value | ||||||
|         val multiplier = getMultiplier(view.dialog_radio_view.checkedRadioButtonId) |         val multiplier = getMultiplier(view.dialog_radio_view.checkedRadioButtonId) | ||||||
|         val minutes = Integer.valueOf(if (value.isEmpty()) "0" else value) |         val minutes = Integer.valueOf(if (value.isEmpty()) "0" else value) | ||||||
|         callback.invoke(minutes * multiplier) |         callback(minutes * multiplier) | ||||||
|         activity.hideKeyboard() |         activity.hideKeyboard() | ||||||
|         dialog.dismiss() |         dialog.dismiss() | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ import com.simplemobiletools.commons.extensions.beVisibleIf | |||||||
| import com.simplemobiletools.commons.extensions.setupDialogStuff | import com.simplemobiletools.commons.extensions.setupDialogStuff | ||||||
| import kotlinx.android.synthetic.main.dialog_delete_event.view.* | import kotlinx.android.synthetic.main.dialog_delete_event.view.* | ||||||
|  |  | ||||||
| class DeleteEventDialog(val activity: Activity, eventIds: List<Int>, val callback: (allOccurrences: Boolean) -> Unit) : AlertDialog.Builder(activity) { | class DeleteEventDialog(val activity: Activity, eventIds: List<Int>, val callback: (allOccurrences: Boolean) -> Unit) { | ||||||
|     val dialog: AlertDialog? |     val dialog: AlertDialog? | ||||||
|  |  | ||||||
|     init { |     init { | ||||||
| @@ -36,6 +36,6 @@ class DeleteEventDialog(val activity: Activity, eventIds: List<Int>, val callbac | |||||||
|     private fun dialogConfirmed(view: ViewGroup, hasRepeatableEvent: Boolean) { |     private fun dialogConfirmed(view: ViewGroup, hasRepeatableEvent: Boolean) { | ||||||
|         val deleteAllOccurrences = !hasRepeatableEvent || view.delete_event_radio_view.checkedRadioButtonId == R.id.delete_event_all |         val deleteAllOccurrences = !hasRepeatableEvent || view.delete_event_radio_view.checkedRadioButtonId == R.id.delete_event_all | ||||||
|         dialog?.dismiss() |         dialog?.dismiss() | ||||||
|         callback.invoke(deleteAllOccurrences) |         callback(deleteAllOccurrences) | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ import com.simplemobiletools.calendar.activities.SimpleActivity | |||||||
| import com.simplemobiletools.commons.extensions.setupDialogStuff | import com.simplemobiletools.commons.extensions.setupDialogStuff | ||||||
| import kotlinx.android.synthetic.main.dialog_edit_repeating_event.view.* | import kotlinx.android.synthetic.main.dialog_edit_repeating_event.view.* | ||||||
|  |  | ||||||
| class EditRepeatingEventDialog(val activity: SimpleActivity, val callback: (allOccurrences: Boolean) -> Unit) : AlertDialog.Builder(activity) { | class EditRepeatingEventDialog(val activity: SimpleActivity, val callback: (allOccurrences: Boolean) -> Unit) { | ||||||
|     var dialog: AlertDialog |     var dialog: AlertDialog | ||||||
|  |  | ||||||
|     init { |     init { | ||||||
|   | |||||||
| @@ -11,8 +11,7 @@ import com.simplemobiletools.commons.extensions.* | |||||||
| import kotlinx.android.synthetic.main.dialog_export_events.view.* | import kotlinx.android.synthetic.main.dialog_export_events.view.* | ||||||
| import java.io.File | import java.io.File | ||||||
|  |  | ||||||
| class ExportEventsDialog(val activity: SimpleActivity, val path: String, val callback: (exportPastEvents: Boolean, file: File, eventTypes: HashSet<String>) -> Unit) | class ExportEventsDialog(val activity: SimpleActivity, val path: String, val callback: (exportPastEvents: Boolean, file: File, eventTypes: HashSet<String>) -> Unit) { | ||||||
|     : AlertDialog.Builder(activity) { |  | ||||||
|  |  | ||||||
|     init { |     init { | ||||||
|         val view = (activity.layoutInflater.inflate(R.layout.dialog_export_events, null) as ViewGroup).apply { |         val view = (activity.layoutInflater.inflate(R.layout.dialog_export_events, null) as ViewGroup).apply { | ||||||
| @@ -42,20 +41,20 @@ class ExportEventsDialog(val activity: SimpleActivity, val path: String, val cal | |||||||
|             activity.setupDialogStuff(view, this, R.string.export_events) |             activity.setupDialogStuff(view, this, R.string.export_events) | ||||||
|             getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ |             getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ | ||||||
|                 val filename = view.export_events_filename.value |                 val filename = view.export_events_filename.value | ||||||
|                 if (filename.isEmpty()) { |                 when { | ||||||
|                     activity.toast(R.string.empty_name) |                     filename.isEmpty() -> activity.toast(R.string.empty_name) | ||||||
|                 } else if (filename.isAValidFilename()) { |                     filename.isAValidFilename() -> { | ||||||
|                     val file = File(path, "$filename.ics") |                         val file = File(path, "$filename.ics") | ||||||
|                     if (file.exists()) { |                         if (file.exists()) { | ||||||
|                         activity.toast(R.string.name_taken) |                             activity.toast(R.string.name_taken) | ||||||
|                         return@setOnClickListener |                             return@setOnClickListener | ||||||
|                     } |                         } | ||||||
|  |  | ||||||
|                     val eventTypes = (view.export_events_types_list.adapter as FilterEventTypeAdapter).getSelectedItemsSet() |                         val eventTypes = (view.export_events_types_list.adapter as FilterEventTypeAdapter).getSelectedItemsSet() | ||||||
|                     callback(view.export_events_checkbox.isChecked, file, eventTypes) |                         callback(view.export_events_checkbox.isChecked, file, eventTypes) | ||||||
|                     dismiss() |                         dismiss() | ||||||
|                 } else { |                     } | ||||||
|                     activity.toast(R.string.invalid_name) |                     else -> activity.toast(R.string.invalid_name) | ||||||
|                 } |                 } | ||||||
|             }) |             }) | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff | |||||||
| import kotlinx.android.synthetic.main.dialog_filter_event_types.view.* | import kotlinx.android.synthetic.main.dialog_filter_event_types.view.* | ||||||
| import java.util.* | import java.util.* | ||||||
|  |  | ||||||
| class FilterEventTypesDialog(val activity: SimpleActivity, val callback: () -> Unit) : AlertDialog.Builder(activity) { | class FilterEventTypesDialog(val activity: SimpleActivity, val callback: () -> Unit) { | ||||||
|     var dialog: AlertDialog |     var dialog: AlertDialog | ||||||
|     var eventTypes = ArrayList<EventType>() |     var eventTypes = ArrayList<EventType>() | ||||||
|     val view = activity.layoutInflater.inflate(R.layout.dialog_filter_event_types, null) |     val view = activity.layoutInflater.inflate(R.layout.dialog_filter_event_types, null) | ||||||
| @@ -35,7 +35,7 @@ class FilterEventTypesDialog(val activity: SimpleActivity, val callback: () -> U | |||||||
|         val selectedItems = (view.filter_event_types_list.adapter as FilterEventTypeAdapter).getSelectedItemsSet() |         val selectedItems = (view.filter_event_types_list.adapter as FilterEventTypeAdapter).getSelectedItemsSet() | ||||||
|         if (activity.config.displayEventTypes != selectedItems) { |         if (activity.config.displayEventTypes != selectedItems) { | ||||||
|             activity.config.displayEventTypes = selectedItems |             activity.config.displayEventTypes = selectedItems | ||||||
|             callback.invoke() |             callback() | ||||||
|         } |         } | ||||||
|         dialog.dismiss() |         dialog.dismiss() | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff | |||||||
| import com.simplemobiletools.commons.extensions.toast | import com.simplemobiletools.commons.extensions.toast | ||||||
| import kotlinx.android.synthetic.main.dialog_import_events.view.* | import kotlinx.android.synthetic.main.dialog_import_events.view.* | ||||||
|  |  | ||||||
| class ImportEventsDialog(val activity: SimpleActivity, val path: String, val callback: (refreshView: Boolean) -> Unit) : AlertDialog.Builder(activity) { | class ImportEventsDialog(val activity: SimpleActivity, val path: String, val callback: (refreshView: Boolean) -> Unit) { | ||||||
|     var currEventTypeId = DBHelper.REGULAR_EVENT_TYPE_ID |     var currEventTypeId = DBHelper.REGULAR_EVENT_TYPE_ID | ||||||
|  |  | ||||||
|     init { |     init { | ||||||
| @@ -45,7 +45,7 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun updateEventType(view: ViewGroup) { |     private fun updateEventType(view: ViewGroup) { | ||||||
|         val eventType = context.dbHelper.getEventType(currEventTypeId) |         val eventType = activity.dbHelper.getEventType(currEventTypeId) | ||||||
|         view.import_event_type_title.text = eventType!!.getDisplayTitle() |         view.import_event_type_title.text = eventType!!.getDisplayTitle() | ||||||
|         view.import_event_type_color.setBackgroundWithStroke(eventType.color, activity.config.backgroundColor) |         view.import_event_type_color.setBackgroundWithStroke(eventType.color, activity.config.backgroundColor) | ||||||
|     } |     } | ||||||
| @@ -56,6 +56,6 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal | |||||||
|             IMPORT_PARTIAL -> R.string.importing_some_events_failed |             IMPORT_PARTIAL -> R.string.importing_some_events_failed | ||||||
|             else -> R.string.importing_events_failed |             else -> R.string.importing_events_failed | ||||||
|         }) |         }) | ||||||
|         callback.invoke(result != IMPORT_FAIL) |         callback(result != IMPORT_FAIL) | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -17,8 +17,7 @@ import kotlinx.android.synthetic.main.dialog_repeat_limit_type_picker.view.* | |||||||
| import org.joda.time.DateTime | import org.joda.time.DateTime | ||||||
| import java.util.* | import java.util.* | ||||||
|  |  | ||||||
| class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Int, val startTS: Int, val callback: (repeatLimit: Int) -> Unit) : | class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Int, val startTS: Int, val callback: (repeatLimit: Int) -> Unit) { | ||||||
|         AlertDialog.Builder(activity) { |  | ||||||
|     lateinit var dialog: AlertDialog |     lateinit var dialog: AlertDialog | ||||||
|     var view: View |     var view: View | ||||||
|  |  | ||||||
| @@ -45,14 +44,13 @@ class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Int, | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun getCheckedItem(): Int { |     private fun getCheckedItem() = when { | ||||||
|         return if (repeatLimit > 0) |         repeatLimit > 0 -> R.id.repeat_type_till_date | ||||||
|             R.id.repeat_type_till_date |         repeatLimit < 0 -> { | ||||||
|         else if (repeatLimit < 0) { |  | ||||||
|             view.repeat_type_count.setText((-repeatLimit).toString()) |             view.repeat_type_count.setText((-repeatLimit).toString()) | ||||||
|             R.id.repeat_type_x_times |             R.id.repeat_type_x_times | ||||||
|         } else |         } | ||||||
|             R.id.repeat_type_forever |         else -> R.id.repeat_type_forever | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun updateRepeatLimitText() { |     private fun updateRepeatLimitText() { | ||||||
| @@ -95,10 +93,10 @@ class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Int, | |||||||
|  |  | ||||||
|     private val repetitionLimitDateSetListener = DatePickerDialog.OnDateSetListener { v, year, monthOfYear, dayOfMonth -> |     private val repetitionLimitDateSetListener = DatePickerDialog.OnDateSetListener { v, year, monthOfYear, dayOfMonth -> | ||||||
|         val repeatLimitDateTime = DateTime().withDate(year, monthOfYear + 1, dayOfMonth).withTime(23, 59, 59, 0) |         val repeatLimitDateTime = DateTime().withDate(year, monthOfYear + 1, dayOfMonth).withTime(23, 59, 59, 0) | ||||||
|         if (repeatLimitDateTime.seconds() < startTS) { |         repeatLimit = if (repeatLimitDateTime.seconds() < startTS) { | ||||||
|             repeatLimit = 0 |             0 | ||||||
|         } else { |         } else { | ||||||
|             repeatLimit = repeatLimitDateTime.seconds() |             repeatLimitDateTime.seconds() | ||||||
|         } |         } | ||||||
|         callback(repeatLimit) |         callback(repeatLimit) | ||||||
|         dialog.dismiss() |         dialog.dismiss() | ||||||
|   | |||||||
| @@ -8,8 +8,7 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff | |||||||
| import com.simplemobiletools.commons.views.MyAppCompatCheckbox | import com.simplemobiletools.commons.views.MyAppCompatCheckbox | ||||||
| import kotlinx.android.synthetic.main.dialog_vertical_linear_layout.view.* | import kotlinx.android.synthetic.main.dialog_vertical_linear_layout.view.* | ||||||
|  |  | ||||||
| class RepeatRuleWeeklyDialog(val activity: Activity, val curRepeatRule: Int, val callback: (repeatRule: Int) -> Unit) : | class RepeatRuleWeeklyDialog(val activity: Activity, val curRepeatRule: Int, val callback: (repeatRule: Int) -> Unit) { | ||||||
|         AlertDialog.Builder(activity) { |  | ||||||
|     val dialog: AlertDialog |     val dialog: AlertDialog | ||||||
|     val view = activity.layoutInflater.inflate(R.layout.dialog_vertical_linear_layout, null) |     val view = activity.layoutInflater.inflate(R.layout.dialog_vertical_linear_layout, null) | ||||||
|  |  | ||||||
| @@ -46,7 +45,7 @@ class RepeatRuleWeeklyDialog(val activity: Activity, val curRepeatRule: Int, val | |||||||
|     private fun getRepeatRuleSum(): Int { |     private fun getRepeatRuleSum(): Int { | ||||||
|         var sum = 0 |         var sum = 0 | ||||||
|         val cnt = view.dialog_vertical_linear_layout.childCount |         val cnt = view.dialog_vertical_linear_layout.childCount | ||||||
|         for (i in 0..cnt - 1) { |         for (i in 0 until cnt) { | ||||||
|             val child = view.dialog_vertical_linear_layout.getChildAt(i) |             val child = view.dialog_vertical_linear_layout.getChildAt(i) | ||||||
|             if (child is MyAppCompatCheckbox) { |             if (child is MyAppCompatCheckbox) { | ||||||
|                 if (child.isChecked) |                 if (child.isChecked) | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ import kotlinx.android.synthetic.main.calendar_item_account.view.* | |||||||
| import kotlinx.android.synthetic.main.calendar_item_calendar.view.* | import kotlinx.android.synthetic.main.calendar_item_calendar.view.* | ||||||
| import kotlinx.android.synthetic.main.dialog_select_calendars.view.* | import kotlinx.android.synthetic.main.dialog_select_calendars.view.* | ||||||
|  |  | ||||||
| class SelectCalendarsDialog(val activity: Activity, val callback: () -> Unit) : AlertDialog.Builder(activity) { | class SelectCalendarsDialog(val activity: Activity, val callback: () -> Unit) { | ||||||
|     var prevAccount = "" |     var prevAccount = "" | ||||||
|     var dialog: AlertDialog |     var dialog: AlertDialog | ||||||
|     var view = (activity.layoutInflater.inflate(R.layout.dialog_select_calendars, null) as ViewGroup) |     var view = (activity.layoutInflater.inflate(R.layout.dialog_select_calendars, null) as ViewGroup) | ||||||
|   | |||||||
| @@ -63,7 +63,7 @@ class SelectEventCalendarDialog(val activity: Activity, val calendars: List<CalD | |||||||
|         if (!wasInit) |         if (!wasInit) | ||||||
|             return |             return | ||||||
|  |  | ||||||
|         callback.invoke(typeId) |         callback(typeId) | ||||||
|         dialog?.dismiss() |         dialog?.dismiss() | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -55,7 +55,7 @@ class SelectEventTypeColorDialog(val activity: Activity, val eventType: EventTyp | |||||||
|         if (!wasInit) |         if (!wasInit) | ||||||
|             return |             return | ||||||
|  |  | ||||||
|         callback.invoke(colors[colorKey]) |         callback(colors[colorKey]) | ||||||
|         dialog?.dismiss() |         dialog?.dismiss() | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -69,12 +69,12 @@ class SelectEventTypeDialog(val activity: Activity, val currEventType: Int, val | |||||||
|  |  | ||||||
|         if (typeId == NEW_TYPE_ID) { |         if (typeId == NEW_TYPE_ID) { | ||||||
|             UpdateEventTypeDialog(activity) { |             UpdateEventTypeDialog(activity) { | ||||||
|                 callback.invoke(it) |                 callback(it) | ||||||
|                 activity.hideKeyboard() |                 activity.hideKeyboard() | ||||||
|                 dialog?.dismiss() |                 dialog?.dismiss() | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             callback.invoke(typeId) |             callback(typeId) | ||||||
|             dialog?.dismiss() |             dialog?.dismiss() | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -9,8 +9,7 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff | |||||||
| import com.simplemobiletools.commons.extensions.value | import com.simplemobiletools.commons.extensions.value | ||||||
| import kotlinx.android.synthetic.main.dialog_snooze_picker.view.* | import kotlinx.android.synthetic.main.dialog_snooze_picker.view.* | ||||||
|  |  | ||||||
| class SnoozePickerDialog(val activity: SimpleActivity, val minutes: Int, val callback: (newMinutes: Int) -> Unit) | class SnoozePickerDialog(val activity: SimpleActivity, val minutes: Int, val callback: (newMinutes: Int) -> Unit) { | ||||||
|     : AlertDialog.Builder(activity) { |  | ||||||
|     init { |     init { | ||||||
|         val view = (activity.layoutInflater.inflate(R.layout.dialog_snooze_picker, null) as ViewGroup).apply { |         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_label.text = snooze_picker_label.text.toString().capitalize() | ||||||
|   | |||||||
| @@ -15,7 +15,7 @@ import com.simplemobiletools.commons.extensions.toast | |||||||
| import com.simplemobiletools.commons.extensions.value | import com.simplemobiletools.commons.extensions.value | ||||||
| import kotlinx.android.synthetic.main.dialog_event_type.view.* | import kotlinx.android.synthetic.main.dialog_event_type.view.* | ||||||
|  |  | ||||||
| class UpdateEventTypeDialog(val activity: Activity, var eventType: EventType? = null, val callback: (eventTypeId: Int) -> Unit) : AlertDialog.Builder(activity) { | class UpdateEventTypeDialog(val activity: Activity, var eventType: EventType? = null, val callback: (eventTypeId: Int) -> Unit) { | ||||||
|     var isNewEvent = eventType == null |     var isNewEvent = eventType == null | ||||||
|  |  | ||||||
|     init { |     init { | ||||||
| @@ -73,7 +73,7 @@ class UpdateEventTypeDialog(val activity: Activity, var eventType: EventType? = | |||||||
|  |  | ||||||
|                 if (eventTypeId != -1) { |                 if (eventTypeId != -1) { | ||||||
|                     dismiss() |                     dismiss() | ||||||
|                     callback.invoke(eventTypeId) |                     callback(eventTypeId) | ||||||
|                 } else { |                 } else { | ||||||
|                     activity.toast(R.string.editing_calendar_failed) |                     activity.toast(R.string.editing_calendar_failed) | ||||||
|                 } |                 } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user