[Android] Fix the RTL problem of SwipeToUnlockView

Habib Kazemi git at videolan.org
Tue Jan 5 08:08:18 UTC 2021


vlc-android | branch: master | Habib Kazemi <kazemihabib1996 at gmail.com> | Wed Dec 30 13:04:49 2020 +0330| [b81844654f0a5ef3209b4779830c4bf5899d3f6c] | committer: Nicolas Pomepuy

Fix the RTL problem of SwipeToUnlockView

Fixes #1578 problem number 6

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

 .../vlc-android/src/org/videolan/vlc/gui/view/SwipeToUnlockView.kt  | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/view/SwipeToUnlockView.kt b/application/vlc-android/src/org/videolan/vlc/gui/view/SwipeToUnlockView.kt
index 670d326b7..dd5ad8e7f 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/view/SwipeToUnlockView.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/view/SwipeToUnlockView.kt
@@ -31,6 +31,7 @@ import android.text.SpannableString
 import android.text.Spanned
 import android.text.style.MaskFilterSpan
 import android.util.AttributeSet
+import android.util.LayoutDirection
 import android.util.Log
 import android.view.KeyEvent
 import android.view.LayoutInflater
@@ -101,7 +102,10 @@ class SwipeToUnlockView : ConstraintLayout {
     override fun onTouchEvent(event: MotionEvent?): Boolean {
         if (unlocking) return super.onTouchEvent(event)
         event?.let { event ->
-            val currentX = event.x.toInt().coerceAtLeast(extremum).coerceAtMost(width - extremum)
+            val currentX = event.x.toInt().coerceAtLeast(extremum).coerceAtMost(width - extremum).run {
+                if (layoutDirection == LayoutDirection.RTL) width - this
+                else this
+            }
 
             when (event.action) {
                 MotionEvent.ACTION_DOWN -> {



More information about the Android mailing list