For #13911: Fix resolving color attribute for title and description.
For SDK < 23 color attr cannot be resolved in selectors.
This commit is contained in:
parent
50948ef06e
commit
91a9200fe3
|
@ -9,7 +9,7 @@ import android.text.Spannable
|
|||
import android.text.SpannableString
|
||||
import android.text.style.AbsoluteSizeSpan
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import androidx.core.content.ContextCompat
|
||||
import mozilla.components.support.ktx.android.content.getColorFromAttr
|
||||
import mozilla.components.support.ktx.android.util.dpToPx
|
||||
|
||||
fun SpannableString.setTextSize(context: Context, textSize: Int) =
|
||||
|
@ -23,10 +23,7 @@ fun SpannableString.setTextSize(context: Context, textSize: Int) =
|
|||
fun SpannableString.setTextColor(context: Context, colorResId: Int) =
|
||||
this.setSpan(
|
||||
ForegroundColorSpan(
|
||||
ContextCompat.getColor(
|
||||
context,
|
||||
colorResId
|
||||
)
|
||||
context.getColorFromAttr(colorResId)
|
||||
),
|
||||
0,
|
||||
this.length,
|
||||
|
|
|
@ -71,14 +71,14 @@ class OnboardingRadioButton(
|
|||
|
||||
val spannableTitle = SpannableString(resources.getString(title))
|
||||
spannableTitle.setTextSize(context, TITLE_TEXT_SIZE)
|
||||
spannableTitle.setTextColor(context, R.color.primary_state_list_text_color)
|
||||
spannableTitle.setTextColor(context, R.attr.primaryText)
|
||||
|
||||
builder.append(spannableTitle)
|
||||
|
||||
if (description != 0) {
|
||||
val spannableDescription = SpannableString(resources.getString(description))
|
||||
spannableDescription.setTextSize(context, DESCRIPTION_TEXT_SIZE)
|
||||
spannableDescription.setTextColor(context, R.color.secondary_state_list_text_color)
|
||||
spannableDescription.setTextColor(context, R.attr.secondaryText)
|
||||
builder.append("\n")
|
||||
builder.append(spannableDescription)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user