Allow to use monospaced font

This commit is contained in:
Nikola Trubitsyn 2017-09-19 18:35:37 +03:00
parent 8ed2901389
commit 7de615fecc
18 changed files with 53 additions and 0 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -93,6 +93,29 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_monospaced_font_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_monospaced_font"
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/monospaced_font"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_font_size_holder"
android:layout_width="match_parent"

View File

@ -31,6 +31,7 @@
<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="monospaced_font">Use monospaced font</string>
<string name="gravity">Ausrichtung</string>
<string name="left">Linksbündig</string>
<string name="center">Zentriert</string>

View File

@ -30,6 +30,7 @@
<!-- Settings -->
<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="monospaced_font">Use monospaced font</string>
<string name="widget_note">Nota del widget</string>
<string name="gravity">Alineación del texto</string>
<string name="left">Izquierda</string>

View File

@ -31,6 +31,7 @@
<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">Placer le curseur à la fin de la note</string>
<string name="monospaced_font">Use monospaced font</string>
<string name="gravity">Gravité</string>
<string name="left">Gauche</string>
<string name="center">Centre</string>

View File

@ -31,6 +31,7 @@
<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="monospaced_font">Use monospaced font</string>
<string name="gravity">Igazítottság</string>
<string name="left">Bal</string>
<string name="center">Közép</string>

View File

@ -30,6 +30,7 @@
<!-- Settings -->
<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="monospaced_font">Use monospaced font</string>
<string name="widget_note">Note used in widget</string>
<string name="gravity">Gravity</string>
<string name="left">Left</string>

View File

@ -30,6 +30,7 @@
<!-- Settings -->
<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="monospaced_font">Use monospaced font</string>
<string name="widget_note">ウィジェットで使用するメモ</string>
<string name="gravity">重力</string>
<string name="left"></string>

View File

@ -31,6 +31,7 @@
<string name="widget_note">Áraðas panaudotas ðaukinyje</string>
<string name="links_and_emails_clickable">Paspaudþiamos nuorodos ir elektroninio paðto adresai</string>
<string name="place_cursor_end">Perkelti þymeklá á áraðo pabaigà</string>
<string name="monospaced_font">Use monospaced font</string>
<string name="gravity">Átrauka</string>
<string name="left">Kairëje</string>
<string name="center">Centre</string>

View File

@ -31,6 +31,7 @@
<string name="widget_note">Notatka używana w widżecie</string>
<string name="links_and_emails_clickable">Przetwarzaj linki i adresy e-mail do klikalnej formy.</string>
<string name="place_cursor_end">Umieszczaj kursor na końcu notatki</string>
<string name="monospaced_font">Use monospaced font</string>
<string name="gravity">Wyrównanie tekstu w notatkach</string>
<string name="left">Do lewej strony</string>
<string name="center">Do środka</string>

View File

@ -30,6 +30,7 @@
<!-- Settings -->
<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="monospaced_font">Use monospaced font</string>
<string name="widget_note">Nota utilizada no widget</string>
<string name="gravity">Gravidade</string>
<string name="left">Esquerda</string>

View File

@ -30,6 +30,7 @@
<!-- Settings -->
<string name="links_and_emails_clickable">Ativar clique em ligações e endereços de e-mail</string>
<string name="place_cursor_end">Colocar cursor no fim da nota</string>
<string name="monospaced_font">Use monospaced font</string>
<string name="widget_note">Nota utilizada no widget</string>
<string name="gravity">Gravidade</string>
<string name="left">Esquerda</string>

View File

@ -31,6 +31,7 @@
<string name="widget_note">Заметка, отображаемая в виджете</string>
<string name="links_and_emails_clickable">Сделать ссылки и адреса электронной почты активными</string>
<string name="place_cursor_end">Помещать курсор в конец заметки</string>
<string name="monospaced_font">Использовать моноширинный шрифт</string>
<string name="gravity">Выравнивание</string>
<string name="left">По левому краю</string>
<string name="center">По центру</string>

View File

@ -30,6 +30,7 @@
<!-- Settings -->
<string name="links_and_emails_clickable">Gör länkar och e-postadresser klickbara</string>
<string name="place_cursor_end">Placera markören vid slutet av anteckningen</string>
<string name="monospaced_font">Use monospaced font</string>
<string name="widget_note">Anteckningen används i widgeten</string>
<string name="gravity">Justering</string>
<string name="left">Vänster</string>

View File

@ -31,6 +31,7 @@
<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="monospaced_font">Use monospaced font</string>
<string name="gravity">Gravity</string>
<string name="left">Left</string>
<string name="center">Center</string>