Merge pull request #98 from trubitsyn/master

Allow to choose whether to put cursor to end of note
This commit is contained in:
Tibor Kaputa 2017-06-19 09:12:12 +02:00 committed by GitHub
commit 1431637266
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

View File

@ -70,6 +70,29 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_cursor_placement_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingBottom="@dimen/bigger_margin"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:paddingTop="@dimen/bigger_margin">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/settings_cursor_placement"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:paddingLeft="@dimen/medium_margin"
android:paddingStart="@dimen/medium_margin"
android:text="@string/place_cursor_end"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_font_size_holder"
android:layout_width="match_parent"

View File

@ -30,6 +30,7 @@
<!-- Settings -->
<string name="widget_note">Widget-Notiz</string>
<string name="links_and_emails_clickable">Links und E-Mail Adressen anklickbar</string>
<string name="place_cursor_end">Place cursor to the end of note</string>
<string name="note_font_size">Schriftgröße</string>
<string name="small">Klein</string>
<string name="normal">Normal</string>

View File

@ -30,6 +30,7 @@
<!-- Settings -->
<string name="note_font_size">Tamaño de fuente</string>
<string name="links_and_emails_clickable">Make links and emails clickable</string>
<string name="place_cursor_end">Place cursor to the end of note</string>
<string name="widget_note">Nota del widget</string>
<string name="small">Pequeña</string>
<string name="normal">Normal</string>

View File

@ -30,6 +30,7 @@
<!-- Settings -->
<string name="widget_note">Note utilisée dans le widget</string>
<string name="links_and_emails_clickable">Rendre les liens et les emails cliquables</string>
<string name="place_cursor_end">Place cursor to the end of note</string>
<string name="note_font_size">Taille de la police de la note</string>
<string name="small">Petite</string>
<string name="normal">Normale</string>

View File

@ -30,6 +30,7 @@
<!-- Settings -->
<string name="widget_note">Widgetben használt jegyzet</string>
<string name="links_and_emails_clickable">Hivatkozások és e-mail címek felismerése</string>
<string name="place_cursor_end">Place cursor to the end of note</string>
<string name="note_font_size">Jegyzet betűméret</string>
<string name="small">Kicsi</string>
<string name="normal">Közepes</string>

View File

@ -30,6 +30,7 @@
<!-- Settings -->
<string name="note_font_size">Note font size</string>
<string name="links_and_emails_clickable">Make links and emails clickable</string>
<string name="place_cursor_end">Place cursor to the end of note</string>
<string name="widget_note">Note used in widget</string>
<string name="small">Small</string>
<string name="normal">Normal</string>

View File

@ -30,6 +30,7 @@
<!-- Settings -->
<string name="note_font_size">メモのフォントサイズ</string>
<string name="links_and_emails_clickable">Make links and emails clickable</string>
<string name="place_cursor_end">Place cursor to the end of note</string>
<string name="widget_note">ウィジェットで使用するメモ</string>
<string name="small"></string>
<string name="normal">通常</string>

View File

@ -30,6 +30,7 @@
<!-- Settings -->
<string name="widget_note">Note used in widget</string>
<string name="links_and_emails_clickable">Make links and emails clickable</string>
<string name="place_cursor_end">Place cursor to the end of note</string>
<string name="note_font_size">Note font size</string>
<string name="small">Small</string>
<string name="normal">Normal</string>

View File

@ -30,6 +30,7 @@
<!-- Settings -->
<string name="note_font_size">Tamanho do texto da nota</string>
<string name="links_and_emails_clickable">Ativar clique em ligações e endereços de e-mail</string>
<string name="place_cursor_end">Place cursor to the end of note</string>
<string name="widget_note">Nota utilizada no widget</string>
<string name="small">Pequeno</string>
<string name="normal">Normal</string>

View File

@ -30,6 +30,7 @@
<!-- Settings -->
<string name="note_font_size">Tamanho do texto da nota</string>
<string name="links_and_emails_clickable">Ativar clique em ligações e endereços de e-mail</string>
<string name="place_cursor_end">Place cursor to the end of note</string>
<string name="widget_note">Nota utilizada no widget</string>
<string name="small">Pequeno</string>
<string name="normal">Normal</string>

View File

@ -30,6 +30,7 @@
<!-- Settings -->
<string name="widget_note">Заметка, отображаемая в виджете</string>
<string name="links_and_emails_clickable">Сделать ссылки и адреса электронной почты активными</string>
<string name="place_cursor_end">Помещать курсор в конец заметки</string>
<string name="note_font_size">Размер текста заметки</string>
<string name="small">Мелкий</string>
<string name="normal">Нормальный</string>

View File

@ -30,6 +30,7 @@
<!-- Settings -->
<string name="note_font_size">Note font size</string>
<string name="links_and_emails_clickable">Make links and emails clickable</string>
<string name="place_cursor_end">Place cursor to the end of note</string>
<string name="widget_note">Note used in widget</string>
<string name="small">Small</string>
<string name="normal">Normal</string>

View File

@ -30,6 +30,7 @@
<!-- Settings -->
<string name="widget_note">Note used in widget</string>
<string name="links_and_emails_clickable">Make links and emails clickable</string>
<string name="place_cursor_end">Place cursor to the end of note</string>
<string name="note_font_size">Note font size</string>
<string name="small">Small</string>
<string name="normal">Normal</string>