make pull-to-refresh for caldav calendars optional, disabled by default

This commit is contained in:
tibbi 2018-10-24 11:40:28 +02:00
parent c983014198
commit e4453a4e33
5 changed files with 45 additions and 2 deletions

View File

@ -133,7 +133,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
search_placeholder_2.setTextColor(config.textColor)
calendar_fab.setColors(config.textColor, getAdjustedPrimaryColor(), config.backgroundColor)
search_holder.background = ColorDrawable(config.backgroundColor)
swipe_refresh_layout.isEnabled = config.caldavSync
swipe_refresh_layout.isEnabled = config.caldavSync && config.pullToRefresh
}
override fun onPause() {

View File

@ -38,7 +38,6 @@ class SettingsActivity : SimpleActivity() {
setContentView(R.layout.activity_settings)
res = resources
mStoredPrimaryColor = config.primaryColor
setupCaldavSync()
}
override fun onResume() {
@ -63,6 +62,9 @@ class SettingsActivity : SimpleActivity() {
setupUseSameSnooze()
setupLoopReminders()
setupSnoozeTime()
setupCaldavSync()
setupManageSyncedCalendars()
setupPullToRefresh()
setupDefaultReminder()
setupDefaultReminder1()
setupDefaultReminder2()
@ -163,7 +165,18 @@ class SettingsActivity : SimpleActivity() {
}
}
}
}
private fun setupPullToRefresh() {
settings_caldav_pull_to_refresh_holder.beVisibleIf(config.caldavSync)
settings_caldav_pull_to_refresh.isChecked = config.pullToRefresh
settings_caldav_pull_to_refresh_holder.setOnClickListener {
settings_caldav_pull_to_refresh.toggle()
config.pullToRefresh = settings_caldav_pull_to_refresh.isChecked
}
}
private fun setupManageSyncedCalendars() {
settings_manage_synced_calendars_holder.beVisibleIf(config.caldavSync)
settings_manage_synced_calendars_holder.setOnClickListener {
showCalendarPicker()
@ -177,6 +190,7 @@ class SettingsActivity : SimpleActivity() {
settings_caldav_sync.isChecked = false
config.caldavSync = false
settings_manage_synced_calendars_holder.beGone()
settings_caldav_pull_to_refresh_holder.beGone()
config.getSyncedCalendarIdsAsList().forEach {
CalDAVHandler(applicationContext).deleteCalDAVCalendarEvents(it.toLong())
}
@ -194,6 +208,7 @@ class SettingsActivity : SimpleActivity() {
}
settings_manage_synced_calendars_holder.beVisibleIf(newCalendarIds.isNotEmpty())
settings_caldav_pull_to_refresh_holder.beVisibleIf(newCalendarIds.isNotEmpty())
settings_caldav_sync.isChecked = newCalendarIds.isNotEmpty()
config.caldavSync = newCalendarIds.isNotEmpty()
if (settings_caldav_sync.isChecked) {

View File

@ -162,4 +162,8 @@ class Config(context: Context) : BaseConfig(context) {
var defaultReminder3: Int
get() = prefs.getInt(DEFAULT_REMINDER_3, REMINDER_OFF)
set(defaultReminder3) = prefs.edit().putInt(DEFAULT_REMINDER_3, defaultReminder3).apply()
var pullToRefresh: Boolean
get() = prefs.getBoolean(PULL_TO_REFRESH, false)
set(pullToRefresh) = prefs.edit().putBoolean(PULL_TO_REFRESH, pullToRefresh).apply()
}

View File

@ -64,6 +64,7 @@ const val USE_PREVIOUS_EVENT_REMINDERS = "use_previous_event_reminders"
const val DEFAULT_REMINDER_1 = "default_reminder_1"
const val DEFAULT_REMINDER_2 = "default_reminder_2"
const val DEFAULT_REMINDER_3 = "default_reminder_3"
const val PULL_TO_REFRESH = "pull_to_refresh"
// repeat_rule for monthly and yearly repetition
const val REPEAT_SAME_DAY = 1 // i.e. 25th every month, or 3rd june (if yearly repetition)

View File

@ -529,6 +529,29 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_caldav_pull_to_refresh_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingLeft="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingRight="@dimen/normal_margin"
android:paddingBottom="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/settings_caldav_pull_to_refresh"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:paddingStart="@dimen/medium_margin"
android:paddingLeft="@dimen/medium_margin"
android:text="@string/enable_pull_to_refresh"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_manage_synced_calendars_holder"
android:layout_width="match_parent"