diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt
index 8715abb4d..160ec62b7 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt
@@ -71,6 +71,10 @@ class EventActivity : SimpleActivity() {
mEvent = event
mEventOccurrenceTS = intent.getIntExtra(EVENT_OCCURRENCE_TS, 0)
setupEditEvent()
+
+ if (intent.getBooleanExtra(IS_DUPLICATE_INTENT, false)) {
+ mEvent.id = 0
+ }
} else {
mEvent = Event()
mReminder1Minutes = config.defaultReminderMinutes
@@ -116,6 +120,7 @@ class EventActivity : SimpleActivity() {
if (wasActivityInitialized) {
menu.findItem(R.id.delete).isVisible = mEvent.id != 0
menu.findItem(R.id.share).isVisible = mEvent.id != 0
+ menu.findItem(R.id.duplicate).isVisible = mEvent.id != 0
}
return true
}
@@ -124,6 +129,7 @@ class EventActivity : SimpleActivity() {
when (item.itemId) {
R.id.save -> saveEvent()
R.id.delete -> deleteEvent()
+ R.id.duplicate -> duplicateEvent()
R.id.share -> shareEvent()
else -> return super.onOptionsItemSelected(item)
}
@@ -515,6 +521,16 @@ class EventActivity : SimpleActivity() {
}
}
+ private fun duplicateEvent() {
+ Intent(this, EventActivity::class.java).apply {
+ putExtra(EVENT_ID, mEvent.id)
+ putExtra(EVENT_OCCURRENCE_TS, mEventOccurrenceTS)
+ putExtra(IS_DUPLICATE_INTENT, true)
+ startActivity(this)
+ }
+ finish()
+ }
+
private fun saveEvent() {
val newTitle = event_title.value
if (newTitle.isEmpty()) {
diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt
index 55891cb5e..4023b8ac8 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt
@@ -7,6 +7,7 @@ const val STORED_LOCALLY_ONLY = 0
const val DAY_CODE = "day_code"
const val YEAR_LABEL = "year"
const val EVENT_ID = "event_id"
+const val IS_DUPLICATE_INTENT = "is_duplicate_intent"
const val EVENT_OCCURRENCE_TS = "event_occurrence_ts"
const val NEW_EVENT_START_TS = "new_event_start_ts"
const val WEEK_START_TIMESTAMP = "week_start_timestamp"
diff --git a/app/src/main/res/menu/menu_event.xml b/app/src/main/res/menu/menu_event.xml
index f76057323..801cf45bc 100644
--- a/app/src/main/res/menu/menu_event.xml
+++ b/app/src/main/res/menu/menu_event.xml
@@ -11,6 +11,11 @@
android:icon="@drawable/ic_delete"
android:title="@string/delete"
app:showAsAction="ifRoom"/>
+