mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-15 15:57:24 +02:00
Merge pull request #648 from Dejvino/bugfix/353
Fix 353: Change gravity internally from Left and Right to Start and End
This commit is contained in:
commit
5bf9b27984
@ -5,6 +5,8 @@ import android.net.Uri
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
|
import androidx.core.text.TextUtilsCompat
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
@ -222,13 +224,8 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
private fun setupGravity() {
|
private fun setupGravity() {
|
||||||
settings_gravity.text = getGravityText()
|
settings_gravity.text = getGravityText()
|
||||||
settings_gravity_holder.setOnClickListener {
|
settings_gravity_holder.setOnClickListener {
|
||||||
val items = arrayListOf(
|
val items = listOf(GRAVITY_START, GRAVITY_CENTER, GRAVITY_END).map { RadioItem(it, getGravityOptionLabel(it)) }
|
||||||
RadioItem(GRAVITY_LEFT, getString(R.string.left)),
|
RadioGroupDialog(this@SettingsActivity, ArrayList(items), config.gravity) {
|
||||||
RadioItem(GRAVITY_CENTER, getString(R.string.center)),
|
|
||||||
RadioItem(GRAVITY_RIGHT, getString(R.string.right))
|
|
||||||
)
|
|
||||||
|
|
||||||
RadioGroupDialog(this@SettingsActivity, items, config.gravity) {
|
|
||||||
config.gravity = it as Int
|
config.gravity = it as Int
|
||||||
settings_gravity.text = getGravityText()
|
settings_gravity.text = getGravityText()
|
||||||
updateWidgets()
|
updateWidgets()
|
||||||
@ -236,13 +233,24 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getGravityText() = getString(
|
private fun getGravityOptionLabel(gravity: Int): String {
|
||||||
when (config.gravity) {
|
val leftToRightDirection = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_LTR
|
||||||
GRAVITY_LEFT -> R.string.left
|
val leftRightLabels = listOf(R.string.left, R.string.right)
|
||||||
GRAVITY_CENTER -> R.string.center
|
val startEndLabels = if (leftToRightDirection) {
|
||||||
else -> R.string.right
|
leftRightLabels
|
||||||
|
} else {
|
||||||
|
leftRightLabels.reversed()
|
||||||
}
|
}
|
||||||
)
|
return getString(
|
||||||
|
when (gravity) {
|
||||||
|
GRAVITY_START -> startEndLabels.first()
|
||||||
|
GRAVITY_CENTER -> R.string.center
|
||||||
|
else -> startEndLabels.last()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getGravityText() = getGravityOptionLabel(config.gravity)
|
||||||
|
|
||||||
private fun setupCursorPlacement() {
|
private fun setupCursorPlacement() {
|
||||||
settings_cursor_placement.isChecked = config.placeCursorToEnd
|
settings_cursor_placement.isChecked = config.placeCursorToEnd
|
||||||
|
@ -6,8 +6,6 @@ import android.graphics.Paint
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.RemoteViews
|
import android.widget.RemoteViews
|
||||||
import android.widget.RemoteViewsService
|
import android.widget.RemoteViewsService
|
||||||
import com.google.gson.Gson
|
|
||||||
import com.google.gson.reflect.TypeToken
|
|
||||||
import com.simplemobiletools.commons.extensions.adjustAlpha
|
import com.simplemobiletools.commons.extensions.adjustAlpha
|
||||||
import com.simplemobiletools.commons.extensions.setText
|
import com.simplemobiletools.commons.extensions.setText
|
||||||
import com.simplemobiletools.commons.extensions.setTextSize
|
import com.simplemobiletools.commons.extensions.setTextSize
|
||||||
@ -95,8 +93,8 @@ class WidgetAdapter(val context: Context, val intent: Intent) : RemoteViewsServi
|
|||||||
return when {
|
return when {
|
||||||
gravity == GRAVITY_CENTER && isMonospaced -> R.id.widget_text_center_monospace
|
gravity == GRAVITY_CENTER && isMonospaced -> R.id.widget_text_center_monospace
|
||||||
gravity == GRAVITY_CENTER -> R.id.widget_text_center
|
gravity == GRAVITY_CENTER -> R.id.widget_text_center
|
||||||
gravity == GRAVITY_RIGHT && isMonospaced -> R.id.widget_text_right_monospace
|
gravity == GRAVITY_END && isMonospaced -> R.id.widget_text_right_monospace
|
||||||
gravity == GRAVITY_RIGHT -> R.id.widget_text_right
|
gravity == GRAVITY_END -> R.id.widget_text_right
|
||||||
isMonospaced -> R.id.widget_text_left_monospace
|
isMonospaced -> R.id.widget_text_left_monospace
|
||||||
else -> R.id.widget_text_left
|
else -> R.id.widget_text_left
|
||||||
}
|
}
|
||||||
@ -109,8 +107,8 @@ class WidgetAdapter(val context: Context, val intent: Intent) : RemoteViewsServi
|
|||||||
return when {
|
return when {
|
||||||
gravity == GRAVITY_CENTER && isMonospaced -> R.id.checklist_text_center_monospace
|
gravity == GRAVITY_CENTER && isMonospaced -> R.id.checklist_text_center_monospace
|
||||||
gravity == GRAVITY_CENTER -> R.id.checklist_text_center
|
gravity == GRAVITY_CENTER -> R.id.checklist_text_center
|
||||||
gravity == GRAVITY_RIGHT && isMonospaced -> R.id.checklist_text_right_monospace
|
gravity == GRAVITY_END && isMonospaced -> R.id.checklist_text_right_monospace
|
||||||
gravity == GRAVITY_RIGHT -> R.id.checklist_text_right
|
gravity == GRAVITY_END -> R.id.checklist_text_right
|
||||||
isMonospaced -> R.id.checklist_text_left_monospace
|
isMonospaced -> R.id.checklist_text_left_monospace
|
||||||
else -> R.id.checklist_text_left
|
else -> R.id.checklist_text_left
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.simplemobiletools.notes.pro.helpers
|
package com.simplemobiletools.notes.pro.helpers
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
@ -41,7 +40,7 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
set(showWordCount) = prefs.edit().putBoolean(SHOW_WORD_COUNT, showWordCount).apply()
|
set(showWordCount) = prefs.edit().putBoolean(SHOW_WORD_COUNT, showWordCount).apply()
|
||||||
|
|
||||||
var gravity: Int
|
var gravity: Int
|
||||||
get() = prefs.getInt(GRAVITY, GRAVITY_LEFT)
|
get() = prefs.getInt(GRAVITY, GRAVITY_START)
|
||||||
set(size) = prefs.edit().putInt(GRAVITY, size).apply()
|
set(size) = prefs.edit().putInt(GRAVITY, size).apply()
|
||||||
|
|
||||||
var currentNoteId: Long
|
var currentNoteId: Long
|
||||||
@ -80,11 +79,10 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
get() = prefs.getBoolean(MOVE_DONE_CHECKLIST_ITEMS, false)
|
get() = prefs.getBoolean(MOVE_DONE_CHECKLIST_ITEMS, false)
|
||||||
set(moveDoneChecklistItems) = prefs.edit().putBoolean(MOVE_DONE_CHECKLIST_ITEMS, moveDoneChecklistItems).apply()
|
set(moveDoneChecklistItems) = prefs.edit().putBoolean(MOVE_DONE_CHECKLIST_ITEMS, moveDoneChecklistItems).apply()
|
||||||
|
|
||||||
@SuppressLint("RtlHardcoded")
|
|
||||||
fun getTextGravity() = when (gravity) {
|
fun getTextGravity() = when (gravity) {
|
||||||
GRAVITY_CENTER -> Gravity.CENTER_HORIZONTAL
|
GRAVITY_CENTER -> Gravity.CENTER_HORIZONTAL
|
||||||
GRAVITY_RIGHT -> Gravity.RIGHT
|
GRAVITY_END -> Gravity.END
|
||||||
else -> Gravity.LEFT
|
else -> Gravity.START
|
||||||
}
|
}
|
||||||
|
|
||||||
var fontSizePercentage: Int
|
var fontSizePercentage: Int
|
||||||
|
@ -40,9 +40,9 @@ const val EXPORT_MIME_TYPE = "text/plain"
|
|||||||
const val ADD_NEW_CHECKLIST_ITEMS_TOP = "add_new_checklist_items_top"
|
const val ADD_NEW_CHECKLIST_ITEMS_TOP = "add_new_checklist_items_top"
|
||||||
|
|
||||||
// gravity
|
// gravity
|
||||||
const val GRAVITY_LEFT = 0
|
const val GRAVITY_START = 0
|
||||||
const val GRAVITY_CENTER = 1
|
const val GRAVITY_CENTER = 1
|
||||||
const val GRAVITY_RIGHT = 2
|
const val GRAVITY_END = 2
|
||||||
|
|
||||||
// mime types
|
// mime types
|
||||||
const val MIME_TEXT_PLAIN = "text/plain"
|
const val MIME_TEXT_PLAIN = "text/plain"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user