[Android] Fix the RTL problem of SwipeToUnlockView

Habib Kazemi git at videolan.org
Wed Jan 20 09:54:27 UTC 2021


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

Fix the RTL problem of SwipeToUnlockView

Fixes #1578 problem number 6

(cherry picked from commit b81844654f0a5ef3209b4779830c4bf5899d3f6c)

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

 .../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