mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
add a new settings button for managing caldav synced calendars
This commit is contained in:
@ -18,6 +18,8 @@ import com.simplemobiletools.calendar.helpers.FONT_SIZE_LARGE
|
||||
import com.simplemobiletools.calendar.helpers.FONT_SIZE_MEDIUM
|
||||
import com.simplemobiletools.calendar.helpers.FONT_SIZE_SMALL
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
import com.simplemobiletools.commons.extensions.beGone
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
@ -107,15 +109,30 @@ class SettingsActivity : SimpleActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
settings_manage_synced_calendars_holder.beVisibleIf(config.caldavSync)
|
||||
settings_manage_synced_calendars_holder.setOnClickListener {
|
||||
showCalendarPicker()
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleCaldavSync(enable: Boolean) {
|
||||
settings_caldav_sync.isChecked = enable
|
||||
config.caldavSync = enable
|
||||
if (enable) {
|
||||
SelectCalendarsDialog(this) {
|
||||
config.isFirstCaldavSync = false
|
||||
}
|
||||
showCalendarPicker()
|
||||
} else {
|
||||
settings_caldav_sync.isChecked = false
|
||||
config.caldavSync = false
|
||||
settings_manage_synced_calendars_holder.beGone()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showCalendarPicker() {
|
||||
SelectCalendarsDialog(this) {
|
||||
config.isFirstCaldavSync = false
|
||||
val ids = config.caldavSyncedCalendarIDs.split(",").filter { it.trim().isNotEmpty() } as ArrayList<String>
|
||||
settings_manage_synced_calendars_holder.beVisibleIf(ids.isNotEmpty())
|
||||
settings_caldav_sync.isChecked = ids.isNotEmpty()
|
||||
config.caldavSync = ids.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)
|
||||
|
||||
init {
|
||||
val ids = activity.config.caldavSyncedCalendarIDs.split(",") as ArrayList<String>
|
||||
val ids = activity.config.caldavSyncedCalendarIDs.split(",").filter { it.trim().isNotEmpty() } as ArrayList<String>
|
||||
val isFirstCaldavSync = activity.config.isFirstCaldavSync
|
||||
val calendars = activity.getCalDAVCalendars()
|
||||
val sorted = calendars.sortedWith(compareBy({ it.accountName }, { it.displayName }))
|
||||
|
@ -233,7 +233,7 @@ fun Context.launchNewEventIntent(startNewTask: Boolean = false, today: Boolean =
|
||||
|
||||
fun Context.getCalDAVCalendars(): List<CalDAVCalendar> {
|
||||
val calendars = ArrayList<CalDAVCalendar>()
|
||||
if (!config.caldavSync || !hasCalendarPermission()) {
|
||||
if (!hasCalendarPermission()) {
|
||||
return calendars
|
||||
}
|
||||
|
||||
|
@ -129,6 +129,29 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_manage_synced_calendars_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingBottom="@dimen/bigger_margin"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/bigger_margin"
|
||||
android:visibility="gone">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_manage_synced_calendars"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingRight="@dimen/medium_margin"
|
||||
android:text="@string/manage_synced_calendars"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_reminder_sound_holder"
|
||||
android:layout_width="match_parent"
|
||||
@ -236,10 +259,10 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/weekly_view_divider"
|
||||
android:importantForAccessibility="no"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:background="@color/divider_strong"/>
|
||||
android:background="@color/divider_strong"
|
||||
android:importantForAccessibility="no"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/weekly_view_label"
|
||||
@ -327,8 +350,8 @@
|
||||
android:id="@+id/monthly_view_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:importantForAccessibility="no"
|
||||
android:background="@color/divider_strong"/>
|
||||
android:background="@color/divider_strong"
|
||||
android:importantForAccessibility="no"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/monthly_view_label"
|
||||
@ -367,8 +390,8 @@
|
||||
android:id="@+id/events_list_view_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:importantForAccessibility="no"
|
||||
android:background="@color/divider_strong"/>
|
||||
android:background="@color/divider_strong"
|
||||
android:importantForAccessibility="no"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/simple_event_list_label"
|
||||
@ -421,8 +444,8 @@
|
||||
android:id="@+id/widgets_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:importantForAccessibility="no"
|
||||
android:background="@color/divider_strong"/>
|
||||
android:background="@color/divider_strong"
|
||||
android:importantForAccessibility="no"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/simple_font_size_label"
|
||||
|
@ -193,6 +193,7 @@
|
||||
|
||||
<!-- CalDAV sync -->
|
||||
<string name="select_caldav_calendars">Select calendars to sync</string>
|
||||
<string name="manage_synced_calendars">Manage synced calendars</string>
|
||||
|
||||
<plurals name="by_minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -193,6 +193,7 @@
|
||||
|
||||
<!-- CalDAV sync -->
|
||||
<string name="select_caldav_calendars">Select calendars to sync</string>
|
||||
<string name="manage_synced_calendars">Manage synced calendars</string>
|
||||
|
||||
<plurals name="by_minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -193,6 +193,7 @@
|
||||
|
||||
<!-- CalDAV sync -->
|
||||
<string name="select_caldav_calendars">Select calendars to sync</string>
|
||||
<string name="manage_synced_calendars">Manage synced calendars</string>
|
||||
|
||||
<plurals name="by_minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -193,6 +193,7 @@
|
||||
|
||||
<!-- CalDAV sync -->
|
||||
<string name="select_caldav_calendars">Select calendars to sync</string>
|
||||
<string name="manage_synced_calendars">Manage synced calendars</string>
|
||||
|
||||
<plurals name="by_minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -193,6 +193,7 @@
|
||||
|
||||
<!-- CalDAV sync -->
|
||||
<string name="select_caldav_calendars">Select calendars to sync</string>
|
||||
<string name="manage_synced_calendars">Manage synced calendars</string>
|
||||
|
||||
<plurals name="by_minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -193,6 +193,7 @@
|
||||
|
||||
<!-- CalDAV sync -->
|
||||
<string name="select_caldav_calendars">Select calendars to sync</string>
|
||||
<string name="manage_synced_calendars">Manage synced calendars</string>
|
||||
|
||||
<plurals name="by_minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -193,6 +193,7 @@
|
||||
|
||||
<!-- CalDAV sync -->
|
||||
<string name="select_caldav_calendars">Select calendars to sync</string>
|
||||
<string name="manage_synced_calendars">Manage synced calendars</string>
|
||||
|
||||
<plurals name="by_minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -193,6 +193,7 @@
|
||||
|
||||
<!-- CalDAV sync -->
|
||||
<string name="select_caldav_calendars">Select calendars to sync</string>
|
||||
<string name="manage_synced_calendars">Manage synced calendars</string>
|
||||
|
||||
<plurals name="by_minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -198,6 +198,7 @@
|
||||
|
||||
<!-- CalDAV sync -->
|
||||
<string name="select_caldav_calendars">Select calendars to sync</string>
|
||||
<string name="manage_synced_calendars">Manage synced calendars</string>
|
||||
|
||||
<plurals name="by_minutes">
|
||||
<item quantity="one">%1$d minutę</item>
|
||||
|
@ -193,6 +193,7 @@
|
||||
|
||||
<!-- CalDAV sync -->
|
||||
<string name="select_caldav_calendars">Select calendars to sync</string>
|
||||
<string name="manage_synced_calendars">Manage synced calendars</string>
|
||||
|
||||
<plurals name="by_minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -193,6 +193,7 @@
|
||||
|
||||
<!-- CalDAV sync -->
|
||||
<string name="select_caldav_calendars">Select calendars to sync</string>
|
||||
<string name="manage_synced_calendars">Manage synced calendars</string>
|
||||
|
||||
<plurals name="by_minutes">
|
||||
<item quantity="one">%1$d minuto</item>
|
||||
|
@ -207,6 +207,7 @@
|
||||
|
||||
<!-- CalDAV sync -->
|
||||
<string name="select_caldav_calendars">Select calendars to sync</string>
|
||||
<string name="manage_synced_calendars">Manage synced calendars</string>
|
||||
|
||||
<plurals name="by_minutes">
|
||||
<item quantity="one">%1$d минута</item>
|
||||
|
@ -200,6 +200,7 @@
|
||||
|
||||
<!-- CalDAV sync -->
|
||||
<string name="select_caldav_calendars">Zvoľte kalendáre pre synchronizáciu</string>
|
||||
<string name="manage_synced_calendars">Spravovať synchronizované kalendáre</string>
|
||||
|
||||
<plurals name="by_minutes">
|
||||
<item quantity="one">%1$d minútu</item>
|
||||
|
@ -193,6 +193,7 @@
|
||||
|
||||
<!-- CalDAV sync -->
|
||||
<string name="select_caldav_calendars">Select calendars to sync</string>
|
||||
<string name="manage_synced_calendars">Manage synced calendars</string>
|
||||
|
||||
<plurals name="by_minutes">
|
||||
<item quantity="one">%1$d minut</item>
|
||||
|
@ -193,6 +193,7 @@
|
||||
|
||||
<!-- CalDAV sync -->
|
||||
<string name="select_caldav_calendars">Select calendars to sync</string>
|
||||
<string name="manage_synced_calendars">Manage synced calendars</string>
|
||||
|
||||
<plurals name="by_minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -193,6 +193,7 @@
|
||||
|
||||
<!-- CalDAV sync -->
|
||||
<string name="select_caldav_calendars">Select calendars to sync</string>
|
||||
<string name="manage_synced_calendars">Manage synced calendars</string>
|
||||
|
||||
<plurals name="by_minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
Reference in New Issue
Block a user