Merge pull request #4592 from Isira-Seneviratne/Use_DrawableCompat

Use DrawableCompat.
pull/4765/head
Tobias Groza 2020-10-25 21:13:02 +01:00 zatwierdzone przez GitHub
commit a86f8e9a22
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 4 dodań i 8 usunięć

Wyświetl plik

@ -2,9 +2,7 @@ package org.schabi.newpipe.settings;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
@ -23,6 +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.fragment.app.Fragment;
@ -238,16 +237,13 @@ public class NotificationSettingsFragment extends Fragment {
// if present set action icon with correct color
if (NotificationConstants.ACTION_ICONS[action] != 0) {
final Drawable drawable = AppCompatResources.getDrawable(requireContext(),
Drawable drawable = AppCompatResources.getDrawable(requireContext(),
NotificationConstants.ACTION_ICONS[action]);
if (drawable != null) {
final int color = ThemeHelper.resolveColorFromAttr(requireContext(),
android.R.attr.textColorPrimary);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
drawable.setTint(color);
} else {
drawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
}
drawable = DrawableCompat.wrap(drawable).mutate();
DrawableCompat.setTint(drawable, color);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(radioButton,
null, null, drawable, null);
}