fix a glitch with wrong calendar source at creating new events

This commit is contained in:
tibbi 2017-10-08 17:52:46 +02:00
parent ad48c85c33
commit a13e8f1147
3 changed files with 13 additions and 5 deletions

View File

@ -399,7 +399,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
val calendars = CalDAVHandler(applicationContext).getCalDAVCalendars().filter {
it.canWrite() && config.getSyncedCalendarIdsAsList().contains(it.id.toString())
}
updateCurrentCalendarInfo(getCalendarWithId(calendars, getCalendarId()))
updateCurrentCalendarInfo(if (mEventCalendarId == STORED_LOCALLY_ONLY) null else getCalendarWithId(calendars, getCalendarId()))
event_caldav_calendar_holder.setOnClickListener {
hideKeyboard()
@ -503,8 +503,17 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
val oldSource = mEvent.source
val newImportId = if (mEvent.id != 0) mEvent.importId else UUID.randomUUID().toString().replace("-", "") + System.currentTimeMillis().toString()
val newEventType = if (!config.caldavSync || config.lastUsedCaldavCalendar == 0) mEventTypeId else dbHelper.getEventTypeWithCalDAVCalendarId(config.lastUsedCaldavCalendar)!!.id
val newSource = if (!config.caldavSync || config.lastUsedCaldavCalendar == 0) SOURCE_SIMPLE_CALENDAR else "$CALDAV-${config.lastUsedCaldavCalendar}"
val newEventType = if (!config.caldavSync || config.lastUsedCaldavCalendar == 0 || mEventCalendarId == STORED_LOCALLY_ONLY) {
mEventTypeId
} else {
dbHelper.getEventTypeWithCalDAVCalendarId(config.lastUsedCaldavCalendar)!!.id
}
val newSource = if (!config.caldavSync || config.lastUsedCaldavCalendar == 0 || mEventCalendarId == STORED_LOCALLY_ONLY) {
SOURCE_SIMPLE_CALENDAR
} else {
"$CALDAV-${config.lastUsedCaldavCalendar}"
}
val reminders = sortedSetOf(mReminder1Minutes, mReminder2Minutes, mReminder3Minutes).filter { it != REMINDER_OFF }
val newDescription = event_description.value

View File

@ -318,7 +318,6 @@ fun Context.addDayEvents(day: DayMonthly, linearLayout: LinearLayout, res: Resou
(View.inflate(this, R.layout.day_monthly_item_view, null) as TextView).apply {
setTextColor(textColor)
text = it.title.replace(" ", "\u00A0") // allow word break by char
gravity = Gravity.START
background = backgroundDrawable
layoutParams = eventLayoutParams
linearLayout.addView(this)

View File

@ -19,7 +19,7 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context)
private val mToday: String = DateTime().toString(Formatter.DAYCODE_PATTERN)
private var mEvents = ArrayList<Event>()
private var days = ArrayList<DayMonthly>(DAYS_CNT)
var mFilterEventTypes = true
private var mFilterEventTypes = true
lateinit var mTargetDate: DateTime