Skip to content

Commit e7be99c

Browse files
committed
apply the selected gravity at checklist items too
1 parent 0dc3f4d commit e7be99c

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
1717
import com.simplemobiletools.commons.views.MyRecyclerView
1818
import com.simplemobiletools.notes.pro.R
1919
import com.simplemobiletools.notes.pro.dialogs.RenameChecklistItemDialog
20+
import com.simplemobiletools.notes.pro.extensions.config
2021
import com.simplemobiletools.notes.pro.extensions.getTextSize
2122
import com.simplemobiletools.notes.pro.helpers.DONE_CHECKLIST_ITEM_ALPHA
2223
import com.simplemobiletools.notes.pro.interfaces.ChecklistItemsListener
@@ -154,6 +155,7 @@ class ChecklistAdapter(activity: BaseSimpleActivity, var items: ArrayList<Checkl
154155
text = checklistItem.title
155156
setTextColor(textColor)
156157
setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getTextSize())
158+
gravity = context.config.getTextGravity()
157159

158160
if (checklistItem.isDone) {
159161
paintFlags = Paint.STRIKE_THRU_TEXT_FLAG

app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/TextFragment.kt

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.simplemobiletools.notes.pro.fragments
22

3-
import android.annotation.SuppressLint
43
import android.graphics.Typeface
54
import android.os.Bundle
65
import android.text.Editable
@@ -9,7 +8,6 @@ import android.text.TextWatcher
98
import android.text.style.UnderlineSpan
109
import android.text.util.Linkify
1110
import android.util.TypedValue
12-
import android.view.Gravity
1311
import android.view.LayoutInflater
1412
import android.view.View
1513
import android.view.ViewGroup
@@ -20,7 +18,9 @@ import com.simplemobiletools.notes.pro.activities.MainActivity
2018
import com.simplemobiletools.notes.pro.extensions.config
2119
import com.simplemobiletools.notes.pro.extensions.getTextSize
2220
import com.simplemobiletools.notes.pro.extensions.updateWidgets
23-
import com.simplemobiletools.notes.pro.helpers.*
21+
import com.simplemobiletools.notes.pro.helpers.MyMovementMethod
22+
import com.simplemobiletools.notes.pro.helpers.NOTE_ID
23+
import com.simplemobiletools.notes.pro.helpers.NotesHelper
2424
import com.simplemobiletools.notes.pro.models.Note
2525
import com.simplemobiletools.notes.pro.models.TextHistory
2626
import com.simplemobiletools.notes.pro.models.TextHistoryItem
@@ -124,7 +124,7 @@ class TextFragment : NoteFragment() {
124124

125125
setColors(config.textColor, config.primaryColor, config.backgroundColor)
126126
setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getTextSize())
127-
gravity = getTextGravity()
127+
gravity = config.getTextGravity()
128128
if (text.toString() != fileContents) {
129129
if (!skipTextUpdating) {
130130
setText(fileContents)
@@ -209,13 +209,6 @@ class TextFragment : NoteFragment() {
209209

210210
fun getCurrentNoteViewText() = view.text_note_view?.text?.toString()
211211

212-
@SuppressLint("RtlHardcoded")
213-
private fun getTextGravity() = when (config!!.gravity) {
214-
GRAVITY_CENTER -> Gravity.CENTER_HORIZONTAL
215-
GRAVITY_RIGHT -> Gravity.RIGHT
216-
else -> Gravity.LEFT
217-
}
218-
219212
private fun setWordCounter(text: String) {
220213
val words = text.replace("\n", " ").split(" ")
221214
view.notes_counter.text = words.count { it.isNotEmpty() }.toString()

app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/Config.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.simplemobiletools.notes.pro.helpers
22

3+
import android.annotation.SuppressLint
34
import android.content.Context
45
import android.os.Environment
6+
import android.view.Gravity
57
import com.simplemobiletools.commons.helpers.BaseConfig
68

79
class Config(context: Context) : BaseConfig(context) {
@@ -80,4 +82,11 @@ class Config(context: Context) : BaseConfig(context) {
8082
var moveUndoneChecklistItems: Boolean
8183
get() = prefs.getBoolean(MOVE_UNDONE_CHECKLIST_ITEMS, false)
8284
set(moveUndoneChecklistItems) = prefs.edit().putBoolean(MOVE_UNDONE_CHECKLIST_ITEMS, moveUndoneChecklistItems).apply()
85+
86+
@SuppressLint("RtlHardcoded")
87+
fun getTextGravity() = when (gravity) {
88+
GRAVITY_CENTER -> Gravity.CENTER_HORIZONTAL
89+
GRAVITY_RIGHT -> Gravity.RIGHT
90+
else -> Gravity.LEFT
91+
}
8392
}

app/src/main/res/layout/item_checklist.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313

1414
<com.simplemobiletools.commons.views.MyTextView
1515
android:id="@+id/checklist_title"
16-
android:layout_width="match_parent"
16+
android:layout_width="0dp"
1717
android:layout_height="wrap_content"
1818
android:paddingStart="@dimen/activity_margin"
1919
android:textSize="@dimen/bigger_text_size"
2020
app:layout_constraintBottom_toBottomOf="parent"
2121
app:layout_constraintEnd_toStartOf="@+id/checklist_image"
22+
app:layout_constraintStart_toStartOf="parent"
2223
app:layout_constraintTop_toTopOf="parent"
2324
tools:text="Butter" />
2425

0 commit comments

Comments
 (0)