mute button color for queue

This commit is contained in:
bopol 2020-03-21 21:42:11 +01:00
parent 47c5008871
commit c54ac32732
5 changed files with 29 additions and 5 deletions

View File

@ -4,6 +4,7 @@ import android.content.ComponentName;
import android.content.Intent; import android.content.Intent;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
@ -700,11 +701,13 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
item.setTitle(player.isMuted() ? R.string.unmute : R.string.mute); item.setTitle(player.isMuted() ? R.string.unmute : R.string.mute);
//2) Icon change accordingly to current App Theme //2) Icon change accordingly to current App Theme
TypedArray a = getTheme().obtainStyledAttributes(R.style.Theme_AppCompat, new int[]{R.attr.volume_off}); item.setIcon(player.isMuted() ? getThemedDrawable(R.attr.volume_off) : getThemedDrawable(R.attr.volume_on));
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);
} }
} }
private Drawable getThemedDrawable(int attribute) {
return getResources().getDrawable(
getTheme().obtainStyledAttributes(R.style.Theme_AppCompat, new int[]{attribute})
.getResourceId(0, 0));
}
} }

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M3,9v6h4l5,5L12,4L7,9L3,9zM16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v8.05c1.48,-0.73 2.5,-2.25 2.5,-4.02zM14,3.23v2.06c2.89,0.86 5,3.54 5,6.71s-2.11,5.85 -5,6.71v2.06c4.01,-0.91 7,-4.49 7,-8.77s-2.99,-7.86 -7,-8.77z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#ffffff"
android:pathData="M3,9v6h4l5,5L12,4L7,9L3,9zM16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v8.05c1.48,-0.73 2.5,-2.25 2.5,-4.02zM14,3.23v2.06c2.89,0.86 5,3.54 5,6.71s-2.11,5.85 -5,6.71v2.06c4.01,-0.91 7,-4.49 7,-8.77s-2.99,-7.86 -7,-8.77z"/>
</vector>

View File

@ -16,6 +16,7 @@
<attr name="expand" format="reference"/> <attr name="expand" format="reference"/>
<attr name="collapse" format="reference"/> <attr name="collapse" format="reference"/>
<attr name="volume_off" format="reference"/> <attr name="volume_off" format="reference"/>
<attr name="volume_on" format="reference"/>
<attr name="clear_history" format="reference" /> <attr name="clear_history" format="reference" />
<attr name="palette" format="reference"/> <attr name="palette" format="reference"/>
<attr name="language" format="reference"/> <attr name="language" format="reference"/>

View File

@ -33,6 +33,7 @@
<item name="expand">@drawable/ic_expand_more_black_24dp</item> <item name="expand">@drawable/ic_expand_more_black_24dp</item>
<item name="collapse">@drawable/ic_expand_less_black_24dp</item> <item name="collapse">@drawable/ic_expand_less_black_24dp</item>
<item name="volume_off">@drawable/ic_volume_off_black_24dp</item> <item name="volume_off">@drawable/ic_volume_off_black_24dp</item>
<item name="volume_on">@drawable/ic_volume_up_black_24dp</item>
<item name="palette">@drawable/ic_palette_black_24dp</item> <item name="palette">@drawable/ic_palette_black_24dp</item>
<item name="language">@drawable/ic_language_black_24dp</item> <item name="language">@drawable/ic_language_black_24dp</item>
<item name="history">@drawable/ic_history_black_24dp</item> <item name="history">@drawable/ic_history_black_24dp</item>
@ -139,6 +140,7 @@
<item name="expand">@drawable/ic_expand_more_white_24dp</item> <item name="expand">@drawable/ic_expand_more_white_24dp</item>
<item name="collapse">@drawable/ic_expand_less_white_24dp</item> <item name="collapse">@drawable/ic_expand_less_white_24dp</item>
<item name="volume_off">@drawable/ic_volume_off_white_24dp</item> <item name="volume_off">@drawable/ic_volume_off_white_24dp</item>
<item name="volume_on">@drawable/ic_volume_up_white_24dp</item>
<item name="palette">@drawable/ic_palette_white_24dp</item> <item name="palette">@drawable/ic_palette_white_24dp</item>
<item name="language">@drawable/ic_language_white_24dp</item> <item name="language">@drawable/ic_language_white_24dp</item>
<item name="history">@drawable/ic_history_white_24dp</item> <item name="history">@drawable/ic_history_white_24dp</item>