adding a settings toggle for enabling task creation

This commit is contained in:
tibbi
2022-02-20 21:44:37 +01:00
parent 75c5be3da4
commit 5e597e69df
4 changed files with 32 additions and 0 deletions

View File

@@ -50,6 +50,7 @@ class SettingsActivity : SimpleActivity() {
setupManageEventTypes() setupManageEventTypes()
setupManageQuickFilterEventTypes() setupManageQuickFilterEventTypes()
setupHourFormat() setupHourFormat()
setupAllowCreatingTasks()
setupSundayFirst() setupSundayFirst()
setupHighlightWeekends() setupHighlightWeekends()
setupHighlightWeekendsColor() 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() { private fun setupCaldavSync() {
settings_caldav_sync.isChecked = config.caldavSync settings_caldav_sync.isChecked = config.caldavSync
checkCalDAVBackgrounds() checkCalDAVBackgrounds()
@@ -872,6 +881,7 @@ class SettingsActivity : SimpleActivity() {
put(SUNDAY_FIRST, config.isSundayFirst) put(SUNDAY_FIRST, config.isSundayFirst)
put(HIGHLIGHT_WEEKENDS, config.highlightWeekends) put(HIGHLIGHT_WEEKENDS, config.highlightWeekends)
put(HIGHLIGHT_WEEKENDS_COLOR, config.highlightWeekendsColor) put(HIGHLIGHT_WEEKENDS_COLOR, config.highlightWeekendsColor)
put(ALLOW_CREATING_TASKS, config.allowCreatingTasks)
} }
exportSettings(configItems) exportSettings(configItems)
@@ -969,6 +979,7 @@ class SettingsActivity : SimpleActivity() {
SUNDAY_FIRST -> config.isSundayFirst = value.toBoolean() SUNDAY_FIRST -> config.isSundayFirst = value.toBoolean()
HIGHLIGHT_WEEKENDS -> config.highlightWeekends = value.toBoolean() HIGHLIGHT_WEEKENDS -> config.highlightWeekends = value.toBoolean()
HIGHLIGHT_WEEKENDS_COLOR -> config.highlightWeekendsColor = value.toInt() HIGHLIGHT_WEEKENDS_COLOR -> config.highlightWeekendsColor = value.toInt()
ALLOW_CREATING_TASKS -> config.allowCreatingTasks = value.toBoolean()
} }
} }

View File

@@ -242,4 +242,8 @@ class Config(context: Context) : BaseConfig(context) {
var lastUsedEventSpan: Int var lastUsedEventSpan: Int
get() = prefs.getInt(LAST_USED_EVENT_SPAN, YEAR_SECONDS) get() = prefs.getInt(LAST_USED_EVENT_SPAN, YEAR_SECONDS)
set(lastUsedEventSpan) = prefs.edit().putInt(LAST_USED_EVENT_SPAN, lastUsedEventSpan).apply() 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()
} }

View File

@@ -104,6 +104,7 @@ const val WEEKLY_VIEW_DAYS = "weekly_view_days"
const val HIGHLIGHT_WEEKENDS = "highlight_weekends" const val HIGHLIGHT_WEEKENDS = "highlight_weekends"
const val HIGHLIGHT_WEEKENDS_COLOR = "highlight_weekends_color" const val HIGHLIGHT_WEEKENDS_COLOR = "highlight_weekends_color"
const val LAST_USED_EVENT_SPAN = "last_used_event_span" 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 // repeat_rule for monthly and yearly repetition
const val REPEAT_SAME_DAY = 1 // i.e. 25th every month, or 3rd june (if yearly repetition) const val REPEAT_SAME_DAY = 1 // i.e. 25th every month, or 3rd june (if yearly repetition)

View File

@@ -138,6 +138,22 @@
</RelativeLayout> </RelativeLayout>
<RelativeLayout
android:id="@+id/settings_allow_creating_tasks_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple_background">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_allow_creating_tasks"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/allow_creating_tasks" />
</RelativeLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/settings_sunday_first_holder" android:id="@+id/settings_sunday_first_holder"
style="@style/SettingsHolderCheckboxStyle" style="@style/SettingsHolderCheckboxStyle"