From 5e597e69df8ce4cd66aca04d5989d0462c8f8ec9 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 20 Feb 2022 21:44:37 +0100 Subject: [PATCH] adding a settings toggle for enabling task creation --- .../calendar/pro/activities/SettingsActivity.kt | 11 +++++++++++ .../calendar/pro/helpers/Config.kt | 4 ++++ .../calendar/pro/helpers/Constants.kt | 1 + app/src/main/res/layout/activity_settings.xml | 16 ++++++++++++++++ 4 files changed, 32 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt index bc6ce02f2..917d181f0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt @@ -50,6 +50,7 @@ class SettingsActivity : SimpleActivity() { setupManageEventTypes() setupManageQuickFilterEventTypes() setupHourFormat() + setupAllowCreatingTasks() setupSundayFirst() setupHighlightWeekends() setupHighlightWeekendsColor() @@ -222,6 +223,14 @@ class SettingsActivity : SimpleActivity() { } } + private fun setupAllowCreatingTasks() { + settings_allow_creating_tasks.isChecked = config.allowCreatingTasks + settings_allow_creating_tasks_holder.setOnClickListener { + settings_allow_creating_tasks.toggle() + config.allowCreatingTasks = settings_allow_creating_tasks.isChecked + } + } + private fun setupCaldavSync() { settings_caldav_sync.isChecked = config.caldavSync checkCalDAVBackgrounds() @@ -872,6 +881,7 @@ class SettingsActivity : SimpleActivity() { put(SUNDAY_FIRST, config.isSundayFirst) put(HIGHLIGHT_WEEKENDS, config.highlightWeekends) put(HIGHLIGHT_WEEKENDS_COLOR, config.highlightWeekendsColor) + put(ALLOW_CREATING_TASKS, config.allowCreatingTasks) } exportSettings(configItems) @@ -969,6 +979,7 @@ class SettingsActivity : SimpleActivity() { SUNDAY_FIRST -> config.isSundayFirst = value.toBoolean() HIGHLIGHT_WEEKENDS -> config.highlightWeekends = value.toBoolean() HIGHLIGHT_WEEKENDS_COLOR -> config.highlightWeekendsColor = value.toInt() + ALLOW_CREATING_TASKS -> config.allowCreatingTasks = value.toBoolean() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt index 120ed7309..5419de4d5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt @@ -242,4 +242,8 @@ class Config(context: Context) : BaseConfig(context) { var lastUsedEventSpan: Int get() = prefs.getInt(LAST_USED_EVENT_SPAN, YEAR_SECONDS) set(lastUsedEventSpan) = prefs.edit().putInt(LAST_USED_EVENT_SPAN, lastUsedEventSpan).apply() + + var allowCreatingTasks: Boolean + get() = prefs.getBoolean(ALLOW_CREATING_TASKS, true) + set(allowCreatingTasks) = prefs.edit().putBoolean(ALLOW_CREATING_TASKS, allowCreatingTasks).apply() } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt index df491551f..3026d4e56 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt @@ -104,6 +104,7 @@ const val WEEKLY_VIEW_DAYS = "weekly_view_days" const val HIGHLIGHT_WEEKENDS = "highlight_weekends" const val HIGHLIGHT_WEEKENDS_COLOR = "highlight_weekends_color" const val LAST_USED_EVENT_SPAN = "last_used_event_span" +const val ALLOW_CREATING_TASKS = "allow_creating_tasks" // repeat_rule for monthly and yearly repetition const val REPEAT_SAME_DAY = 1 // i.e. 25th every month, or 3rd june (if yearly repetition) diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 871b5d931..a3841d4ea 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -138,6 +138,22 @@ + + + + + +