Merge pull request #8655 from Isira-Seneviratne/Use_TextViewCompat_setCompoundDrawableTIntList
Use TextViewCompat.setCompoundDrawableTintList().
This commit is contained in:
commit
84887395f8
|
@ -8,7 +8,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdk 31
|
compileSdk 32
|
||||||
namespace 'org.schabi.newpipe'
|
namespace 'org.schabi.newpipe'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
|
@ -198,7 +198,7 @@ dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}"
|
||||||
|
|
||||||
/** AndroidX **/
|
/** AndroidX **/
|
||||||
implementation 'androidx.appcompat:appcompat:1.4.2'
|
implementation 'androidx.appcompat:appcompat:1.5.1'
|
||||||
implementation 'androidx.cardview:cardview:1.0.0'
|
implementation 'androidx.cardview:cardview:1.0.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
implementation 'androidx.core:core-ktx:1.8.0'
|
implementation 'androidx.core:core-ktx:1.8.0'
|
||||||
|
|
|
@ -5,7 +5,7 @@ import static org.schabi.newpipe.player.notification.NotificationConstants.ACTIO
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.content.res.ColorStateList;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -21,7 +21,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.content.res.AppCompatResources;
|
import androidx.appcompat.content.res.AppCompatResources;
|
||||||
import androidx.core.graphics.drawable.DrawableCompat;
|
import androidx.core.widget.TextViewCompat;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceViewHolder;
|
import androidx.preference.PreferenceViewHolder;
|
||||||
|
|
||||||
|
@ -214,17 +214,13 @@ public class NotificationActionsPreference extends Preference {
|
||||||
.getRoot();
|
.getRoot();
|
||||||
|
|
||||||
// if present set action icon with correct color
|
// if present set action icon with correct color
|
||||||
if (NotificationConstants.ACTION_ICONS[action] != 0) {
|
final int iconId = NotificationConstants.ACTION_ICONS[action];
|
||||||
Drawable drawable = AppCompatResources.getDrawable(getContext(),
|
if (iconId != 0) {
|
||||||
NotificationConstants.ACTION_ICONS[action]);
|
radioButton.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, iconId, 0);
|
||||||
if (drawable != null) {
|
|
||||||
final int color = ThemeHelper.resolveColorFromAttr(getContext(),
|
final var color = ColorStateList.valueOf(ThemeHelper
|
||||||
android.R.attr.textColorPrimary);
|
.resolveColorFromAttr(getContext(), android.R.attr.textColorPrimary));
|
||||||
drawable = DrawableCompat.wrap(drawable).mutate();
|
TextViewCompat.setCompoundDrawableTintList(radioButton, color);
|
||||||
drawable.setTint(color);
|
|
||||||
radioButton.setCompoundDrawablesRelativeWithIntrinsicBounds(null,
|
|
||||||
null, drawable, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
radioButton.setText(NotificationConstants.getActionName(getContext(), action));
|
radioButton.setText(NotificationConstants.getActionName(getContext(), action));
|
||||||
|
|
Loading…
Reference in New Issue