mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-03 18:21:05 +02:00
moving the font size related settings into Commons
This commit is contained in:
parent
6fbffc0d9c
commit
b4b5a181ae
@ -57,7 +57,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.21.28'
|
implementation 'com.simplemobiletools:commons:5.22.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
|
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
|
||||||
|
|
||||||
kapt 'androidx.room:room-compiler:2.2.2'
|
kapt 'androidx.room:room-compiler:2.2.2'
|
||||||
|
@ -4,13 +4,8 @@ import android.content.Intent
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||||
import com.simplemobiletools.commons.extensions.beGone
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
|
|
||||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
|
||||||
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
|
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
|
||||||
import com.simplemobiletools.commons.helpers.isOreoPlus
|
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.notes.pro.R
|
import com.simplemobiletools.notes.pro.R
|
||||||
import com.simplemobiletools.notes.pro.extensions.config
|
import com.simplemobiletools.notes.pro.extensions.config
|
||||||
@ -172,13 +167,6 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getFontSizeText() = getString(when (config.fontSize) {
|
|
||||||
FONT_SIZE_SMALL -> R.string.small
|
|
||||||
FONT_SIZE_MEDIUM -> R.string.medium
|
|
||||||
FONT_SIZE_LARGE -> R.string.large
|
|
||||||
else -> R.string.extra_large
|
|
||||||
})
|
|
||||||
|
|
||||||
private fun setupGravity() {
|
private fun setupGravity() {
|
||||||
settings_gravity.text = getGravityText()
|
settings_gravity.text = getGravityText()
|
||||||
settings_gravity_holder.setOnClickListener {
|
settings_gravity_holder.setOnClickListener {
|
||||||
|
@ -20,7 +20,6 @@ import com.simplemobiletools.commons.models.RadioItem
|
|||||||
import com.simplemobiletools.notes.pro.R
|
import com.simplemobiletools.notes.pro.R
|
||||||
import com.simplemobiletools.notes.pro.adapters.ChecklistAdapter
|
import com.simplemobiletools.notes.pro.adapters.ChecklistAdapter
|
||||||
import com.simplemobiletools.notes.pro.extensions.config
|
import com.simplemobiletools.notes.pro.extensions.config
|
||||||
import com.simplemobiletools.notes.pro.extensions.getTextSize
|
|
||||||
import com.simplemobiletools.notes.pro.extensions.widgetsDB
|
import com.simplemobiletools.notes.pro.extensions.widgetsDB
|
||||||
import com.simplemobiletools.notes.pro.helpers.*
|
import com.simplemobiletools.notes.pro.helpers.*
|
||||||
import com.simplemobiletools.notes.pro.models.ChecklistItem
|
import com.simplemobiletools.notes.pro.models.ChecklistItem
|
||||||
@ -61,7 +60,7 @@ class WidgetConfigureActivity : SimpleActivity() {
|
|||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
text_note_view.setTextSize(TypedValue.COMPLEX_UNIT_PX, applicationContext.getTextSize())
|
text_note_view.setTextSize(TypedValue.COMPLEX_UNIT_PX, getTextSize())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
|
@ -14,11 +14,11 @@ import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
|||||||
import com.simplemobiletools.commons.extensions.applyColorFilter
|
import com.simplemobiletools.commons.extensions.applyColorFilter
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
|
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
|
||||||
|
import com.simplemobiletools.commons.extensions.getTextSize
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.notes.pro.R
|
import com.simplemobiletools.notes.pro.R
|
||||||
import com.simplemobiletools.notes.pro.dialogs.RenameChecklistItemDialog
|
import com.simplemobiletools.notes.pro.dialogs.RenameChecklistItemDialog
|
||||||
import com.simplemobiletools.notes.pro.extensions.config
|
import com.simplemobiletools.notes.pro.extensions.config
|
||||||
import com.simplemobiletools.notes.pro.extensions.getTextSize
|
|
||||||
import com.simplemobiletools.notes.pro.helpers.DONE_CHECKLIST_ITEM_ALPHA
|
import com.simplemobiletools.notes.pro.helpers.DONE_CHECKLIST_ITEM_ALPHA
|
||||||
import com.simplemobiletools.notes.pro.interfaces.ChecklistItemsListener
|
import com.simplemobiletools.notes.pro.interfaces.ChecklistItemsListener
|
||||||
import com.simplemobiletools.notes.pro.interfaces.ItemMoveCallback
|
import com.simplemobiletools.notes.pro.interfaces.ItemMoveCallback
|
||||||
|
@ -9,6 +9,7 @@ import android.widget.RemoteViewsService
|
|||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
import com.simplemobiletools.commons.extensions.adjustAlpha
|
import com.simplemobiletools.commons.extensions.adjustAlpha
|
||||||
|
import com.simplemobiletools.commons.extensions.getTextSize
|
||||||
import com.simplemobiletools.commons.extensions.setText
|
import com.simplemobiletools.commons.extensions.setText
|
||||||
import com.simplemobiletools.commons.extensions.setTextSize
|
import com.simplemobiletools.commons.extensions.setTextSize
|
||||||
import com.simplemobiletools.commons.helpers.WIDGET_TEXT_COLOR
|
import com.simplemobiletools.commons.helpers.WIDGET_TEXT_COLOR
|
||||||
@ -16,7 +17,6 @@ import com.simplemobiletools.notes.pro.R
|
|||||||
import com.simplemobiletools.notes.pro.R.id.checklist_title
|
import com.simplemobiletools.notes.pro.R.id.checklist_title
|
||||||
import com.simplemobiletools.notes.pro.R.id.widget_text_holder
|
import com.simplemobiletools.notes.pro.R.id.widget_text_holder
|
||||||
import com.simplemobiletools.notes.pro.extensions.config
|
import com.simplemobiletools.notes.pro.extensions.config
|
||||||
import com.simplemobiletools.notes.pro.extensions.getTextSize
|
|
||||||
import com.simplemobiletools.notes.pro.extensions.notesDB
|
import com.simplemobiletools.notes.pro.extensions.notesDB
|
||||||
import com.simplemobiletools.notes.pro.helpers.*
|
import com.simplemobiletools.notes.pro.helpers.*
|
||||||
import com.simplemobiletools.notes.pro.models.ChecklistItem
|
import com.simplemobiletools.notes.pro.models.ChecklistItem
|
||||||
|
@ -4,9 +4,9 @@ import android.appwidget.AppWidgetManager
|
|||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import com.simplemobiletools.notes.pro.R
|
|
||||||
import com.simplemobiletools.notes.pro.databases.NotesDatabase
|
import com.simplemobiletools.notes.pro.databases.NotesDatabase
|
||||||
import com.simplemobiletools.notes.pro.helpers.*
|
import com.simplemobiletools.notes.pro.helpers.Config
|
||||||
|
import com.simplemobiletools.notes.pro.helpers.MyWidgetProvider
|
||||||
import com.simplemobiletools.notes.pro.interfaces.NotesDao
|
import com.simplemobiletools.notes.pro.interfaces.NotesDao
|
||||||
import com.simplemobiletools.notes.pro.interfaces.WidgetsDao
|
import com.simplemobiletools.notes.pro.interfaces.WidgetsDao
|
||||||
|
|
||||||
@ -16,13 +16,6 @@ val Context.notesDB: NotesDao get() = NotesDatabase.getInstance(applicationConte
|
|||||||
|
|
||||||
val Context.widgetsDB: WidgetsDao get() = NotesDatabase.getInstance(applicationContext).WidgetsDao()
|
val Context.widgetsDB: WidgetsDao get() = NotesDatabase.getInstance(applicationContext).WidgetsDao()
|
||||||
|
|
||||||
fun Context.getTextSize() = when (config.fontSize) {
|
|
||||||
FONT_SIZE_SMALL -> resources.getDimension(R.dimen.smaller_text_size)
|
|
||||||
FONT_SIZE_LARGE -> resources.getDimension(R.dimen.big_text_size)
|
|
||||||
FONT_SIZE_EXTRA_LARGE -> resources.getDimension(R.dimen.extra_big_text_size)
|
|
||||||
else -> resources.getDimension(R.dimen.bigger_text_size)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Context.updateWidgets() {
|
fun Context.updateWidgets() {
|
||||||
val widgetIDs = AppWidgetManager.getInstance(applicationContext).getAppWidgetIds(ComponentName(applicationContext, MyWidgetProvider::class.java))
|
val widgetIDs = AppWidgetManager.getInstance(applicationContext).getAppWidgetIds(ComponentName(applicationContext, MyWidgetProvider::class.java))
|
||||||
if (widgetIDs.isNotEmpty()) {
|
if (widgetIDs.isNotEmpty()) {
|
||||||
|
@ -16,7 +16,6 @@ import com.simplemobiletools.commons.extensions.*
|
|||||||
import com.simplemobiletools.notes.pro.R
|
import com.simplemobiletools.notes.pro.R
|
||||||
import com.simplemobiletools.notes.pro.activities.MainActivity
|
import com.simplemobiletools.notes.pro.activities.MainActivity
|
||||||
import com.simplemobiletools.notes.pro.extensions.config
|
import com.simplemobiletools.notes.pro.extensions.config
|
||||||
import com.simplemobiletools.notes.pro.extensions.getTextSize
|
|
||||||
import com.simplemobiletools.notes.pro.extensions.updateWidgets
|
import com.simplemobiletools.notes.pro.extensions.updateWidgets
|
||||||
import com.simplemobiletools.notes.pro.helpers.MyMovementMethod
|
import com.simplemobiletools.notes.pro.helpers.MyMovementMethod
|
||||||
import com.simplemobiletools.notes.pro.helpers.NOTE_ID
|
import com.simplemobiletools.notes.pro.helpers.NOTE_ID
|
||||||
|
@ -39,10 +39,6 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
get() = prefs.getBoolean(SHOW_WORD_COUNT, false)
|
get() = prefs.getBoolean(SHOW_WORD_COUNT, false)
|
||||||
set(showWordCount) = prefs.edit().putBoolean(SHOW_WORD_COUNT, showWordCount).apply()
|
set(showWordCount) = prefs.edit().putBoolean(SHOW_WORD_COUNT, showWordCount).apply()
|
||||||
|
|
||||||
var fontSize: Int
|
|
||||||
get() = prefs.getInt(FONT_SIZE, FONT_SIZE_MEDIUM)
|
|
||||||
set(size) = prefs.edit().putInt(FONT_SIZE, size).apply()
|
|
||||||
|
|
||||||
var gravity: Int
|
var gravity: Int
|
||||||
get() = prefs.getInt(GRAVITY, GRAVITY_LEFT)
|
get() = prefs.getInt(GRAVITY, GRAVITY_LEFT)
|
||||||
set(size) = prefs.edit().putInt(GRAVITY, size).apply()
|
set(size) = prefs.edit().putInt(GRAVITY, size).apply()
|
||||||
|
@ -22,7 +22,6 @@ const val MONOSPACED_FONT = "monospaced_font"
|
|||||||
const val SHOW_KEYBOARD = "show_keyboard"
|
const val SHOW_KEYBOARD = "show_keyboard"
|
||||||
const val SHOW_NOTE_PICKER = "show_note_picker"
|
const val SHOW_NOTE_PICKER = "show_note_picker"
|
||||||
const val SHOW_WORD_COUNT = "show_word_count"
|
const val SHOW_WORD_COUNT = "show_word_count"
|
||||||
const val FONT_SIZE = "font_size"
|
|
||||||
const val GRAVITY = "gravity"
|
const val GRAVITY = "gravity"
|
||||||
const val CURSOR_PLACEMENT = "cursor_placement"
|
const val CURSOR_PLACEMENT = "cursor_placement"
|
||||||
const val LAST_USED_EXTENSION = "last_used_extension"
|
const val LAST_USED_EXTENSION = "last_used_extension"
|
||||||
@ -37,12 +36,6 @@ const val GRAVITY_LEFT = 0
|
|||||||
const val GRAVITY_CENTER = 1
|
const val GRAVITY_CENTER = 1
|
||||||
const val GRAVITY_RIGHT = 2
|
const val GRAVITY_RIGHT = 2
|
||||||
|
|
||||||
// font sizes
|
|
||||||
const val FONT_SIZE_SMALL = 0
|
|
||||||
const val FONT_SIZE_MEDIUM = 1
|
|
||||||
const val FONT_SIZE_LARGE = 2
|
|
||||||
const val FONT_SIZE_EXTRA_LARGE = 3
|
|
||||||
|
|
||||||
// note types
|
// note types
|
||||||
const val TYPE_TEXT = 0
|
const val TYPE_TEXT = 0
|
||||||
const val TYPE_CHECKLIST = 1
|
const val TYPE_CHECKLIST = 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user