[Android] [PATCH v2] Fix touch events in RTL mode

habib kazemi kazemihabib1996 at gmail.com
Fri Jun 2 20:54:16 CEST 2017


Reverse seek touch direction and
reverse the location BrightnessTouch and VolumeTouch
---
 .../vlc/gui/video/VideoPlayerActivity.java         | 23 ++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 305deb04c..fc56ed7d8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -2081,6 +2081,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
+        final boolean rtl = AndroidUtil.isJellyBeanMR1OrLater && TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL;
         if (mService == null)
             return false;
         if (mDetector == null) {
@@ -2156,19 +2157,25 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                             return false;
                         mTouchY = event.getRawY();
                         mTouchX = event.getRawX();
-                        // Volume (Up or Down - Right side)
-                        if ((mTouchControls & TOUCH_FLAG_AUDIO_VOLUME) != 0 && (int)mTouchX > (4 * mScreen.widthPixels / 7f)){
-                            doVolumeTouch(y_changed);
+                        // (Up or Down - Right side) LTR: Volume RTL: Brightness
+                        if ((mTouchControls & (!rtl ? TOUCH_FLAG_AUDIO_VOLUME : TOUCH_FLAG_BRIGHTNESS)) != 0 && (int)mTouchX > (4 * mScreen.widthPixels / 7f)){
+                            if (!rtl)
+                                doVolumeTouch(y_changed);
+                            else
+                                doBrightnessTouch(y_changed);
                             hideOverlay(true);
                         }
-                        // Brightness (Up or Down - Left side)
-                        if ((mTouchControls & TOUCH_FLAG_BRIGHTNESS) != 0 && (int)mTouchX < (3 * mScreen.widthPixels / 7f)){
-                            doBrightnessTouch(y_changed);
+                        // (Up or Down - Left side) LTR: Brightness RTL: Volume
+                        if ((mTouchControls & (!rtl ? TOUCH_FLAG_BRIGHTNESS : TOUCH_FLAG_AUDIO_VOLUME)) != 0 && (int)mTouchX < (3 * mScreen.widthPixels / 7f)){
+                            if(!rtl)
+                                doBrightnessTouch(y_changed);
+                            else
+                                doVolumeTouch(y_changed);
                             hideOverlay(true);
                         }
                     } else {
                         // Seek (Right or Left move)
-                        doSeekTouch(Math.round(delta_y), xgesturesize, false);
+                        doSeekTouch(Math.round(delta_y), rtl ? -xgesturesize : xgesturesize , false);
                     }
                 } else {
                     mTouchY = event.getRawY();
@@ -2185,7 +2192,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                 sendMouseEvent(MotionEvent.ACTION_UP, 0, xTouch, yTouch);
                 // Seek
                 if (mTouchAction == TOUCH_SEEK)
-                    doSeekTouch(Math.round(delta_y), xgesturesize, true);
+                    doSeekTouch(Math.round(delta_y), rtl ? -xgesturesize : xgesturesize , true);
                 mTouchX = -1f;
                 mTouchY = -1f;
                 break;
-- 
2.12.2



More information about the Android mailing list