summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2016-04-20 23:54:14 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2016-04-20 23:54:14 -0700
commit2da109a668171d90ae07cfe894a1930741b428b3 (patch)
treef738fd8e5f4123262035dbe042f2ccc7263407b6 /src/com
parent45e77b8fe6a6fb9f30622e7cca76be7d959d27f7 (diff)
parent52e876d66572992b1a40e3fe76330f5747bfb7b4 (diff)
downloadandroid_packages_apps_Gallery2-2da109a668171d90ae07cfe894a1930741b428b3.tar.gz
android_packages_apps_Gallery2-2da109a668171d90ae07cfe894a1930741b428b3.tar.bz2
android_packages_apps_Gallery2-2da109a668171d90ae07cfe894a1930741b428b3.zip
Merge "Gallery2: Add video snapshot function according to UI spec." into android_ui.lnx.1.2-dev
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/gallery3d/app/MovieControllerOverlayNew.java110
-rwxr-xr-xsrc/com/android/gallery3d/app/MoviePlayer.java4
2 files changed, 112 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/app/MovieControllerOverlayNew.java b/src/com/android/gallery3d/app/MovieControllerOverlayNew.java
index 135591c05..e9e44edb7 100644
--- a/src/com/android/gallery3d/app/MovieControllerOverlayNew.java
+++ b/src/com/android/gallery3d/app/MovieControllerOverlayNew.java
@@ -30,16 +30,21 @@
package com.android.gallery3d.app;
import android.content.Context;
+import android.graphics.Color;
import android.graphics.Rect;
import android.view.MotionEvent;
import android.view.View;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
import android.widget.ImageView;
+import org.codeaurora.gallery3d.video.IVideoSnapshotListener;
+import org.codeaurora.gallery3d.video.IControllerRewindAndForward;
import com.android.gallery3d.R;
-import org.codeaurora.gallery3d.video.IControllerRewindAndForward;
-
public class MovieControllerOverlayNew extends MovieControllerOverlay {
+ private VideoSnapshotLayout mVideoSnapshotLayout = new VideoSnapshotLayout();
+ private IVideoSnapshotListener mVideoSnapshotListener;
private boolean mIsLive = false;
private ImageView mLiveImage;
@@ -49,6 +54,8 @@ public class MovieControllerOverlayNew extends MovieControllerOverlay {
public MovieControllerOverlayNew(Context context) {
super(context);
+
+ mVideoSnapshotLayout.init(context);
mLiveImage = ((MovieActivity) mContext).getLiveImage();
mStopBtn = mControllerRewindAndForwardExt.getStopBtn();
mLiveMargin = context.getResources().getDimensionPixelSize(
@@ -116,6 +123,13 @@ public class MovieControllerOverlayNew extends MovieControllerOverlay {
}
mTimeBar.layout(mTimeBar.getPreferredHeight(), y - mTimeBar.getPreferredHeight(),
width - mScreenModeExt.getAddedRightPadding(), y);
+
+ mVideoSnapshotLayout.layoutButton(
+ w - pr - mVideoSnapshotLayout.getButtonWidth(),
+ y - mTimeBar.getPreferredHeight() - mVideoSnapshotLayout.getButtonHeight(),
+ w - pr,
+ y - mTimeBar.getPreferredHeight());
+ mVideoSnapshotLayout.layoutAnim(left, top, right, bottom);
}
public void setLive(boolean live) {
@@ -134,4 +148,96 @@ public class MovieControllerOverlayNew extends MovieControllerOverlay {
return false;
}
+ public void setVideoSnapshotListener(IVideoSnapshotListener listener) {
+ mVideoSnapshotListener = listener;
+ }
+
+ public void showVideoSnapshotButton(boolean show) {
+ if (mVideoSnapshotLayout != null) {
+ mVideoSnapshotLayout.showVideoSnapshotButton(show);
+ }
+ }
+
+ class VideoSnapshotLayout implements View.OnClickListener {
+ private ImageView mVideoSnapshotButton;
+ private ImageView mVideoSnapshotAnimView;
+ private Animation mVideoSnapshotAnimation;
+
+ public void init(Context context) {
+ LayoutParams wrapContent =
+ new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
+ mVideoSnapshotButton = new ImageView(context);
+ mVideoSnapshotButton.setImageResource(R.drawable.ic_video_snapshot_padding);
+ mVideoSnapshotButton.setScaleType(ImageView.ScaleType.CENTER);
+ mVideoSnapshotButton.setFocusable(true);
+ mVideoSnapshotButton.setClickable(true);
+ mVideoSnapshotButton.setOnClickListener(this);
+ addView(mVideoSnapshotButton, wrapContent);
+
+ LayoutParams matchParent =
+ new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
+ mVideoSnapshotAnimView = new ImageView(context);
+ addView(mVideoSnapshotAnimView, matchParent);
+
+ mVideoSnapshotAnimation = AnimationUtils.loadAnimation(context, R.anim.player_out);
+ mVideoSnapshotAnimation.setAnimationListener(new Animation.AnimationListener() {
+ @Override
+ public void onAnimationStart(Animation animation) {
+ mVideoSnapshotAnimView.setBackgroundColor(Color.WHITE);
+ mVideoSnapshotButton.setEnabled(false);
+ }
+
+ @Override
+ public void onAnimationEnd(Animation animation) {
+ mVideoSnapshotAnimView.setBackgroundColor(Color.TRANSPARENT);
+ mVideoSnapshotButton.setEnabled(true);
+ }
+
+ @Override
+ public void onAnimationRepeat(Animation animation) {
+ }
+ });
+ }
+
+ public int getButtonWidth() {
+ return mVideoSnapshotButton == null ? 0 : mVideoSnapshotButton.getMeasuredWidth();
+ }
+
+ public int getButtonHeight() {
+ return mVideoSnapshotButton == null ? 0 : mVideoSnapshotButton.getMeasuredHeight();
+ }
+
+ public void layoutButton(int l, int t, int r, int b) {
+ if (mVideoSnapshotButton != null) {
+ mVideoSnapshotButton.layout(l, t, r, b);
+ }
+ }
+
+ public void layoutAnim(int l, int t, int r, int b) {
+ if (mVideoSnapshotAnimView != null) {
+ mVideoSnapshotAnimView.layout(l, t, r, b);
+ }
+ }
+
+ public void showVideoSnapshotButton(boolean show) {
+ if (mVideoSnapshotButton != null) {
+ mVideoSnapshotButton.setVisibility(show ? VISIBLE : GONE);
+ }
+ }
+
+ @Override
+ public void onClick(View v) {
+ maybeStartHiding();
+ if (mVideoSnapshotListener != null && mVideoSnapshotListener.canVideoSnapshot()) {
+ mVideoSnapshotListener.onVideoSnapshot();
+ startAnimation();
+ }
+ }
+
+ private void startAnimation() {
+ if (mVideoSnapshotAnimView != null) {
+ mVideoSnapshotAnimView.startAnimation(mVideoSnapshotAnimation);
+ }
+ }
+ }
}
diff --git a/src/com/android/gallery3d/app/MoviePlayer.java b/src/com/android/gallery3d/app/MoviePlayer.java
index 1f6401ee5..8581f80e8 100755
--- a/src/com/android/gallery3d/app/MoviePlayer.java
+++ b/src/com/android/gallery3d/app/MoviePlayer.java
@@ -62,6 +62,7 @@ import org.codeaurora.gallery3d.video.IControllerRewindAndForward.IRewindAndForw
import org.codeaurora.gallery3d.video.ScreenModeManager;
import org.codeaurora.gallery3d.video.ScreenModeManager.ScreenModeListener;
import org.codeaurora.gallery3d.video.CodeauroraVideoView;
+import org.codeaurora.gallery3d.video.VideoSnapshotExt;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -161,6 +162,8 @@ public class MoviePlayer implements
private IMovieItem mMovieItem;
private int mVideoLastDuration;//for duration displayed in init state
+ private VideoSnapshotExt mVideoSnapshotExt = new VideoSnapshotExt();
+
private enum TState {
PLAYING,
PAUSED,
@@ -364,6 +367,7 @@ public class MoviePlayer implements
}
}
mScreenModeExt.setScreenMode();
+ mVideoSnapshotExt.init(mController, mVideoView, isLocalFile());
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)