[Android] SlidingMenu: merge "Scale margin threshold according to screen density" & increase threshold to 16dp

Sébastien Toque git at videolan.org
Mon Sep 3 23:51:05 CEST 2012


vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Mon Sep  3 13:13:57 2012 +0200| [9e536a580413297e60fda698ff0431276807e434] | committer: Edward Wang

SlidingMenu: merge "Scale margin threshold according to screen density" & increase threshold to 16dp

This fix the issue on my two htc phones, the threshold of 10px was way too small,
it was almost impossible to open the menu with a gesture.

https://github.com/jfeinstein10/SlidingMenu/commit/1a7d6a9cc3ee05bddb984649f0f55f587dfdc422

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=9e536a580413297e60fda698ff0431276807e434
---

 .../SlidingMenu/src/com/slidingmenu/lib/CustomViewAbove.java    |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/java-libs/SlidingMenu/src/com/slidingmenu/lib/CustomViewAbove.java b/java-libs/SlidingMenu/src/com/slidingmenu/lib/CustomViewAbove.java
index 1add3f8..0abca6f 100644
--- a/java-libs/SlidingMenu/src/com/slidingmenu/lib/CustomViewAbove.java
+++ b/java-libs/SlidingMenu/src/com/slidingmenu/lib/CustomViewAbove.java
@@ -19,6 +19,7 @@ import android.support.v4.view.ViewCompat;
 import android.support.v4.view.ViewConfigurationCompat;
 import android.util.AttributeSet;
 import android.util.Log;
+import android.util.TypedValue;
 import android.view.FocusFinder;
 import android.view.Gravity;
 import android.view.KeyEvent;
@@ -119,7 +120,7 @@ public class CustomViewAbove extends ViewGroup {
 		private boolean mCalledSuper;
 
 		private boolean mLastTouchAllowed = false;
-		private final int mSlidingMenuThreshold = 10;
+		private final int mSlidingMenuThreshold = 16;
 		private CustomViewBehind mCustomViewBehind;
 		private boolean mEnabled = true;
 
@@ -1022,7 +1023,9 @@ public class CustomViewAbove extends ViewGroup {
 				case SlidingMenu.TOUCHMODE_FULLSCREEN:
 					return true;
 				case SlidingMenu.TOUCHMODE_MARGIN:
-					return ev.getX() >= 0 && ev.getX() <= mSlidingMenuThreshold;
+					int pixels = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
+							mSlidingMenuThreshold, getResources().getDisplayMetrics());
+					return ev.getX() >= 0 && ev.getX() <= pixels;
 				default:
 					return false;
 				}



More information about the Android mailing list