mute icon change in action bar

This commit is contained in:
karol 2020-03-04 18:37:04 +01:00
parent 840bb29c54
commit 1ae8a72ba6
4 changed files with 19 additions and 51 deletions

View file

@ -88,7 +88,6 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
private TextView seekDisplay;
private ImageButton repeatButton;
private ImageButton muteButton;
private ImageButton backwardButton;
private ImageButton playPauseButton;
private ImageButton forwardButton;
@ -319,7 +318,6 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
private void buildControls() {
repeatButton = rootView.findViewById(R.id.control_repeat);
muteButton = rootView.findViewById(R.id.control_mute);
backwardButton = rootView.findViewById(R.id.control_backward);
playPauseButton = rootView.findViewById(R.id.control_play_pause);
forwardButton = rootView.findViewById(R.id.control_forward);
@ -329,7 +327,6 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
progressBar = rootView.findViewById(R.id.control_progress_bar);
repeatButton.setOnClickListener(this);
muteButton.setOnClickListener(this);
backwardButton.setOnClickListener(this);
playPauseButton.setOnClickListener(this);
forwardButton.setOnClickListener(this);
@ -462,10 +459,7 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
if (view.getId() == repeatButton.getId()) {
player.onRepeatClicked();
} else if (view.getId() == muteButton.getId()) {
player.onMuteUnmuteButtonClicked();
} else if (view.getId() == backwardButton.getId()) {
} else if (view.getId() == backwardButton.getId()) {
player.onPlayPrevious();
} else if (view.getId() == playPauseButton.getId()) {
@ -698,9 +692,7 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
}
private void onMaybeMuteChanged() {
muteButton.setColorFilter(ContextCompat.getColor(getApplicationContext(), player.isMuted() ? R.color.white : R.color.gray));
if (menu != null) {
if (menu != null && player != null) {
MenuItem item = menu.findItem(R.id.action_mute);
TypedArray a = getTheme().obtainStyledAttributes(R.style.Theme_AppCompat, new int[]{R.attr.volume_off});
int attributeResourceId = a.getResourceId(0, 0);

View file

@ -1,5 +1,10 @@
<vector android:height="24dp" android:tint="#515151"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@color/gray" android:pathData="M16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v2.21l2.45,2.45c0.03,-0.2 0.05,-0.41 0.05,-0.63zM19,12c0,0.94 -0.2,1.82 -0.54,2.64l1.51,1.51C20.63,14.91 21,13.5 21,12c0,-4.28 -2.99,-7.86 -7,-8.77v2.06c2.89,0.86 5,3.54 5,6.71zM4.27,3L3,4.27 7.73,9L3,9v6h4l5,5v-6.73l4.25,4.25c-0.67,0.52 -1.42,0.93 -2.25,1.18v2.06c1.38,-0.31 2.63,-0.95 3.69,-1.81L19.73,21 21,19.73l-9,-9L4.27,3zM12,4L9.91,6.09 12,8.18L12,4z"/>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#4EFFFFFF"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/gray"
android:pathData="M16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v2.21l2.45,2.45c0.03,-0.2 0.05,-0.41 0.05,-0.63zM19,12c0,0.94 -0.2,1.82 -0.54,2.64l1.51,1.51C20.63,14.91 21,13.5 21,12c0,-4.28 -2.99,-7.86 -7,-8.77v2.06c2.89,0.86 5,3.54 5,6.71zM4.27,3L3,4.27 7.73,9L3,9v6h4l5,5v-6.73l4.25,4.25c-0.67,0.52 -1.42,0.93 -2.25,1.18v2.06c1.38,-0.31 2.63,-0.95 3.69,-1.81L19.73,21 21,19.73l-9,-9L4.27,3zM12,4L9.91,6.09 12,8.18L12,4z" />
</vector>

View file

@ -192,7 +192,7 @@
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/control_mute"
android:layout_toLeftOf="@+id/control_repeat"
android:gravity="center"
android:minWidth="50dp"
android:text="1x"
@ -201,30 +201,13 @@
android:background="?attr/selectableItemBackground"
tools:ignore="HardcodedText,RtlHardcoded"/>
<ImageButton
android:id="@+id/control_mute"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_toLeftOf="@+id/control_repeat"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:scaleType="fitXY"
app:srcCompat="@drawable/ic_volume_off_white_72dp"
android:tint="@color/gray"
tools:ignore="ContentDescription"/>
<ImageButton
android:id="@+id/control_repeat"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_toLeftOf="@+id/anchor"
android:layout_centerVertical="true"
android:layout_centerInParent="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
@ -233,12 +216,16 @@
android:src="@drawable/ic_repeat_white"
tools:ignore="ContentDescription"/>
<View android:layout_width="10dp"
android:layout_height="1dp"
android:layout_centerInParent="true"
android:id="@+id/anchor"/>
<ImageButton
android:id="@+id/control_shuffle"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_toRightOf="@+id/control_repeat"
android:layout_toRightOf="@+id/anchor"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:background="?attr/selectableItemBackgroundBorderless"

View file

@ -176,7 +176,7 @@
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/control_mute"
android:layout_toLeftOf="@+id/control_repeat"
android:gravity="center"
android:minWidth="50dp"
android:text="1x"
@ -185,22 +185,6 @@
android:background="?attr/selectableItemBackground"
tools:ignore="HardcodedText,RtlHardcoded"/>
<ImageButton
android:id="@+id/control_mute"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_toLeftOf="@+id/control_repeat"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:scaleType="fitXY"
app:srcCompat="@drawable/ic_volume_off_white_72dp"
android:tint="@color/gray"
tools:ignore="ContentDescription"/>
<ImageButton
android:id="@+id/control_repeat"
android:layout_width="30dp"