Merge pull request #3252 from B0pol/mute_button

Change mute button color for more visibility
This commit is contained in:
Tobias Groza 2020-03-23 23:10:48 +01:00 committed by GitHub
commit 5a8b565199
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 31 additions and 12 deletions

View file

@ -403,7 +403,7 @@ public final class MainVideoPlayer extends AppCompatActivity
}
protected void setMuteButton(final ImageButton muteButton, final boolean isMuted) {
muteButton.setColorFilter(ContextCompat.getColor(getApplicationContext(), isMuted ? R.color.white : R.color.gray));
muteButton.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), isMuted ? R.drawable.ic_volume_off_white_72dp : R.drawable.ic_volume_up_white_72dp));
}

View file

@ -3,14 +3,12 @@ package org.schabi.newpipe.player;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.IBinder;
import android.provider.Settings;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.appcompat.widget.Toolbar;
@ -700,11 +698,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));
}
}

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="#FFFFFFFF"
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

@ -405,8 +405,7 @@
android:src="@drawable/ic_volume_off_white_24dp"
android:background="?attr/selectableItemBackground"
android:contentDescription="@string/switch_to_background"
tools:ignore="RtlHardcoded"
android:tint="@color/gray"/>
tools:ignore="RtlHardcoded" />
</RelativeLayout>
<LinearLayout

View file

@ -403,8 +403,7 @@
app:srcCompat="@drawable/ic_volume_off_white_72dp"
android:background="?attr/selectableItemBackground"
android:contentDescription="@string/switch_to_background"
tools:ignore="RtlHardcoded"
android:tint="@color/gray"/>
tools:ignore="RtlHardcoded" />
</RelativeLayout>

View file

@ -16,6 +16,7 @@
<attr name="expand" format="reference"/>
<attr name="collapse" format="reference"/>
<attr name="volume_off" format="reference"/>
<attr name="volume_on" format="reference"/>
<attr name="clear_history" format="reference" />
<attr name="palette" 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="collapse">@drawable/ic_expand_less_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="language">@drawable/ic_language_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="collapse">@drawable/ic_expand_less_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="language">@drawable/ic_language_white_24dp</item>
<item name="history">@drawable/ic_history_white_24dp</item>