fix #311, handle some event INSERT and EDIT intents
This commit is contained in:
parent
3bd689ce65
commit
9614997324
2 changed files with 32 additions and 19 deletions
|
@ -95,8 +95,16 @@
|
|||
|
||||
<activity
|
||||
android:name=".activities.EventActivity"
|
||||
android:label="@string/event"
|
||||
android:parentActivityName=".activities.DayActivity"/>
|
||||
android:parentActivityName=".activities.DayActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.EDIT"/>
|
||||
<action android:name="android.intent.action.INSERT"/>
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<data android:mimeType="vnd.android.cursor.item/event"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".activities.SettingsActivity"
|
||||
|
|
|
@ -66,12 +66,7 @@ class EventActivity : SimpleActivity() {
|
|||
mReminder1Minutes = config.defaultReminderMinutes
|
||||
mReminder2Minutes = -1
|
||||
mReminder3Minutes = -1
|
||||
val startTS = intent.getIntExtra(NEW_EVENT_START_TS, 0)
|
||||
if (startTS == 0) {
|
||||
return
|
||||
}
|
||||
|
||||
setupNewEvent(Formatter.getDateTimeFromTS(startTS))
|
||||
setupNewEvent()
|
||||
}
|
||||
|
||||
checkReminderTexts()
|
||||
|
@ -80,7 +75,6 @@ class EventActivity : SimpleActivity() {
|
|||
updateEndTexts()
|
||||
updateEventType()
|
||||
updateCalDAVCalendar()
|
||||
updateLocation()
|
||||
|
||||
event_show_on_map.setOnClickListener { showOnMap() }
|
||||
event_start_date.setOnClickListener { setupStartDate() }
|
||||
|
@ -130,16 +124,31 @@ class EventActivity : SimpleActivity() {
|
|||
checkRepeatTexts(mRepeatInterval)
|
||||
}
|
||||
|
||||
private fun setupNewEvent(dateTime: DateTime) {
|
||||
private fun setupNewEvent() {
|
||||
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE)
|
||||
supportActionBar?.title = resources.getString(R.string.new_event)
|
||||
mEventStartDateTime = dateTime
|
||||
|
||||
val addHours = if (intent.getBooleanExtra(NEW_EVENT_SET_HOUR_DURATION, false)) 1 else 0
|
||||
mEventEndDateTime = mEventStartDateTime.plusHours(addHours)
|
||||
|
||||
val isLastCaldavCalendarOK = config.caldavSync && config.getSyncedCalendarIdsAsList().contains(config.lastUsedCaldavCalendar.toString())
|
||||
mEventCalendarId = if (isLastCaldavCalendarOK) config.lastUsedCaldavCalendar else STORED_LOCALLY_ONLY
|
||||
|
||||
if (intent.action == Intent.ACTION_EDIT || intent.action == Intent.ACTION_INSERT) {
|
||||
val startTS = (intent.getLongExtra("beginTime", System.currentTimeMillis()) / 1000).toInt()
|
||||
mEventStartDateTime = Formatter.getDateTimeFromTS(startTS)
|
||||
|
||||
val endTS = (intent.getLongExtra("endTime", System.currentTimeMillis()) / 1000).toInt()
|
||||
mEventEndDateTime = Formatter.getDateTimeFromTS(endTS)
|
||||
|
||||
event_title.setText(intent.getStringExtra("title"))
|
||||
event_location.setText(intent.getStringExtra("eventLocation"))
|
||||
event_description.setText(intent.getStringExtra("description"))
|
||||
event_description.movementMethod = LinkMovementMethod.getInstance()
|
||||
} else {
|
||||
val startTS = intent.getIntExtra(NEW_EVENT_START_TS, 0)
|
||||
val dateTime = Formatter.getDateTimeFromTS(startTS)
|
||||
mEventStartDateTime = dateTime
|
||||
|
||||
val addHours = if (intent.getBooleanExtra(NEW_EVENT_SET_HOUR_DURATION, false)) 1 else 0
|
||||
mEventEndDateTime = mEventStartDateTime.plusHours(addHours)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showReminder1Dialog() {
|
||||
|
@ -467,10 +476,6 @@ class EventActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun updateLocation() {
|
||||
event_location.setText(mEvent.location)
|
||||
}
|
||||
|
||||
private fun toggleAllDay(isChecked: Boolean) {
|
||||
hideKeyboard()
|
||||
event_start_time.beGoneIf(isChecked)
|
||||
|
|
Loading…
Reference in a new issue