diff options
-rw-r--r-- | app/src/main/java/foundation/e/privacycentralapp/common/TextViewHelpers.kt | 13 | ||||
-rw-r--r-- | app/src/main/res/drawable/ic_info_16dp.xml | 16 |
2 files changed, 26 insertions, 3 deletions
diff --git a/app/src/main/java/foundation/e/privacycentralapp/common/TextViewHelpers.kt b/app/src/main/java/foundation/e/privacycentralapp/common/TextViewHelpers.kt index a5c576c..1cdc06f 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/common/TextViewHelpers.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/common/TextViewHelpers.kt @@ -18,6 +18,7 @@ package foundation.e.privacycentralapp.common import android.content.Context +import android.content.res.ColorStateList import android.text.Spannable import android.text.SpannableString import android.text.style.ImageSpan @@ -30,18 +31,24 @@ import foundation.e.privacycentralapp.R fun setToolTipForAsterisk( textView: TextView, @StringRes textId: Int, - @StringRes tooltipTextId: Int) { - textView.text = asteriskAsInfoIconSpannable(textView.context, textId) + @StringRes tooltipTextId: Int +) { + textView.text = asteriskAsInfoIconSpannable(textView.context, textId, textView.textColors) TooltipCompat.setTooltipText(textView, textView.context.getString(tooltipTextId)) textView.setOnClickListener { it.performLongClick() } } -private fun asteriskAsInfoIconSpannable(context: Context, @StringRes textId: Int): Spannable { +private fun asteriskAsInfoIconSpannable( + context: Context, + @StringRes textId: Int, + tint: ColorStateList +): Spannable { val spannable = SpannableString(context.getString(textId)) val index = spannable.lastIndexOf("*") if (index != -1) { AppCompatResources.getDrawable(context, R.drawable.ic_info_16dp)?.let { + it.setTintList(tint) it.setBounds(0, 0, it.intrinsicWidth, it.intrinsicHeight) spannable.setSpan( ImageSpan(it), diff --git a/app/src/main/res/drawable/ic_info_16dp.xml b/app/src/main/res/drawable/ic_info_16dp.xml index 5d241e7..063fb73 100644 --- a/app/src/main/res/drawable/ic_info_16dp.xml +++ b/app/src/main/res/drawable/ic_info_16dp.xml @@ -1,3 +1,19 @@ +<!-- + ~ Copyright (C) 2022 E FOUNDATION + ~ + ~ This program is free software: you can redistribute it and/or modify + ~ it under the terms of the GNU General Public License as published by + ~ the Free Software Foundation, either version 3 of the License, or + ~ (at your option) any later version. + ~ + ~ This program is distributed in the hope that it will be useful, + ~ but WITHOUT ANY WARRANTY; without even the implied warranty of + ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ~ GNU General Public License for more details. + ~ + ~ You should have received a copy of the GNU General Public License + ~ along with this program. If not, see <https://www.gnu.org/licenses/>. + --> <vector android:height="16dp" android:viewportHeight="24" android:viewportWidth="24" android:width="16dp" xmlns:android="http://schemas.android.com/apk/res/android"> <path android:fillColor="#000000" android:pathData="M11,7H13V9H11V7ZM11,11H13V17H11V11ZM12,2C6.48,2 2,6.48 2,12C2,17.52 6.48,22 12,22C17.52,22 22,17.52 22,12C22,6.48 17.52,2 12,2ZM12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20Z"/> |