mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-06-05 17:00:23 +02:00
Allow to choose whether to put cursor to end of note
This commit is contained in:
@ -31,6 +31,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
setupFontSize()
|
||||
setupGravity()
|
||||
setupWidgetNote()
|
||||
setupCursorPlacement()
|
||||
updateTextColors(settings_scrollview)
|
||||
}
|
||||
|
||||
@ -121,6 +122,14 @@ class SettingsActivity : SimpleActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupCursorPlacement() {
|
||||
settings_cursor_placement.isChecked = config.placeCursorToEnd
|
||||
settings_cursor_placement_holder.setOnClickListener {
|
||||
settings_cursor_placement.toggle()
|
||||
config.placeCursorToEnd = settings_cursor_placement.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCurrentWidgetNoteTitle(currentNoteId: Int, notes: List<Note>): String {
|
||||
return notes.firstOrNull { it.id == currentNoteId }?.title ?: ""
|
||||
}
|
||||
|
@ -111,7 +111,10 @@ class NoteFragment : Fragment() {
|
||||
setColors(config.textColor, config.primaryColor, config.backgroundColor)
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getTextSize())
|
||||
gravity = getTextGravity()
|
||||
setSelection(text.length)
|
||||
|
||||
if (config.placeCursorToEnd) {
|
||||
setSelection(text.length)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,4 +31,8 @@ class Config(context: Context) : BaseConfig(context) {
|
||||
var widgetNoteId: Int
|
||||
get() = prefs.getInt(WIDGET_NOTE_ID, 1)
|
||||
set(id) = prefs.edit().putInt(WIDGET_NOTE_ID, id).apply()
|
||||
|
||||
var placeCursorToEnd: Boolean
|
||||
get() = prefs.getBoolean(CURSOR_PLACEMENT, true)
|
||||
set(placement) = prefs.edit().putBoolean(CURSOR_PLACEMENT, placement).apply()
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ val CLICKABLE_LINKS = "clickable_links"
|
||||
val WIDGET_NOTE_ID = "widget_note_id"
|
||||
val FONT_SIZE = "font_size"
|
||||
val GRAVITY = "gravity"
|
||||
val CURSOR_PLACEMENT = "cursor_placement"
|
||||
|
||||
// gravity
|
||||
val GRAVITY_LEFT = 0
|
||||
|
Reference in New Issue
Block a user