From bf3f02461d2093dfb754568d597fe03120b877dc Mon Sep 17 00:00:00 2001
From: tibbi <tibor@kaputa.sk>
Date: Sat, 7 Dec 2019 15:04:40 +0100
Subject: [PATCH] adding the settings item for moving undone checklist items

---
 .../notes/pro/activities/SettingsActivity.kt  |  9 ++++++++
 .../notes/pro/helpers/Config.kt               |  4 ++++
 .../notes/pro/helpers/Constants.kt            |  1 +
 app/src/main/res/layout/activity_settings.xml | 23 +++++++++++++++++++
 4 files changed, 37 insertions(+)

diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/SettingsActivity.kt
index c009a20b..9064ec66 100644
--- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/SettingsActivity.kt
@@ -38,6 +38,7 @@ class SettingsActivity : SimpleActivity() {
         setupMonospacedFont()
         setupShowKeyboard()
         setupShowNotePicker()
+        setupMoveUndoneChecklistItems()
         setupShowWordCount()
         setupEnableLineWrap()
         setupFontSize()
@@ -130,6 +131,14 @@ class SettingsActivity : SimpleActivity() {
         }
     }
 
+    private fun setupMoveUndoneChecklistItems() {
+        settings_move_undone_checklist_items.isChecked = config.moveUndoneChecklistItems
+        settings_move_undone_checklist_items_holder.setOnClickListener {
+            settings_move_undone_checklist_items.toggle()
+            config.moveUndoneChecklistItems = settings_move_undone_checklist_items.isChecked
+        }
+    }
+
     private fun setupShowWordCount() {
         settings_show_word_count.isChecked = config.showWordCount
         settings_show_word_count_holder.setOnClickListener {
diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/Config.kt
index 300b2e09..b20e5558 100644
--- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/Config.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/Config.kt
@@ -76,4 +76,8 @@ class Config(context: Context) : BaseConfig(context) {
     var lastCreatedNoteType: Int
         get() = prefs.getInt(LAST_CREATED_NOTE_TYPE, TYPE_TEXT)
         set(lastCreatedNoteType) = prefs.edit().putInt(LAST_CREATED_NOTE_TYPE, lastCreatedNoteType).apply()
+
+    var moveUndoneChecklistItems: Boolean
+        get() = prefs.getBoolean(MOVE_UNDONE_CHECKLIST_ITEMS, false)
+        set(moveUndoneChecklistItems) = prefs.edit().putBoolean(MOVE_UNDONE_CHECKLIST_ITEMS, moveUndoneChecklistItems).apply()
 }
diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/Constants.kt
index 1a49e375..fe56c4d5 100644
--- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/Constants.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/Constants.kt
@@ -30,6 +30,7 @@ const val LAST_USED_SAVE_PATH = "last_used_save_path"
 const val ENABLE_LINE_WRAP = "enable_line_wrap"
 const val USE_INCOGNITO_MODE = "use_incognito_mode"
 const val LAST_CREATED_NOTE_TYPE = "last_created_note_type"
+const val MOVE_UNDONE_CHECKLIST_ITEMS = "move_undone_checklist_items"
 
 // gravity
 const val GRAVITY_LEFT = 0
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
index e03189e5..a3036128 100644
--- a/app/src/main/res/layout/activity_settings.xml
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -338,6 +338,29 @@
 
         </RelativeLayout>
 
+        <RelativeLayout
+            android:id="@+id/settings_move_undone_checklist_items_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_move_undone_checklist_items"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:background="@null"
+                android:clickable="false"
+                android:paddingStart="@dimen/medium_margin"
+                android:text="@string/move_undone_checklist_items"
+                app:switchPadding="@dimen/medium_margin"/>
+
+        </RelativeLayout>
+
         <View
             android:id="@+id/saving_divider"
             android:layout_width="match_parent"