From 4b892e2b30839aad924ef91c69bc77df1049e814 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sat, 13 Aug 2022 09:23:25 +0530 Subject: [PATCH 1/2] Update AppCompat to 1.5.1. --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d52e8b32c..b3dcf16da 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,7 +8,7 @@ plugins { } android { - compileSdk 31 + compileSdk 32 namespace 'org.schabi.newpipe' defaultConfig { @@ -198,7 +198,7 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}" /** AndroidX **/ - implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.appcompat:appcompat:1.5.1' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.core:core-ktx:1.8.0' From 51bdc30ed0362a0520972e1e9bd2688f9c9d5f2e Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sat, 16 Jul 2022 06:20:27 +0530 Subject: [PATCH 2/2] Use TextViewCompat.setCompoundDrawableTintList(). --- .../custom/NotificationActionsPreference.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/settings/custom/NotificationActionsPreference.java b/app/src/main/java/org/schabi/newpipe/settings/custom/NotificationActionsPreference.java index 1770685e4..3e92f297e 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/custom/NotificationActionsPreference.java +++ b/app/src/main/java/org/schabi/newpipe/settings/custom/NotificationActionsPreference.java @@ -5,7 +5,7 @@ import static org.schabi.newpipe.player.notification.NotificationConstants.ACTIO import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; -import android.graphics.drawable.Drawable; +import android.content.res.ColorStateList; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; @@ -21,7 +21,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.content.res.AppCompatResources; -import androidx.core.graphics.drawable.DrawableCompat; +import androidx.core.widget.TextViewCompat; import androidx.preference.Preference; import androidx.preference.PreferenceViewHolder; @@ -214,17 +214,13 @@ public class NotificationActionsPreference extends Preference { .getRoot(); // if present set action icon with correct color - if (NotificationConstants.ACTION_ICONS[action] != 0) { - Drawable drawable = AppCompatResources.getDrawable(getContext(), - NotificationConstants.ACTION_ICONS[action]); - if (drawable != null) { - final int color = ThemeHelper.resolveColorFromAttr(getContext(), - android.R.attr.textColorPrimary); - drawable = DrawableCompat.wrap(drawable).mutate(); - drawable.setTint(color); - radioButton.setCompoundDrawablesRelativeWithIntrinsicBounds(null, - null, drawable, null); - } + final int iconId = NotificationConstants.ACTION_ICONS[action]; + if (iconId != 0) { + radioButton.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, iconId, 0); + + final var color = ColorStateList.valueOf(ThemeHelper + .resolveColorFromAttr(getContext(), android.R.attr.textColorPrimary)); + TextViewCompat.setCompoundDrawableTintList(radioButton, color); } radioButton.setText(NotificationConstants.getActionName(getContext(), action));