mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-12 10:20:30 +00:00
mute icon in main refactored
This commit is contained in:
parent
40f54aea53
commit
0400fcb106
@ -34,6 +34,7 @@ import android.os.Bundle;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -43,6 +44,7 @@ import androidx.appcompat.content.res.AppCompatResources;
|
|||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||||
|
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
@ -115,7 +117,8 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||||||
|
|
||||||
private SharedPreferences defaultPreferences;
|
private SharedPreferences defaultPreferences;
|
||||||
|
|
||||||
@Nullable private PlayerState playerState;
|
@Nullable
|
||||||
|
private PlayerState playerState;
|
||||||
private boolean isInMultiWindow;
|
private boolean isInMultiWindow;
|
||||||
private boolean isBackPressed;
|
private boolean isBackPressed;
|
||||||
|
|
||||||
@ -129,11 +132,13 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
assureCorrectAppLanguage(this);
|
assureCorrectAppLanguage(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (DEBUG) Log.d(TAG, "onCreate() called with: savedInstanceState = [" + savedInstanceState + "]");
|
if (DEBUG)
|
||||||
|
Log.d(TAG, "onCreate() called with: savedInstanceState = [" + savedInstanceState + "]");
|
||||||
defaultPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
defaultPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
ThemeHelper.setTheme(this);
|
ThemeHelper.setTheme(this);
|
||||||
getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK));
|
getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK));
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getWindow().setStatusBarColor(Color.BLACK);
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
getWindow().setStatusBarColor(Color.BLACK);
|
||||||
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||||
|
|
||||||
WindowManager.LayoutParams lp = getWindow().getAttributes();
|
WindowManager.LayoutParams lp = getWindow().getAttributes();
|
||||||
@ -395,6 +400,16 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||||||
shuffleButton.setImageAlpha(shuffleAlpha);
|
shuffleButton.setImageAlpha(shuffleAlpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setMuteButton(final ImageButton muteButton, final boolean isMuted) {
|
||||||
|
if (isMuted) {
|
||||||
|
muteButton.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.white));
|
||||||
|
} else {
|
||||||
|
muteButton.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.gray));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean isInMultiWindow() {
|
private boolean isInMultiWindow() {
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isInMultiWindowMode();
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isInMultiWindowMode();
|
||||||
}
|
}
|
||||||
@ -676,20 +691,11 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||||||
destroy();
|
destroy();
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMuteUnmuteButtonClicled() {
|
public void onMuteUnmuteButtonClicled() {
|
||||||
super.onMuteUnmuteButtonClicled();
|
super.onMuteUnmuteButtonClicled();
|
||||||
setMuteIcon();
|
updatePlaybackButtons();
|
||||||
}
|
|
||||||
|
|
||||||
public void setMuteIcon() {
|
|
||||||
if (simpleExoPlayer.getVolume() == 0){
|
|
||||||
muteButton.setColorFilter(ContextCompat.getColor(context, R.color.white));
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
muteButton.setColorFilter(ContextCompat.getColor(context, R.color.gray));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -978,6 +984,7 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||||||
|
|
||||||
setRepeatModeButton(repeatButton, getRepeatMode());
|
setRepeatModeButton(repeatButton, getRepeatMode());
|
||||||
setShuffleButton(shuffleButton, playQueue.isShuffled());
|
setShuffleButton(shuffleButton, playQueue.isShuffled());
|
||||||
|
setMuteButton(muteButton, playerImpl.isMuted());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildQueue() {
|
private void buildQueue() {
|
||||||
@ -1097,7 +1104,8 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onDoubleTap(MotionEvent e) {
|
public boolean onDoubleTap(MotionEvent e) {
|
||||||
if (DEBUG) Log.d(TAG, "onDoubleTap() called with: e = [" + e + "]" + "rawXy = " + e.getRawX() + ", " + e.getRawY() + ", xy = " + e.getX() + ", " + e.getY());
|
if (DEBUG)
|
||||||
|
Log.d(TAG, "onDoubleTap() called with: e = [" + e + "]" + "rawXy = " + e.getRawX() + ", " + e.getRawY() + ", xy = " + e.getX() + ", " + e.getY());
|
||||||
|
|
||||||
if (e.getX() > playerImpl.getRootView().getWidth() * 2 / 3) {
|
if (e.getX() > playerImpl.getRootView().getWidth() * 2 / 3) {
|
||||||
playerImpl.onFastForward();
|
playerImpl.onFastForward();
|
||||||
@ -1193,7 +1201,8 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||||||
layoutParams.screenBrightness = currentProgressPercent;
|
layoutParams.screenBrightness = currentProgressPercent;
|
||||||
getWindow().setAttributes(layoutParams);
|
getWindow().setAttributes(layoutParams);
|
||||||
|
|
||||||
if (DEBUG) Log.d(TAG, "onScroll().brightnessControl, currentBrightness = " + currentProgressPercent);
|
if (DEBUG)
|
||||||
|
Log.d(TAG, "onScroll().brightnessControl, currentBrightness = " + currentProgressPercent);
|
||||||
|
|
||||||
final int resId =
|
final int resId =
|
||||||
currentProgressPercent < 0.25 ? R.drawable.ic_brightness_low_white_72dp
|
currentProgressPercent < 0.25 ? R.drawable.ic_brightness_low_white_72dp
|
||||||
@ -1232,7 +1241,8 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
//noinspection PointlessBooleanExpression
|
//noinspection PointlessBooleanExpression
|
||||||
if (DEBUG && false) Log.d(TAG, "onTouch() called with: v = [" + v + "], event = [" + event + "]");
|
if (DEBUG && false)
|
||||||
|
Log.d(TAG, "onTouch() called with: v = [" + v + "], event = [" + event + "]");
|
||||||
gestureDetector.onTouchEvent(event);
|
gestureDetector.onTouchEvent(event);
|
||||||
if (event.getAction() == MotionEvent.ACTION_UP && isMoving) {
|
if (event.getAction() == MotionEvent.ACTION_UP && isMoving) {
|
||||||
isMoving = false;
|
isMoving = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user