diff options
author | ByteHamster <info@bytehamster.com> | 2020-04-04 00:40:58 +0200 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2020-04-04 11:03:53 +0200 |
commit | 658ae3d43fd5c17c47491df70c5dad4ff9eb411e (patch) | |
tree | ad5261c3134ffc58824aa970b530758141e525e5 /app/src/main/java/de/danoeh | |
parent | 0d9587f09c1e1285b2804ad520b62110b05c6f5e (diff) | |
download | AntennaPod-658ae3d43fd5c17c47491df70c5dad4ff9eb411e.zip |
Double-tap video to skip
Diffstat (limited to 'app/src/main/java/de/danoeh')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java index cb79a9265..8c66b6a4c 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java @@ -6,6 +6,11 @@ import android.graphics.drawable.ColorDrawable; import android.os.Build; import android.os.Bundle; import android.os.Handler; +import android.view.Gravity; +import android.view.animation.AlphaAnimation; +import android.view.animation.AnimationSet; +import android.view.animation.ScaleAnimation; +import android.widget.ImageView; import androidx.core.view.WindowCompat; import androidx.appcompat.app.ActionBar; import android.text.TextUtils; @@ -48,6 +53,7 @@ public class VideoplayerActivity extends MediaplayerActivity { private boolean videoControlsShowing = true; private boolean videoSurfaceCreated = false; private boolean destroyingDueToReload = false; + private long lastScreenTap = 0; private VideoControlsHider videoControlsHider = new VideoControlsHider(this); @@ -58,6 +64,7 @@ public class VideoplayerActivity extends MediaplayerActivity { private AspectRatioVideoView videoview; private ProgressBar progressIndicator; private FrameLayout videoframe; + private ImageView skipAnimationView; @Override protected void chooseTheme() { @@ -148,6 +155,7 @@ public class VideoplayerActivity extends MediaplayerActivity { videoview = findViewById(R.id.videoview); videoframe = findViewById(R.id.videoframe); progressIndicator = findViewById(R.id.progressIndicator); + skipAnimationView = findViewById(R.id.skip_animation); videoview.getHolder().addCallback(surfaceHolderCallback); videoframe.setOnTouchListener(onVideoviewTouched); videoOverlay.setOnTouchListener((view, motionEvent) -> true); // To suppress touches directly below the slider @@ -177,16 +185,72 @@ public class VideoplayerActivity extends MediaplayerActivity { return true; } videoControlsHider.stop(); + + if (System.currentTimeMillis() - lastScreenTap < 300) { + if (event.getX() > v.getMeasuredWidth() / 2) { + onFastForward(); + showSkipAnimation(true); + } else { + onRewind(); + showSkipAnimation(false); + } + if (videoControlsShowing) { + getSupportActionBar().hide(); + hideVideoControls(false); + videoControlsShowing = false; + } + return true; + } + toggleVideoControlsVisibility(); if (videoControlsShowing) { setupVideoControlsToggler(); } + + lastScreenTap = System.currentTimeMillis(); return true; } else { return false; } }; + private void showSkipAnimation(boolean isForward) { + AnimationSet skipAnimation = new AnimationSet(true); + skipAnimation.addAnimation(new ScaleAnimation(1f, 2f, 1f, 2f, + Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f)); + skipAnimation.addAnimation(new AlphaAnimation(1f, 0f)); + skipAnimation.setFillAfter(false); + skipAnimation.setDuration(800); + + FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) skipAnimationView.getLayoutParams(); + if (isForward) { + skipAnimationView.setImageResource(R.drawable.ic_av_fast_forward_white_80dp); + params.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL; + } else { + skipAnimationView.setImageResource(R.drawable.ic_av_fast_rewind_white_80dp); + params.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL; + } + + skipAnimationView.setVisibility(View.VISIBLE); + skipAnimationView.setLayoutParams(params); + skipAnimationView.startAnimation(skipAnimation); + skipAnimation.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + } + + @Override + public void onAnimationEnd(Animation animation) { + skipAnimationView.setVisibility(View.GONE); + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + }); + } + @SuppressLint("NewApi") private void setupVideoControlsToggler() { videoControlsHider.stop(); |