Skip to content

Commit 241691e

Browse files
authored
Make text sizes more flexible (#906)
1 parent 8f7d52e commit 241691e

40 files changed

Lines changed: 318 additions & 175 deletions

File tree

TRANSLATIONS.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,34 @@ See [Android Translations Converter](https://github.com/Crustack/android-transla
1919
<!-- translations:start -->
2020
| Language | Coverage |
2121
|----------|----------|
22-
| 🇺🇸 English | 100% (337/337) |
23-
| 🇪🇸 Catalan | 19% (65/337) |
24-
| 🇨🇿 Czech | 92% (313/337) |
25-
| 🇩🇰 Danish | 20% (69/337) |
26-
| 🇩🇪 German | 99% (335/337) |
27-
| 🇬🇷 Greek | 21% (72/337) |
28-
| 🇪🇸 Spanish | 93% (314/337) |
29-
| 🇫🇷 French | 97% (327/337) |
30-
| 🇭🇺 Hungarian | 19% (65/337) |
31-
| 🇮🇩 Indonesian | 22% (75/337) |
32-
| 🇮🇹 Italian | 86% (291/337) |
33-
| 🇯🇵 Japanese | 21% (73/337) |
34-
| 🇲🇲 Burmese | 26% (90/337) |
35-
| 🇳🇴 Norwegian Bokmål | 31% (106/337) |
36-
| 🇳🇱 Dutch | 62% (212/337) |
37-
| 🇳🇴 Norwegian Nynorsk | 31% (106/337) |
38-
| 🇵🇱 Polish | 89% (300/337) |
39-
| 🇧🇷 Portuguese (Brazil) | 92% (312/337) |
40-
| 🇵🇹 Portuguese (Portugal) | 21% (71/337) |
41-
| 🇷🇴 Romanian | 89% (301/337) |
42-
| 🇷🇺 Russian | 90% (305/337) |
43-
| 🇸🇰 Slovak | 19% (65/337) |
44-
| 🇸🇮 Slovenian | 32% (109/337) |
45-
| 🇸🇪 Swedish | 18% (63/337) |
46-
| 🇵🇭 Tagalog | 19% (65/337) |
47-
| 🇹🇷 Turkish | 21% (73/337) |
48-
| 🇺🇦 Ukrainian | 98% (331/337) |
49-
| 🇻🇳 Vietnamese | 31% (107/337) |
50-
| 🇨🇳 Chinese (Simplified) | 97% (328/337) |
51-
| 🇹🇼 Chinese (Traditional) | 87% (294/337) |
22+
| 🇺🇸 English | 100% (339/339) |
23+
| 🇪🇸 Catalan | 19% (65/339) |
24+
| 🇨🇿 Czech | 92% (314/339) |
25+
| 🇩🇰 Danish | 20% (69/339) |
26+
| 🇩🇪 German | 99% (336/339) |
27+
| 🇬🇷 Greek | 21% (72/339) |
28+
| 🇪🇸 Spanish | 92% (315/339) |
29+
| 🇫🇷 French | 96% (328/339) |
30+
| 🇭🇺 Hungarian | 19% (65/339) |
31+
| 🇮🇩 Indonesian | 22% (75/339) |
32+
| 🇮🇹 Italian | 86% (292/339) |
33+
| 🇯🇵 Japanese | 21% (73/339) |
34+
| 🇲🇲 Burmese | 26% (91/339) |
35+
| 🇳🇴 Norwegian Bokmål | 31% (107/339) |
36+
| 🇳🇱 Dutch | 62% (213/339) |
37+
| 🇳🇴 Norwegian Nynorsk | 31% (107/339) |
38+
| 🇵🇱 Polish | 88% (301/339) |
39+
| 🇧🇷 Portuguese (Brazil) | 92% (313/339) |
40+
| 🇵🇹 Portuguese (Portugal) | 20% (71/339) |
41+
| 🇷🇴 Romanian | 89% (302/339) |
42+
| 🇷🇺 Russian | 90% (306/339) |
43+
| 🇸🇰 Slovak | 19% (65/339) |
44+
| 🇸🇮 Slovenian | 32% (110/339) |
45+
| 🇸🇪 Swedish | 18% (63/339) |
46+
| 🇵🇭 Tagalog | 19% (65/339) |
47+
| 🇹🇷 Turkish | 21% (73/339) |
48+
| 🇺🇦 Ukrainian | 97% (332/339) |
49+
| 🇻🇳 Vietnamese | 31% (108/339) |
50+
| 🇨🇳 Chinese (Simplified) | 97% (329/339) |
51+
| 🇹🇼 Chinese (Traditional) | 87% (295/339) |
5252
<!-- translations:end -->

app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ import com.philkes.notallyx.presentation.view.note.listitem.ListManager
110110
import com.philkes.notallyx.presentation.view.note.listitem.adapter.ListItemVH
111111
import com.philkes.notallyx.presentation.viewmodel.BaseNoteModel
112112
import com.philkes.notallyx.presentation.viewmodel.preference.DateFormat
113-
import com.philkes.notallyx.presentation.viewmodel.preference.TextSize
113+
import com.philkes.notallyx.presentation.viewmodel.preference.displayBodySize
114114
import com.philkes.notallyx.utils.changehistory.ChangeHistory
115115
import com.philkes.notallyx.utils.changehistory.EditTextState
116116
import com.philkes.notallyx.utils.changehistory.EditTextWithHistoryChange
@@ -299,6 +299,10 @@ fun TextView.displayFormattedTimestamp(
299299
} else visibility = View.GONE
300300
}
301301

302+
fun TextView.setTextSizeSp(textSizeSp: Float) {
303+
setTextSize(TypedValue.COMPLEX_UNIT_SP, textSizeSp)
304+
}
305+
302306
val Int.dp: Int
303307
get() = (this * Resources.getSystem().displayMetrics.density + 0.5f).toInt()
304308

@@ -1043,7 +1047,7 @@ fun Window.setLightStatusAndNavBar(value: Boolean, view: View = decorView) {
10431047

10441048
fun ChipGroup.bindLabels(
10451049
labels: List<String>,
1046-
textSize: TextSize,
1050+
textSize: Float,
10471051
paddingTop: Boolean,
10481052
color: Int? = null,
10491053
onClick: ((label: String) -> Unit)? = null,
@@ -1062,7 +1066,7 @@ fun ChipGroup.bindLabels(
10621066
for (label in labels) {
10631067
LabelBinding.inflate(inflater, this, true).root.apply {
10641068
background = getOutlinedDrawable(this@bindLabels.context)
1065-
setTextSize(TypedValue.COMPLEX_UNIT_SP, labelSize)
1069+
setTextSizeSp(labelSize)
10661070
text = label
10671071
color?.let { setControlsContrastColorForAllViews(it) }
10681072
onClick?.let { setOnClickListener { it(label) } }
@@ -1138,7 +1142,7 @@ fun Context.createTextView(textResId: Int, padding: Int = 16.dp): TextView {
11381142
}
11391143
}
11401144

1141-
fun Chip.setupReminderChip(baseNote: BaseNote) {
1145+
fun Chip.setupReminderChip(baseNote: BaseNote, textSize: Float? = null) {
11421146
val now = Date(System.currentTimeMillis())
11431147
val mostRecentNotificationDate =
11441148
baseNote.reminders.findNextNotificationDate()
@@ -1150,6 +1154,15 @@ fun Chip.setupReminderChip(baseNote: BaseNote) {
11501154
this.apply {
11511155
visibility = VISIBLE
11521156
text = mostRecentNotificationDate.format()
1157+
textSize?.let {
1158+
setTextSizeSp(it)
1159+
chipIconSize =
1160+
TypedValue.applyDimension(
1161+
TypedValue.COMPLEX_UNIT_SP,
1162+
it + 4,
1163+
resources.displayMetrics,
1164+
)
1165+
}
11531166
setCloseIconVisible(baseNote.reminders.haveAnyRepetition())
11541167
val isElapsed = mostRecentNotificationDate < now
11551168
alpha = if (isElapsed) 0.5f else 1.0f

app/src/main/java/com/philkes/notallyx/presentation/activity/main/fragment/NotallyFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ abstract class NotallyFragment : Fragment(), ItemListener {
263263
dateFormat.value,
264264
notesSorting.value,
265265
BaseNoteVHPreferences(
266-
textSize.value,
266+
textSizeOverview.value,
267267
maxItems.value,
268268
maxLines.value,
269269
maxTitle.value,

app/src/main/java/com/philkes/notallyx/presentation/activity/main/fragment/settings/PreferenceBindingExtensions.kt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import com.philkes.notallyx.databinding.PreferenceSeekbarBinding
2525
import com.philkes.notallyx.presentation.checkedTag
2626
import com.philkes.notallyx.presentation.select
2727
import com.philkes.notallyx.presentation.setCancelButton
28+
import com.philkes.notallyx.presentation.setTextSizeSp
2829
import com.philkes.notallyx.presentation.showAndFocus
2930
import com.philkes.notallyx.presentation.showToast
3031
import com.philkes.notallyx.presentation.view.misc.MenuDialog
@@ -34,6 +35,7 @@ import com.philkes.notallyx.presentation.viewmodel.preference.BooleanPreference
3435
import com.philkes.notallyx.presentation.viewmodel.preference.Constants.PASSWORD_EMPTY
3536
import com.philkes.notallyx.presentation.viewmodel.preference.DateFormat
3637
import com.philkes.notallyx.presentation.viewmodel.preference.EnumPreference
38+
import com.philkes.notallyx.presentation.viewmodel.preference.FloatPreference
3739
import com.philkes.notallyx.presentation.viewmodel.preference.IntPreference
3840
import com.philkes.notallyx.presentation.viewmodel.preference.NotallyXPreferences.Companion.EMPTY_PATH
3941
import com.philkes.notallyx.presentation.viewmodel.preference.NotallyXPreferences.Companion.START_VIEW_DEFAULT
@@ -509,6 +511,43 @@ fun PreferenceSeekbarBinding.setup(
509511
}
510512
}
511513

514+
fun PreferenceSeekbarBinding.setupTextSizePreference(
515+
preference: FloatPreference,
516+
context: Context,
517+
value: Float = preference.value,
518+
tooltipResId: Int? = null,
519+
onChange: (newValue: Float) -> Unit,
520+
) {
521+
setup(
522+
value.toInt(),
523+
preference.titleResId!!,
524+
preference.min.toInt(),
525+
preference.max.toInt(),
526+
context,
527+
tooltipResId = tooltipResId,
528+
) { newValue ->
529+
onChange(newValue.toFloat())
530+
}
531+
PreviewText.apply {
532+
isVisible = false
533+
setTextSizeSp(value)
534+
}
535+
Slider.apply {
536+
addOnChangeListener { _, newValue, _ -> PreviewText.setTextSizeSp(newValue) }
537+
addOnSliderTouchListener(
538+
object : Slider.OnSliderTouchListener {
539+
override fun onStartTrackingTouch(slider: Slider) {
540+
PreviewText.isVisible = true
541+
}
542+
543+
override fun onStopTrackingTouch(slider: Slider) {
544+
PreviewText.isVisible = false
545+
}
546+
}
547+
)
548+
}
549+
}
550+
512551
fun PreferenceSeekbarBinding.setupAutoSaveIdleTime(
513552
preference: IntPreference,
514553
context: Context,

app/src/main/java/com/philkes/notallyx/presentation/activity/main/fragment/settings/SettingsFragment.kt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,22 @@ class SettingsFragment : Fragment() {
307307
}
308308
}
309309

310-
textSize.observe(viewLifecycleOwner) { value ->
311-
binding.TextSize.setup(textSize, value, requireContext()) { newValue ->
312-
model.savePreference(textSize, newValue)
310+
textSizeNoteEditor.observe(viewLifecycleOwner) { value ->
311+
binding.TextSize.setupTextSizePreference(
312+
textSizeNoteEditor,
313+
requireContext(),
314+
value = value,
315+
) { newValue ->
316+
model.savePreference(textSizeNoteEditor, newValue)
317+
}
318+
}
319+
textSizeOverview.observe(viewLifecycleOwner) { value ->
320+
binding.TextSizeOverview.setupTextSizePreference(
321+
textSizeOverview,
322+
requireContext(),
323+
value = value,
324+
) { newValue ->
325+
model.savePreference(textSizeOverview, newValue)
313326
}
314327
}
315328
alwaysShowSearchBar.observe(viewLifecycleOwner) { value ->

app/src/main/java/com/philkes/notallyx/presentation/activity/note/EditActivity.kt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import android.text.Editable
1313
import android.text.Spanned
1414
import android.text.style.URLSpan
1515
import android.util.Log
16-
import android.util.TypedValue
1716
import android.view.MenuItem
1817
import android.view.View
1918
import android.view.View.GONE
@@ -57,6 +56,7 @@ import com.philkes.notallyx.presentation.isLightColor
5756
import com.philkes.notallyx.presentation.setCancelButton
5857
import com.philkes.notallyx.presentation.setControlsContrastColorForAllViews
5958
import com.philkes.notallyx.presentation.setLightStatusAndNavBar
59+
import com.philkes.notallyx.presentation.setTextSizeSp
6060
import com.philkes.notallyx.presentation.setupProgressDialog
6161
import com.philkes.notallyx.presentation.setupReminderChip
6262
import com.philkes.notallyx.presentation.showKeyboard
@@ -74,6 +74,9 @@ import com.philkes.notallyx.presentation.viewmodel.preference.EditAction
7474
import com.philkes.notallyx.presentation.viewmodel.preference.ListItemSort
7575
import com.philkes.notallyx.presentation.viewmodel.preference.NotallyXPreferences
7676
import com.philkes.notallyx.presentation.viewmodel.preference.NotesSortBy
77+
import com.philkes.notallyx.presentation.viewmodel.preference.displaySmallerSize
78+
import com.philkes.notallyx.presentation.viewmodel.preference.editBodySize
79+
import com.philkes.notallyx.presentation.viewmodel.preference.editTitleSize
7780
import com.philkes.notallyx.presentation.widget.WidgetProvider
7881
import com.philkes.notallyx.utils.FileError
7982
import com.philkes.notallyx.utils.changeStatusAndNavigationBarColor
@@ -671,7 +674,10 @@ abstract class EditActivity(private val type: Type) : LockedActivity<ActivityEdi
671674
if (preferences.applyDateFormatInNoteView.value) {
672675
preferences.dateFormat.value
673676
} else DateFormat.ABSOLUTE
674-
binding.Date.displayFormattedTimestamp(date, dateFormat, datePrefixResId)
677+
binding.Date.apply {
678+
displayFormattedTimestamp(date, dateFormat, datePrefixResId)
679+
setTextSizeSp(notallyModel.textSize.displaySmallerSize)
680+
}
675681
binding.EnterTitle.setText(notallyModel.title)
676682
bindLabels()
677683
setColor()
@@ -925,13 +931,9 @@ abstract class EditActivity(private val type: Type) : LockedActivity<ActivityEdi
925931
}
926932
}
927933

928-
val title = notallyModel.textSize.editTitleSize
929-
val date = notallyModel.textSize.displayBodySize
930-
val body = notallyModel.textSize.editBodySize
931-
932-
binding.EnterTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, title)
933-
binding.Date.setTextSize(TypedValue.COMPLEX_UNIT_SP, date)
934-
binding.EnterBody.setTextSize(TypedValue.COMPLEX_UNIT_SP, body)
934+
binding.EnterTitle.setTextSizeSp(notallyModel.textSize.editTitleSize)
935+
binding.Date.setTextSizeSp(notallyModel.textSize.displaySmallerSize)
936+
binding.EnterBody.setTextSizeSp(notallyModel.textSize.editBodySize)
935937

936938
setupImages()
937939
setupFiles()
@@ -979,7 +981,10 @@ abstract class EditActivity(private val type: Type) : LockedActivity<ActivityEdi
979981

980982
fun setupEditNoteReminderChip() {
981983
notallyModel.originalNote?.let { note ->
982-
binding.EditNoteReminderChip.setupReminderChip(note)
984+
binding.EditNoteReminderChip.setupReminderChip(
985+
note,
986+
notallyModel.textSize.displaySmallerSize,
987+
)
983988
binding.EditNoteReminderChip.setOnClickListener {
984989
val intent =
985990
Intent(this@EditActivity, RemindersActivity::class.java)

app/src/main/java/com/philkes/notallyx/presentation/activity/note/PickNoteActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ open class PickNoteActivity : LockedActivity<ActivityPickNoteBinding>(), ItemLis
5252
dateFormat.value,
5353
notesSorting.value,
5454
BaseNoteVHPreferences(
55-
textSize.value,
55+
textSizeOverview.value,
5656
maxItems.value,
5757
maxLines.value,
5858
maxTitle.value,

0 commit comments

Comments
 (0)