mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-06-05 17:00:23 +02:00
Added new checklist items at the top (#439)
This commit is contained in:
@ -48,6 +48,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
setupCustomizeWidgetColors()
|
||||
updateTextColors(settings_scrollview)
|
||||
setupSectionColors()
|
||||
setupAddNewChecklistItemsTop()
|
||||
invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
@ -251,4 +252,12 @@ class SettingsActivity : SimpleActivity() {
|
||||
config.useIncognitoMode = settings_use_incognito_mode.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupAddNewChecklistItemsTop() {
|
||||
settings_add_checklist_top.isChecked = config.addNewChecklistItemsTop
|
||||
settings_add_checklist_top_holder.setOnClickListener {
|
||||
settings_add_checklist_top.toggle()
|
||||
config.addNewChecklistItemsTop = settings_add_checklist_top.isChecked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -136,14 +136,21 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
||||
private fun showNewItemDialog() {
|
||||
NewChecklistItemDialog(activity as SimpleActivity) { titles ->
|
||||
var currentMaxId = items.maxBy { item -> item.id }?.id ?: 0
|
||||
val newItems = ArrayList<ChecklistItem>()
|
||||
|
||||
titles.forEach { title ->
|
||||
title.split("\n").map { it.trim() }.filter { it.isNotBlank() }.forEach { row ->
|
||||
items.add(ChecklistItem(currentMaxId + 1, row, false))
|
||||
newItems.add(ChecklistItem(currentMaxId + 1, row, false))
|
||||
currentMaxId++
|
||||
}
|
||||
}
|
||||
|
||||
if (config?.addNewChecklistItemsTop == true) {
|
||||
items.addAll(0, newItems)
|
||||
} else {
|
||||
items.addAll(newItems)
|
||||
}
|
||||
|
||||
saveNote()
|
||||
setupAdapter()
|
||||
}
|
||||
|
@ -89,4 +89,8 @@ class Config(context: Context) : BaseConfig(context) {
|
||||
var fontSizePercentage: Int
|
||||
get() = prefs.getInt(FONT_SIZE_PERCENTAGE, 100)
|
||||
set(fontSizePercentage) = prefs.edit().putInt(FONT_SIZE_PERCENTAGE, fontSizePercentage).apply()
|
||||
|
||||
var addNewChecklistItemsTop: Boolean
|
||||
get() = prefs.getBoolean(ADD_NEW_CHECKLIST_ITEMS_TOP, false)
|
||||
set(addNewCheckListItemsTop) = prefs.edit().putBoolean(ADD_NEW_CHECKLIST_ITEMS_TOP, addNewCheckListItemsTop).apply()
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ const val USE_INCOGNITO_MODE = "use_incognito_mode"
|
||||
const val LAST_CREATED_NOTE_TYPE = "last_created_note_type"
|
||||
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
|
||||
const val FONT_SIZE_PERCENTAGE = "font_size_percentage"
|
||||
const val ADD_NEW_CHECKLIST_ITEMS_TOP = "add_new_checklist_items_top"
|
||||
|
||||
// gravity
|
||||
const val GRAVITY_LEFT = 0
|
||||
|
Reference in New Issue
Block a user