fix #199, allow duplicating events
This commit is contained in:
parent
e8db3657ec
commit
bcd20f254e
|
@ -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()) {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -11,6 +11,11 @@
|
|||
android:icon="@drawable/ic_delete"
|
||||
android:title="@string/delete"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/duplicate"
|
||||
android:icon="@drawable/ic_copy"
|
||||
android:title="@string/duplicate_event"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/share"
|
||||
android:icon="@drawable/ic_share"
|
||||
|
|
Loading…
Reference in New Issue