Merge pull request #1312 from Yairks/master
Add option to update this and future occurrences
This commit is contained in:
commit
cead17087f
|
@ -1135,25 +1135,41 @@ class EventActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun showEditRepeatingEventDialog() {
|
private fun showEditRepeatingEventDialog() {
|
||||||
EditRepeatingEventDialog(this) {
|
EditRepeatingEventDialog(this) {
|
||||||
if (it) {
|
when (it) {
|
||||||
ensureBackgroundThread {
|
0 -> {
|
||||||
eventsHelper.updateEvent(mEvent, true, true) {
|
ensureBackgroundThread {
|
||||||
finish()
|
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 {
|
1 -> {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
eventsHelper.addEventRepetitionException(mEvent.id!!, mEventOccurrenceTS, true)
|
eventsHelper.addEventRepeatLimit(mEvent.id!!, mEventOccurrenceTS)
|
||||||
mEvent.apply {
|
mEvent.apply {
|
||||||
parentId = id!!.toLong()
|
id = null
|
||||||
id = null
|
}
|
||||||
repeatRule = 0
|
eventsHelper.insertEvent(mEvent, true, true) {
|
||||||
repeatInterval = 0
|
finish()
|
||||||
repeatLimit = 0
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
eventsHelper.insertEvent(mEvent, true, true) {
|
2 -> {
|
||||||
finish()
|
ensureBackgroundThread {
|
||||||
|
eventsHelper.addEventRepeatLimit(mEvent.id!!, mEventOccurrenceTS)
|
||||||
|
eventsHelper.updateEvent(mEvent, true, true) {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,14 @@ import com.simplemobiletools.commons.extensions.hideKeyboard
|
||||||
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) {
|
class EditRepeatingEventDialog(val activity: SimpleActivity, val callback: (allOccurrences: Int) -> Unit) {
|
||||||
var dialog: AlertDialog
|
var dialog: AlertDialog
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val view = (activity.layoutInflater.inflate(R.layout.dialog_edit_repeating_event, null) as ViewGroup).apply {
|
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_one_only.setOnClickListener { sendResult(0) }
|
||||||
edit_repeating_event_all_occurrences.setOnClickListener { sendResult(true) }
|
edit_repeating_event_this_and_future_occurences.setOnClickListener { sendResult(1)}
|
||||||
|
edit_repeating_event_all_occurrences.setOnClickListener { sendResult(2) }
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog = AlertDialog.Builder(activity)
|
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)
|
callback(allOccurrences)
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,14 @@
|
||||||
android:paddingTop="@dimen/activity_margin"
|
android:paddingTop="@dimen/activity_margin"
|
||||||
android:text="@string/update_one_only"/>
|
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
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
android:id="@+id/edit_repeating_event_all_occurrences"
|
android:id="@+id/edit_repeating_event_all_occurrences"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
<string name="delete_future_occurrences">Delete this and all future occurrences</string>
|
<string name="delete_future_occurrences">Delete this and all future occurrences</string>
|
||||||
<string name="delete_all_occurrences">Delete all 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_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="update_all_occurrences">Update all occurrences</string>
|
||||||
<string name="repeat_till_date">Repeat till a date</string>
|
<string name="repeat_till_date">Repeat till a date</string>
|
||||||
<string name="stop_repeating_after_x">Stop repeating after x occurrences</string>
|
<string name="stop_repeating_after_x">Stop repeating after x occurrences</string>
|
||||||
|
|
Loading…
Reference in New Issue