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

Habib Kazemi kazemihabib1996 at gmail.com
Fri Jun 2 18:50:00 CEST 2017


I made a mistake here , there are "TOUCH_FLAG_BRIGHTNESS" and
"TOUCH_FLAG_BRIGHTNESS" for disabling and enabling volume touch and
brightness touch and with this patch it disables reversely.
and also in default mode (LTR) the volume touch width is larger (4/7
of screen) and brightness touch is 3/7 of width.

but the more import thing here is that I checked other apps and
websites like Youtube and aparat.com(persian video sharing website and
app) and they didn't change the direction of  seekbar in rtl mode and
I was thinking maybe we should keep it as a standard and not change
direction.

On Fri, Jun 2, 2017 at 7:56 PM, Geoffrey Métais <geoffrey at videolan.org> wrote:
> 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


More information about the Android mailing list