Gallery2: Add gesture controller in MoviePlayer according to UI spec.
1. Add gesture controller in MoviePlayer according to UI spec,
include adjust brightness, adjust volume, adjust video position.
2. Tap screen when system ui is shown, hide system ui immediately.
Change-Id: I759246baa1efb18cd525716da59a314ecefaf163
CRs-Fixed: 988590
diff --git a/res/drawable-hdpi/bg_controller_indicator.9.png b/res/drawable-hdpi/bg_controller_indicator.9.png
new file mode 100644
index 0000000..e90e9f7
--- /dev/null
+++ b/res/drawable-hdpi/bg_controller_indicator.9.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_menu_disabled_forward.png b/res/drawable-hdpi/ic_menu_disabled_forward.png
deleted file mode 100644
index c9683df..0000000
--- a/res/drawable-hdpi/ic_menu_disabled_forward.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_menu_disabled_rewind.png b/res/drawable-hdpi/ic_menu_disabled_rewind.png
deleted file mode 100644
index 1f74fb8..0000000
--- a/res/drawable-hdpi/ic_menu_disabled_rewind.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_menu_forward.png b/res/drawable-hdpi/ic_menu_forward.png
deleted file mode 100644
index 4680082..0000000
--- a/res/drawable-hdpi/ic_menu_forward.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_menu_rewind.png b/res/drawable-hdpi/ic_menu_rewind.png
deleted file mode 100644
index 37c5708..0000000
--- a/res/drawable-hdpi/ic_menu_rewind.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_menu_disabled_forward.png b/res/drawable-mdpi/ic_menu_disabled_forward.png
deleted file mode 100644
index bbc8920..0000000
--- a/res/drawable-mdpi/ic_menu_disabled_forward.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_menu_disabled_rewind.png b/res/drawable-mdpi/ic_menu_disabled_rewind.png
deleted file mode 100644
index 28acd42..0000000
--- a/res/drawable-mdpi/ic_menu_disabled_rewind.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_menu_forward.png b/res/drawable-mdpi/ic_menu_forward.png
deleted file mode 100644
index 85b7057..0000000
--- a/res/drawable-mdpi/ic_menu_forward.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_menu_rewind.png b/res/drawable-mdpi/ic_menu_rewind.png
deleted file mode 100644
index 8b46eee..0000000
--- a/res/drawable-mdpi/ic_menu_rewind.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/bg_controller_indicator.9.png b/res/drawable-xhdpi/bg_controller_indicator.9.png
new file mode 100644
index 0000000..203a93b
--- /dev/null
+++ b/res/drawable-xhdpi/bg_controller_indicator.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_menu_disabled_forward.png b/res/drawable-xhdpi/ic_menu_disabled_forward.png
deleted file mode 100644
index e73d4d4..0000000
--- a/res/drawable-xhdpi/ic_menu_disabled_forward.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_menu_disabled_rewind.png b/res/drawable-xhdpi/ic_menu_disabled_rewind.png
deleted file mode 100644
index ad3be64..0000000
--- a/res/drawable-xhdpi/ic_menu_disabled_rewind.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_menu_forward.png b/res/drawable-xhdpi/ic_menu_forward.png
deleted file mode 100644
index f225ffc..0000000
--- a/res/drawable-xhdpi/ic_menu_forward.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_menu_rewind.png b/res/drawable-xhdpi/ic_menu_rewind.png
deleted file mode 100644
index fbfa5ca..0000000
--- a/res/drawable-xhdpi/ic_menu_rewind.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/bg_controller_indicator.9.png b/res/drawable-xxhdpi/bg_controller_indicator.9.png
new file mode 100644
index 0000000..093f136
--- /dev/null
+++ b/res/drawable-xxhdpi/bg_controller_indicator.9.png
Binary files differ
diff --git a/res/drawable/ic_controller_brightness.xml b/res/drawable/ic_controller_brightness.xml
new file mode 100644
index 0000000..8c912fc
--- /dev/null
+++ b/res/drawable/ic_controller_brightness.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (c) 2016, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="108.0"
+ android:viewportWidth="108.0">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M87.94,39.94L87.94,20.06L68.06,20.06L54,6 39.94,20.06L20.06,20.06L20.06,39.94L6,54l14.06,14.06v19.88h19.88L54,102l14.06,-14.06h19.88L87.94,68.06L102,54ZM54,78a24,24 0,1 1,24 -24A24,24 0,0 1,54 78ZM54,36a18,18 0,1 0,18 18A18,18 0,0 0,54 36Z"/>
+</vector>
diff --git a/res/drawable/ic_controller_volume.xml b/res/drawable/ic_controller_volume.xml
new file mode 100644
index 0000000..39b2440
--- /dev/null
+++ b/res/drawable/ic_controller_volume.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (c) 2016, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="108.0"
+ android:viewportWidth="108.0">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M33,32.04L12,32.04a5.99,5.99 0,0 0,-6 5.99v31.93a5.99,5.99 0,0 0,6 5.99L33,75.95v-0.04l23.98,18.63a1.88,1.88 0,0 0,3.03 -1.48L60.01,14.93a1.88,1.88 0,0 0,-3.03 -1.48L33,32.08L33,32.04ZM72.58,26.48 L66.21,32.83a29.89,29.89 0,0 1,0 42.33l6.36,6.35A38.85,38.85 0,0 0,72.58 26.48ZM85.3,13.78 L78.94,20.13a47.82,47.82 0,0 1,0 67.74l6.36,6.35A56.79,56.79 0,0 0,85.3 13.78Z"/>
+</vector>
diff --git a/res/drawable/ic_menu_disabled_forward.xml b/res/drawable/ic_menu_disabled_forward.xml
new file mode 100644
index 0000000..2927aee
--- /dev/null
+++ b/res/drawable/ic_menu_disabled_forward.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (c) 2016, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="108.0"
+ android:viewportWidth="108.0">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:fillAlpha="0.30"
+ android:pathData="M47,22v64l50,-32ZM11,22v64l50,-32Z"/>
+</vector>
diff --git a/res/drawable/ic_menu_disabled_rewind.xml b/res/drawable/ic_menu_disabled_rewind.xml
new file mode 100644
index 0000000..e63a188
--- /dev/null
+++ b/res/drawable/ic_menu_disabled_rewind.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (c) 2016, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="108.0"
+ android:viewportWidth="108.0">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:fillAlpha="0.30"
+ android:pathData="M61,22v64l-50,-32ZM97,22v64l-50,-32Z"/>
+</vector>
diff --git a/res/drawable/ic_menu_forward.xml b/res/drawable/ic_menu_forward.xml
new file mode 100644
index 0000000..da3482a
--- /dev/null
+++ b/res/drawable/ic_menu_forward.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (c) 2016, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="108.0"
+ android:viewportWidth="108.0">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M47,22v64l50,-32ZM11,22v64l50,-32Z"/>
+</vector>
diff --git a/res/drawable/ic_menu_rewind.xml b/res/drawable/ic_menu_rewind.xml
new file mode 100644
index 0000000..a044914
--- /dev/null
+++ b/res/drawable/ic_menu_rewind.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (c) 2016, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportHeight="108.0"
+ android:viewportWidth="108.0">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M61,22v64l-50,-32ZM97,22v64l-50,-32Z"/>
+</vector>
diff --git a/res/layout/movie_view.xml b/res/layout/movie_view.xml
index 3a412e1..de9584b 100644
--- a/res/layout/movie_view.xml
+++ b/res/layout/movie_view.xml
@@ -30,6 +30,7 @@
android:id="@+id/img_live"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:src="@drawable/ic_media_live"/>
</RelativeLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 6b5a515..8078611 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -218,4 +218,12 @@
<dimen name="timebar_margin">30dp</dimen>
<dimen name="timebar_time_margin">45dp</dimen>
<dimen name="livestream_icon_padding">12dp</dimen>
+
+ <!-- configuration for gesture controller indicator. -->
+ <dimen name="controller_indicator_width">80dp</dimen>
+ <dimen name="controller_indicator_height">90dp</dimen>
+ <dimen name="controller_indicator_padding_v">15dp</dimen>
+ <dimen name="controller_indicator_padding_h">10dp</dimen>
+ <dimen name="controller_indicator_icon_size">36dp</dimen>
+ <dimen name="controller_indicator_text_size">16sp</dimen>
</resources>
diff --git a/src/com/android/gallery3d/app/GestureController.java b/src/com/android/gallery3d/app/GestureController.java
new file mode 100644
index 0000000..51ca04d
--- /dev/null
+++ b/src/com/android/gallery3d/app/GestureController.java
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.android.gallery3d.app;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.view.GestureDetector;
+import android.view.MotionEvent;
+
+public class GestureController {
+ private static final int GESTURE_THRESHOLD = 20;
+ private GestureDetector mGestureDetector;
+ private GestureControlListener mGestureControlListener;
+
+ private Rect mFullRect = new Rect();
+ private Rect mBrightnessRect = new Rect();
+ private Rect mVolumeRect = new Rect();
+ private Type mType = Type.NONE;
+
+ private MotionEvent mStartEvent;
+
+ public GestureController(Context context, GestureControlListener gestureControlListener) {
+ mGestureControlListener = gestureControlListener;
+ mGestureDetector =
+ new GestureDetector(context, new GestureListener(gestureControlListener));
+ }
+
+ public interface GestureControlListener {
+ void onGestureDone(boolean notStart);
+ /**
+ * change current windows brightness by add adjustPercent.
+ *
+ * @param adjustPercent: -1.0f ~ 1.0f, increase if adjustPercent > 0,
+ * decrease if adjustPercent < 0;
+ */
+ void adjustBrightness(double adjustPercent);
+
+ /**
+ * change volume level by add adjustPercent.
+ *
+ * @param adjustPercent: -1.0f ~ 1.0f, increase if adjustPercent > 0,
+ * decrease if adjustPercent < 0;
+ */
+ void adjustVolumeLevel(double adjustPercent);
+
+ /**
+ * change video position by add adjustPercent.
+ *
+ * @param adjustPercent: -1.0f ~ 1.0f, increase if adjustPercent > 0,
+ * decrease if adjustPercent < 0;
+ * @param forwardDirection: true if direction is forward.
+ */
+ void adjustVideoPosition(double adjustPercent, boolean forwardDirection);
+ }
+
+ private enum Type {
+ NONE,
+ BRIGHTNESS,
+ VOLUME,
+ SEEK,
+ }
+
+ public void setRect(Rect rect) {
+ this.setRect(rect.left, rect.top, rect.right, rect.bottom);
+ }
+
+ public void setRect(int l, int t, int r, int b) {
+ mFullRect.left = l;
+ mFullRect.top = t;
+ mFullRect.right = r;
+ mFullRect.bottom = b;
+
+ mBrightnessRect.left = l;
+ mBrightnessRect.top = t;
+ mBrightnessRect.right = r / 2;
+ mBrightnessRect.bottom = b;
+
+ mVolumeRect.left = l / 2;
+ mVolumeRect.top = t;
+ mVolumeRect.right = r;
+ mVolumeRect.bottom = b;
+ }
+
+ private class GestureListener extends GestureDetector.SimpleOnGestureListener {
+ private GestureControlListener mGestureControlListener;
+
+ public GestureListener(GestureControlListener controlListener) {
+ mGestureControlListener = controlListener;
+ }
+
+ @Override
+ public boolean onScroll(MotionEvent start, MotionEvent end,
+ float distanceX, float distanceY) {
+ if (mGestureControlListener == null) {
+ return super.onScroll(start, end, distanceX, distanceY);
+ }
+ // function depends on start position. (volume or brightness or play position.)
+ double yDistance = end.getY() - start.getY();
+ double xDistance = end.getX() - start.getX();
+
+ if (mType == Type.BRIGHTNESS) {
+ // use half of BrightnessRect's height to calc percent.
+ if (mBrightnessRect.height() != 0) {
+ double percent = yDistance / (mBrightnessRect.height() / 2.0f) * -1.0f;
+ mGestureControlListener.adjustBrightness(percent);
+ }
+ } else if (mType == Type.VOLUME) {
+ // use half of VolumeRect's height to calc percent.
+ if (mVolumeRect.height() != 0) {
+ double percent = yDistance / (mVolumeRect.height() / 2.0f) * -1.0f;
+ mGestureControlListener.adjustVolumeLevel(percent);
+ }
+ } else if (mType == Type.SEEK) {
+ if (mFullRect.width() != 0) {
+ double percent = xDistance / mFullRect.width();
+ mGestureControlListener.adjustVideoPosition(percent, distanceX < 0);
+ }
+ }
+ return true;
+ }
+ }
+
+ private boolean isEventValid(MotionEvent event) {
+ // this gesture just worked on single pointer.
+ return (mGestureDetector != null && event.getPointerCount() == 1);
+ }
+
+ public boolean onTouchEvent(MotionEvent event) {
+ if (!isEventValid(event)) {
+ return false;
+ }
+ // decide which process is needed.
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ mStartEvent = event.copy();
+ break;
+ case MotionEvent.ACTION_MOVE:
+ if (mType == Type.NONE && mStartEvent != null) {
+ mType = calcControllerType(mStartEvent, event);
+ }
+ break;
+ case MotionEvent.ACTION_UP:
+ if (mGestureControlListener != null) {
+ if (mType == Type.NONE) {
+ mGestureControlListener.onGestureDone(true);
+ } else {
+ mGestureControlListener.onGestureDone(false);
+ }
+ }
+ mType = Type.NONE;
+ mStartEvent = null;
+ break;
+ default:
+ break;
+ }
+
+ return mGestureDetector.onTouchEvent(event);
+ }
+
+ private Type calcControllerType(MotionEvent startEvent, MotionEvent currentEvent) {
+ float startX = startEvent.getX();
+ float startY = startEvent.getY();
+ float currentX = currentEvent.getX();
+ float currentY = currentEvent.getY();
+ if (Math.abs(currentX - startX) >= GESTURE_THRESHOLD) {
+ return Type.SEEK;
+ } else if (Math.abs(currentY - startY) >= GESTURE_THRESHOLD) {
+ if (mBrightnessRect.contains((int) startX, (int) startY)) {
+ return Type.BRIGHTNESS;
+ } else if (mVolumeRect.contains((int) startX, (int) startY)) {
+ return Type.VOLUME;
+ }
+ }
+ return Type.NONE;
+ }
+}
diff --git a/src/com/android/gallery3d/app/GestureControllerOverlay.java b/src/com/android/gallery3d/app/GestureControllerOverlay.java
new file mode 100644
index 0000000..c97245c
--- /dev/null
+++ b/src/com/android/gallery3d/app/GestureControllerOverlay.java
@@ -0,0 +1,401 @@
+/*
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.android.gallery3d.app;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Color;
+import android.graphics.drawable.Drawable;
+import android.media.AudioManager;
+import android.util.TypedValue;
+import android.view.Gravity;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.FrameLayout;
+
+import android.widget.TextView;
+import com.android.gallery3d.R;
+import com.android.gallery3d.util.GalleryUtils;
+
+public class GestureControllerOverlay extends FrameLayout implements
+ ControllerOverlay, GestureController.GestureControlListener {
+ private GestureController mGestureController;
+
+ private static final int MAX_VIDEO_STEP_TIME = 2 * 60 * 1000;
+ private static final int MAX_BRIGHTNESS = 100;
+ private static final int INDICATOR_FADE_OUT_TIME = 200; // millisecond
+
+ private float mStartBrightness = -1.0f;
+ private double mStartVolumePercent = -1.0f;
+ private int mStartVideoTime = -1;
+
+ private TextView mCurrentIndicator;
+ private Drawable mBrightnessDrawable;
+ private Drawable mVolumeDrawable;
+ private Drawable mRewindDrawable;
+ private Drawable mForwardDrawable;
+
+ private final int mIndicatorHeight;
+ private final int mIndicatorWidth;
+ private final int mIndicatorIconSize;
+ private final int mIndicatorTextSize;
+
+ private Listener mListener;
+ private TimeBar mTimeBar;
+
+ private CommonControllerOverlay mControllerOverlay;
+ private boolean mSystemUiVisible = false;
+
+ public GestureControllerOverlay(Context context) {
+ super(context);
+ Resources res = getResources();
+ mIndicatorHeight = res.getDimensionPixelSize(R.dimen.controller_indicator_height);
+ mIndicatorWidth = res.getDimensionPixelSize(R.dimen.controller_indicator_width);
+ mIndicatorIconSize = res.getDimensionPixelSize(R.dimen.controller_indicator_icon_size);
+ mIndicatorTextSize = res.getDimensionPixelSize(R.dimen.controller_indicator_text_size);
+ init(context);
+ }
+
+ public GestureControllerOverlay(Context context,
+ MovieControllerOverlay movieControllerOverlay) {
+ this(context);
+ mControllerOverlay = movieControllerOverlay;
+ if (movieControllerOverlay instanceof MovieControllerOverlayNew) {
+ mTimeBar = ((MovieControllerOverlayNew) movieControllerOverlay).getTimeBar();
+ }
+ }
+
+ private void init(Context context) {
+ mGestureController = new GestureController(context, this);
+
+ mBrightnessDrawable = getResources().getDrawable(R.drawable.ic_controller_brightness, null);
+ if (mBrightnessDrawable != null) {
+ mBrightnessDrawable.setBounds(0, 0, mIndicatorIconSize, mIndicatorIconSize);
+ }
+
+ mVolumeDrawable = getResources().getDrawable(R.drawable.ic_controller_volume, null);
+ if (mVolumeDrawable != null) {
+ mVolumeDrawable.setBounds(0, 0, mIndicatorIconSize, mIndicatorIconSize);
+ }
+
+ mRewindDrawable = getResources().getDrawable(R.drawable.ic_menu_rewind, null);
+ if (mRewindDrawable != null) {
+ mRewindDrawable.setBounds(0, 0, mIndicatorIconSize, mIndicatorIconSize);
+ }
+
+ mForwardDrawable = getResources().getDrawable(R.drawable.ic_menu_forward, null);
+ if (mForwardDrawable != null) {
+ mForwardDrawable.setBounds(0, 0, mIndicatorIconSize, mIndicatorIconSize);
+ }
+
+ LayoutParams matchParent =
+ new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
+ View background = new View(context);
+ background.setBackgroundColor(Color.TRANSPARENT);
+ addView(background, matchParent);
+
+ LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, mIndicatorHeight);
+ int paddingH = getResources().getDimensionPixelSize(R.dimen.controller_indicator_padding_h);
+ int paddingV = getResources().getDimensionPixelSize(R.dimen.controller_indicator_padding_v);
+ mCurrentIndicator = new TextView(context);
+ mCurrentIndicator.setBackgroundResource(R.drawable.bg_controller_indicator);
+ mCurrentIndicator.setPadding(paddingH, paddingV, paddingH, paddingV);
+ mCurrentIndicator.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
+ mCurrentIndicator.setTextSize(TypedValue.COMPLEX_UNIT_PX, mIndicatorTextSize);
+ mCurrentIndicator.setMinWidth(mIndicatorWidth);
+ addView(mCurrentIndicator, layoutParams);
+ mCurrentIndicator.setVisibility(INVISIBLE);
+ }
+
+ private void showIndicator() {
+ if (mCurrentIndicator != null) {
+ mCurrentIndicator.setAlpha(1.0f);
+ mCurrentIndicator.setVisibility(VISIBLE);
+ }
+ }
+
+ private void hideIndicator() {
+ if (mCurrentIndicator != null) {
+ mCurrentIndicator.setText(null);
+ mCurrentIndicator.setVisibility(INVISIBLE);
+ }
+ }
+
+ public void doOnPause() {
+ hideIndicator();
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ if (mGestureController != null) {
+ mGestureController.onTouchEvent(event);
+ }
+ return true;
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ measureChildren(widthMeasureSpec, heightMeasureSpec);
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ if (changed && mGestureController != null) {
+ mGestureController.setRect(left, top, right, bottom);
+ }
+
+ int h = bottom - top;
+ int w = right - left;
+
+ if (mCurrentIndicator != null) {
+ layoutCenteredView(mCurrentIndicator, 0, 0, w, h);
+ }
+ }
+
+ protected void layoutCenteredView(View view, int l, int t, int r, int b) {
+ int cw = view.getMeasuredWidth();
+ int ch = view.getMeasuredHeight();
+ int cl = (r - l - cw) / 2;
+ int ct = (b - t - ch) / 2;
+ view.layout(cl, ct, cl + cw, ct + ch);
+ }
+
+ public void setSystemUiVisible(boolean visible) {
+ mSystemUiVisible = visible;
+ }
+
+ @Override
+ public void onGestureDone(boolean notStart) {
+ mStartBrightness = -1.0f;
+ mStartVolumePercent = -1.0f;
+ mStartVideoTime = -1;
+ hideIndicator();
+
+ if (notStart) {
+ if (mSystemUiVisible) {
+ // hide system ui
+ if (mControllerOverlay != null) {
+ mControllerOverlay.hide();
+ }
+ } else {
+ // show system ui
+ if (mControllerOverlay != null) {
+ mControllerOverlay.show();
+ }
+ }
+ }
+ }
+
+ @Override
+ public void adjustBrightness(double adjustPercent) {
+ if (adjustPercent < -1.0f) {
+ adjustPercent = -1.0f;
+ } else if (adjustPercent > 1.0f) {
+ adjustPercent = 1.0f;
+ }
+
+ WindowManager.LayoutParams lp = ((MovieActivity) mContext).getWindow().getAttributes();
+ if (mStartBrightness < 0) {
+ mStartBrightness = lp.screenBrightness;
+ }
+ float targetBrightness = (float) (mStartBrightness + adjustPercent * 1.0f);
+ if (targetBrightness <= 0.0f) {
+ targetBrightness = 0.0f;
+ } else if (targetBrightness >= 1.0f) {
+ targetBrightness = 1.0f;
+ }
+ lp.screenBrightness = targetBrightness;
+ ((MovieActivity) mContext).getWindow().setAttributes(lp);
+
+ if (mCurrentIndicator != null) {
+ mCurrentIndicator.setCompoundDrawables(null, mBrightnessDrawable, null, null);
+ mCurrentIndicator.setText((int) (targetBrightness * MAX_BRIGHTNESS) + "%");
+ }
+ showIndicator();
+ }
+
+ @Override
+ public void adjustVolumeLevel(double adjustPercent) {
+ if (adjustPercent < -1.0f) {
+ adjustPercent = -1.0f;
+ } else if (adjustPercent > 1.0f) {
+ adjustPercent = 1.0f;
+ }
+
+ AudioManager audioManager = (AudioManager) mContext
+ .getSystemService(Context.AUDIO_SERVICE);
+ final int STREAM = AudioManager.STREAM_MUSIC;
+ int maxVolume = audioManager.getStreamMaxVolume(STREAM);
+
+ if (maxVolume == 0) return;
+
+ if (mStartVolumePercent < 0) {
+ int curVolume = audioManager.getStreamVolume(STREAM);
+ mStartVolumePercent = curVolume * 1.0f / maxVolume;
+ }
+ double targetPercent = mStartVolumePercent + adjustPercent;
+ if (targetPercent > 1.0f) {
+ targetPercent = 1.0f;
+ } else if (targetPercent < 0) {
+ targetPercent = 0;
+ }
+
+ int index = (int) (maxVolume * targetPercent);
+ if (index > maxVolume) {
+ index = maxVolume;
+ } else if (index < 0) {
+ index = 0;
+ }
+ audioManager.setStreamVolume(STREAM, index, 0);
+
+ if (mCurrentIndicator != null) {
+ mCurrentIndicator.setCompoundDrawables(null, mVolumeDrawable, null, null);
+ mCurrentIndicator.setText(index * 100 / maxVolume + "%");
+ }
+ showIndicator();
+ }
+
+ @Override
+ public void adjustVideoPosition(double adjustPercent, boolean forwardDirection) {
+ if (mTimeBar == null || !(mTimeBar instanceof TimeBarNew)) {
+ return;
+ }
+
+ if (!((TimeBarNew) mTimeBar).seekable() || !mTimeBar.getScrubbing()
+ || !mTimeBar.isClickable()) {
+ return;
+ }
+
+ if (adjustPercent < -1.0f) {
+ adjustPercent = -1.0f;
+ } else if (adjustPercent > 1.0f) {
+ adjustPercent = 1.0f;
+ }
+
+ int totalTime = ((TimeBarNew) mTimeBar).getTotalTime();
+
+ if (mStartVideoTime < 0) {
+ mStartVideoTime = ((TimeBarNew) mTimeBar).getCurrentTime();
+ }
+
+ int targetTime = mStartVideoTime + (int) (MAX_VIDEO_STEP_TIME * adjustPercent);
+ if (targetTime > totalTime) {
+ targetTime = totalTime;
+ }
+ if (targetTime < 0) {
+ targetTime = 0;
+ }
+
+ String targetTimeString = GalleryUtils.formatDuration(getContext(), targetTime / 1000);
+
+ if (forwardDirection) {
+ if (mCurrentIndicator != null) {
+ mCurrentIndicator.setCompoundDrawables(null, mForwardDrawable, null, null);
+ mCurrentIndicator.setText(targetTimeString);
+ }
+ } else {
+ if (mCurrentIndicator != null) {
+ mCurrentIndicator.setCompoundDrawables(null, mRewindDrawable, null, null);
+ mCurrentIndicator.setText(targetTimeString);
+ }
+ }
+
+ if (mListener != null) {
+ mListener.onSeekEnd(targetTime, 0, 0);
+ }
+ if (mTimeBar != null) {
+ mTimeBar.setTime(targetTime, totalTime, 0, 0);
+ }
+
+ showIndicator();
+ }
+
+ @Override
+ public void setListener(Listener listener) {
+ this.mListener = listener;
+ }
+
+ @Override
+ public void setCanReplay(boolean canReplay) {
+
+ }
+
+ @Override
+ public View getView() {
+ return this;
+ }
+
+ @Override
+ public void show() {
+
+ }
+
+ @Override
+ public void showPlaying() {
+
+ }
+
+ @Override
+ public void showPaused() {
+
+ }
+
+ @Override
+ public void showEnded() {
+
+ }
+
+ @Override
+ public void showLoading() {
+
+ }
+
+ @Override
+ public void showErrorMessage(String message) {
+
+ }
+
+ @Override
+ public void setTimes(int currentTime, int totalTime, int trimStartTime, int trimEndTime) {
+
+ }
+
+ @Override
+ public void setViewEnabled(boolean isEnabled) {
+
+ }
+
+ @Override
+ public void setPlayPauseReplayResume() {
+
+ }
+}
diff --git a/src/com/android/gallery3d/app/MovieControllerOverlay.java b/src/com/android/gallery3d/app/MovieControllerOverlay.java
index 82b0181..4d497ac 100644
--- a/src/com/android/gallery3d/app/MovieControllerOverlay.java
+++ b/src/com/android/gallery3d/app/MovieControllerOverlay.java
@@ -30,26 +30,18 @@
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
-import android.view.View.OnClickListener;
import android.view.ViewGroup;
-import android.view.ViewGroup.LayoutParams;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
-import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
-import android.widget.ProgressBar;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
import com.android.gallery3d.R;
-import com.android.gallery3d.app.CommonControllerOverlay.State;
+
import org.codeaurora.gallery3d.ext.IContrllerOverlayExt;
import org.codeaurora.gallery3d.video.IControllerRewindAndForward;
-import org.codeaurora.gallery3d.video.IControllerRewindAndForward.IRewindAndForwardListener;
-import org.codeaurora.gallery3d.video.ExtensionHelper;
import org.codeaurora.gallery3d.video.ScreenModeManager;
import org.codeaurora.gallery3d.video.ScreenModeManager.ScreenModeListener;
@@ -82,7 +74,7 @@
mContext = context;
handler = new Handler();
startHidingRunnable = new Runnable() {
- @Override
+ @Override
public void run() {
startHiding();
}
@@ -788,10 +780,9 @@
void init(Context context) {
Log.v(TAG, "ControllerRewindAndForwardExt init");
mTimeBarHeight = mTimeBar.getPreferredHeight();
- Bitmap button = BitmapFactory.decodeResource(context.getResources(),
- R.drawable.ic_menu_forward);
- mButtonWidth = button.getWidth();
- button.recycle();
+ VectorDrawable drawable =
+ VectorDrawable.create(context.getResources(), R.drawable.ic_menu_forward);
+ mButtonWidth = drawable.getIntrinsicWidth();
mContollerButtons = new LinearLayout(context);
LinearLayout.LayoutParams wrapContent = new LinearLayout.LayoutParams(
diff --git a/src/com/android/gallery3d/app/MovieControllerOverlayNew.java b/src/com/android/gallery3d/app/MovieControllerOverlayNew.java
index e9e44ed..7d93b2b 100644
--- a/src/com/android/gallery3d/app/MovieControllerOverlayNew.java
+++ b/src/com/android/gallery3d/app/MovieControllerOverlayNew.java
@@ -68,17 +68,13 @@
mTimeBar = new TimeBarNew(context, this);
}
+ public TimeBar getTimeBar() {
+ return mTimeBar;
+ }
+
@Override
public boolean onTouchEvent(MotionEvent event) {
- if (event.getAction() == MotionEvent.ACTION_DOWN) {
- cancelHiding();
- return true;
- } else if (event.getAction() == MotionEvent.ACTION_UP) {
- maybeStartHiding();
- return true;
- } else {
- return super.onTouchEvent(event);
- }
+ return false;
}
@Override
@@ -97,9 +93,9 @@
mScreenModeExt.onLayout(w, pr, y);
if (mIsLive && mState != State.ENDED) {
if (mLiveImage != null) {
+ mLiveImage.setPadding(mLiveImage.getPaddingLeft(), mLiveMargin + pt,
+ mLiveMargin + pr, mLiveImage.getPaddingBottom());
mLiveImage.setVisibility(View.VISIBLE);
- mLiveImage.layout(width - mLiveImage.getWidth() - mLiveMargin, pt + mLiveMargin,
- width - mLiveMargin, pt + mLiveMargin + mLiveImage.getHeight());
}
if (isPrepared()) {
mPlayPauseReplayView.setVisibility(View.GONE);
@@ -137,6 +133,7 @@
mTimeBar.setClickable(!mIsLive);
}
+ @Override
public IControllerRewindAndForward getControllerRewindAndForwardExt() {
return mControllerRewindAndForwardExt;
}
diff --git a/src/com/android/gallery3d/app/MoviePlayer.java b/src/com/android/gallery3d/app/MoviePlayer.java
index 8581f80..f97df7d 100755
--- a/src/com/android/gallery3d/app/MoviePlayer.java
+++ b/src/com/android/gallery3d/app/MoviePlayer.java
@@ -123,6 +123,7 @@
private final Handler mHandler = new Handler();
private final AudioBecomingNoisyReceiver mAudioBecomingNoisyReceiver;
private final MovieControllerOverlayNew mController;
+ private final GestureControllerOverlay mGestureController;
private long mResumeableTime = Long.MAX_VALUE;
private int mVideoPosition = 0;
@@ -266,7 +267,12 @@
mBookmarker = new Bookmarker(movieActivity);
mController = new MovieControllerOverlayNew(movieActivity);
- ((ViewGroup)rootView).addView(mController.getView());
+
+ mGestureController = new GestureControllerOverlay(movieActivity, mController);
+ ((ViewGroup) rootView).addView(mGestureController.getView());
+ mGestureController.setListener(this);
+
+ ((ViewGroup) rootView).addView(mController.getView());
mController.setListener(this);
mController.setCanReplay(canReplay);
@@ -388,6 +394,13 @@
&& (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) {
mController.show();
mRootView.setBackgroundColor(Color.BLACK);
+ if (mGestureController != null) {
+ mGestureController.setSystemUiVisible(true);
+ }
+ } else {
+ if (mGestureController != null) {
+ mGestureController.setSystemUiVisible(false);
+ }
}
if (LOG) {
@@ -408,7 +421,8 @@
if (!visible) {
// We used the deprecated "STATUS_BAR_HIDDEN" for unbundling
flag |= View.STATUS_BAR_HIDDEN | View.SYSTEM_UI_FLAG_FULLSCREEN
- | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_IMMERSIVE;
}
mVideoView.setSystemUiVisibility(flag);
}
@@ -514,6 +528,9 @@
// TODO comments by sunlei
mOverlayExt.clearBuffering();
mServerTimeoutExt.recordDisconnectTime();
+ if (mGestureController != null) {
+ mGestureController.doOnPause();
+ }
if (LOG) {
Log.v(TAG, "doOnPause() save video info consume:" + (end1 - start));
Log.v(TAG, "doOnPause() suspend video consume:" + (end2 - end1));
@@ -600,14 +617,15 @@
// second by mProgressChecker and also from places where the time bar needs
// to be updated immediately.
private int setProgress() {
- if (mDragging || (!mShowing && !mIsOnlyAudio)) {
- return 0;
- }
int position = mVideoView.getCurrentPosition();
int duration = mVideoView.getDuration();
mController.setTimes(position, duration, 0, 0);
+
+ if (mDragging || (!mShowing && !mIsOnlyAudio)) {
+ return 0;
+ }
if (mControllerRewindAndForwardExt != null
- && mControllerRewindAndForwardExt.getPlayPauseEanbled()) {
+ && mControllerRewindAndForwardExt.getPlayPauseEanbled()) {
updateRewindAndForwardUI();
}
return position;
diff --git a/src/com/android/gallery3d/app/TimeBarNew.java b/src/com/android/gallery3d/app/TimeBarNew.java
index 74a2b5c..370b4c6 100644
--- a/src/com/android/gallery3d/app/TimeBarNew.java
+++ b/src/com/android/gallery3d/app/TimeBarNew.java
@@ -61,4 +61,16 @@
}
return super.dispatchTouchEvent(event);
}
+
+ public int getTotalTime() {
+ return mTotalTime;
+ }
+
+ public int getCurrentTime() {
+ return mCurrentTime;
+ }
+
+ public boolean seekable() {
+ return mShowScrubber;
+ }
}
\ No newline at end of file