From 7de615fecc2f82cb723c8a1439075eff7614b697 Mon Sep 17 00:00:00 2001 From: Nikola Trubitsyn Date: Tue, 19 Sep 2017 18:35:37 +0300 Subject: [PATCH] Allow to use monospaced font --- .../notes/activities/SettingsActivity.kt | 9 ++++++++ .../notes/fragments/NoteFragment.kt | 3 +++ .../simplemobiletools/notes/helpers/Config.kt | 4 ++++ .../notes/helpers/Constants.kt | 1 + app/src/main/res/layout/activity_settings.xml | 23 +++++++++++++++++++ app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values-hu/strings.xml | 1 + app/src/main/res/values-it/strings.xml | 1 + app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values-lt/strings.xml | 1 + app/src/main/res/values-pl/strings.xml | 1 + app/src/main/res/values-pt-rBR/strings.xml | 1 + app/src/main/res/values-pt/strings.xml | 1 + app/src/main/res/values-ru/strings.xml | 1 + app/src/main/res/values-sv/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 18 files changed, 53 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/notes/activities/SettingsActivity.kt index 1a5e5d45..6d1c4229 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/activities/SettingsActivity.kt @@ -28,6 +28,7 @@ class SettingsActivity : SimpleActivity() { setupCustomizeColors() setupDisplaySuccess() setupClickableLinks() + setupMonospacedFont() setupFontSize() setupGravity() setupWidgetNote() @@ -57,6 +58,14 @@ class SettingsActivity : SimpleActivity() { } } + private fun setupMonospacedFont() { + settings_monospaced_font.isChecked = config.monospacedFont + settings_monospaced_font_holder.setOnClickListener { + settings_monospaced_font.toggle() + config.monospacedFont = settings_monospaced_font.isChecked + } + } + private fun setupFontSize() { settings_font_size.text = getFontSizeText() settings_font_size_holder.setOnClickListener { diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/fragments/NoteFragment.kt b/app/src/main/kotlin/com/simplemobiletools/notes/fragments/NoteFragment.kt index b19b0634..718e6eec 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/fragments/NoteFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/fragments/NoteFragment.kt @@ -1,6 +1,7 @@ package com.simplemobiletools.notes.fragments import android.content.Context +import android.graphics.Typeface import android.os.Bundle import android.support.v4.app.Fragment import android.text.method.LinkMovementMethod @@ -100,6 +101,8 @@ class NoteFragment : Fragment() { val config = context.config view.notes_view.apply { + typeface = if (config.monospacedFont) Typeface.MONOSPACE else Typeface.DEFAULT + val fileContents = context.getNoteStoredValue(note) if (fileContents == null) { diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/notes/helpers/Config.kt index 9869137e..76e35565 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/helpers/Config.kt @@ -16,6 +16,10 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getBoolean(CLICKABLE_LINKS, false) set(clickableLinks) = prefs.edit().putBoolean(CLICKABLE_LINKS, clickableLinks).apply() + var monospacedFont: Boolean + get() = prefs.getBoolean(MONOSPACED_FONT, false) + set(monospacedFont) = prefs.edit().putBoolean(MONOSPACED_FONT, monospacedFont).apply() + var fontSize: Int get() = prefs.getInt(FONT_SIZE, FONT_SIZE_MEDIUM) set(size) = prefs.edit().putInt(FONT_SIZE, size).apply() diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/notes/helpers/Constants.kt index 4cec9a61..6975fd3e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/helpers/Constants.kt @@ -8,6 +8,7 @@ val CURRENT_NOTE_ID = "current_note_id" val DISPLAY_SUCCESS = "display_success" val CLICKABLE_LINKS = "clickable_links" val WIDGET_NOTE_ID = "widget_note_id" +val MONOSPACED_FONT = "monospaced_font" val FONT_SIZE = "font_size" val GRAVITY = "gravity" val CURSOR_PLACEMENT = "cursor_placement" diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 3fc758ad..dbc9120e 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -93,6 +93,29 @@ + + + + + + Widget-Notiz Links und E-Mail Adressen anklickbar Place cursor to the end of note + Use monospaced font Ausrichtung Linksbündig Zentriert diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index f6e9b8ea..d9349359 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -30,6 +30,7 @@ Make links and emails clickable Place cursor to the end of note + Use monospaced font Nota del widget Alineación del texto Izquierda diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 5397e9d1..61f20d8d 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -31,6 +31,7 @@ Note utilisée dans le widget Rendre les liens et les emails cliquables Placer le curseur à la fin de la note + Use monospaced font Gravité Gauche Centre diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 7c667a16..ea698eb2 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -31,6 +31,7 @@ Widgetben használt jegyzet Hivatkozások és e-mail címek felismerése Place cursor to the end of note + Use monospaced font Igazítottság Bal Közép diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index e7a63e4b..002d964d 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -30,6 +30,7 @@ Make links and emails clickable Place cursor to the end of note + Use monospaced font Note used in widget Gravity Left diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index a1aac4a8..fefa3bf8 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -30,6 +30,7 @@ Make links and emails clickable Place cursor to the end of note + Use monospaced font ウィジェットで使用するメモ 重力 diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index 4b997b81..e9f04250 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -31,6 +31,7 @@ Áraðas panaudotas ðaukinyje Paspaudþiamos nuorodos ir elektroninio paðto adresai Perkelti þymeklá á áraðo pabaigà + Use monospaced font Átrauka Kairëje Centre diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 23cfee7e..e59bcd50 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -31,6 +31,7 @@ Notatka używana w widżecie Przetwarzaj linki i adresy e-mail do klikalnej formy. Umieszczaj kursor na końcu notatki + Use monospaced font Wyrównanie tekstu w notatkach Do lewej strony Do środka diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 58dc87b7..641dec76 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -30,6 +30,7 @@ Ativar clique em ligações e endereços de e-mail Place cursor to the end of note + Use monospaced font Nota utilizada no widget Gravidade Esquerda diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index bffa2bd8..59d25bfd 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -30,6 +30,7 @@ Ativar clique em ligações e endereços de e-mail Colocar cursor no fim da nota + Use monospaced font Nota utilizada no widget Gravidade Esquerda diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 8031eb4a..b5b61465 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -31,6 +31,7 @@ Заметка, отображаемая в виджете Сделать ссылки и адреса электронной почты активными Помещать курсор в конец заметки + Использовать моноширинный шрифт Выравнивание По левому краю По центру diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 209961a9..d316373c 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -30,6 +30,7 @@ Gör länkar och e-postadresser klickbara Placera markören vid slutet av anteckningen + Use monospaced font Anteckningen används i widgeten Justering Vänster diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dafabc7c..dab71556 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -31,6 +31,7 @@ Note used in widget Make links and emails clickable Place cursor to the end of note + Use monospaced font Gravity Left Center