mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-15 05:11:08 +01:00
Perfect shadow
This commit is contained in:
parent
150e156d26
commit
a5312c1341
@ -17,7 +17,6 @@ import android.os.Build;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
import androidx.core.text.HtmlCompat;
|
import androidx.core.text.HtmlCompat;
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@ -2040,8 +2039,7 @@ public class VideoDetailFragment
|
|||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
|
||||||
&& (isInMultiWindow() || (player != null && player.isFullscreen()))) {
|
&& (isInMultiWindow() || (player != null && player.isFullscreen()))) {
|
||||||
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
|
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
activity.getWindow().setNavigationBarColor(
|
activity.getWindow().setNavigationBarColor(Color.TRANSPARENT);
|
||||||
ActivityCompat.getColor(activity, R.color.video_overlay_color));
|
|
||||||
}
|
}
|
||||||
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
}
|
}
|
||||||
|
@ -128,6 +128,8 @@ public abstract class VideoPlayer extends BasePlayer
|
|||||||
|
|
||||||
private View controlsRoot;
|
private View controlsRoot;
|
||||||
private TextView currentDisplaySeek;
|
private TextView currentDisplaySeek;
|
||||||
|
private View playerTopShadow;
|
||||||
|
private View playerBottomShadow;
|
||||||
|
|
||||||
private View bottomControlsRoot;
|
private View bottomControlsRoot;
|
||||||
private SeekBar playbackSeekBar;
|
private SeekBar playbackSeekBar;
|
||||||
@ -190,6 +192,8 @@ public abstract class VideoPlayer extends BasePlayer
|
|||||||
this.controlAnimationView = view.findViewById(R.id.controlAnimationView);
|
this.controlAnimationView = view.findViewById(R.id.controlAnimationView);
|
||||||
this.controlsRoot = view.findViewById(R.id.playbackControlRoot);
|
this.controlsRoot = view.findViewById(R.id.playbackControlRoot);
|
||||||
this.currentDisplaySeek = view.findViewById(R.id.currentDisplaySeek);
|
this.currentDisplaySeek = view.findViewById(R.id.currentDisplaySeek);
|
||||||
|
this.playerTopShadow = view.findViewById(R.id.playerTopShadow);
|
||||||
|
this.playerBottomShadow = view.findViewById(R.id.playerBottomShadow);
|
||||||
this.playbackSeekBar = view.findViewById(R.id.playbackSeekBar);
|
this.playbackSeekBar = view.findViewById(R.id.playbackSeekBar);
|
||||||
this.playbackCurrentTime = view.findViewById(R.id.playbackCurrentTime);
|
this.playbackCurrentTime = view.findViewById(R.id.playbackCurrentTime);
|
||||||
this.playbackEndTime = view.findViewById(R.id.playbackEndTime);
|
this.playbackEndTime = view.findViewById(R.id.playbackEndTime);
|
||||||
@ -754,7 +758,6 @@ public abstract class VideoPlayer extends BasePlayer
|
|||||||
}
|
}
|
||||||
qualityPopupMenu.show();
|
qualityPopupMenu.show();
|
||||||
isSomePopupMenuVisible = true;
|
isSomePopupMenuVisible = true;
|
||||||
showControls(DEFAULT_CONTROLS_DURATION);
|
|
||||||
|
|
||||||
final VideoStream videoStream = getSelectedVideoStream();
|
final VideoStream videoStream = getSelectedVideoStream();
|
||||||
if (videoStream != null) {
|
if (videoStream != null) {
|
||||||
@ -772,7 +775,6 @@ public abstract class VideoPlayer extends BasePlayer
|
|||||||
}
|
}
|
||||||
playbackSpeedPopupMenu.show();
|
playbackSpeedPopupMenu.show();
|
||||||
isSomePopupMenuVisible = true;
|
isSomePopupMenuVisible = true;
|
||||||
showControls(DEFAULT_CONTROLS_DURATION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onCaptionClicked() {
|
private void onCaptionClicked() {
|
||||||
@ -781,7 +783,6 @@ public abstract class VideoPlayer extends BasePlayer
|
|||||||
}
|
}
|
||||||
captionPopupMenu.show();
|
captionPopupMenu.show();
|
||||||
isSomePopupMenuVisible = true;
|
isSomePopupMenuVisible = true;
|
||||||
showControls(DEFAULT_CONTROLS_DURATION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onResizeClicked() {
|
void onResizeClicked() {
|
||||||
@ -958,6 +959,7 @@ public abstract class VideoPlayer extends BasePlayer
|
|||||||
? DEFAULT_CONTROLS_HIDE_TIME
|
? DEFAULT_CONTROLS_HIDE_TIME
|
||||||
: DPAD_CONTROLS_HIDE_TIME;
|
: DPAD_CONTROLS_HIDE_TIME;
|
||||||
|
|
||||||
|
showHideShadow(true, DEFAULT_CONTROLS_DURATION, 0);
|
||||||
animateView(controlsRoot, true, DEFAULT_CONTROLS_DURATION, 0,
|
animateView(controlsRoot, true, DEFAULT_CONTROLS_DURATION, 0,
|
||||||
() -> hideControls(DEFAULT_CONTROLS_DURATION, hideTime));
|
() -> hideControls(DEFAULT_CONTROLS_DURATION, hideTime));
|
||||||
}
|
}
|
||||||
@ -967,6 +969,7 @@ public abstract class VideoPlayer extends BasePlayer
|
|||||||
Log.d(TAG, "showControls() called");
|
Log.d(TAG, "showControls() called");
|
||||||
}
|
}
|
||||||
controlsVisibilityHandler.removeCallbacksAndMessages(null);
|
controlsVisibilityHandler.removeCallbacksAndMessages(null);
|
||||||
|
showHideShadow(true, duration, 0);
|
||||||
animateView(controlsRoot, true, duration);
|
animateView(controlsRoot, true, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -986,8 +989,10 @@ public abstract class VideoPlayer extends BasePlayer
|
|||||||
Log.d(TAG, "hideControls() called with: delay = [" + delay + "]");
|
Log.d(TAG, "hideControls() called with: delay = [" + delay + "]");
|
||||||
}
|
}
|
||||||
controlsVisibilityHandler.removeCallbacksAndMessages(null);
|
controlsVisibilityHandler.removeCallbacksAndMessages(null);
|
||||||
controlsVisibilityHandler.postDelayed(() ->
|
controlsVisibilityHandler.postDelayed(() -> {
|
||||||
animateView(controlsRoot, false, duration), delay);
|
showHideShadow(false, duration, 0);
|
||||||
|
animateView(controlsRoot, false, duration);
|
||||||
|
}, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideControlsAndButton(final long duration, final long delay, final View button) {
|
public void hideControlsAndButton(final long duration, final long delay, final View button) {
|
||||||
@ -1006,6 +1011,11 @@ public abstract class VideoPlayer extends BasePlayer
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showHideShadow(final boolean show, final long duration, final long delay) {
|
||||||
|
animateView(playerTopShadow, show, duration, delay, null);
|
||||||
|
animateView(playerBottomShadow, show, duration, delay, null);
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void hideSystemUIIfNeeded();
|
public abstract void hideSystemUIIfNeeded();
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -27,13 +27,12 @@ import android.content.IntentFilter;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.view.DisplayCutout;
|
import android.view.DisplayCutout;
|
||||||
import androidx.annotation.ColorInt;
|
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
@ -813,6 +812,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
|||||||
|
|
||||||
if (getCurrentState() != STATE_COMPLETED) {
|
if (getCurrentState() != STATE_COMPLETED) {
|
||||||
getControlsVisibilityHandler().removeCallbacksAndMessages(null);
|
getControlsVisibilityHandler().removeCallbacksAndMessages(null);
|
||||||
|
showHideShadow(true, DEFAULT_CONTROLS_DURATION, 0);
|
||||||
animateView(getControlsRoot(), true, DEFAULT_CONTROLS_DURATION, 0, () -> {
|
animateView(getControlsRoot(), true, DEFAULT_CONTROLS_DURATION, 0, () -> {
|
||||||
if (getCurrentState() == STATE_PLAYING && !isSomePopupMenuVisible()) {
|
if (getCurrentState() == STATE_PLAYING && !isSomePopupMenuVisible()) {
|
||||||
if (v.getId() == playPauseButton.getId()) {
|
if (v.getId() == playPauseButton.getId()) {
|
||||||
@ -842,7 +842,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
|||||||
buildQueue();
|
buildQueue();
|
||||||
updatePlaybackButtons();
|
updatePlaybackButtons();
|
||||||
|
|
||||||
getControlsRoot().setVisibility(View.INVISIBLE);
|
hideControls(0, 0);
|
||||||
queueLayout.requestFocus();
|
queueLayout.requestFocus();
|
||||||
animateView(queueLayout, SLIDE_AND_ALPHA, true,
|
animateView(queueLayout, SLIDE_AND_ALPHA, true,
|
||||||
DEFAULT_CONTROLS_DURATION);
|
DEFAULT_CONTROLS_DURATION);
|
||||||
@ -1436,9 +1436,10 @@ public class VideoPlayerImpl extends VideoPlayer
|
|||||||
showOrHideButtons();
|
showOrHideButtons();
|
||||||
|
|
||||||
getControlsVisibilityHandler().removeCallbacksAndMessages(null);
|
getControlsVisibilityHandler().removeCallbacksAndMessages(null);
|
||||||
getControlsVisibilityHandler().postDelayed(() ->
|
getControlsVisibilityHandler().postDelayed(() -> {
|
||||||
animateView(getControlsRoot(), false, duration, 0,
|
showHideShadow(false, duration, 0);
|
||||||
this::hideSystemUIIfNeeded), delay
|
animateView(getControlsRoot(), false, duration, 0, this::hideSystemUIIfNeeded);
|
||||||
|
}, delay
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1469,10 +1470,8 @@ public class VideoPlayerImpl extends VideoPlayer
|
|||||||
final AppCompatActivity activity = getParentActivity();
|
final AppCompatActivity activity = getParentActivity();
|
||||||
if (isFullscreen() && activity != null) {
|
if (isFullscreen() && activity != null) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
@ColorInt final int systemUiColor =
|
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||||
ActivityCompat.getColor(service, R.color.video_overlay_color);
|
activity.getWindow().setNavigationBarColor(Color.TRANSPARENT);
|
||||||
activity.getWindow().setStatusBarColor(systemUiColor);
|
|
||||||
activity.getWindow().setNavigationBarColor(systemUiColor);
|
|
||||||
}
|
}
|
||||||
final int visibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
final int visibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||||
|
@ -28,6 +28,22 @@
|
|||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:layout_gravity="center"/>
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/playerTopShadow"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:background="@drawable/player_controls_top_background"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/playerBottomShadow"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:background="@drawable/player_controls_background"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/endScreen"
|
android:id="@+id/endScreen"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -47,18 +63,6 @@
|
|||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible">
|
tools:visibility="visible">
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="30dp"
|
|
||||||
android:background="@drawable/player_controls_top_background"
|
|
||||||
android:layout_alignParentTop="true" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="30dp"
|
|
||||||
android:background="@drawable/player_controls_background"
|
|
||||||
android:layout_alignParentBottom="true" />
|
|
||||||
|
|
||||||
<!-- All top controls in this layout -->
|
<!-- All top controls in this layout -->
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/playbackWindowRoot"
|
android:id="@+id/playbackWindowRoot"
|
||||||
|
@ -28,6 +28,22 @@
|
|||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:layout_gravity="center"/>
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/playerTopShadow"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:background="@drawable/player_controls_top_background"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/playerBottomShadow"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:background="@drawable/player_controls_background"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/endScreen"
|
android:id="@+id/endScreen"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -47,18 +63,6 @@
|
|||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible">
|
tools:visibility="visible">
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="30dp"
|
|
||||||
android:background="@drawable/player_controls_top_background"
|
|
||||||
android:layout_alignParentTop="true" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="30dp"
|
|
||||||
android:background="@drawable/player_controls_background"
|
|
||||||
android:layout_alignParentBottom="true" />
|
|
||||||
|
|
||||||
<!-- All top controls in this layout -->
|
<!-- All top controls in this layout -->
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/playbackWindowRoot"
|
android:id="@+id/playbackWindowRoot"
|
||||||
|
Loading…
Reference in New Issue
Block a user