Save last used value for ignore event types checkbox when importing

This commit is contained in:
Ensar Sarajčić
2023-09-25 17:26:45 +02:00
parent 07eae3e3f2
commit 2b0dacae45
3 changed files with 7 additions and 0 deletions

View File

@@ -40,6 +40,7 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal
} else { } else {
config.lastUsedLocalEventTypeId config.lastUsedLocalEventTypeId
} }
binding.importEventsCheckbox.isChecked = config.lastUsedIgnoreEventTypesState
activity.runOnUiThread { activity.runOnUiThread {
initDialog() initDialog()
@@ -85,6 +86,7 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal
activity.toast(com.simplemobiletools.commons.R.string.importing) activity.toast(com.simplemobiletools.commons.R.string.importing)
ensureBackgroundThread { ensureBackgroundThread {
val overrideFileEventTypes = binding.importEventsCheckbox.isChecked val overrideFileEventTypes = binding.importEventsCheckbox.isChecked
config.lastUsedIgnoreEventTypesState = overrideFileEventTypes
val result = IcsImporter(activity).importEvents(path, currEventTypeId, currEventTypeCalDAVCalendarId, overrideFileEventTypes) val result = IcsImporter(activity).importEvents(path, currEventTypeId, currEventTypeCalDAVCalendarId, overrideFileEventTypes)
handleParseResult(result) handleParseResult(result)
alertDialog.dismiss() alertDialog.dismiss()

View File

@@ -121,6 +121,10 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getLong(LAST_USED_LOCAL_EVENT_TYPE_ID, REGULAR_EVENT_TYPE_ID) get() = prefs.getLong(LAST_USED_LOCAL_EVENT_TYPE_ID, REGULAR_EVENT_TYPE_ID)
set(lastUsedLocalEventTypeId) = prefs.edit().putLong(LAST_USED_LOCAL_EVENT_TYPE_ID, lastUsedLocalEventTypeId).apply() set(lastUsedLocalEventTypeId) = prefs.edit().putLong(LAST_USED_LOCAL_EVENT_TYPE_ID, lastUsedLocalEventTypeId).apply()
var lastUsedIgnoreEventTypesState: Boolean
get() = prefs.getBoolean(LAST_USED_IGNORE_EVENT_TYPES_STATE, false)
set(lastUsedIgnoreEventTypesState) = prefs.edit().putBoolean(LAST_USED_IGNORE_EVENT_TYPES_STATE, lastUsedIgnoreEventTypesState).apply()
var reminderAudioStream: Int var reminderAudioStream: Int
get() = prefs.getInt(REMINDER_AUDIO_STREAM, AudioManager.STREAM_NOTIFICATION) get() = prefs.getInt(REMINDER_AUDIO_STREAM, AudioManager.STREAM_NOTIFICATION)
set(reminderAudioStream) = prefs.edit().putInt(REMINDER_AUDIO_STREAM, reminderAudioStream).apply() set(reminderAudioStream) = prefs.edit().putInt(REMINDER_AUDIO_STREAM, reminderAudioStream).apply()

View File

@@ -101,6 +101,7 @@ 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 LAST_USED_LOCAL_EVENT_TYPE_ID = "last_used_local_event_type_id"
const val LAST_USED_IGNORE_EVENT_TYPES_STATE = "last_used_ignore_event_types_state"
const val DISPLAY_PAST_EVENTS = "display_past_events" const val DISPLAY_PAST_EVENTS = "display_past_events"
const val DISPLAY_DESCRIPTION = "display_description" const val DISPLAY_DESCRIPTION = "display_description"
const val REPLACE_DESCRIPTION = "replace_description" const val REPLACE_DESCRIPTION = "replace_description"