From c54ac32732b7e253610770069bb722d7156fd4a4 Mon Sep 17 00:00:00 2001 From: bopol Date: Sat, 21 Mar 2020 21:42:11 +0100 Subject: [PATCH] mute button color for queue --- .../newpipe/player/ServicePlayerActivity.java | 13 ++++++++----- .../main/res/drawable/ic_volume_up_black_24dp.xml | 9 +++++++++ .../main/res/drawable/ic_volume_up_white_24dp.xml | 9 +++++++++ app/src/main/res/values/attrs.xml | 1 + app/src/main/res/values/styles.xml | 2 ++ 5 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 app/src/main/res/drawable/ic_volume_up_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_volume_up_white_24dp.xml diff --git a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java index e7700351e..f0223f8ce 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -4,6 +4,7 @@ import android.content.ComponentName; import android.content.Intent; import android.content.ServiceConnection; import android.content.res.TypedArray; +import android.graphics.Color; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.IBinder; @@ -700,11 +701,13 @@ public abstract class ServicePlayerActivity extends AppCompatActivity item.setTitle(player.isMuted() ? R.string.unmute : R.string.mute); //2) Icon change accordingly to current App Theme - TypedArray a = getTheme().obtainStyledAttributes(R.style.Theme_AppCompat, new int[]{R.attr.volume_off}); - int attributeResourceId = a.getResourceId(0, 0); - Drawable drawableMuted = getResources().getDrawable(attributeResourceId); - Drawable drawableUnmuted = getResources().getDrawable(R.drawable.ic_volume_off_gray_24dp); - item.setIcon(player.isMuted() ? drawableMuted : drawableUnmuted); + item.setIcon(player.isMuted() ? getThemedDrawable(R.attr.volume_off) : getThemedDrawable(R.attr.volume_on)); } } + + private Drawable getThemedDrawable(int attribute) { + return getResources().getDrawable( + getTheme().obtainStyledAttributes(R.style.Theme_AppCompat, new int[]{attribute}) + .getResourceId(0, 0)); + } } diff --git a/app/src/main/res/drawable/ic_volume_up_black_24dp.xml b/app/src/main/res/drawable/ic_volume_up_black_24dp.xml new file mode 100644 index 000000000..bb0c74ba1 --- /dev/null +++ b/app/src/main/res/drawable/ic_volume_up_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_volume_up_white_24dp.xml b/app/src/main/res/drawable/ic_volume_up_white_24dp.xml new file mode 100644 index 000000000..f63b9e451 --- /dev/null +++ b/app/src/main/res/drawable/ic_volume_up_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 4cda52a99..39a51f234 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -16,6 +16,7 @@ + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index f7d09ef9c..9a41752b1 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -33,6 +33,7 @@ @drawable/ic_expand_more_black_24dp @drawable/ic_expand_less_black_24dp @drawable/ic_volume_off_black_24dp + @drawable/ic_volume_up_black_24dp @drawable/ic_palette_black_24dp @drawable/ic_language_black_24dp @drawable/ic_history_black_24dp @@ -139,6 +140,7 @@ @drawable/ic_expand_more_white_24dp @drawable/ic_expand_less_white_24dp @drawable/ic_volume_off_white_24dp + @drawable/ic_volume_up_white_24dp @drawable/ic_palette_white_24dp @drawable/ic_language_white_24dp @drawable/ic_history_white_24dp