store the last used event type id, use it as default in new events
This commit is contained in:
parent
4383ed1f53
commit
e6d49184a5
|
@ -60,6 +60,12 @@ class EventActivity : SimpleActivity() {
|
|||
return
|
||||
}
|
||||
|
||||
if (dbHelper.getEventType(config.lastUsedLocalEventTypeId) == null) {
|
||||
config.lastUsedLocalEventTypeId = DBHelper.REGULAR_EVENT_TYPE_ID
|
||||
}
|
||||
|
||||
mEventTypeId = config.lastUsedLocalEventTypeId
|
||||
|
||||
if (event != null) {
|
||||
mEvent = event
|
||||
mEventOccurrenceTS = intent.getIntExtra(EVENT_OCCURRENCE_TS, 0)
|
||||
|
@ -440,7 +446,7 @@ class EventActivity : SimpleActivity() {
|
|||
hideKeyboard()
|
||||
SelectEventCalendarDialog(this, calendars, mEventCalendarId) {
|
||||
if (mEventCalendarId != STORED_LOCALLY_ONLY && it == STORED_LOCALLY_ONLY) {
|
||||
mEventTypeId = DBHelper.REGULAR_EVENT_TYPE_ID
|
||||
mEventTypeId = config.lastUsedLocalEventTypeId
|
||||
updateEventType()
|
||||
}
|
||||
mEventCalendarId = it
|
||||
|
@ -522,10 +528,11 @@ class EventActivity : SimpleActivity() {
|
|||
val newEventType = if (!config.caldavSync || config.lastUsedCaldavCalendar == 0 || mEventCalendarId == STORED_LOCALLY_ONLY) {
|
||||
mEventTypeId
|
||||
} else {
|
||||
dbHelper.getEventTypeWithCalDAVCalendarId(config.lastUsedCaldavCalendar)?.id ?: DBHelper.REGULAR_EVENT_TYPE_ID
|
||||
dbHelper.getEventTypeWithCalDAVCalendarId(config.lastUsedCaldavCalendar)?.id ?: config.lastUsedLocalEventTypeId
|
||||
}
|
||||
|
||||
val newSource = if (!config.caldavSync || config.lastUsedCaldavCalendar == 0 || mEventCalendarId == STORED_LOCALLY_ONLY) {
|
||||
config.lastUsedLocalEventTypeId = newEventType
|
||||
SOURCE_SIMPLE_CALENDAR
|
||||
} else {
|
||||
"$CALDAV-${config.lastUsedCaldavCalendar}"
|
||||
|
|
|
@ -81,6 +81,10 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
get() = prefs.getInt(LAST_USED_CALDAV_CALENDAR, getSyncedCalendarIdsAsList().first().toInt())
|
||||
set(calendarId) = prefs.edit().putInt(LAST_USED_CALDAV_CALENDAR, calendarId).apply()
|
||||
|
||||
var lastUsedLocalEventTypeId: Int
|
||||
get() = prefs.getInt(LAST_USED_LOCAL_EVENT_TYPE_ID, DBHelper.REGULAR_EVENT_TYPE_ID)
|
||||
set(lastUsedLocalEventTypeId) = prefs.edit().putInt(LAST_USED_LOCAL_EVENT_TYPE_ID, lastUsedLocalEventTypeId).apply()
|
||||
|
||||
var replaceDescription: Boolean
|
||||
get() = prefs.getBoolean(REPLACE_DESCRIPTION, false)
|
||||
set(replaceDescription) = prefs.edit().putBoolean(REPLACE_DESCRIPTION, replaceDescription).apply()
|
||||
|
|
|
@ -48,6 +48,7 @@ const val FONT_SIZE = "font_size"
|
|||
const val CALDAV_SYNC = "caldav_sync"
|
||||
const val CALDAV_SYNCED_CALENDAR_IDS = "caldav_synced_calendar_ids"
|
||||
const val LAST_USED_CALDAV_CALENDAR = "last_used_caldav_calendar"
|
||||
const val LAST_USED_LOCAL_EVENT_TYPE_ID = "last_used_local_event_type_id"
|
||||
const val DISPLAY_PAST_EVENTS = "display_past_events"
|
||||
const val REPLACE_DESCRIPTION = "replace_description"
|
||||
const val SHOW_GRID = "show_grid"
|
||||
|
|
Loading…
Reference in New Issue