1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-14 21:00:17 +01:00

Perfect shadow

This commit is contained in:
Avently 2020-09-15 19:50:46 +03:00
parent 150e156d26
commit a5312c1341
5 changed files with 59 additions and 44 deletions

View File

@ -17,7 +17,6 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import androidx.core.app.ActivityCompat;
import androidx.core.text.HtmlCompat;
import androidx.preference.PreferenceManager;
import android.provider.Settings;
@ -2040,8 +2039,7 @@ public class VideoDetailFragment
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
&& (isInMultiWindow() || (player != null && player.isFullscreen()))) {
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
activity.getWindow().setNavigationBarColor(
ActivityCompat.getColor(activity, R.color.video_overlay_color));
activity.getWindow().setNavigationBarColor(Color.TRANSPARENT);
}
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}

View File

@ -128,6 +128,8 @@ public abstract class VideoPlayer extends BasePlayer
private View controlsRoot;
private TextView currentDisplaySeek;
private View playerTopShadow;
private View playerBottomShadow;
private View bottomControlsRoot;
private SeekBar playbackSeekBar;
@ -190,6 +192,8 @@ public abstract class VideoPlayer extends BasePlayer
this.controlAnimationView = view.findViewById(R.id.controlAnimationView);
this.controlsRoot = view.findViewById(R.id.playbackControlRoot);
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.playbackCurrentTime = view.findViewById(R.id.playbackCurrentTime);
this.playbackEndTime = view.findViewById(R.id.playbackEndTime);
@ -754,7 +758,6 @@ public abstract class VideoPlayer extends BasePlayer
}
qualityPopupMenu.show();
isSomePopupMenuVisible = true;
showControls(DEFAULT_CONTROLS_DURATION);
final VideoStream videoStream = getSelectedVideoStream();
if (videoStream != null) {
@ -772,7 +775,6 @@ public abstract class VideoPlayer extends BasePlayer
}
playbackSpeedPopupMenu.show();
isSomePopupMenuVisible = true;
showControls(DEFAULT_CONTROLS_DURATION);
}
private void onCaptionClicked() {
@ -781,7 +783,6 @@ public abstract class VideoPlayer extends BasePlayer
}
captionPopupMenu.show();
isSomePopupMenuVisible = true;
showControls(DEFAULT_CONTROLS_DURATION);
}
void onResizeClicked() {
@ -958,6 +959,7 @@ public abstract class VideoPlayer extends BasePlayer
? DEFAULT_CONTROLS_HIDE_TIME
: DPAD_CONTROLS_HIDE_TIME;
showHideShadow(true, DEFAULT_CONTROLS_DURATION, 0);
animateView(controlsRoot, true, DEFAULT_CONTROLS_DURATION, 0,
() -> hideControls(DEFAULT_CONTROLS_DURATION, hideTime));
}
@ -967,6 +969,7 @@ public abstract class VideoPlayer extends BasePlayer
Log.d(TAG, "showControls() called");
}
controlsVisibilityHandler.removeCallbacksAndMessages(null);
showHideShadow(true, duration, 0);
animateView(controlsRoot, true, duration);
}
@ -986,8 +989,10 @@ public abstract class VideoPlayer extends BasePlayer
Log.d(TAG, "hideControls() called with: delay = [" + delay + "]");
}
controlsVisibilityHandler.removeCallbacksAndMessages(null);
controlsVisibilityHandler.postDelayed(() ->
animateView(controlsRoot, false, duration), delay);
controlsVisibilityHandler.postDelayed(() -> {
showHideShadow(false, duration, 0);
animateView(controlsRoot, false, duration);
}, delay);
}
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();
/*//////////////////////////////////////////////////////////////////////////

View File

@ -27,13 +27,12 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.database.ContentObserver;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.view.DisplayCutout;
import androidx.annotation.ColorInt;
import androidx.core.app.ActivityCompat;
import androidx.preference.PreferenceManager;
import android.provider.Settings;
import android.util.DisplayMetrics;
@ -813,6 +812,7 @@ public class VideoPlayerImpl extends VideoPlayer
if (getCurrentState() != STATE_COMPLETED) {
getControlsVisibilityHandler().removeCallbacksAndMessages(null);
showHideShadow(true, DEFAULT_CONTROLS_DURATION, 0);
animateView(getControlsRoot(), true, DEFAULT_CONTROLS_DURATION, 0, () -> {
if (getCurrentState() == STATE_PLAYING && !isSomePopupMenuVisible()) {
if (v.getId() == playPauseButton.getId()) {
@ -842,7 +842,7 @@ public class VideoPlayerImpl extends VideoPlayer
buildQueue();
updatePlaybackButtons();
getControlsRoot().setVisibility(View.INVISIBLE);
hideControls(0, 0);
queueLayout.requestFocus();
animateView(queueLayout, SLIDE_AND_ALPHA, true,
DEFAULT_CONTROLS_DURATION);
@ -1436,9 +1436,10 @@ public class VideoPlayerImpl extends VideoPlayer
showOrHideButtons();
getControlsVisibilityHandler().removeCallbacksAndMessages(null);
getControlsVisibilityHandler().postDelayed(() ->
animateView(getControlsRoot(), false, duration, 0,
this::hideSystemUIIfNeeded), delay
getControlsVisibilityHandler().postDelayed(() -> {
showHideShadow(false, duration, 0);
animateView(getControlsRoot(), false, duration, 0, this::hideSystemUIIfNeeded);
}, delay
);
}
@ -1469,10 +1470,8 @@ public class VideoPlayerImpl extends VideoPlayer
final AppCompatActivity activity = getParentActivity();
if (isFullscreen() && activity != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
@ColorInt final int systemUiColor =
ActivityCompat.getColor(service, R.color.video_overlay_color);
activity.getWindow().setStatusBarColor(systemUiColor);
activity.getWindow().setNavigationBarColor(systemUiColor);
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
activity.getWindow().setNavigationBarColor(Color.TRANSPARENT);
}
final int visibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

View File

@ -28,6 +28,22 @@
android:layout_centerInParent="true"
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
android:id="@+id/endScreen"
android:layout_width="match_parent"
@ -47,18 +63,6 @@
android:visibility="gone"
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 -->
<RelativeLayout
android:id="@+id/playbackWindowRoot"

View File

@ -28,6 +28,22 @@
android:layout_centerInParent="true"
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
android:id="@+id/endScreen"
android:layout_width="match_parent"
@ -47,18 +63,6 @@
android:visibility="gone"
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 -->
<RelativeLayout
android:id="@+id/playbackWindowRoot"