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

Geoffrey Métais geoffrey at videolan.org
Fri Jun 2 17:26:46 CEST 2017


Looks good to me.

Le ven. 2 juin 2017 à 17:20, habib kazemi <kazemihabib1996 at gmail.com> a
écrit :

> ---
>  .../videolan/vlc/gui/video/VideoPlayerActivity.java   | 19
> +++++++++++++------
>  1 file changed, 13 insertions(+), 6 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..a01aad539 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)
> +                        // (Up or Down - Right side) LTR: Volume RTL:
> Brightness
>                          if ((mTouchControls & TOUCH_FLAG_AUDIO_VOLUME) !=
> 0 && (int)mTouchX > (4 * mScreen.widthPixels / 7f)){
> -                            doVolumeTouch(y_changed);
> +                            if (!rtl)
> +                                doVolumeTouch(y_changed);
> +                            else
> +                                doBrightnessTouch(y_changed);
>                              hideOverlay(true);
>                          }
> -                        // Brightness (Up or Down - Left side)
> +                        // (Up or Down - Left side) LTR: Brightness RTL:
> Volume
>                          if ((mTouchControls & TOUCH_FLAG_BRIGHTNESS) != 0
> && (int)mTouchX < (3 * mScreen.widthPixels / 7f)){
> -                            doBrightnessTouch(y_changed);
> +                            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
>
> _______________________________________________
> Android mailing list
> Android at videolan.org
> https://mailman.videolan.org/listinfo/android
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/android/attachments/20170602/eb420569/attachment.html>


More information about the Android mailing list