mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-18 20:50:40 +01:00
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dbHelper.getEventType(config.lastUsedLocalEventTypeId) == null) {
|
||||||
|
config.lastUsedLocalEventTypeId = DBHelper.REGULAR_EVENT_TYPE_ID
|
||||||
|
}
|
||||||
|
|
||||||
|
mEventTypeId = config.lastUsedLocalEventTypeId
|
||||||
|
|
||||||
if (event != null) {
|
if (event != null) {
|
||||||
mEvent = event
|
mEvent = event
|
||||||
mEventOccurrenceTS = intent.getIntExtra(EVENT_OCCURRENCE_TS, 0)
|
mEventOccurrenceTS = intent.getIntExtra(EVENT_OCCURRENCE_TS, 0)
|
||||||
@ -440,7 +446,7 @@ class EventActivity : SimpleActivity() {
|
|||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
SelectEventCalendarDialog(this, calendars, mEventCalendarId) {
|
SelectEventCalendarDialog(this, calendars, mEventCalendarId) {
|
||||||
if (mEventCalendarId != STORED_LOCALLY_ONLY && it == STORED_LOCALLY_ONLY) {
|
if (mEventCalendarId != STORED_LOCALLY_ONLY && it == STORED_LOCALLY_ONLY) {
|
||||||
mEventTypeId = DBHelper.REGULAR_EVENT_TYPE_ID
|
mEventTypeId = config.lastUsedLocalEventTypeId
|
||||||
updateEventType()
|
updateEventType()
|
||||||
}
|
}
|
||||||
mEventCalendarId = it
|
mEventCalendarId = it
|
||||||
@ -522,10 +528,11 @@ class EventActivity : SimpleActivity() {
|
|||||||
val newEventType = if (!config.caldavSync || config.lastUsedCaldavCalendar == 0 || mEventCalendarId == STORED_LOCALLY_ONLY) {
|
val newEventType = if (!config.caldavSync || config.lastUsedCaldavCalendar == 0 || mEventCalendarId == STORED_LOCALLY_ONLY) {
|
||||||
mEventTypeId
|
mEventTypeId
|
||||||
} else {
|
} 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) {
|
val newSource = if (!config.caldavSync || config.lastUsedCaldavCalendar == 0 || mEventCalendarId == STORED_LOCALLY_ONLY) {
|
||||||
|
config.lastUsedLocalEventTypeId = newEventType
|
||||||
SOURCE_SIMPLE_CALENDAR
|
SOURCE_SIMPLE_CALENDAR
|
||||||
} else {
|
} else {
|
||||||
"$CALDAV-${config.lastUsedCaldavCalendar}"
|
"$CALDAV-${config.lastUsedCaldavCalendar}"
|
||||||
|
@ -81,6 +81,10 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
get() = prefs.getInt(LAST_USED_CALDAV_CALENDAR, getSyncedCalendarIdsAsList().first().toInt())
|
get() = prefs.getInt(LAST_USED_CALDAV_CALENDAR, getSyncedCalendarIdsAsList().first().toInt())
|
||||||
set(calendarId) = prefs.edit().putInt(LAST_USED_CALDAV_CALENDAR, calendarId).apply()
|
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
|
var replaceDescription: Boolean
|
||||||
get() = prefs.getBoolean(REPLACE_DESCRIPTION, false)
|
get() = prefs.getBoolean(REPLACE_DESCRIPTION, false)
|
||||||
set(replaceDescription) = prefs.edit().putBoolean(REPLACE_DESCRIPTION, replaceDescription).apply()
|
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_SYNC = "caldav_sync"
|
||||||
const val CALDAV_SYNCED_CALENDAR_IDS = "caldav_synced_calendar_ids"
|
const val CALDAV_SYNCED_CALENDAR_IDS = "caldav_synced_calendar_ids"
|
||||||
const val LAST_USED_CALDAV_CALENDAR = "last_used_caldav_calendar"
|
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 DISPLAY_PAST_EVENTS = "display_past_events"
|
||||||
const val REPLACE_DESCRIPTION = "replace_description"
|
const val REPLACE_DESCRIPTION = "replace_description"
|
||||||
const val SHOW_GRID = "show_grid"
|
const val SHOW_GRID = "show_grid"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user