[Android] Audio player play queue tips for large screens
Nicolas Pomepuy
git at videolan.org
Thu Dec 23 09:45:07 UTC 2021
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Dec 13 08:26:52 2021 +0100| [0055bc886355fdebb8efe13c372d2d54536a1871] | committer: Nicolas Pomepuy
Audio player play queue tips for large screens
Relates to #2258
> https://code.videolan.org/videolan/vlc-android/commit/0055bc886355fdebb8efe13c372d2d54536a1871
---
.../resources/src/main/res/values/strings.xml | 2 +
.../vlc-android/res/layout/audio_playlist_tips.xml | 2 +
.../vlc-android/res/layout/playlist_item.xml | 4 ++
.../vlc/gui/audio/AudioPlaylistTipsDelegate.kt | 51 ++++++++++++++++------
4 files changed, 46 insertions(+), 13 deletions(-)
diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 1c437d1fb..9ea0eba87 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -223,6 +223,8 @@
<string name="tips_play_description">Tap to play video</string>
<string name="lock">Lock</string>
<string name="tap">Tap to view</string>
+ <string name="tap_to_remove">Tap to remove</string>
+ <string name="tap_to_rearrange">Tap to rearrange</string>
<string name="lock_orientation">Orientation</string>
<string name="lock_orientation_description">Tap to lock/unlock orientation</string>
<string name="aspect_ratio">Aspect ratio</string>
diff --git a/application/vlc-android/res/layout/audio_playlist_tips.xml b/application/vlc-android/res/layout/audio_playlist_tips.xml
index 155227357..5cadb4dad 100644
--- a/application/vlc-android/res/layout/audio_playlist_tips.xml
+++ b/application/vlc-android/res/layout/audio_playlist_tips.xml
@@ -305,4 +305,6 @@
app:layout_constraintTop_toTopOf="@+id/pl_tips_next"
tools:alpha="1"
tools:visibility="visible" />
+
+
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
diff --git a/application/vlc-android/res/layout/playlist_item.xml b/application/vlc-android/res/layout/playlist_item.xml
index 1510f4812..9125d0662 100644
--- a/application/vlc-android/res/layout/playlist_item.xml
+++ b/application/vlc-android/res/layout/playlist_item.xml
@@ -151,6 +151,7 @@
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_marginRight="4dp"
+ android:padding="8dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:onClick="@{holder::onMoreClick}"
android:scaleType="center"
@@ -172,6 +173,7 @@
android:focusable="true"
android:onClick="@{holder::onDeleteClick}"
android:scaleType="center"
+ android:padding="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/item_more"
app:layout_constraintTop_toTopOf="parent"
@@ -185,6 +187,7 @@
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_marginEnd="8dp"
+ android:padding="8dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
@@ -203,6 +206,7 @@
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_marginEnd="8dp"
+ android:padding="8dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistTipsDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistTipsDelegate.kt
index 84ff31c47..0cb697e72 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistTipsDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistTipsDelegate.kt
@@ -42,16 +42,25 @@ import androidx.core.animation.doOnEnd
import androidx.core.animation.doOnStart
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider
+import androidx.lifecycle.lifecycleScope
import androidx.transition.Fade
import androidx.transition.TransitionManager
+import kotlinx.android.synthetic.main.audio_player_tips.*
import kotlinx.android.synthetic.main.audio_playlist_tips.*
+import kotlinx.android.synthetic.main.audio_playlist_tips.helpDescription
+import kotlinx.android.synthetic.main.audio_playlist_tips.helpTitle
+import kotlinx.android.synthetic.main.audio_playlist_tips.nextButton
+import kotlinx.android.synthetic.main.audio_playlist_tips.tapGestureHorizontal
+import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
+import kotlinx.coroutines.launch
import org.videolan.tools.*
import org.videolan.vlc.R
import org.videolan.vlc.databinding.PlaylistItemBinding
import org.videolan.vlc.gui.AudioPlayerContainerActivity
import org.videolan.vlc.gui.helpers.TipsUtils
+import org.videolan.vlc.gui.helpers.UiTools.isTablet
import org.videolan.vlc.media.MediaUtils
import org.videolan.vlc.viewmodels.PlaylistModel
@@ -113,7 +122,7 @@ class AudioPlaylistTipsDelegate(private val activity: AudioPlayerContainerActivi
}
activity.audioPlaylistTips.setVisible()
- next()
+ activity.lifecycleScope.launch(Dispatchers.Main) { next() }
}
private fun getItemColor(): Int {
@@ -257,12 +266,23 @@ class AudioPlaylistTipsDelegate(private val activity: AudioPlayerContainerActivi
when (currentTip) {
AudioPlaylistTipsStep.REMOVE -> {
- constraintSet.setVisibility(R.id.tap_gesture_horizontal_background, View.VISIBLE)
- constraintSet.setVisibility(R.id.tapGestureHorizontal, View.VISIBLE)
- currentAnimations.clear()
- currentAnimations.add(TipsUtils.horizontalSwipe(activity.tapGestureHorizontal) {
- secondItemBinding.itemContainer.translationX = (it.animatedValue as Float) * 4
- })
+ if (activity.isTablet()){
+ val indicatorY = secondItemBinding.itemContainer.top + (secondItemBinding.itemContainer.height / 2) - 24.dp
+ constraintSet.setMargin(R.id.tapIndicatorRearrange, ConstraintSet.TOP, indicatorY)
+ currentAnimations.clear()
+ constraintSet.setVisibility(R.id.tapIndicatorRearrange, View.VISIBLE)
+ val indicatorX = secondItemBinding.itemDelete.left + (secondItemBinding.itemDelete.width / 2) - 24.dp
+ constraintSet.setMargin(R.id.tapIndicatorRearrange, ConstraintSet.START, indicatorX)
+ constraintSet.clear(R.id.tapIndicatorRearrange, ConstraintSet.END)
+ TipsUtils.startTapAnimation(listOf(activity.tapIndicatorRearrange))
+ } else {
+ constraintSet.setVisibility(R.id.tap_gesture_horizontal_background, View.VISIBLE)
+ constraintSet.setVisibility(R.id.tapGestureHorizontal, View.VISIBLE)
+ currentAnimations.clear()
+ currentAnimations.add(TipsUtils.horizontalSwipe(activity.tapGestureHorizontal) {
+ secondItemBinding.itemContainer.translationX = (it.animatedValue as Float) * 4
+ })
+ }
}
AudioPlaylistTipsStep.REARRANGE -> {
secondItemBinding.itemContainer.translationX = 0F
@@ -274,7 +294,12 @@ class AudioPlaylistTipsDelegate(private val activity: AudioPlayerContainerActivi
val indicatorY = thirdItemBinding.itemContainer.top + (thirdItemBinding.itemContainer.height / 2) - 24.dp
constraintSet.setMargin(R.id.tapIndicatorRearrange, ConstraintSet.TOP, indicatorY)
currentAnimations.clear()
- currentAnimations.add(dragAndDrop(activity.tapIndicatorRearrange, thirdItemBinding.itemContainer))
+ if (activity.isTablet()){
+ val indicatorX = thirdItemBinding.itemMoveUp.left + (thirdItemBinding.itemMoveUp.width / 2) - 24.dp
+ constraintSet.setMargin(R.id.tapIndicatorRearrange, ConstraintSet.START, indicatorX)
+ constraintSet.clear(R.id.tapIndicatorRearrange, ConstraintSet.END)
+ TipsUtils.startTapAnimation(listOf(activity.tapIndicatorRearrange))
+ } else currentAnimations.add(dragAndDrop(activity.tapIndicatorRearrange, thirdItemBinding.itemContainer))
}
AudioPlaylistTipsStep.SEEK -> {
@@ -297,7 +322,7 @@ class AudioPlaylistTipsDelegate(private val activity: AudioPlayerContainerActivi
constraintSet.applyTo(activity.audioPlaylistTips)
activity.helpTitle.setText(currentTip!!.titleText)
- activity.helpDescription.setText(currentTip!!.descriptionText)
+ activity.helpDescription.setText(if (activity.isTablet()) currentTip!!.descriptionTextTablet else currentTip!!.descriptionText)
}
/**
@@ -329,10 +354,10 @@ class AudioPlaylistTipsDelegate(private val activity: AudioPlayerContainerActivi
* @param titleText: the string resource to display in the title [TextView]
* @param descriptionText: the string resource to display in the description [TextView]
*/
-enum class AudioPlaylistTipsStep(@StringRes var titleText: Int, @StringRes var descriptionText: Int) {
- REMOVE(R.string.remove_song, R.string.tips_swipe_horizontal),
- REARRANGE(R.string.rearrange_order, R.string.tips_long_drop),
- SEEK(R.string.seek, R.string.tips_hold_seek);
+enum class AudioPlaylistTipsStep(@StringRes var titleText: Int, @StringRes var descriptionText: Int, @StringRes var descriptionTextTablet: Int) {
+ REMOVE(R.string.remove_song, R.string.tips_swipe_horizontal, R.string.tap_to_remove),
+ REARRANGE(R.string.rearrange_order, R.string.tips_long_drop, R.string.tap_to_rearrange),
+ SEEK(R.string.seek, R.string.tips_hold_seek, R.string.tips_hold_seek);
/**
* @return the next step
More information about the Android
mailing list