Added settings export

This commit is contained in:
Somethingweirdhere 2018-04-21 21:11:52 +02:00
parent bdb45295b9
commit f94f14ab65
3 changed files with 114 additions and 11 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;
@ -174,10 +175,12 @@ public final class PopupVideoPlayer extends Service {
// Init
//////////////////////////////////////////////////////////////////////////*/
View rootView;
@SuppressLint("RtlHardcoded")
private void initPopup() {
if (DEBUG) Log.d(TAG, "initPopup() called");
View rootView = View.inflate(this, R.layout.player_popup, null);
rootView = View.inflate(this, R.layout.player_popup, null);
playerImpl.setup(rootView);
shutdownFlingVelocity = PlayerHelper.getShutdownFlingVelocity(this);
@ -666,7 +669,6 @@ 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);
lockManager.releaseWifiAndCpu();
}
@ -730,7 +732,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

@ -40,6 +40,7 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.SurfaceView;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.PopupMenu;
import android.widget.ProgressBar;
@ -157,6 +158,8 @@ public abstract class VideoPlayer extends BasePlayer
private int captionPopupMenuGroupId = 89;
private PopupMenu captionPopupMenu;
private ImageButton buttonPlayPause;
///////////////////////////////////////////////////////////////////////////
public VideoPlayer(String debugTag, Context context) {
@ -211,6 +214,9 @@ public abstract class VideoPlayer extends BasePlayer
((ProgressBar) this.loadingPanel.findViewById(R.id.progressBarLoadingPanel))
.getIndeterminateDrawable().setColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY);
buttonPlayPause = rootView.findViewById(R.id.videoPlayPause);
buttonPlayPause.setTag(1);
}
protected abstract void setupSubtitleView(@NonNull SubtitleView view,
@ -226,6 +232,22 @@ public abstract class VideoPlayer extends BasePlayer
captionTextView.setOnClickListener(this);
resizeView.setOnClickListener(this);
playbackLiveSync.setOnClickListener(this);
buttonPlayPause.setOnClickListener(new View.OnClickListener() {
public void onClick(View ib) {
if((int)ib.getTag()==2) {
onPlay();
ib.setBackgroundResource(R.drawable.ic_pause_white);
ib.setTag(1);
} else {
ib.setBackgroundResource(R.drawable.ic_play_arrow_white);
onPause();
ib.setTag(2);
}
}
});
}
@Override
@ -864,18 +886,68 @@ public abstract class VideoPlayer extends BasePlayer
controlViewAnimator.start();
}
public void showPlayPause(final int drawableId) {
if (DEBUG) Log.d(TAG, "showAndAnimateControl() called with: drawableId = [" + drawableId + "], goneOnEnd = [" + false + "]");
if (controlViewAnimator != null && controlViewAnimator.isRunning()) {
if (DEBUG) Log.d(TAG, "showAndAnimateControl: controlViewAnimator.isRunning");
controlViewAnimator.end();
}
if (drawableId == -1) {
if (controlAnimationView.getVisibility() == View.VISIBLE) {
controlViewAnimator = ObjectAnimator.ofPropertyValuesHolder(controlAnimationView,
PropertyValuesHolder.ofFloat(View.ALPHA, 1f, 0f),
PropertyValuesHolder.ofFloat(View.SCALE_X, 1.4f, 1f),
PropertyValuesHolder.ofFloat(View.SCALE_Y, 1.4f, 1f)
).setDuration(DEFAULT_CONTROLS_DURATION);
controlViewAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
controlAnimationView.setVisibility(View.GONE);
}
});
controlViewAnimator.start();
}
return;
}
float scaleFrom = 1f, scaleTo = 1.4f;
float alphaFrom = 0f, alphaTo = 1f;
controlViewAnimator = ObjectAnimator.ofPropertyValuesHolder(controlAnimationView,
PropertyValuesHolder.ofFloat(View.ALPHA, alphaFrom, alphaTo),
PropertyValuesHolder.ofFloat(View.SCALE_X, scaleFrom, scaleTo),
PropertyValuesHolder.ofFloat(View.SCALE_Y, scaleFrom, scaleTo)
);
controlViewAnimator.setDuration(500);
controlViewAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
controlAnimationView.setVisibility(View.VISIBLE);
}
});
controlAnimationView.setVisibility(View.VISIBLE);
controlAnimationView.setImageDrawable(ContextCompat.getDrawable(context, drawableId));
controlViewAnimator.start();
}
public boolean isSomePopupMenuVisible() {
return isSomePopupMenuVisible;
}
public void showControlsThenHide() {
if (DEBUG) Log.d(TAG, "showControlsThenHide() called");
buttonPlayPause.setVisibility(View.VISIBLE);
animateView(controlsRoot, true, DEFAULT_CONTROLS_DURATION, 0,
() -> hideControls(DEFAULT_CONTROLS_DURATION, DEFAULT_CONTROLS_HIDE_TIME));
}
public void showControls(long duration) {
if (DEBUG) Log.d(TAG, "showControls() called");
buttonPlayPause.setVisibility(View.VISIBLE);
controlsVisibilityHandler.removeCallbacksAndMessages(null);
animateView(controlsRoot, true, duration);
}
@ -883,8 +955,15 @@ public abstract class VideoPlayer extends BasePlayer
public void hideControls(final long duration, long delay) {
if (DEBUG) Log.d(TAG, "hideControls() called with: delay = [" + delay + "]");
controlsVisibilityHandler.removeCallbacksAndMessages(null);
controlsVisibilityHandler.postDelayed(
() -> animateView(controlsRoot, false, duration), delay);
controlsVisibilityHandler.postDelayed(hideControlsHandler(duration), delay);
}
private Runnable hideControlsHandler(long duration)
{
return () -> {
buttonPlayPause.setVisibility(View.INVISIBLE);
animateView(controlsRoot, false,duration);
};
}
/*//////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -101,17 +102,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 +134,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-->
@ -216,6 +218,21 @@
android:weightSum="5.5">
<!--tools:visibility="gone">-->
<ImageButton
android:id="@+id/videoPlayPause"
android:layout_width="30dp"
android:layout_height="60dp"
android:layout_alignParentRight="true"
android:layout_weight="1"
android:background="@drawable/ic_pause_white"
android:clickable="true"
android:focusable="true"
android:scaleType="centerInside"
android:scaleX="1"
android:scaleY="1"
android:visibility="invisible"
tools:ignore="ContentDescription,RtlHardcoded" />
<ImageView
android:id="@+id/controlAnimationView"
android:layout_width="0dp"