Skip to content

Commit cad1cee

Browse files
committed
Allow to choose whether to put cursor to end of note
1 parent dbdfc7b commit cad1cee

File tree

17 files changed

+53
-1
lines changed

17 files changed

+53
-1
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class SettingsActivity : SimpleActivity() {
3131
setupFontSize()
3232
setupGravity()
3333
setupWidgetNote()
34+
setupCursorPlacement()
3435
updateTextColors(settings_scrollview)
3536
}
3637

@@ -121,6 +122,14 @@ class SettingsActivity : SimpleActivity() {
121122
}
122123
}
123124

125+
private fun setupCursorPlacement() {
126+
settings_cursor_placement.isChecked = config.placeCursorToEnd
127+
settings_cursor_placement_holder.setOnClickListener {
128+
settings_cursor_placement.toggle()
129+
config.placeCursorToEnd = settings_cursor_placement.isChecked
130+
}
131+
}
132+
124133
private fun getCurrentWidgetNoteTitle(currentNoteId: Int, notes: List<Note>): String {
125134
return notes.firstOrNull { it.id == currentNoteId }?.title ?: ""
126135
}

app/src/main/kotlin/com/simplemobiletools/notes/fragments/NoteFragment.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ class NoteFragment : Fragment() {
111111
setColors(config.textColor, config.primaryColor, config.backgroundColor)
112112
setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getTextSize())
113113
gravity = getTextGravity()
114-
setSelection(text.length)
114+
115+
if (config.placeCursorToEnd) {
116+
setSelection(text.length)
117+
}
115118
}
116119
}
117120

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,8 @@ class Config(context: Context) : BaseConfig(context) {
3131
var widgetNoteId: Int
3232
get() = prefs.getInt(WIDGET_NOTE_ID, 1)
3333
set(id) = prefs.edit().putInt(WIDGET_NOTE_ID, id).apply()
34+
35+
var placeCursorToEnd: Boolean
36+
get() = prefs.getBoolean(CURSOR_PLACEMENT, true)
37+
set(placement) = prefs.edit().putBoolean(CURSOR_PLACEMENT, placement).apply()
3438
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ val CLICKABLE_LINKS = "clickable_links"
1010
val WIDGET_NOTE_ID = "widget_note_id"
1111
val FONT_SIZE = "font_size"
1212
val GRAVITY = "gravity"
13+
val CURSOR_PLACEMENT = "cursor_placement"
1314

1415
// gravity
1516
val GRAVITY_LEFT = 0

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,29 @@
7070

7171
</RelativeLayout>
7272

73+
<RelativeLayout
74+
android:id="@+id/settings_cursor_placement_holder"
75+
android:layout_width="match_parent"
76+
android:layout_height="wrap_content"
77+
android:layout_marginTop="@dimen/medium_margin"
78+
android:background="?attr/selectableItemBackground"
79+
android:paddingBottom="@dimen/bigger_margin"
80+
android:paddingLeft="@dimen/activity_margin"
81+
android:paddingRight="@dimen/activity_margin"
82+
android:paddingTop="@dimen/bigger_margin">
83+
84+
<com.simplemobiletools.commons.views.MySwitchCompat
85+
android:id="@+id/settings_cursor_placement"
86+
android:layout_width="match_parent"
87+
android:layout_height="wrap_content"
88+
android:background="@null"
89+
android:clickable="false"
90+
android:paddingLeft="@dimen/medium_margin"
91+
android:paddingStart="@dimen/medium_margin"
92+
android:text="@string/place_cursor_end"/>
93+
94+
</RelativeLayout>
95+
7396
<RelativeLayout
7497
android:id="@+id/settings_font_size_holder"
7598
android:layout_width="match_parent"

app/src/main/res/values-de/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<!-- Settings -->
3131
<string name="widget_note">Widget-Notiz</string>
3232
<string name="links_and_emails_clickable">Links und E-Mail Adressen anklickbar</string>
33+
<string name="place_cursor_end">Place cursor to the end of note</string>
3334
<string name="note_font_size">Schriftgröße</string>
3435
<string name="small">Klein</string>
3536
<string name="normal">Normal</string>

app/src/main/res/values-es/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<!-- Settings -->
3131
<string name="note_font_size">Tamaño de fuente</string>
3232
<string name="links_and_emails_clickable">Make links and emails clickable</string>
33+
<string name="place_cursor_end">Place cursor to the end of note</string>
3334
<string name="widget_note">Nota del widget</string>
3435
<string name="small">Pequeña</string>
3536
<string name="normal">Normal</string>

app/src/main/res/values-fr/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<!-- Settings -->
3131
<string name="widget_note">Note utilisée dans le widget</string>
3232
<string name="links_and_emails_clickable">Rendre les liens et les emails cliquables</string>
33+
<string name="place_cursor_end">Place cursor to the end of note</string>
3334
<string name="note_font_size">Taille de la police de la note</string>
3435
<string name="small">Petite</string>
3536
<string name="normal">Normale</string>

app/src/main/res/values-hu/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<!-- Settings -->
3131
<string name="widget_note">Widgetben használt jegyzet</string>
3232
<string name="links_and_emails_clickable">Hivatkozások és e-mail címek felismerése</string>
33+
<string name="place_cursor_end">Place cursor to the end of note</string>
3334
<string name="note_font_size">Jegyzet betűméret</string>
3435
<string name="small">Kicsi</string>
3536
<string name="normal">Közepes</string>

app/src/main/res/values-it/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<!-- Settings -->
3131
<string name="note_font_size">Note font size</string>
3232
<string name="links_and_emails_clickable">Make links and emails clickable</string>
33+
<string name="place_cursor_end">Place cursor to the end of note</string>
3334
<string name="widget_note">Note used in widget</string>
3435
<string name="small">Small</string>
3536
<string name="normal">Normal</string>

app/src/main/res/values-ja/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<!-- Settings -->
3131
<string name="note_font_size">メモのフォントサイズ</string>
3232
<string name="links_and_emails_clickable">Make links and emails clickable</string>
33+
<string name="place_cursor_end">Place cursor to the end of note</string>
3334
<string name="widget_note">ウィジェットで使用するメモ</string>
3435
<string name="small">小</string>
3536
<string name="normal">通常</string>

app/src/main/res/values-lt/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<!-- Settings -->
3131
<string name="widget_note">Note used in widget</string>
3232
<string name="links_and_emails_clickable">Make links and emails clickable</string>
33+
<string name="place_cursor_end">Place cursor to the end of note</string>
3334
<string name="note_font_size">Note font size</string>
3435
<string name="small">Small</string>
3536
<string name="normal">Normal</string>

app/src/main/res/values-pt-rBR/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<!-- Settings -->
3131
<string name="note_font_size">Tamanho do texto da nota</string>
3232
<string name="links_and_emails_clickable">Ativar clique em ligações e endereços de e-mail</string>
33+
<string name="place_cursor_end">Place cursor to the end of note</string>
3334
<string name="widget_note">Nota utilizada no widget</string>
3435
<string name="small">Pequeno</string>
3536
<string name="normal">Normal</string>

app/src/main/res/values-pt/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<!-- Settings -->
3131
<string name="note_font_size">Tamanho do texto da nota</string>
3232
<string name="links_and_emails_clickable">Ativar clique em ligações e endereços de e-mail</string>
33+
<string name="place_cursor_end">Place cursor to the end of note</string>
3334
<string name="widget_note">Nota utilizada no widget</string>
3435
<string name="small">Pequeno</string>
3536
<string name="normal">Normal</string>

app/src/main/res/values-ru/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<!-- Settings -->
3131
<string name="widget_note">Заметка, отображаемая в виджете</string>
3232
<string name="links_and_emails_clickable">Сделать ссылки и адреса электронной почты активными</string>
33+
<string name="place_cursor_end">Помещать курсор в конец заметки</string>
3334
<string name="note_font_size">Размер текста заметки</string>
3435
<string name="small">Мелкий</string>
3536
<string name="normal">Нормальный</string>

app/src/main/res/values-sv/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<!-- Settings -->
3131
<string name="note_font_size">Note font size</string>
3232
<string name="links_and_emails_clickable">Make links and emails clickable</string>
33+
<string name="place_cursor_end">Place cursor to the end of note</string>
3334
<string name="widget_note">Note used in widget</string>
3435
<string name="small">Small</string>
3536
<string name="normal">Normal</string>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<!-- Settings -->
3131
<string name="widget_note">Note used in widget</string>
3232
<string name="links_and_emails_clickable">Make links and emails clickable</string>
33+
<string name="place_cursor_end">Place cursor to the end of note</string>
3334
<string name="note_font_size">Note font size</string>
3435
<string name="small">Small</string>
3536
<string name="normal">Normal</string>

0 commit comments

Comments
 (0)