From 2b25d26a7c836382039cbca3244663dedf1a1a57 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Tue, 7 Jul 2020 18:20:31 +0530 Subject: [PATCH] Use ContextCompat.getColor(). --- src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java | 2 +- .../kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java | 2 +- .../Plugins/SftpPlugin/StoragePreferenceDialogFragment.java | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java index ff1724d4..25dce3ef 100644 --- a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java +++ b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java @@ -269,7 +269,7 @@ public class MprisActivity extends AppCompatActivity { final Drawable drawable = ContextCompat.getDrawable(this, R.drawable.ic_album_art_placeholder); assert drawable != null; Drawable placeholder_art = DrawableCompat.wrap(drawable); - DrawableCompat.setTint(placeholder_art, getResources().getColor(R.color.primary)); + DrawableCompat.setTint(placeholder_art, ContextCompat.getColor(this, R.color.primary)); albumArtView.setImageDrawable(placeholder_art); } else { albumArtView.setImageBitmap(albumArt); diff --git a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java index f33d6cd9..85863e43 100644 --- a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java +++ b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java @@ -375,7 +375,7 @@ public class MprisMediaSession implements SharedPreferences.OnSharedPreferenceCh .setContentIntent(piOpenActivity) .setSmallIcon(R.drawable.ic_play_white) .setShowWhen(false) - .setColor(service.getResources().getColor(R.color.primary)) + .setColor(ContextCompat.getColor(service, R.color.primary)) .setVisibility(androidx.core.app.NotificationCompat.VISIBILITY_PUBLIC) .setSubText(service.getDevice(notificationDevice).getName()); diff --git a/src/org/kde/kdeconnect/Plugins/SftpPlugin/StoragePreferenceDialogFragment.java b/src/org/kde/kdeconnect/Plugins/SftpPlugin/StoragePreferenceDialogFragment.java index dbcdbdab..25fb8c91 100644 --- a/src/org/kde/kdeconnect/Plugins/SftpPlugin/StoragePreferenceDialogFragment.java +++ b/src/org/kde/kdeconnect/Plugins/SftpPlugin/StoragePreferenceDialogFragment.java @@ -29,6 +29,7 @@ import org.kde.kdeconnect_tp.R; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.content.res.AppCompatResources; +import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; import androidx.preference.PreferenceDialogFragmentCompat; import butterknife.BindView; @@ -87,7 +88,8 @@ public class StoragePreferenceDialogFragment extends PreferenceDialogFragmentCom Drawable drawable = AppCompatResources.getDrawable(requireContext(), R.drawable.ic_arrow_drop_down_24px); if (drawable != null) { drawable = DrawableCompat.wrap(drawable); - DrawableCompat.setTint(drawable, getResources().getColor(android.R.color.darker_gray)); + DrawableCompat.setTint(drawable, ContextCompat.getColor(requireContext(), + android.R.color.darker_gray)); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); arrowDropDownDrawable = drawable; }