Skip to content

Commit 840bb29

Browse files
icon color change in action bar
1 parent c79f09c commit 840bb29

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33
import android.content.ComponentName;
44
import android.content.Intent;
55
import android.content.ServiceConnection;
6+
import android.content.res.TypedArray;
7+
import android.graphics.drawable.Drawable;
68
import android.os.Bundle;
79
import android.os.IBinder;
810
import android.provider.Settings;
11+
912
import androidx.appcompat.app.AppCompatActivity;
1013
import androidx.core.content.ContextCompat;
1114
import androidx.recyclerview.widget.LinearLayoutManager;
1215
import androidx.recyclerview.widget.RecyclerView;
1316
import androidx.appcompat.widget.Toolbar;
1417
import androidx.recyclerview.widget.ItemTouchHelper;
18+
1519
import android.util.Log;
1620
import android.view.Menu;
1721
import android.view.MenuItem;
@@ -94,6 +98,8 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
9498
private TextView playbackSpeedButton;
9599
private TextView playbackPitchButton;
96100

101+
private Menu menu;
102+
97103
////////////////////////////////////////////////////////////////////////////
98104
// Abstracts
99105
////////////////////////////////////////////////////////////////////////////
@@ -147,8 +153,10 @@ protected void onResume() {
147153

148154
@Override
149155
public boolean onCreateOptionsMenu(Menu menu) {
156+
this.menu = menu;
150157
getMenuInflater().inflate(R.menu.menu_play_queue, menu);
151158
getMenuInflater().inflate(getPlayerOptionMenuResource(), menu);
159+
onMaybeMuteChanged();
152160
return true;
153161
}
154162

@@ -174,8 +182,8 @@ public boolean onOptionsItemSelected(MenuItem item) {
174182
this.player.setRecovery();
175183
getApplicationContext().sendBroadcast(getPlayerShutdownIntent());
176184
getApplicationContext().startActivity(
177-
getSwitchIntent(MainVideoPlayer.class)
178-
.putExtra(BasePlayer.START_PAUSED, !this.player.isPlaying())
185+
getSwitchIntent(MainVideoPlayer.class)
186+
.putExtra(BasePlayer.START_PAUSED, !this.player.isPlaying())
179187
);
180188
return true;
181189
}
@@ -218,7 +226,7 @@ private void bind() {
218226
}
219227

220228
private void unbind() {
221-
if(serviceBound) {
229+
if (serviceBound) {
222230
unbindService(serviceConnection);
223231
serviceBound = false;
224232
stopPlayerListener();
@@ -689,7 +697,16 @@ private void onMaybePlaybackAdapterChanged() {
689697
}
690698
}
691699

692-
private void onMaybeMuteChanged(){
700+
private void onMaybeMuteChanged() {
693701
muteButton.setColorFilter(ContextCompat.getColor(getApplicationContext(), player.isMuted() ? R.color.white : R.color.gray));
702+
703+
if (menu != null) {
704+
MenuItem item = menu.findItem(R.id.action_mute);
705+
TypedArray a = getTheme().obtainStyledAttributes(R.style.Theme_AppCompat, new int[]{R.attr.volume_off});
706+
int attributeResourceId = a.getResourceId(0, 0);
707+
Drawable drawableMuted = getResources().getDrawable(attributeResourceId);
708+
Drawable drawableUnmuted = getResources().getDrawable(R.drawable.ic_volume_off_gray_24dp);
709+
item.setIcon(player.isMuted() ? drawableMuted : drawableUnmuted);
710+
}
694711
}
695712
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#515151"
2+
android:viewportHeight="24.0" android:viewportWidth="24.0"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<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"/>
5+
</vector>

0 commit comments

Comments
 (0)