mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-20 18:40:20 +01:00
Merge pull request #584 from Aga-C/add_checklist_items_top
Added new checklist items at the top (#583)
This commit is contained in:
commit
0672614101
@ -9,8 +9,11 @@ import android.view.inputmethod.EditorInfo
|
|||||||
import androidx.appcompat.widget.AppCompatEditText
|
import androidx.appcompat.widget.AppCompatEditText
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.DARK_GREY
|
import com.simplemobiletools.commons.helpers.DARK_GREY
|
||||||
|
import com.simplemobiletools.commons.helpers.SORT_BY_CUSTOM
|
||||||
import com.simplemobiletools.notes.pro.R
|
import com.simplemobiletools.notes.pro.R
|
||||||
|
import com.simplemobiletools.notes.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.dialog_new_checklist_item.view.*
|
import kotlinx.android.synthetic.main.dialog_new_checklist_item.view.*
|
||||||
|
import kotlinx.android.synthetic.main.dialog_new_checklist_item.view.dialog_holder
|
||||||
import kotlinx.android.synthetic.main.item_add_checklist.view.*
|
import kotlinx.android.synthetic.main.item_add_checklist.view.*
|
||||||
|
|
||||||
class NewChecklistItemDialog(val activity: Activity, callback: (titles: ArrayList<String>) -> Unit) {
|
class NewChecklistItemDialog(val activity: Activity, callback: (titles: ArrayList<String>) -> Unit) {
|
||||||
@ -31,6 +34,8 @@ class NewChecklistItemDialog(val activity: Activity, callback: (titles: ArrayLis
|
|||||||
add_item.setOnClickListener {
|
add_item.setOnClickListener {
|
||||||
addNewEditText()
|
addNewEditText()
|
||||||
}
|
}
|
||||||
|
settings_add_checklist_top.beVisibleIf(activity.config.sorting == SORT_BY_CUSTOM)
|
||||||
|
settings_add_checklist_top.isChecked = activity.config.addNewChecklistItemsTop
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
@ -40,6 +45,7 @@ class NewChecklistItemDialog(val activity: Activity, callback: (titles: ArrayLis
|
|||||||
activity.setupDialogStuff(view, this, R.string.add_new_checklist_items) { alertDialog ->
|
activity.setupDialogStuff(view, this, R.string.add_new_checklist_items) { alertDialog ->
|
||||||
alertDialog.showKeyboard(titles.first())
|
alertDialog.showKeyboard(titles.first())
|
||||||
alertDialog.getButton(BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(BUTTON_POSITIVE).setOnClickListener {
|
||||||
|
activity.config.addNewChecklistItemsTop = view.settings_add_checklist_top.isChecked
|
||||||
when {
|
when {
|
||||||
titles.all { it.text!!.isEmpty() } -> activity.toast(R.string.empty_name)
|
titles.all { it.text!!.isEmpty() } -> activity.toast(R.string.empty_name)
|
||||||
else -> {
|
else -> {
|
||||||
|
@ -152,7 +152,12 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
items.addAll(newItems)
|
if (config?.addNewChecklistItemsTop == true) {
|
||||||
|
items.addAll(0, newItems)
|
||||||
|
} else {
|
||||||
|
items.addAll(newItems)
|
||||||
|
}
|
||||||
|
|
||||||
saveNote()
|
saveNote()
|
||||||
setupAdapter()
|
setupAdapter()
|
||||||
}
|
}
|
||||||
|
@ -89,4 +89,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
var fontSizePercentage: Int
|
var fontSizePercentage: Int
|
||||||
get() = prefs.getInt(FONT_SIZE_PERCENTAGE, 100)
|
get() = prefs.getInt(FONT_SIZE_PERCENTAGE, 100)
|
||||||
set(fontSizePercentage) = prefs.edit().putInt(FONT_SIZE_PERCENTAGE, fontSizePercentage).apply()
|
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()
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ 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 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 FONT_SIZE_PERCENTAGE = "font_size_percentage"
|
||||||
const val EXPORT_MIME_TYPE = "text/plain"
|
const val EXPORT_MIME_TYPE = "text/plain"
|
||||||
|
const val ADD_NEW_CHECKLIST_ITEMS_TOP = "add_new_checklist_items_top"
|
||||||
|
|
||||||
// gravity
|
// gravity
|
||||||
const val GRAVITY_LEFT = 0
|
const val GRAVITY_LEFT = 0
|
||||||
|
@ -32,5 +32,12 @@
|
|||||||
android:paddingBottom="@dimen/medium_margin"
|
android:paddingBottom="@dimen/medium_margin"
|
||||||
android:src="@drawable/ic_plus_vector" />
|
android:src="@drawable/ic_plus_vector" />
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||||
|
android:id="@+id/settings_add_checklist_top"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/add_to_the_top"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user