1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 16:40:32 +00:00

Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Weblate 2018-05-04 09:40:15 +02:00
commit fcb67f5119
3 changed files with 67 additions and 9 deletions

View File

@ -44,6 +44,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.PopupMenu;
import android.widget.RemoteViews;
import android.widget.SeekBar;
@ -370,6 +371,7 @@ public final class PopupVideoPlayer extends Service {
protected class VideoPlayerImpl extends VideoPlayer implements View.OnLayoutChangeListener {
private TextView resizingIndicator;
private ImageButton fullScreenButton;
private ImageView videoPlayPause;
private View extraOptionsView;
@ -391,6 +393,8 @@ public final class PopupVideoPlayer extends Service {
resizingIndicator = rootView.findViewById(R.id.resizing_indicator);
fullScreenButton = rootView.findViewById(R.id.fullScreenButton);
fullScreenButton.setOnClickListener(v -> onFullScreenButtonClicked());
videoPlayPause = rootView.findViewById(R.id.videoPlayPause);
videoPlayPause.setOnClickListener(this::onPlayPauseButtonPressed);
extraOptionsView = rootView.findViewById(R.id.extraOptionsView);
rootView.addOnLayoutChangeListener(this);
@ -406,6 +410,10 @@ public final class PopupVideoPlayer extends Service {
view.setStyle(captionStyle);
}
private void onPlayPauseButtonPressed(View ib) {
onPlayPause();
}
@Override
public void onLayoutChange(final View view, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
@ -651,6 +659,7 @@ public final class PopupVideoPlayer extends Service {
public void onPlaying() {
super.onPlaying();
updateNotification(R.drawable.ic_pause_white);
videoPlayPause.setBackgroundResource(R.drawable.ic_pause_white);
lockManager.acquireWifiAndCpu();
hideControls(DEFAULT_CONTROLS_DURATION, DEFAULT_CONTROLS_HIDE_TIME);
@ -666,13 +675,14 @@ public final class PopupVideoPlayer extends Service {
public void onPaused() {
super.onPaused();
updateNotification(R.drawable.ic_play_arrow_white);
showAndAnimateControl(R.drawable.ic_play_arrow_white, false);
videoPlayPause.setBackgroundResource(R.drawable.ic_play_arrow_white);
lockManager.releaseWifiAndCpu();
}
@Override
public void onPausedSeek() {
super.onPausedSeek();
videoPlayPause.setBackgroundResource(R.drawable.ic_pause_white);
updateNotification(R.drawable.ic_play_arrow_white);
}
@ -680,10 +690,27 @@ public final class PopupVideoPlayer extends Service {
public void onCompleted() {
super.onCompleted();
updateNotification(R.drawable.ic_replay_white);
showAndAnimateControl(R.drawable.ic_replay_white, false);
videoPlayPause.setBackgroundResource(R.drawable.ic_replay_white);
lockManager.releaseWifiAndCpu();
}
@Override
public void showControlsThenHide() {
videoPlayPause.setVisibility(View.VISIBLE);
super.showControlsThenHide();
}
public void showControls(long duration) {
videoPlayPause.setVisibility(View.VISIBLE);
super.showControls(duration);
}
public void hideControls(final long duration, long delay) {
super.hideControlsAndButton(duration, delay, videoPlayPause);
}
/*//////////////////////////////////////////////////////////////////////////
// Utils
//////////////////////////////////////////////////////////////////////////*/
@ -717,6 +744,8 @@ public final class PopupVideoPlayer extends Service {
Log.d(TAG, "onDoubleTap() called with: e = [" + e + "]" + "rawXy = " + e.getRawX() + ", " + e.getRawY() + ", xy = " + e.getX() + ", " + e.getY());
if (playerImpl == null || !playerImpl.isPlaying()) return false;
playerImpl.hideControls(0, 0);
if (e.getX() > popupWidth / 2) {
playerImpl.onFastForward();
} else {
@ -730,7 +759,12 @@ public final class PopupVideoPlayer extends Service {
public boolean onSingleTapConfirmed(MotionEvent e) {
if (DEBUG) Log.d(TAG, "onSingleTapConfirmed() called with: e = [" + e + "]");
if (playerImpl == null || playerImpl.getPlayer() == null) return false;
playerImpl.onPlayPause();
if (playerImpl.isControlsVisible()) {
playerImpl.hideControls(100, 100);
} else {
playerImpl.showControlsThenHide();
}
return true;
}

View File

@ -887,6 +887,19 @@ public abstract class VideoPlayer extends BasePlayer
() -> animateView(controlsRoot, false, duration), delay);
}
public void hideControlsAndButton(final long duration, long delay, View button) {
if (DEBUG) Log.d(TAG, "hideControls() called with: delay = [" + delay + "]");
controlsVisibilityHandler.removeCallbacksAndMessages(null);
controlsVisibilityHandler.postDelayed(hideControlsAndButtonHandler(duration, button), delay);
}
private Runnable hideControlsAndButtonHandler(long duration, View videoPlayPause)
{
return () -> {
videoPlayPause.setVisibility(View.INVISIBLE);
animateView(controlsRoot, false,duration);
};
}
/*//////////////////////////////////////////////////////////////////////////
// Getters and Setters
//////////////////////////////////////////////////////////////////////////*/

View File

@ -53,6 +53,16 @@
android:visibility="gone"
tools:visibility="visible">
<ImageView
android:id="@+id/videoPlayPause"
android:layout_width="55dp"
android:layout_height="55dp"
android:layout_centerHorizontal="false"
android:layout_centerInParent="true"
android:visibility="gone"
tools:ignore="ContentDescription"
tools:visibility="visible" />
<RelativeLayout
android:id="@+id/topControls"
android:layout_width="match_parent"
@ -101,17 +111,17 @@
<TextView
android:id="@+id/resizeTextView"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp"
android:layout_alignParentLeft="true"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:minWidth="50dp"
android:padding="5dp"
android:textColor="@android:color/white"
android:textStyle="bold"
android:background="?attr/selectableItemBackground"
tools:ignore="HardcodedText,RtlHardcoded"
tools:text="FIT"/>
tools:text="FIT" />
<TextView
android:id="@+id/captionTextView"
@ -133,12 +143,13 @@
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:scaleType="fitCenter"
android:background="?attr/selectableItemBackground"
android:src="@drawable/ic_fullscreen_white"
tools:ignore="ContentDescription,RtlHardcoded"/>
tools:ignore="ContentDescription,RtlHardcoded" />
</RelativeLayout>
<!--Shadow Bottom Control-->