Add option to update this and future occurrences

This commit is contained in:
yairks 2021-03-15 12:08:52 -04:00
parent 566039fa1c
commit 18c98171bb
5 changed files with 48 additions and 22 deletions

View File

@ -1135,13 +1135,8 @@ class EventActivity : SimpleActivity() {
private fun showEditRepeatingEventDialog() {
EditRepeatingEventDialog(this) {
if (it) {
ensureBackgroundThread {
eventsHelper.updateEvent(mEvent, true, true) {
finish()
}
}
} else {
when (it) {
0 -> {
ensureBackgroundThread {
eventsHelper.addEventRepetitionException(mEvent.id!!, mEventOccurrenceTS, true)
mEvent.apply {
@ -1157,6 +1152,27 @@ class EventActivity : SimpleActivity() {
}
}
}
1 -> {
ensureBackgroundThread {
eventsHelper.addEventRepeatLimit(mEvent.id!!, mEventOccurrenceTS)
mEvent.apply {
id = null
}
eventsHelper.insertEvent(mEvent, true, true) {
finish()
}
}
}
2 -> {
ensureBackgroundThread {
eventsHelper.addEventRepeatLimit(mEvent.id!!, mEventOccurrenceTS)
eventsHelper.updateEvent(mEvent, true, true) {
finish()
}
}
}
}
}
}

View File

@ -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()
}

View File

@ -30,6 +30,14 @@
android:paddingTop="@dimen/activity_margin"
android:text="@string/update_one_only"/>
<com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/edit_repeating_event_this_and_future_occurences"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin"
android:text="@string/update_this_and_future_occurrences" />
<com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/edit_repeating_event_all_occurrences"
android:layout_width="match_parent"

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources xmlns:tools="http://schemas.android.com/tools">
<string name="app_name">Simple Calendar</string>
<string name="app_launcher_name">Calendar</string>
<string name="change_view">Change view</string>
@ -51,6 +51,7 @@
<string name="delete_future_occurrences">Delete this and all future occurrences</string>
<string name="delete_all_occurrences">Delete all occurrences</string>
<string name="update_one_only">Update the selected occurrence only</string>
<string name="update_this_and_future_occurrences">Update this and all future occurrences</string>
<string name="update_all_occurrences">Update all occurrences</string>
<string name="repeat_till_date">Repeat till a date</string>
<string name="stop_repeating_after_x">Stop repeating after x occurrences</string>

View File

@ -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