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"