Merge pull request #1312 from Yairks/master

Add option to update this and future occurrences
This commit is contained in:
Tibor Kaputa 2021-03-21 19:02:14 +01:00 committed by GitHub
commit cead17087f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 19 deletions

View File

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

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

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