diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/ImportEventsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/ImportEventsDialog.kt index 5a013c2f4..bc0b50676 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/ImportEventsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/ImportEventsDialog.kt @@ -25,6 +25,20 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal if (activity.eventTypesDB.getEventTypeWithId(config.lastUsedLocalEventTypeId) == null) { config.lastUsedLocalEventTypeId = REGULAR_EVENT_TYPE_ID } + + val isLastCaldavCalendarOK = config.caldavSync && config.getSyncedCalendarIdsAsList().contains(config.lastUsedCaldavCalendarId) + currEventTypeId = if (isLastCaldavCalendarOK) { + val lastUsedCalDAVCalendar = activity.eventsHelper.getEventTypeWithCalDAVCalendarId(config.lastUsedCaldavCalendarId) + if (lastUsedCalDAVCalendar != null) { + currEventTypeCalDAVCalendarId = config.lastUsedCaldavCalendarId + lastUsedCalDAVCalendar.id!! + } else { + REGULAR_EVENT_TYPE_ID + } + } else { + config.lastUsedLocalEventTypeId + } + activity.runOnUiThread { initDialog() } @@ -32,19 +46,6 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal } private fun initDialog() { - val isLastCaldavCalendarOK = config.caldavSync && config.getSyncedCalendarIdsAsList().contains(config.lastUsedCaldavCalendarId) - currEventTypeId = if (isLastCaldavCalendarOK) { - val lastUsedCalDAVCalendar = activity.eventsHelper.getEventTypeWithCalDAVCalendarId(config.lastUsedCaldavCalendarId) - if (lastUsedCalDAVCalendar != null) { - currEventTypeCalDAVCalendarId = config.lastUsedCaldavCalendarId - lastUsedCalDAVCalendar.id!! - } else { - REGULAR_EVENT_TYPE_ID - } - } else { - config.lastUsedLocalEventTypeId - } - val view = (activity.layoutInflater.inflate(R.layout.dialog_import_events, null) as ViewGroup).apply { updateEventType(this) import_event_type_holder.setOnClickListener { diff --git a/app/src/main/res/layout/dialog_import_events.xml b/app/src/main/res/layout/dialog_import_events.xml index acdcc46ed..822a87356 100644 --- a/app/src/main/res/layout/dialog_import_events.xml +++ b/app/src/main/res/layout/dialog_import_events.xml @@ -5,8 +5,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - android:paddingRight="@dimen/activity_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingTop="@dimen/activity_margin" + android:paddingRight="@dimen/activity_margin"> @@ -49,8 +50,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/normal_margin" - android:paddingBottom="@dimen/activity_margin" android:paddingTop="@dimen/activity_margin" + android:paddingBottom="@dimen/activity_margin" android:text="@string/override_event_types"/>