From 18c98171bbc08ed1ff0f48a2bbd5a6bb297cdfc7 Mon Sep 17 00:00:00 2001 From: yairks Date: Mon, 15 Mar 2021 12:08:52 -0400 Subject: [PATCH] Add option to update this and future occurrences --- .../calendar/pro/activities/EventActivity.kt | 46 +++++++++++++------ .../pro/dialogs/EditRepeatingEventDialog.kt | 9 ++-- .../layout/dialog_edit_repeating_event.xml | 8 ++++ app/src/main/res/values/strings.xml | 3 +- gradle/wrapper/gradle-wrapper.properties | 4 +- 5 files changed, 48 insertions(+), 22 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt index c1b05bb43..ac296ee8d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt @@ -1135,25 +1135,41 @@ class EventActivity : SimpleActivity() { private fun showEditRepeatingEventDialog() { EditRepeatingEventDialog(this) { - if (it) { - ensureBackgroundThread { - eventsHelper.updateEvent(mEvent, true, true) { - finish() + when (it) { + 0 -> { + ensureBackgroundThread { + eventsHelper.addEventRepetitionException(mEvent.id!!, mEventOccurrenceTS, true) + mEvent.apply { + parentId = id!!.toLong() + id = null + repeatRule = 0 + repeatInterval = 0 + repeatLimit = 0 + } + + eventsHelper.insertEvent(mEvent, true, true) { + finish() + } } } - } else { - ensureBackgroundThread { - eventsHelper.addEventRepetitionException(mEvent.id!!, mEventOccurrenceTS, true) - mEvent.apply { - parentId = id!!.toLong() - id = null - repeatRule = 0 - repeatInterval = 0 - repeatLimit = 0 + 1 -> { + ensureBackgroundThread { + eventsHelper.addEventRepeatLimit(mEvent.id!!, mEventOccurrenceTS) + mEvent.apply { + id = null + } + eventsHelper.insertEvent(mEvent, true, true) { + finish() + } } + } - eventsHelper.insertEvent(mEvent, true, true) { - finish() + 2 -> { + ensureBackgroundThread { + eventsHelper.addEventRepeatLimit(mEvent.id!!, mEventOccurrenceTS) + eventsHelper.updateEvent(mEvent, true, true) { + finish() + } } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/EditRepeatingEventDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/EditRepeatingEventDialog.kt index f9530aaea..adab8087f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/EditRepeatingEventDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/EditRepeatingEventDialog.kt @@ -8,13 +8,14 @@ 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 callback: (allOccurrences: Boolean) -> Unit) { +class EditRepeatingEventDialog(val activity: SimpleActivity, val callback: (allOccurrences: Int) -> Unit) { var dialog: AlertDialog init { val view = (activity.layoutInflater.inflate(R.layout.dialog_edit_repeating_event, null) as ViewGroup).apply { - edit_repeating_event_one_only.setOnClickListener { sendResult(false) } - edit_repeating_event_all_occurrences.setOnClickListener { sendResult(true) } + edit_repeating_event_one_only.setOnClickListener { sendResult(0) } + edit_repeating_event_this_and_future_occurences.setOnClickListener { sendResult(1)} + edit_repeating_event_all_occurrences.setOnClickListener { sendResult(2) } } dialog = AlertDialog.Builder(activity) @@ -25,7 +26,7 @@ class EditRepeatingEventDialog(val activity: SimpleActivity, val callback: (allO } } - private fun sendResult(allOccurrences: Boolean) { + private fun sendResult(allOccurrences: Int) { callback(allOccurrences) dialog.dismiss() } diff --git a/app/src/main/res/layout/dialog_edit_repeating_event.xml b/app/src/main/res/layout/dialog_edit_repeating_event.xml index 071a934c4..218122516 100644 --- a/app/src/main/res/layout/dialog_edit_repeating_event.xml +++ b/app/src/main/res/layout/dialog_edit_repeating_event.xml @@ -30,6 +30,14 @@ android:paddingTop="@dimen/activity_margin" android:text="@string/update_one_only"/> + + - + Simple Calendar Calendar Change view @@ -51,6 +51,7 @@ Delete this and all future occurrences Delete all occurrences Update the selected occurrence only + Update this and all future occurrences Update all occurrences Repeat till a date Stop repeating after x occurrences diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4a0ca69c0..be1e41212 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Nov 02 19:09:05 CET 2020 +#Mon Mar 15 09:51:01 EDT 2021 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip