mirror of
https://github.com/PhilKes/NotallyX.git
synced 2025-06-28 12:19:55 +00:00
For API >= 33 use font weight 700 for bold
This commit is contained in:
parent
118285545a
commit
86b74762c5
3 changed files with 12 additions and 3 deletions
|
@ -122,7 +122,7 @@ fun String.applySpans(representations: List<SpanRepresentation>): Editable {
|
|||
->
|
||||
try {
|
||||
if (bold) {
|
||||
editable.setSpan(StyleSpan(Typeface.BOLD), start, end)
|
||||
editable.setSpan(createBoldSpan(), start, end)
|
||||
}
|
||||
if (italic) {
|
||||
editable.setSpan(StyleSpan(Typeface.ITALIC), start, end)
|
||||
|
@ -144,6 +144,13 @@ fun String.applySpans(representations: List<SpanRepresentation>): Editable {
|
|||
return editable
|
||||
}
|
||||
|
||||
fun createBoldSpan() =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
StyleSpan(Typeface.BOLD, 700)
|
||||
} else {
|
||||
StyleSpan(Typeface.BOLD)
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts or removes spans based on the selection range.
|
||||
*
|
||||
|
|
|
@ -40,6 +40,7 @@ import com.philkes.notallyx.presentation.activity.note.PickNoteActivity.Companio
|
|||
import com.philkes.notallyx.presentation.activity.note.PickNoteActivity.Companion.EXTRA_PICKED_NOTE_TYPE
|
||||
import com.philkes.notallyx.presentation.add
|
||||
import com.philkes.notallyx.presentation.addIconButton
|
||||
import com.philkes.notallyx.presentation.createBoldSpan
|
||||
import com.philkes.notallyx.presentation.dp
|
||||
import com.philkes.notallyx.presentation.hideKeyboard
|
||||
import com.philkes.notallyx.presentation.setControlsContrastColorForAllViews
|
||||
|
@ -212,7 +213,7 @@ class EditNoteActivity : EditActivity(Type.NOTE), AddNoteActions {
|
|||
0,
|
||||
showAsAction = MenuItem.SHOW_AS_ACTION_NEVER,
|
||||
) {
|
||||
binding.EnterBody.applySpan(StyleSpan(Typeface.BOLD))
|
||||
binding.EnterBody.applySpan(createBoldSpan())
|
||||
mode?.finish()
|
||||
}
|
||||
add(
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.text.style.TypefaceSpan
|
|||
import android.text.style.URLSpan
|
||||
import androidx.annotation.ColorInt
|
||||
import com.philkes.notallyx.R
|
||||
import com.philkes.notallyx.presentation.createBoldSpan
|
||||
import com.philkes.notallyx.presentation.view.misc.StylableEditTextWithHistory
|
||||
|
||||
class TextFormattingAdapter(
|
||||
|
@ -35,7 +36,7 @@ class TextFormattingAdapter(
|
|||
private val bold: Toggle =
|
||||
Toggle(R.string.bold, R.drawable.format_bold, false) {
|
||||
if (!it.checked) {
|
||||
editText.applySpan(StyleSpan(Typeface.BOLD))
|
||||
editText.applySpan(createBoldSpan())
|
||||
} else {
|
||||
editText.clearFormatting(type = StylableEditTextWithHistory.TextStyleType.BOLD)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue