Allow to choose whether to put cursor to end of note

This commit is contained in:
Nikola Trubitsyn
2017-06-19 01:33:25 +03:00
parent dbdfc7b49f
commit cad1cee0a2
17 changed files with 53 additions and 1 deletions

View File

@ -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 ?: ""
}

View File

@ -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)
}
}
}

View File

@ -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()
}

View File

@ -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