Skip to content

Commit ba07d6b

Browse files
committed
Added new checklist items at the top (#583)
1 parent d34defe commit ba07d6b

File tree

5 files changed

+35
-1
lines changed

5 files changed

+35
-1
lines changed

app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/SettingsActivity.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class SettingsActivity : SimpleActivity() {
5050
setupCursorPlacement()
5151
setupIncognitoMode()
5252
setupCustomizeWidgetColors()
53+
setupAddNewChecklistItemsTop()
5354
updateTextColors(settings_nested_scrollview)
5455

5556
arrayOf(
@@ -257,4 +258,12 @@ class SettingsActivity : SimpleActivity() {
257258
config.useIncognitoMode = settings_use_incognito_mode.isChecked
258259
}
259260
}
261+
262+
private fun setupAddNewChecklistItemsTop() {
263+
settings_add_checklist_top.isChecked = config.addNewChecklistItemsTop
264+
settings_add_checklist_top_holder.setOnClickListener {
265+
settings_add_checklist_top.toggle()
266+
config.addNewChecklistItemsTop = settings_add_checklist_top.isChecked
267+
}
268+
}
260269
}

app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,12 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
152152
}
153153
}
154154

155-
items.addAll(newItems)
155+
if (config?.addNewChecklistItemsTop == true) {
156+
items.addAll(0, newItems)
157+
} else {
158+
items.addAll(newItems)
159+
}
160+
156161
saveNote()
157162
setupAdapter()
158163
}

app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/Config.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,8 @@ class Config(context: Context) : BaseConfig(context) {
8989
var fontSizePercentage: Int
9090
get() = prefs.getInt(FONT_SIZE_PERCENTAGE, 100)
9191
set(fontSizePercentage) = prefs.edit().putInt(FONT_SIZE_PERCENTAGE, fontSizePercentage).apply()
92+
93+
var addNewChecklistItemsTop: Boolean
94+
get() = prefs.getBoolean(ADD_NEW_CHECKLIST_ITEMS_TOP, false)
95+
set(addNewCheckListItemsTop) = prefs.edit().putBoolean(ADD_NEW_CHECKLIST_ITEMS_TOP, addNewCheckListItemsTop).apply()
9296
}

app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/Constants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const val LAST_CREATED_NOTE_TYPE = "last_created_note_type"
3737
const val MOVE_DONE_CHECKLIST_ITEMS = "move_undone_checklist_items" // it has been replaced from moving undone items at the top to moving done to bottom
3838
const val FONT_SIZE_PERCENTAGE = "font_size_percentage"
3939
const val EXPORT_MIME_TYPE = "text/plain"
40+
const val ADD_NEW_CHECKLIST_ITEMS_TOP = "add_new_checklist_items_top"
4041

4142
// gravity
4243
const val GRAVITY_LEFT = 0

app/src/main/res/layout/activity_settings.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,21 @@
227227

228228
</RelativeLayout>
229229

230+
<RelativeLayout
231+
android:id="@+id/settings_add_checklist_top_holder"
232+
style="@style/SettingsHolderCheckboxStyle"
233+
android:layout_width="match_parent"
234+
android:layout_height="wrap_content">
235+
236+
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
237+
android:id="@+id/settings_add_checklist_top"
238+
style="@style/SettingsCheckboxStyle"
239+
android:layout_width="match_parent"
240+
android:layout_height="wrap_content"
241+
android:text="@string/add_new_checklist_items_top" />
242+
243+
</RelativeLayout>
244+
230245
<RelativeLayout
231246
android:id="@+id/settings_gravity_holder"
232247
style="@style/SettingsHolderTextViewStyle"

0 commit comments

Comments
 (0)