[Android] Disable pinch-to-zoom for Android 2.x

Geoffrey Métais git at videolan.org
Fri Apr 1 18:08:29 CEST 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Apr  1 17:58:04 2016 +0200| [8b14428204afc36080e0a6989f2934610ed6ffb1] | committer: Geoffrey Métais

Disable pinch-to-zoom for Android 2.x

> https://code.videolan.org/videolan/vlc-android/commit/8b14428204afc36080e0a6989f2934610ed6ffb1
---

 vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java b/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
index e3a3d72..ab6bef0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
@@ -50,6 +50,7 @@ import android.widget.RelativeLayout;
 import org.videolan.libvlc.IVLCVout;
 import org.videolan.libvlc.Media;
 import org.videolan.libvlc.MediaPlayer;
+import org.videolan.libvlc.util.AndroidUtil;
 import org.videolan.vlc.PlaybackService;
 import org.videolan.vlc.R;
 import org.videolan.vlc.VLCApplication;
@@ -119,8 +120,10 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
         params.y = 50;
 
         mGestureDetector = new GestureDetectorCompat(mService, mGestureListener);
-        mScaleGestureDetector = new ScaleGestureDetector(VLCApplication.getAppContext(), this);
         mGestureDetector.setOnDoubleTapListener(this);
+        if (AndroidUtil.isHoneycombOrLater()) {
+            mScaleGestureDetector = new ScaleGestureDetector(VLCApplication.getAppContext(), this);
+        }
         mRootView.setOnTouchListener(new View.OnTouchListener() {
             private int initialX;
             private int initialY;
@@ -131,7 +134,8 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
             public boolean onTouch(View v, MotionEvent event) {
                 if (mRootView == null)
                     return false;
-                mScaleGestureDetector.onTouchEvent(event);
+                if (mScaleGestureDetector != null)
+                    mScaleGestureDetector.onTouchEvent(event);
                 if (mGestureDetector != null && mGestureDetector.onTouchEvent(event))
                     return true;
                 switch (event.getAction()) {
@@ -144,7 +148,7 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
                     case MotionEvent.ACTION_UP:
                         return true;
                     case MotionEvent.ACTION_MOVE:
-                        if (!mScaleGestureDetector.isInProgress()) {
+                        if (mScaleGestureDetector == null || !mScaleGestureDetector.isInProgress()) {
                             params.x = initialX + (int) (event.getRawX() - initialTouchX);
                             params.y = initialY - (int) (event.getRawY() - initialTouchY);
                             windowManager.updateViewLayout(mRootView, params);



More information about the Android mailing list