[Android] Fix video tips for RTL
Nicolas Pomepuy
git at videolan.org
Fri Nov 22 13:53:25 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Nov 22 11:56:43 2024 +0100| [7c5f6795b8bfbe924069884e2ed16221fcf6c87e] | committer: Nicolas Pomepuy
Fix video tips for RTL
> https://code.videolan.org/videolan/vlc-android/commit/7c5f6795b8bfbe924069884e2ed16221fcf6c87e
---
application/vlc-android/res/layout/player_tips.xml | 12 +++++-----
.../videolan/vlc/gui/video/VideoTipsDelegate.kt | 27 ++++++++++++++--------
2 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/application/vlc-android/res/layout/player_tips.xml b/application/vlc-android/res/layout/player_tips.xml
index 6500e709d3..87fed85e06 100644
--- a/application/vlc-android/res/layout/player_tips.xml
+++ b/application/vlc-android/res/layout/player_tips.xml
@@ -58,9 +58,9 @@
android:textColor="?attr/font_default"
android:textSize="24sp"
app:layout_constraintBottom_toTopOf="@+id/guideline8"
- app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="0.5"
- app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintLeft_toLeftOf="parent"
tools:text="Help title" />
<TextView
@@ -74,9 +74,9 @@
android:textColor="@color/white_transparent_50"
android:textSize="14sp"
app:layout_constrainedWidth="true"
- app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="0.5"
- app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline8"
tools:text="Help description" />
@@ -261,7 +261,7 @@
android:layout_marginEnd="24dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />
@@ -300,7 +300,7 @@
android:layout_marginStart="24dp"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@+id/guideline8"
- app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline8"
tools:visibility="visible" />
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoTipsDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoTipsDelegate.kt
index fce2b20365..5adda5bf1d 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoTipsDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoTipsDelegate.kt
@@ -46,6 +46,7 @@ import org.videolan.tools.*
import org.videolan.vlc.R
import org.videolan.vlc.gui.helpers.TipsUtils
import org.videolan.vlc.gui.view.PlayerProgress
+import org.videolan.vlc.util.LocaleUtil
/**
* Delegate to manage the video tips workflow.
@@ -233,17 +234,23 @@ class VideoTipsDelegate(private val player: VideoPlayerActivity) : OnClickListen
clearAllAnimations()
nextButton.setText(R.string.next_step)
+ // For RTL, we have to invert some constraints as the volume and brightness gestures are kept at the same side of the screen
+ val independentStart = if (LocaleUtil.isRtl()) ConstraintSet.END else ConstraintSet.START
+ val independentEnd = if (LocaleUtil.isRtl()) ConstraintSet.START else ConstraintSet.END
when (currentTip) {
VideoPlayerTipsStep.CONTROLS -> {
getTapIndicators().forEach { constraintSet.setVisibility(it.id, VISIBLE) }
TipsUtils.startTapAnimation(getTapIndicators().toList())
}
VideoPlayerTipsStep.BRIGHTNESS -> {
- constraintSet.connect(R.id.helpTitle, ConstraintSet.START, R.id.tap_gesture_background, ConstraintSet.END, 16.dp)
- constraintSet.connect(R.id.helpTitle, ConstraintSet.END, R.id.tipsBrightnessProgress, ConstraintSet.START, 16.dp)
+ constraintSet.clear(R.id.tap_gesture_background, independentEnd)
+ constraintSet.connect(R.id.tap_gesture_background, independentStart, ConstraintSet.PARENT_ID, independentStart, 32.dp)
+
+ constraintSet.connect(R.id.helpTitle, ConstraintSet.LEFT, R.id.tap_gesture_background, ConstraintSet.RIGHT, 16.dp)
+ constraintSet.connect(R.id.helpTitle, ConstraintSet.RIGHT, R.id.tipsBrightnessProgress, ConstraintSet.LEFT, 16.dp)
constraintSet.setHorizontalBias(R.id.helpTitle, 1F)
- constraintSet.connect(R.id.helpDescription, ConstraintSet.START, R.id.tap_gesture_background, ConstraintSet.END, 16.dp)
- constraintSet.connect(R.id.helpDescription, ConstraintSet.END, R.id.tipsBrightnessProgress, ConstraintSet.START, 16.dp)
+ constraintSet.connect(R.id.helpDescription, ConstraintSet.LEFT, R.id.tap_gesture_background, ConstraintSet.RIGHT, 16.dp)
+ constraintSet.connect(R.id.helpDescription, ConstraintSet.RIGHT, R.id.tipsBrightnessProgress, ConstraintSet.LEFT, 16.dp)
constraintSet.setHorizontalBias(R.id.helpDescription, 1F)
constraintSet.setVisibility(R.id.tapGesture, VISIBLE)
@@ -255,14 +262,14 @@ class VideoTipsDelegate(private val player: VideoPlayerActivity) : OnClickListen
currentAnimations.add(swipe(tipsBrightnessProgress, tipsBrightnessText))
}
VideoPlayerTipsStep.VOLUME -> {
- constraintSet.clear(R.id.tap_gesture_background, ConstraintSet.START)
- constraintSet.connect(R.id.tap_gesture_background, ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END, 32.dp)
+ constraintSet.clear(R.id.tap_gesture_background, independentStart)
+ constraintSet.connect(R.id.tap_gesture_background, independentEnd, ConstraintSet.PARENT_ID, independentEnd, 32.dp)
- constraintSet.connect(R.id.helpTitle, ConstraintSet.START, R.id.tipsVolumeProgress, ConstraintSet.END, 16.dp)
- constraintSet.connect(R.id.helpTitle, ConstraintSet.END, R.id.tap_gesture_background, ConstraintSet.START, 16.dp)
+ constraintSet.connect(R.id.helpTitle, ConstraintSet.LEFT, R.id.tipsVolumeProgress, ConstraintSet.RIGHT, 16.dp)
+ constraintSet.connect(R.id.helpTitle, ConstraintSet.RIGHT, R.id.tap_gesture_background, ConstraintSet.LEFT, 16.dp)
constraintSet.setHorizontalBias(R.id.helpTitle, 0F)
- constraintSet.connect(R.id.helpDescription, ConstraintSet.START, R.id.tipsVolumeProgress, ConstraintSet.END, 16.dp)
- constraintSet.connect(R.id.helpDescription, ConstraintSet.END, R.id.tap_gesture_background, ConstraintSet.START, 16.dp)
+ constraintSet.connect(R.id.helpDescription, ConstraintSet.LEFT, R.id.tipsVolumeProgress, ConstraintSet.RIGHT, 16.dp)
+ constraintSet.connect(R.id.helpDescription, ConstraintSet.RIGHT, R.id.tap_gesture_background, ConstraintSet.LEFT, 16.dp)
constraintSet.setHorizontalBias(R.id.helpDescription, 0F)
constraintSet.setVisibility(R.id.tapGesture, VISIBLE)
More information about the Android
mailing list