do not show not synced calendars at the calendar selector
This commit is contained in:
parent
82d18556bf
commit
53e08da673
|
@ -390,7 +390,9 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
event_caldav_calendar_holder.beVisible()
|
event_caldav_calendar_holder.beVisible()
|
||||||
event_caldav_calendar_divider.beVisible()
|
event_caldav_calendar_divider.beVisible()
|
||||||
|
|
||||||
val calendars = CalDAVEventsHandler(applicationContext).getCalDAVCalendars().filter { it.canWrite() }
|
val calendars = CalDAVEventsHandler(applicationContext).getCalDAVCalendars().filter {
|
||||||
|
it.canWrite() && config.getSyncedCalendarIdsAsList().contains(it.id.toString())
|
||||||
|
}
|
||||||
updateCurrentCalendarInfo(getCalendarWithId(calendars))
|
updateCurrentCalendarInfo(getCalendarWithId(calendars))
|
||||||
|
|
||||||
event_caldav_calendar_holder.setOnClickListener {
|
event_caldav_calendar_holder.setOnClickListener {
|
||||||
|
|
|
@ -125,17 +125,17 @@ class SettingsActivity : SimpleActivity() {
|
||||||
settings_caldav_sync.isChecked = false
|
settings_caldav_sync.isChecked = false
|
||||||
config.caldavSync = false
|
config.caldavSync = false
|
||||||
settings_manage_synced_calendars_holder.beGone()
|
settings_manage_synced_calendars_holder.beGone()
|
||||||
config.getCalendarIdsAsList().forEach {
|
config.getSyncedCalendarIdsAsList().forEach {
|
||||||
CalDAVEventsHandler(applicationContext).deleteCalDAVCalendarEvents(it.toLong())
|
CalDAVEventsHandler(applicationContext).deleteCalDAVCalendarEvents(it.toLong())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showCalendarPicker() {
|
private fun showCalendarPicker() {
|
||||||
val oldCalendarIds = config.getCalendarIdsAsList()
|
val oldCalendarIds = config.getSyncedCalendarIdsAsList()
|
||||||
|
|
||||||
SelectCalendarsDialog(this) {
|
SelectCalendarsDialog(this) {
|
||||||
val newCalendarIds = config.getCalendarIdsAsList()
|
val newCalendarIds = config.getSyncedCalendarIdsAsList()
|
||||||
settings_manage_synced_calendars_holder.beVisibleIf(newCalendarIds.isNotEmpty())
|
settings_manage_synced_calendars_holder.beVisibleIf(newCalendarIds.isNotEmpty())
|
||||||
settings_caldav_sync.isChecked = newCalendarIds.isNotEmpty()
|
settings_caldav_sync.isChecked = newCalendarIds.isNotEmpty()
|
||||||
config.caldavSync = newCalendarIds.isNotEmpty()
|
config.caldavSync = newCalendarIds.isNotEmpty()
|
||||||
|
|
|
@ -20,7 +20,7 @@ class SelectCalendarsDialog(val activity: Activity, val callback: () -> Unit) :
|
||||||
var view = (activity.layoutInflater.inflate(R.layout.dialog_select_calendars, null) as ViewGroup)
|
var view = (activity.layoutInflater.inflate(R.layout.dialog_select_calendars, null) as ViewGroup)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val ids = activity.config.getCalendarIdsAsList()
|
val ids = activity.config.getSyncedCalendarIdsAsList()
|
||||||
val calendars = CalDAVEventsHandler(activity).getCalDAVCalendars()
|
val calendars = CalDAVEventsHandler(activity).getCalDAVCalendars()
|
||||||
val sorted = calendars.sortedWith(compareBy({ it.accountName }, { it.displayName }))
|
val sorted = calendars.sortedWith(compareBy({ it.accountName }, { it.displayName }))
|
||||||
sorted.forEach {
|
sorted.forEach {
|
||||||
|
|
|
@ -79,10 +79,10 @@ class Config(context: Context) : BaseConfig(context) {
|
||||||
set(calendarIDs) = prefs.edit().putString(CALDAV_SYNCED_CALENDAR_IDS, calendarIDs).apply()
|
set(calendarIDs) = prefs.edit().putString(CALDAV_SYNCED_CALENDAR_IDS, calendarIDs).apply()
|
||||||
|
|
||||||
var lastUsedCaldavCalendar: Int
|
var lastUsedCaldavCalendar: Int
|
||||||
get() = prefs.getInt(LAST_USED_CALDAV_CALENDAR, getCalendarIdsAsList().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()
|
||||||
|
|
||||||
fun getCalendarIdsAsList() = caldavSyncedCalendarIDs.split(",").filter { it.trim().isNotEmpty() } as ArrayList<String>
|
fun getSyncedCalendarIdsAsList() = caldavSyncedCalendarIDs.split(",").filter { it.trim().isNotEmpty() } as ArrayList<String>
|
||||||
|
|
||||||
fun addDisplayEventType(type: String) {
|
fun addDisplayEventType(type: String) {
|
||||||
addDisplayEventTypes(HashSet<String>(Arrays.asList(type)))
|
addDisplayEventTypes(HashSet<String>(Arrays.asList(type)))
|
||||||
|
|
Loading…
Reference in New Issue