playback: introduce swipe to next
This commit is contained in:
@@ -64,6 +64,7 @@ import org.oxycblt.auxio.playback.PlaybackViewModel
|
|||||||
import org.oxycblt.auxio.ui.FadingToolbarOffsetListener
|
import org.oxycblt.auxio.ui.FadingToolbarOffsetListener
|
||||||
import org.oxycblt.auxio.util.collect
|
import org.oxycblt.auxio.util.collect
|
||||||
import org.oxycblt.auxio.util.collectImmediately
|
import org.oxycblt.auxio.util.collectImmediately
|
||||||
|
import org.oxycblt.auxio.util.dampen
|
||||||
import org.oxycblt.auxio.util.lazyReflectedField
|
import org.oxycblt.auxio.util.lazyReflectedField
|
||||||
import org.oxycblt.auxio.util.navigateSafe
|
import org.oxycblt.auxio.util.navigateSafe
|
||||||
import org.oxycblt.auxio.util.showToast
|
import org.oxycblt.auxio.util.showToast
|
||||||
@@ -157,14 +158,7 @@ class HomeFragment : SelectionFragment<FragmentHomeBinding>() {
|
|||||||
// debug UI performance.
|
// debug UI performance.
|
||||||
offscreenPageLimit = Tab.MAX_SEQUENCE_IDX + 1
|
offscreenPageLimit = Tab.MAX_SEQUENCE_IDX + 1
|
||||||
|
|
||||||
// By default, ViewPager2's sensitivity is high enough to result in vertical scroll
|
dampen()
|
||||||
// events being registered as horizontal scroll events. Reflect into the internal
|
|
||||||
// RecyclerView and change the touch slope so that touch actions will act more as a
|
|
||||||
// scroll than as a swipe. Derived from:
|
|
||||||
// https://al-e-shevelev.medium.com/how-to-reduce-scroll-sensitivity-of-viewpager2-widget-87797ad02414
|
|
||||||
val recycler = VP_RECYCLER_FIELD.get(this@apply)
|
|
||||||
val slop = RV_TOUCH_SLOP_FIELD.get(recycler) as Int
|
|
||||||
RV_TOUCH_SLOP_FIELD.set(recycler, slop * 3)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Further initialization must be done in the function that also handles
|
// Further initialization must be done in the function that also handles
|
||||||
@@ -499,9 +493,4 @@ class HomeFragment : SelectionFragment<FragmentHomeBinding>() {
|
|||||||
MusicType.PLAYLISTS -> PlaylistListFragment()
|
MusicType.PLAYLISTS -> PlaylistListFragment()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
|
||||||
val VP_RECYCLER_FIELD: Field by lazyReflectedField(ViewPager2::class, "mRecyclerView")
|
|
||||||
val RV_TOUCH_SLOP_FIELD: Field by lazyReflectedField(RecyclerView::class, "mTouchSlop")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,13 +25,14 @@ import android.media.audiofx.AudioEffect
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.ViewTreeObserver
|
import android.view.View
|
||||||
import androidx.activity.result.ActivityResultLauncher
|
import androidx.activity.result.ActivityResultLauncher
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.dynamicanimation.animation.SpringForce
|
import androidx.dynamicanimation.animation.SpringForce
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import androidx.fragment.app.viewModels
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
import org.oxycblt.auxio.databinding.FragmentPlaybackPanelBinding
|
import org.oxycblt.auxio.databinding.FragmentPlaybackPanelBinding
|
||||||
@@ -39,16 +40,23 @@ import org.oxycblt.auxio.detail.DetailViewModel
|
|||||||
import org.oxycblt.auxio.list.ListViewModel
|
import org.oxycblt.auxio.list.ListViewModel
|
||||||
import org.oxycblt.auxio.music.resolve
|
import org.oxycblt.auxio.music.resolve
|
||||||
import org.oxycblt.auxio.music.resolveNames
|
import org.oxycblt.auxio.music.resolveNames
|
||||||
|
import org.oxycblt.auxio.playback.queue.QueueViewModel
|
||||||
import org.oxycblt.auxio.playback.state.RepeatMode
|
import org.oxycblt.auxio.playback.state.RepeatMode
|
||||||
import org.oxycblt.auxio.playback.ui.StyledSeekBar
|
import org.oxycblt.auxio.playback.ui.StyledSeekBar
|
||||||
|
import org.oxycblt.auxio.playback.ui.swiper.CarouselTransformer
|
||||||
|
import org.oxycblt.auxio.playback.ui.swiper.CoverPagerAdapter
|
||||||
|
import org.oxycblt.auxio.playback.ui.swiper.UserAwarePagerCallback
|
||||||
import org.oxycblt.auxio.playback.ui.stepper.Direction
|
import org.oxycblt.auxio.playback.ui.stepper.Direction
|
||||||
import org.oxycblt.auxio.playback.ui.stepper.PlayerFastSeekOverlay
|
import org.oxycblt.auxio.playback.ui.stepper.PlayerFastSeekOverlay
|
||||||
import org.oxycblt.auxio.ui.ViewBindingFragment
|
import org.oxycblt.auxio.ui.ViewBindingFragment
|
||||||
import org.oxycblt.auxio.util.collectImmediately
|
import org.oxycblt.auxio.util.collectImmediately
|
||||||
|
import org.oxycblt.auxio.util.dampen
|
||||||
|
import org.oxycblt.auxio.util.recycler
|
||||||
import org.oxycblt.auxio.util.showToast
|
import org.oxycblt.auxio.util.showToast
|
||||||
import org.oxycblt.auxio.util.systemBarInsetsCompat
|
import org.oxycblt.auxio.util.systemBarInsetsCompat
|
||||||
import org.oxycblt.musikr.MusicParent
|
import org.oxycblt.musikr.MusicParent
|
||||||
import org.oxycblt.musikr.Song
|
import org.oxycblt.musikr.Song
|
||||||
|
import kotlin.math.abs
|
||||||
import timber.log.Timber as L
|
import timber.log.Timber as L
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,13 +72,15 @@ class PlaybackPanelFragment :
|
|||||||
ViewBindingFragment<FragmentPlaybackPanelBinding>(),
|
ViewBindingFragment<FragmentPlaybackPanelBinding>(),
|
||||||
Toolbar.OnMenuItemClickListener,
|
Toolbar.OnMenuItemClickListener,
|
||||||
StyledSeekBar.Listener,
|
StyledSeekBar.Listener,
|
||||||
ViewTreeObserver.OnGlobalLayoutListener,
|
|
||||||
PlayerFastSeekOverlay.PerformListener {
|
PlayerFastSeekOverlay.PerformListener {
|
||||||
|
private val coverPagerAdapter = CoverPagerAdapter(this)
|
||||||
private val playbackModel: PlaybackViewModel by activityViewModels()
|
private val playbackModel: PlaybackViewModel by activityViewModels()
|
||||||
private val detailModel: DetailViewModel by activityViewModels()
|
private val detailModel: DetailViewModel by activityViewModels()
|
||||||
private val listModel: ListViewModel by activityViewModels()
|
private val listModel: ListViewModel by activityViewModels()
|
||||||
|
private val queueModel: QueueViewModel by viewModels()
|
||||||
private var equalizerLauncher: ActivityResultLauncher<Intent>? = null
|
private var equalizerLauncher: ActivityResultLauncher<Intent>? = null
|
||||||
private var lastCoverWidth = 0
|
private var userAwarePagerCallback: UserAwarePagerCallback? = null
|
||||||
|
private var currentPagerPosition = 0
|
||||||
|
|
||||||
override fun onCreateBinding(inflater: LayoutInflater) =
|
override fun onCreateBinding(inflater: LayoutInflater) =
|
||||||
FragmentPlaybackPanelBinding.inflate(inflater)
|
FragmentPlaybackPanelBinding.inflate(inflater)
|
||||||
@@ -100,11 +110,27 @@ class PlaybackPanelFragment :
|
|||||||
setOnMenuItemClickListener(this@PlaybackPanelFragment)
|
setOnMenuItemClickListener(this@PlaybackPanelFragment)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable swipe gestures on cover for now
|
binding.playbackPager?.apply {
|
||||||
binding.playbackCover.onSwipeListener = null
|
adapter = coverPagerAdapter
|
||||||
|
userAwarePagerCallback = UserAwarePagerCallback(this) {
|
||||||
|
// Posting the queue goto command prevents the seekbar pos from desyncing
|
||||||
|
// from the song's duration, which creates a visual flicker in the seekbar.
|
||||||
|
post { queueModel.goto(it) }
|
||||||
|
}.also { it.attach() }
|
||||||
|
setPageTransformer(CarouselTransformer())
|
||||||
|
recycler().apply {
|
||||||
|
// Make it possible to collapse the bottom sheet from the ViewPager's touch area.
|
||||||
|
isNestedScrollingEnabled = false
|
||||||
|
// Visual effect consistency
|
||||||
|
// TODO: Custom overscroll?
|
||||||
|
overScrollMode = View.OVER_SCROLL_NEVER
|
||||||
|
}
|
||||||
|
// Make it easier to collapse the bottom sheet
|
||||||
|
dampen()
|
||||||
|
offscreenPageLimit = 1
|
||||||
|
}
|
||||||
|
|
||||||
// Set up fast seek overlay
|
// Set up fast seek overlay
|
||||||
binding.playbackFastSeekOverlay?.performListener = this
|
|
||||||
binding.playbackSong.apply {
|
binding.playbackSong.apply {
|
||||||
isSelected = true
|
isSelected = true
|
||||||
setOnClickListener { navigateToCurrentSong() }
|
setOnClickListener { navigateToCurrentSong() }
|
||||||
@@ -149,23 +175,25 @@ class PlaybackPanelFragment :
|
|||||||
collectImmediately(playbackModel.repeatMode, ::updateRepeat)
|
collectImmediately(playbackModel.repeatMode, ::updateRepeat)
|
||||||
collectImmediately(playbackModel.isPlaying, ::updatePlaying)
|
collectImmediately(playbackModel.isPlaying, ::updatePlaying)
|
||||||
collectImmediately(playbackModel.isShuffled, ::updateShuffled)
|
collectImmediately(playbackModel.isShuffled, ::updateShuffled)
|
||||||
|
collectImmediately(playbackModel.pagerQueue, ::updatePager)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
// FIXME: Old code!! Maybe not necessary anymore?
|
||||||
super.onStart()
|
// override fun onStart() {
|
||||||
playbackModel.song.value?.let { requireBinding().playbackCover.bind(it) }
|
// super.onStart()
|
||||||
requireBinding().root.viewTreeObserver.addOnGlobalLayoutListener(this)
|
// playbackModel.song.value?.let { requireBinding().playbackCover.bind(it) }
|
||||||
}
|
// requireBinding().root.viewTreeObserver.addOnGlobalLayoutListener(this)
|
||||||
|
// }
|
||||||
|
|
||||||
override fun onStop() {
|
// override fun onStop() {
|
||||||
super.onStop()
|
// super.onStop()
|
||||||
requireBinding().root.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
// requireBinding().root.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||||
}
|
// }
|
||||||
|
|
||||||
override fun onGlobalLayout() {
|
// override fun onGlobalLayout() {
|
||||||
if (binding == null || lastCoverWidth < 0) {
|
// if (binding == null || lastCoverWidth < 0) {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
// Hacky workaround for cover radius not being preserved in between sizing changes
|
// Hacky workaround for cover radius not being preserved in between sizing changes
|
||||||
// (i.e split screen or landscape mode)
|
// (i.e split screen or landscape mode)
|
||||||
// For some reason ConstraintLayout does several passes on 1:1 elements that causes their
|
// For some reason ConstraintLayout does several passes on 1:1 elements that causes their
|
||||||
@@ -175,15 +203,15 @@ class PlaybackPanelFragment :
|
|||||||
// covers) we can force it to reload.
|
// covers) we can force it to reload.
|
||||||
// If this breaks, it's fine since we also started a load as we normally did w/state
|
// If this breaks, it's fine since we also started a load as we normally did w/state
|
||||||
// updates, so the cover will not break.
|
// updates, so the cover will not break.
|
||||||
val binding = requireBinding()
|
// val binding = requireBinding()
|
||||||
val coverWidth = binding.playbackCover.width
|
// val coverWidth = binding.playbackCover.width
|
||||||
if (lastCoverWidth != coverWidth) {
|
// if (lastCoverWidth != coverWidth) {
|
||||||
lastCoverWidth = coverWidth
|
// lastCoverWidth = coverWidth
|
||||||
} else {
|
// } else {
|
||||||
playbackModel.song.value?.let { binding.playbackCover.bind(it) }
|
// playbackModel.song.value?.let { binding.playbackCover.bind(it) }
|
||||||
lastCoverWidth = -1
|
// lastCoverWidth = -1
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
override fun onDestroyBinding(binding: FragmentPlaybackPanelBinding) {
|
override fun onDestroyBinding(binding: FragmentPlaybackPanelBinding) {
|
||||||
equalizerLauncher = null
|
equalizerLauncher = null
|
||||||
@@ -192,6 +220,8 @@ class PlaybackPanelFragment :
|
|||||||
binding.playbackArtist.isSelected = false
|
binding.playbackArtist.isSelected = false
|
||||||
binding.playbackAlbum?.isSelected = false
|
binding.playbackAlbum?.isSelected = false
|
||||||
binding.playbackToolbar.setOnMenuItemClickListener(null)
|
binding.playbackToolbar.setOnMenuItemClickListener(null)
|
||||||
|
userAwarePagerCallback?.release()
|
||||||
|
binding.playbackPager?.adapter = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMenuItemClick(item: MenuItem): Boolean {
|
override fun onMenuItemClick(item: MenuItem): Boolean {
|
||||||
@@ -231,7 +261,6 @@ class PlaybackPanelFragment :
|
|||||||
val binding = requireBinding()
|
val binding = requireBinding()
|
||||||
val context = requireContext()
|
val context = requireContext()
|
||||||
L.d("Updating song display: $song")
|
L.d("Updating song display: $song")
|
||||||
binding.playbackCover.bind(song)
|
|
||||||
binding.playbackSong.text = song.name.resolve(context)
|
binding.playbackSong.text = song.name.resolve(context)
|
||||||
binding.playbackArtist.text = song.artists.resolveNames(context)
|
binding.playbackArtist.text = song.artists.resolveNames(context)
|
||||||
binding.playbackAlbum?.text = song.album.name.resolve(context)
|
binding.playbackAlbum?.text = song.album.name.resolve(context)
|
||||||
@@ -264,6 +293,40 @@ class PlaybackPanelFragment :
|
|||||||
requireBinding().playbackShuffle.isChecked = isShuffled
|
requireBinding().playbackShuffle.isChecked = isShuffled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updatePager(queue: PagerQueue) {
|
||||||
|
val binding = requireBinding()
|
||||||
|
|
||||||
|
val command = playbackModel.pagerCommand.consume()
|
||||||
|
if (command == null) {
|
||||||
|
// This probably shouldn't happen in practice, as QueueViewModel directly
|
||||||
|
// attaches to PlaybackStateManager and will basically always initialize
|
||||||
|
// with a command as a result.
|
||||||
|
//
|
||||||
|
// If it does happen we should just make sure the UI state is aligned. Don't
|
||||||
|
// want broken UI.
|
||||||
|
coverPagerAdapter.update(queue.queue, null)
|
||||||
|
binding.playbackPager.setCurrentItem(queue.index, false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (command.update != null) {
|
||||||
|
// queue needs to be updated.
|
||||||
|
coverPagerAdapter.update(queue.queue, command.update)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (command.scroll != null) {
|
||||||
|
// we need to scroll, however the smooth scroll only really looks best
|
||||||
|
// when we are only doing next/prev due to various factors. better to
|
||||||
|
// just not animate on outright gotos or queue updates
|
||||||
|
val delta = binding.playbackPager.currentItem - command.scroll
|
||||||
|
if (delta == 0) {
|
||||||
|
// user scroll, carry on
|
||||||
|
return
|
||||||
|
}
|
||||||
|
binding.playbackPager.setCurrentItem(command.scroll, command.update == null && abs(delta) == 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun navigateToCurrentSong() {
|
private fun navigateToCurrentSong() {
|
||||||
playbackModel.song.value?.let(detailModel::showAlbum)
|
playbackModel.song.value?.let(detailModel::showAlbum)
|
||||||
}
|
}
|
||||||
@@ -282,4 +345,8 @@ class PlaybackPanelFragment :
|
|||||||
Direction.BACKWARDS -> playbackModel.stepBackwards()
|
Direction.BACKWARDS -> playbackModel.stepBackwards()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
|||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.oxycblt.auxio.list.ListSettings
|
import org.oxycblt.auxio.list.ListSettings
|
||||||
|
import org.oxycblt.auxio.list.adapter.UpdateInstructions
|
||||||
import org.oxycblt.auxio.playback.state.DeferredPlayback
|
import org.oxycblt.auxio.playback.state.DeferredPlayback
|
||||||
import org.oxycblt.auxio.playback.state.PlaybackCommand
|
import org.oxycblt.auxio.playback.state.PlaybackCommand
|
||||||
import org.oxycblt.auxio.playback.state.PlaybackStateManager
|
import org.oxycblt.auxio.playback.state.PlaybackStateManager
|
||||||
@@ -104,6 +105,15 @@ constructor(
|
|||||||
val openPanel: Event<OpenPanel>
|
val openPanel: Event<OpenPanel>
|
||||||
get() = _openPanel
|
get() = _openPanel
|
||||||
|
|
||||||
|
private val _pagerQueue = MutableStateFlow(PagerQueue(listOf(), 0))
|
||||||
|
/** The current queue in a special bundled format suitable for the cover ViewPager2. */
|
||||||
|
val pagerQueue: StateFlow<PagerQueue> = _pagerQueue
|
||||||
|
|
||||||
|
private val _pagerCommand = MutableEvent<PagerCommand>()
|
||||||
|
/** Specialized ViewPager2-friendly queue commands */
|
||||||
|
val pagerCommand: Event<PagerCommand>
|
||||||
|
get() = _pagerCommand
|
||||||
|
|
||||||
private val _playbackDecision = MutableEvent<PlaybackDecision>()
|
private val _playbackDecision = MutableEvent<PlaybackDecision>()
|
||||||
/**
|
/**
|
||||||
* A [PlaybackDecision] command that is awaiting a view capable of responding to it. Null if
|
* A [PlaybackDecision] command that is awaiting a view capable of responding to it. Null if
|
||||||
@@ -130,7 +140,16 @@ constructor(
|
|||||||
|
|
||||||
override fun onIndexMoved(index: Int) {
|
override fun onIndexMoved(index: Int) {
|
||||||
L.d("Index moved, updating current song")
|
L.d("Index moved, updating current song")
|
||||||
|
_positionDs.value = playbackManager.progression.calculateElapsedPositionMs().msToDs()
|
||||||
_song.value = playbackManager.currentSong
|
_song.value = playbackManager.currentSong
|
||||||
|
|
||||||
|
_pagerCommand.put(
|
||||||
|
PagerCommand(
|
||||||
|
update = null,
|
||||||
|
scroll = index
|
||||||
|
)
|
||||||
|
)
|
||||||
|
_pagerQueue.value = _pagerQueue.value.copy(index = index)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onQueueChanged(queue: List<Song>, index: Int, change: QueueChange) {
|
override fun onQueueChanged(queue: List<Song>, index: Int, change: QueueChange) {
|
||||||
@@ -139,11 +158,33 @@ constructor(
|
|||||||
L.d("Queue changed, updating current song")
|
L.d("Queue changed, updating current song")
|
||||||
_song.value = playbackManager.currentSong
|
_song.value = playbackManager.currentSong
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_pagerCommand.put(
|
||||||
|
PagerCommand(
|
||||||
|
update = change.instructions,
|
||||||
|
scroll = index.takeIf { change.type != QueueChange.Type.MAPPING }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
_pagerQueue.value = PagerQueue(
|
||||||
|
queue = queue,
|
||||||
|
index = index
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onQueueReordered(queue: List<Song>, index: Int, isShuffled: Boolean) {
|
override fun onQueueReordered(queue: List<Song>, index: Int, isShuffled: Boolean) {
|
||||||
L.d("Queue completely changed, updating current song")
|
L.d("Queue completely changed, updating current song")
|
||||||
_isShuffled.value = isShuffled
|
_isShuffled.value = isShuffled
|
||||||
|
|
||||||
|
_pagerCommand.put(
|
||||||
|
PagerCommand(
|
||||||
|
update = UpdateInstructions.Replace(0),
|
||||||
|
scroll = index
|
||||||
|
)
|
||||||
|
)
|
||||||
|
_pagerQueue.value = PagerQueue(
|
||||||
|
queue = queue,
|
||||||
|
index = index
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNewPlayback(
|
override fun onNewPlayback(
|
||||||
@@ -156,6 +197,17 @@ constructor(
|
|||||||
_song.value = playbackManager.currentSong
|
_song.value = playbackManager.currentSong
|
||||||
_parent.value = parent
|
_parent.value = parent
|
||||||
_isShuffled.value = isShuffled
|
_isShuffled.value = isShuffled
|
||||||
|
|
||||||
|
_pagerCommand.put(
|
||||||
|
PagerCommand(
|
||||||
|
update = UpdateInstructions.Replace(0),
|
||||||
|
scroll = index
|
||||||
|
)
|
||||||
|
)
|
||||||
|
_pagerQueue.value = PagerQueue(
|
||||||
|
queue = queue,
|
||||||
|
index = index
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onProgressionChanged(progression: Progression) {
|
override fun onProgressionChanged(progression: Progression) {
|
||||||
@@ -632,6 +684,17 @@ constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
data class PagerQueue(
|
||||||
|
val queue: List<Song>,
|
||||||
|
val index: Int
|
||||||
|
)
|
||||||
|
|
||||||
|
data class PagerCommand(
|
||||||
|
val update: UpdateInstructions?,
|
||||||
|
val scroll: Int?
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command for controlling the main playback panel UI.
|
* Command for controlling the main playback panel UI.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,144 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023 Auxio Project
|
|
||||||
* ControlledCoverView.kt is part of Auxio.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.oxycblt.auxio.playback.ui
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.content.Context
|
|
||||||
import android.util.AttributeSet
|
|
||||||
import android.view.GestureDetector
|
|
||||||
import android.view.GestureDetector.OnDoubleTapListener
|
|
||||||
import android.view.GestureDetector.OnGestureListener
|
|
||||||
import android.view.MotionEvent
|
|
||||||
import android.view.ViewConfiguration
|
|
||||||
import androidx.annotation.AttrRes
|
|
||||||
import kotlin.math.abs
|
|
||||||
import org.oxycblt.auxio.image.CoverView
|
|
||||||
import org.oxycblt.auxio.util.isRtl
|
|
||||||
|
|
||||||
class ControlledCoverView
|
|
||||||
@JvmOverloads
|
|
||||||
constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr: Int = 0) :
|
|
||||||
CoverView(context, attrs, defStyleAttr), OnGestureListener, OnDoubleTapListener {
|
|
||||||
|
|
||||||
private val gestureDetector =
|
|
||||||
GestureDetector(context, this).apply { setOnDoubleTapListener(this@ControlledCoverView) }
|
|
||||||
private val viewConfig = ViewConfiguration.get(context)
|
|
||||||
|
|
||||||
var onSwipeListener: OnSwipeListener? = null
|
|
||||||
|
|
||||||
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
|
|
||||||
return gestureDetector.onTouchEvent(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
|
||||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
|
||||||
return gestureDetector.onTouchEvent(event) || super.onTouchEvent(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onGenericMotionEvent(event: MotionEvent): Boolean {
|
|
||||||
return gestureDetector.onGenericMotionEvent(event) || super.onGenericMotionEvent(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDown(e: MotionEvent): Boolean = true
|
|
||||||
|
|
||||||
override fun onShowPress(e: MotionEvent) = Unit
|
|
||||||
|
|
||||||
override fun onSingleTapUp(e: MotionEvent): Boolean = false
|
|
||||||
|
|
||||||
override fun onScroll(
|
|
||||||
e1: MotionEvent?,
|
|
||||||
e2: MotionEvent,
|
|
||||||
velocityX: Float,
|
|
||||||
velocityY: Float,
|
|
||||||
): Boolean = false
|
|
||||||
|
|
||||||
override fun onFling(
|
|
||||||
e1: MotionEvent?,
|
|
||||||
e2: MotionEvent,
|
|
||||||
velocityX: Float,
|
|
||||||
velocityY: Float,
|
|
||||||
): Boolean {
|
|
||||||
e1 ?: return false
|
|
||||||
val diffY = e2.y - e1.y
|
|
||||||
val diffX = e2.x - e1.x
|
|
||||||
if (
|
|
||||||
abs(diffX) > abs(diffY) &&
|
|
||||||
abs(diffX) > viewConfig.scaledTouchSlop &&
|
|
||||||
abs(velocityX) > viewConfig.scaledMinimumFlingVelocity
|
|
||||||
) {
|
|
||||||
if (diffX > 0) {
|
|
||||||
onSwipeRight()
|
|
||||||
} else {
|
|
||||||
onSwipeLeft()
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onLongPress(e: MotionEvent) = Unit
|
|
||||||
|
|
||||||
override fun onSingleTapConfirmed(e: MotionEvent): Boolean = false
|
|
||||||
|
|
||||||
override fun onDoubleTap(e: MotionEvent): Boolean {
|
|
||||||
val width = width
|
|
||||||
val tapX = e.x
|
|
||||||
|
|
||||||
when {
|
|
||||||
tapX < width * 0.33f -> {
|
|
||||||
if (isRtl) {
|
|
||||||
onSwipeListener?.onStepForward()
|
|
||||||
} else {
|
|
||||||
onSwipeListener?.onStepBack()
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
tapX > width * 0.67f -> {
|
|
||||||
if (isRtl) {
|
|
||||||
onSwipeListener?.onStepBack()
|
|
||||||
} else {
|
|
||||||
onSwipeListener?.onStepForward()
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
else -> return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDoubleTapEvent(e: MotionEvent): Boolean = false
|
|
||||||
|
|
||||||
private fun onSwipeRight() {
|
|
||||||
onSwipeListener?.run { if (isRtl) onSwipeNext() else onSwipePrevious() }
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun onSwipeLeft() {
|
|
||||||
onSwipeListener?.run { if (isRtl) onSwipePrevious() else onSwipeNext() }
|
|
||||||
}
|
|
||||||
|
|
||||||
interface OnSwipeListener {
|
|
||||||
|
|
||||||
fun onSwipePrevious()
|
|
||||||
|
|
||||||
fun onSwipeNext()
|
|
||||||
|
|
||||||
fun onStepBack()
|
|
||||||
|
|
||||||
fun onStepForward()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,295 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2025 Auxio Project
|
|
||||||
* PlayerSwipeIndicatorOverlay.kt is part of Auxio.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.oxycblt.auxio.playback.ui.swipe
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.util.AttributeSet
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
import com.google.android.material.shape.MaterialShapeDrawable
|
|
||||||
import com.google.android.material.shape.ShapeAppearanceModel
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
|
||||||
import javax.inject.Inject
|
|
||||||
import org.oxycblt.auxio.R
|
|
||||||
import org.oxycblt.auxio.ui.UISettings
|
|
||||||
import org.oxycblt.auxio.util.isRtl
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
|
||||||
class PlayerSwipeIndicatorOverlay(context: Context, attrs: AttributeSet?) :
|
|
||||||
ConstraintLayout(context, attrs) {
|
|
||||||
|
|
||||||
@Inject lateinit var uiSettings: UISettings
|
|
||||||
|
|
||||||
private var leftSwipeIndicator: SwipeIndicatorView
|
|
||||||
private var rightSwipeIndicator: SwipeIndicatorView
|
|
||||||
private var leftSwipeClipView: SwipeClipView
|
|
||||||
private var rightSwipeClipView: SwipeClipView
|
|
||||||
private var rootConstraintLayout: ConstraintLayout
|
|
||||||
|
|
||||||
private val shapeAppearance: ShapeAppearanceModel
|
|
||||||
|
|
||||||
/** The width used for calculating full slide translation */
|
|
||||||
private var indicatorSlideDistance = 100f
|
|
||||||
|
|
||||||
/** Current swipe direction, null if no swipe in progress */
|
|
||||||
private var currentSwipeDirection: SwipeDirection? = null
|
|
||||||
|
|
||||||
init {
|
|
||||||
LayoutInflater.from(context).inflate(R.layout.player_swipe_indicator_overlay, this, true)
|
|
||||||
|
|
||||||
// Set up shape appearance based on UISettings similar to CoverView
|
|
||||||
val styledAttrs =
|
|
||||||
context.obtainStyledAttributes(attrs, R.styleable.PlayerSwipeIndicatorOverlay)
|
|
||||||
val shapeAppearanceRes =
|
|
||||||
styledAttrs.getResourceId(R.styleable.PlayerSwipeIndicatorOverlay_shapeAppearance, 0)
|
|
||||||
|
|
||||||
shapeAppearance =
|
|
||||||
if (uiSettings.roundMode) {
|
|
||||||
if (shapeAppearanceRes != 0) {
|
|
||||||
ShapeAppearanceModel.builder(context, shapeAppearanceRes, -1).build()
|
|
||||||
} else {
|
|
||||||
ShapeAppearanceModel.builder(
|
|
||||||
context,
|
|
||||||
com.google.android.material.R.style
|
|
||||||
.ShapeAppearance_Material3_Corner_Medium,
|
|
||||||
-1,
|
|
||||||
)
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ShapeAppearanceModel.builder().build()
|
|
||||||
}
|
|
||||||
|
|
||||||
styledAttrs.recycle()
|
|
||||||
|
|
||||||
leftSwipeIndicator = findViewById(R.id.left_swipe_indicator)
|
|
||||||
rightSwipeIndicator = findViewById(R.id.right_swipe_indicator)
|
|
||||||
leftSwipeClipView = findViewById(R.id.left_swipe_clip_view)
|
|
||||||
rightSwipeClipView = findViewById(R.id.right_swipe_clip_view)
|
|
||||||
rootConstraintLayout = findViewById(R.id.root_constraint_layout)
|
|
||||||
|
|
||||||
// Apply shape clipping to the overlay
|
|
||||||
clipToOutline = true
|
|
||||||
background =
|
|
||||||
MaterialShapeDrawable().apply {
|
|
||||||
shapeAppearanceModel = shapeAppearance
|
|
||||||
fillColor =
|
|
||||||
android.content.res.ColorStateList.valueOf(android.graphics.Color.TRANSPARENT)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hide overlay elements by default
|
|
||||||
leftSwipeIndicator.alpha = 0f
|
|
||||||
rightSwipeIndicator.alpha = 0f
|
|
||||||
leftSwipeClipView.alpha = 0f
|
|
||||||
rightSwipeClipView.alpha = 0f
|
|
||||||
leftSwipeIndicator.visibility = INVISIBLE
|
|
||||||
rightSwipeIndicator.visibility = INVISIBLE
|
|
||||||
leftSwipeClipView.visibility = INVISIBLE
|
|
||||||
rightSwipeClipView.visibility = INVISIBLE
|
|
||||||
|
|
||||||
addOnLayoutChangeListener { view, _, _, _, _, _, _, _, _ ->
|
|
||||||
leftSwipeClipView.updateArcSize(view)
|
|
||||||
rightSwipeClipView.updateArcSize(view)
|
|
||||||
// Set slide distance based on indicator width plus some padding
|
|
||||||
indicatorSlideDistance = view.width * 0.3f
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize directions for each side
|
|
||||||
// In LTR: left side = previous, right side = next
|
|
||||||
// In RTL: left side = next, right side = previous
|
|
||||||
leftSwipeClipView.updatePosition(true)
|
|
||||||
rightSwipeClipView.updatePosition(false)
|
|
||||||
updateIndicatorDirections()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateIndicatorDirections() {
|
|
||||||
val isRtl = isRtl
|
|
||||||
// Left indicator: previous in LTR, next in RTL
|
|
||||||
leftSwipeIndicator.setIsNext(isRtl)
|
|
||||||
// Right indicator: next in LTR, previous in RTL
|
|
||||||
rightSwipeIndicator.setIsNext(!isRtl)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a swipe gesture starts.
|
|
||||||
*
|
|
||||||
* @param direction The direction of the swipe (LEFT for swiping left, RIGHT for swiping right)
|
|
||||||
*/
|
|
||||||
fun onSwipeStarted(direction: SwipeDirection) {
|
|
||||||
// Cancel any pending animations on ALL indicators (in case previous swipe
|
|
||||||
// was in a different direction and its fade-out animation is still running)
|
|
||||||
cancelAllAnimations()
|
|
||||||
|
|
||||||
currentSwipeDirection = direction
|
|
||||||
|
|
||||||
val indicatorView = getIndicatorForDirection(direction)
|
|
||||||
val clipView = getClipViewForDirection(direction)
|
|
||||||
|
|
||||||
indicatorView.visibility = VISIBLE
|
|
||||||
clipView.visibility = VISIBLE
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun cancelAllAnimations() {
|
|
||||||
// Cancel animations and reset state for both indicators
|
|
||||||
leftSwipeIndicator.animate().cancel()
|
|
||||||
rightSwipeIndicator.animate().cancel()
|
|
||||||
leftSwipeClipView.animate().cancel()
|
|
||||||
rightSwipeClipView.animate().cancel()
|
|
||||||
|
|
||||||
// Reset the non-active indicator to hidden state
|
|
||||||
leftSwipeIndicator.alpha = 0f
|
|
||||||
leftSwipeIndicator.translationX = 0f
|
|
||||||
leftSwipeIndicator.visibility = INVISIBLE
|
|
||||||
leftSwipeClipView.alpha = 0f
|
|
||||||
leftSwipeClipView.swipeProgress = 0f
|
|
||||||
leftSwipeClipView.visibility = INVISIBLE
|
|
||||||
|
|
||||||
rightSwipeIndicator.alpha = 0f
|
|
||||||
rightSwipeIndicator.translationX = 0f
|
|
||||||
rightSwipeIndicator.visibility = INVISIBLE
|
|
||||||
rightSwipeClipView.alpha = 0f
|
|
||||||
rightSwipeClipView.swipeProgress = 0f
|
|
||||||
rightSwipeClipView.visibility = INVISIBLE
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called as the user swipes to update the visual progress.
|
|
||||||
*
|
|
||||||
* @param progress Normalized progress of the swipe (0 to 1+, where 1 is the commit threshold)
|
|
||||||
* @param direction The direction of the swipe
|
|
||||||
*/
|
|
||||||
fun onSwipeProgress(progress: Float, direction: SwipeDirection) {
|
|
||||||
val indicatorView = getIndicatorForDirection(direction)
|
|
||||||
val clipView = getClipViewForDirection(direction)
|
|
||||||
|
|
||||||
// Clamp progress for visual calculations (allow slight overshoot)
|
|
||||||
val visualProgress = progress.coerceIn(0f, 1.2f)
|
|
||||||
|
|
||||||
// Alpha: fade in from 0 to 1 as progress goes from 0 to 1
|
|
||||||
val alpha = (visualProgress).coerceIn(0f, 1f)
|
|
||||||
indicatorView.alpha = alpha
|
|
||||||
clipView.alpha = alpha
|
|
||||||
|
|
||||||
// Translation: slide in from the edge
|
|
||||||
// At progress 0: fully translated off screen
|
|
||||||
// At progress 1: at final position (translation = 0)
|
|
||||||
val translationFactor = 1f - visualProgress.coerceIn(0f, 1f)
|
|
||||||
val translation =
|
|
||||||
when (direction) {
|
|
||||||
SwipeDirection.LEFT -> indicatorSlideDistance * translationFactor
|
|
||||||
SwipeDirection.RIGHT -> -indicatorSlideDistance * translationFactor
|
|
||||||
}
|
|
||||||
indicatorView.translationX = translation
|
|
||||||
|
|
||||||
// Update clip view progress
|
|
||||||
clipView.swipeProgress = visualProgress.coerceIn(0f, 1f)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the swipe gesture is released.
|
|
||||||
*
|
|
||||||
* @param committed True if the swipe passed the commit threshold and the action should execute
|
|
||||||
* @param direction The direction of the swipe
|
|
||||||
*/
|
|
||||||
fun onSwipeReleased(committed: Boolean, direction: SwipeDirection) {
|
|
||||||
val indicatorView = getIndicatorForDirection(direction)
|
|
||||||
val clipView = getClipViewForDirection(direction)
|
|
||||||
|
|
||||||
if (committed) {
|
|
||||||
// Committed: fade out immediately without sliding
|
|
||||||
indicatorView
|
|
||||||
.animate()
|
|
||||||
.alpha(0f)
|
|
||||||
.setDuration(200)
|
|
||||||
.withEndAction { indicatorView.visibility = INVISIBLE }
|
|
||||||
.start()
|
|
||||||
clipView
|
|
||||||
.animate()
|
|
||||||
.alpha(0f)
|
|
||||||
.setDuration(200)
|
|
||||||
.withEndAction {
|
|
||||||
clipView.visibility = INVISIBLE
|
|
||||||
clipView.swipeProgress = 0f
|
|
||||||
}
|
|
||||||
.start()
|
|
||||||
} else {
|
|
||||||
// Not committed: slide back out and fade out
|
|
||||||
val slideOutTranslation =
|
|
||||||
when (direction) {
|
|
||||||
SwipeDirection.LEFT -> indicatorSlideDistance
|
|
||||||
SwipeDirection.RIGHT -> -indicatorSlideDistance
|
|
||||||
}
|
|
||||||
indicatorView
|
|
||||||
.animate()
|
|
||||||
.alpha(0f)
|
|
||||||
.translationX(slideOutTranslation)
|
|
||||||
.setDuration(200)
|
|
||||||
.withEndAction {
|
|
||||||
indicatorView.visibility = INVISIBLE
|
|
||||||
indicatorView.translationX = 0f
|
|
||||||
}
|
|
||||||
.start()
|
|
||||||
// Animate clip view progress back to 0
|
|
||||||
val startProgress = clipView.swipeProgress
|
|
||||||
clipView
|
|
||||||
.animate()
|
|
||||||
.alpha(0f)
|
|
||||||
.setDuration(200)
|
|
||||||
.setUpdateListener { animator ->
|
|
||||||
val fraction = animator.animatedFraction
|
|
||||||
clipView.swipeProgress = startProgress * (1f - fraction)
|
|
||||||
}
|
|
||||||
.withEndAction {
|
|
||||||
clipView.visibility = INVISIBLE
|
|
||||||
clipView.swipeProgress = 0f
|
|
||||||
}
|
|
||||||
.start()
|
|
||||||
}
|
|
||||||
|
|
||||||
currentSwipeDirection = null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Cancels any in-progress swipe indicator without animation. */
|
|
||||||
fun cancelSwipe() {
|
|
||||||
cancelAllAnimations()
|
|
||||||
currentSwipeDirection = null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getIndicatorForDirection(direction: SwipeDirection): View {
|
|
||||||
// When swiping left, we show the right indicator (next)
|
|
||||||
// When swiping right, we show the left indicator (previous)
|
|
||||||
return when (direction) {
|
|
||||||
SwipeDirection.LEFT -> rightSwipeIndicator
|
|
||||||
SwipeDirection.RIGHT -> leftSwipeIndicator
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getClipViewForDirection(direction: SwipeDirection): SwipeClipView {
|
|
||||||
return when (direction) {
|
|
||||||
SwipeDirection.LEFT -> rightSwipeClipView
|
|
||||||
SwipeDirection.RIGHT -> leftSwipeClipView
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class SwipeDirection {
|
|
||||||
LEFT,
|
|
||||||
RIGHT,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2025 Auxio Project
|
|
||||||
* SwipeClipView.kt is part of Auxio.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.oxycblt.auxio.playback.ui.swipe
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.graphics.Canvas
|
|
||||||
import android.graphics.Paint
|
|
||||||
import android.graphics.Path
|
|
||||||
import android.util.AttributeSet
|
|
||||||
import android.view.View
|
|
||||||
|
|
||||||
class SwipeClipView(context: Context?, attrs: AttributeSet) : View(context, attrs) {
|
|
||||||
|
|
||||||
private var backgroundPaint = Paint()
|
|
||||||
|
|
||||||
private var widthPx = 0
|
|
||||||
private var heightPx = 0
|
|
||||||
|
|
||||||
private var shapePath = Path()
|
|
||||||
private var arcSize: Float = 80f
|
|
||||||
private var isLeft = true
|
|
||||||
|
|
||||||
/** Progress from 0.0 to 1.0 indicating how much of the swipe area to show */
|
|
||||||
var swipeProgress: Float = 0f
|
|
||||||
set(value) {
|
|
||||||
field = value.coerceIn(0f, 1f)
|
|
||||||
updatePathShape()
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
|
||||||
requireNotNull(context) { "Context is null." }
|
|
||||||
|
|
||||||
backgroundPaint.apply {
|
|
||||||
style = Paint.Style.FILL
|
|
||||||
isAntiAlias = true
|
|
||||||
color = 0x30000000
|
|
||||||
}
|
|
||||||
|
|
||||||
val dm = context.resources.displayMetrics
|
|
||||||
widthPx = dm.widthPixels
|
|
||||||
heightPx = dm.heightPixels
|
|
||||||
|
|
||||||
updatePathShape()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun updateArcSize(baseView: View) {
|
|
||||||
val newArcSize = baseView.height / 11.4f
|
|
||||||
if (arcSize != newArcSize) {
|
|
||||||
arcSize = newArcSize
|
|
||||||
updatePathShape()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun updatePosition(newIsLeft: Boolean) {
|
|
||||||
if (isLeft != newIsLeft) {
|
|
||||||
isLeft = newIsLeft
|
|
||||||
updatePathShape()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updatePathShape() {
|
|
||||||
// The maximum width the swipe area can take (half of the view)
|
|
||||||
val maxSwipeWidth = widthPx * 0.5f
|
|
||||||
// The current swipe width based on progress
|
|
||||||
val currentSwipeWidth = maxSwipeWidth * swipeProgress
|
|
||||||
|
|
||||||
shapePath.reset()
|
|
||||||
|
|
||||||
if (currentSwipeWidth <= 0) {
|
|
||||||
invalidate()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isLeft) {
|
|
||||||
// Draw from left edge
|
|
||||||
shapePath.moveTo(0f, 0f)
|
|
||||||
shapePath.lineTo(currentSwipeWidth - arcSize.coerceAtMost(currentSwipeWidth), 0f)
|
|
||||||
shapePath.quadTo(
|
|
||||||
currentSwipeWidth + arcSize.coerceAtMost(currentSwipeWidth),
|
|
||||||
heightPx.toFloat() / 2,
|
|
||||||
currentSwipeWidth - arcSize.coerceAtMost(currentSwipeWidth),
|
|
||||||
heightPx.toFloat(),
|
|
||||||
)
|
|
||||||
shapePath.lineTo(0f, heightPx.toFloat())
|
|
||||||
} else {
|
|
||||||
// Draw from right edge
|
|
||||||
val rightEdge = widthPx.toFloat()
|
|
||||||
shapePath.moveTo(rightEdge, 0f)
|
|
||||||
shapePath.lineTo(
|
|
||||||
rightEdge - currentSwipeWidth + arcSize.coerceAtMost(currentSwipeWidth),
|
|
||||||
0f,
|
|
||||||
)
|
|
||||||
shapePath.quadTo(
|
|
||||||
rightEdge - currentSwipeWidth - arcSize.coerceAtMost(currentSwipeWidth),
|
|
||||||
heightPx.toFloat() / 2,
|
|
||||||
rightEdge - currentSwipeWidth + arcSize.coerceAtMost(currentSwipeWidth),
|
|
||||||
heightPx.toFloat(),
|
|
||||||
)
|
|
||||||
shapePath.lineTo(rightEdge, heightPx.toFloat())
|
|
||||||
}
|
|
||||||
|
|
||||||
shapePath.close()
|
|
||||||
invalidate()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
|
||||||
super.onSizeChanged(w, h, oldw, oldh)
|
|
||||||
widthPx = w
|
|
||||||
heightPx = h
|
|
||||||
updatePathShape()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDraw(canvas: Canvas) {
|
|
||||||
super.onDraw(canvas)
|
|
||||||
|
|
||||||
if (swipeProgress > 0) {
|
|
||||||
canvas.clipPath(shapePath)
|
|
||||||
canvas.drawPath(shapePath, backgroundPaint)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2025 Auxio Project
|
|
||||||
* SwipeIndicatorView.kt is part of Auxio.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.oxycblt.auxio.playback.ui.swipe
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.util.AttributeSet
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.widget.LinearLayout
|
|
||||||
import org.oxycblt.auxio.R
|
|
||||||
import org.oxycblt.auxio.databinding.PlayerSwipeIndicatorViewBinding
|
|
||||||
|
|
||||||
class SwipeIndicatorView(context: Context, attrs: AttributeSet?) : LinearLayout(context, attrs) {
|
|
||||||
|
|
||||||
val binding = PlayerSwipeIndicatorViewBinding.inflate(LayoutInflater.from(context), this)
|
|
||||||
|
|
||||||
init {
|
|
||||||
orientation = HORIZONTAL
|
|
||||||
layoutParams = LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setIsNext(isNext: Boolean) {
|
|
||||||
if (isNext) {
|
|
||||||
// For "next": Text on left, icon on right
|
|
||||||
binding.swipeIcon.setImageResource(R.drawable.ic_skip_next_24)
|
|
||||||
binding.swipeText.setText(R.string.desc_skip_next)
|
|
||||||
// Reorder views: text first, then icon
|
|
||||||
removeAllViews()
|
|
||||||
addView(binding.swipeText)
|
|
||||||
addView(binding.swipeIcon)
|
|
||||||
} else {
|
|
||||||
// For "previous": Icon on left, text on right
|
|
||||||
binding.swipeIcon.setImageResource(R.drawable.ic_skip_prev_24)
|
|
||||||
binding.swipeText.setText(R.string.desc_skip_prev)
|
|
||||||
// Reorder views: icon first, then text
|
|
||||||
removeAllViews()
|
|
||||||
addView(binding.swipeIcon)
|
|
||||||
addView(binding.swipeText)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
package org.oxycblt.auxio.playback.ui.swiper
|
||||||
|
|
||||||
|
import android.graphics.RectF
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.viewpager2.widget.ViewPager2
|
||||||
|
import com.google.android.material.carousel.MaskableFrameLayout
|
||||||
|
import com.google.android.material.math.MathUtils.lerp
|
||||||
|
import kotlin.math.abs
|
||||||
|
|
||||||
|
class CarouselTransformer : ViewPager2.PageTransformer {
|
||||||
|
override fun transformPage(page: View, position: Float) {
|
||||||
|
// drafted by codex mostly due to the insane complexity of abusing a viewpager2
|
||||||
|
// into a m3 carousel like thing
|
||||||
|
// cleaned/rewritten/documented by me for cognitive ownership
|
||||||
|
val maskable = page as MaskableFrameLayout
|
||||||
|
val width = page.width.toFloat()
|
||||||
|
val height = page.height.toFloat()
|
||||||
|
|
||||||
|
// pin the page
|
||||||
|
// normally the page's layout is controlled by linearlayoutmanager which we dont
|
||||||
|
// like since it means we cant arrange them in the carousel
|
||||||
|
// so we use translationX to fix them to the same pos so we can remask them however
|
||||||
|
// we want to create our effect
|
||||||
|
page.translationX = -position * width
|
||||||
|
|
||||||
|
val p =
|
||||||
|
when {
|
||||||
|
// prev page, just abs
|
||||||
|
// so in this case p will be 1.0 -> 0.0, so 1.0 when fully outset and 0.0 when inset
|
||||||
|
// we must conform to this!
|
||||||
|
position < 0f -> -position
|
||||||
|
// next page, take the inverse actually
|
||||||
|
// remember, this must also be normalized to outset = 1.0, inset = 0.0
|
||||||
|
// so take the opposite end (1f - pos)
|
||||||
|
position > 0f -> 1f - position
|
||||||
|
else -> 0f
|
||||||
|
}
|
||||||
|
|
||||||
|
// breakpoints for the gap
|
||||||
|
// the thing is that really we have to encode the "gap" an equation such that
|
||||||
|
// the masking effect looks like a contiguous transform of adjacent covers.
|
||||||
|
// if we just add a fixed gap it'll appear instantly, and any p * gap or similar
|
||||||
|
// logic will morph over time. even polynomials will morph as well. hence this
|
||||||
|
// really funky piecewise function
|
||||||
|
|
||||||
|
// basically at the first and last 18% of progress we should grow and shrink the gap
|
||||||
|
// respectively
|
||||||
|
val gapEnterBreakpoint = GAP_BREAKPOINT // when growth ends
|
||||||
|
val gapExitBreakpoint = 1f - GAP_BREAKPOINT // symmetric, when shrink starts
|
||||||
|
val maxGap = width * 0.08f
|
||||||
|
|
||||||
|
val gap =
|
||||||
|
when {
|
||||||
|
// gap is not fully grown yet, so we do the gap size * how close we are to a fully
|
||||||
|
// grown gap
|
||||||
|
p < gapEnterBreakpoint ->
|
||||||
|
maxGap * (p / gapEnterBreakpoint)
|
||||||
|
|
||||||
|
// gap should be shrinking, so we need to downscale maxgap by how close we are
|
||||||
|
// actually to the end
|
||||||
|
p > gapExitBreakpoint ->
|
||||||
|
maxGap * ((1f - p) / (1f - gapExitBreakpoint))
|
||||||
|
|
||||||
|
// not growing or shrinking
|
||||||
|
else ->
|
||||||
|
maxGap
|
||||||
|
}
|
||||||
|
|
||||||
|
// then we need to get how much we actually want to reveal the incoming covers post-gap
|
||||||
|
// so first normalize p past gapEnterBreakpoint, then normalize it to the range
|
||||||
|
// between the gap transform breakpoints, so this range:
|
||||||
|
// [enter] - [reveal] - [exit]
|
||||||
|
// if p is inside [enter] or [exit] we snap to 0f/1f respectively, so i.e
|
||||||
|
// dont reveal more/less than we need to if the gap being phased out already
|
||||||
|
// handles it
|
||||||
|
val reveal =
|
||||||
|
((p - gapEnterBreakpoint) / ((gapExitBreakpoint) - gapEnterBreakpoint)).coerceIn(0f, 1f)
|
||||||
|
|
||||||
|
// alloc space for incoming cover, gap, outgoing cover
|
||||||
|
val available = width - gap
|
||||||
|
val incomingWidth = available * reveal
|
||||||
|
val outgoingWidth = available - incomingWidth
|
||||||
|
|
||||||
|
val rect =
|
||||||
|
when {
|
||||||
|
// previous cover -> fit to outgoing width to the right
|
||||||
|
// gap is already factored into the available calculation outgoingWidth depends
|
||||||
|
// on
|
||||||
|
position < 0f -> {
|
||||||
|
RectF(0f, 0f, outgoingWidth, height)
|
||||||
|
}
|
||||||
|
|
||||||
|
// incoming cover -> mask to incoming width towards the left
|
||||||
|
// note:
|
||||||
|
// left = width - incomingWidth = width - (width - **gap**) * reveal
|
||||||
|
// this means that we automatically inset for the gap without including
|
||||||
|
// it as an explicit term
|
||||||
|
// and since gap itself is scaled via the piecewise function this makes
|
||||||
|
// it so that the gap automatically appears
|
||||||
|
position > 0f -> {
|
||||||
|
RectF(width - incomingWidth, 0f, width, height)
|
||||||
|
}
|
||||||
|
|
||||||
|
// current cover, mask to normal
|
||||||
|
else -> {
|
||||||
|
RectF(0f, 0f, width, height)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
maskable.setMaskRectF(rect)
|
||||||
|
|
||||||
|
// internal page parallax
|
||||||
|
// this does assume the cover item setup but thats fine
|
||||||
|
val content = page.getChildAt(0)
|
||||||
|
val maskCenter = (rect.left + rect.right) / 2f
|
||||||
|
val pageCenter = width / 2f
|
||||||
|
// easy parallax where left content moves more left,
|
||||||
|
// right content moves more to the right
|
||||||
|
content.translationX = (maskCenter - pageCenter) * PARALLAX
|
||||||
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
const val GAP_BREAKPOINT = 0.18f
|
||||||
|
const val PARALLAX = 0.2f
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package org.oxycblt.auxio.playback.ui.swiper
|
||||||
|
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import org.oxycblt.auxio.databinding.ItemCoverBinding
|
||||||
|
import org.oxycblt.auxio.list.adapter.FlexibleListAdapter
|
||||||
|
import org.oxycblt.auxio.list.adapter.SimpleDiffCallback
|
||||||
|
import org.oxycblt.auxio.playback.ui.stepper.PlayerFastSeekOverlay
|
||||||
|
import org.oxycblt.auxio.util.inflater
|
||||||
|
import org.oxycblt.musikr.Song
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A [FlexibleListAdapter] that hosts [CoverViewHolder]s containing a [Song]'s cover and step
|
||||||
|
* gesture overlays.
|
||||||
|
*
|
||||||
|
* @param listener The [PlayerFastSeekOverlay.PerformListener] that step gesture events will be
|
||||||
|
* forwarded to
|
||||||
|
*
|
||||||
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
|
*/
|
||||||
|
class CoverPagerAdapter(
|
||||||
|
private val listener: PlayerFastSeekOverlay.PerformListener
|
||||||
|
) : FlexibleListAdapter<Song, CoverViewHolder>(CoverViewHolder.DIFF_CALLBACK) {
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, pos: Int) = CoverViewHolder.from(parent)
|
||||||
|
|
||||||
|
override fun onBindViewHolder(viewHolder: CoverViewHolder, pos: Int) {
|
||||||
|
viewHolder.bind(currentList[pos], listener)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A [RecyclerView.ViewHolder] that displays a [Song]'s cover and step gesture overlays.
|
||||||
|
*
|
||||||
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
|
*/
|
||||||
|
class CoverViewHolder private constructor(private val binding: ItemCoverBinding) :
|
||||||
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
|
/**
|
||||||
|
* Bind new data to this instance.
|
||||||
|
*
|
||||||
|
* @param song The new [Song] to bind.
|
||||||
|
* @param listener An [PlayerFastSeekOverlay.PerformListener] to bind fast seek interactions to.
|
||||||
|
*/
|
||||||
|
fun bind(song: Song, listener: PlayerFastSeekOverlay.PerformListener) {
|
||||||
|
binding.cover.bind(song)
|
||||||
|
binding.coverFastSeekOverlay.performListener = listener
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
/**
|
||||||
|
* Create a new instance.
|
||||||
|
*
|
||||||
|
* @param parent The parent to inflate this instance from.
|
||||||
|
* @return A new instance.
|
||||||
|
*/
|
||||||
|
fun from(parent: ViewGroup) = CoverViewHolder(ItemCoverBinding.inflate(parent.context.inflater, parent, false))
|
||||||
|
|
||||||
|
/** A comparator that can be used with DiffUtil. */
|
||||||
|
val DIFF_CALLBACK =
|
||||||
|
object : SimpleDiffCallback<Song>() {
|
||||||
|
override fun areContentsTheSame(oldItem: Song, newItem: Song) =
|
||||||
|
oldItem.cover == newItem.cover
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package org.oxycblt.auxio.playback.ui.swiper
|
||||||
|
|
||||||
|
import androidx.viewpager2.widget.ViewPager2
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A [ViewPager2.OnPageChangeCallback] that only fires [userCallback] when a user actually
|
||||||
|
* enagages in a swipe action. [ViewPager2] doesn't normally supply this so we have to do it
|
||||||
|
* via a stateful object.
|
||||||
|
*
|
||||||
|
* @param viewPager [ViewPager2] that this will be attached to (must do this separately)
|
||||||
|
* @param userCallback The callback to run on a user-driven swipe
|
||||||
|
*
|
||||||
|
* @author Alexander Capehart (OxygenCobalt), Idea from GPT-5.5 (Rewritten)
|
||||||
|
*/
|
||||||
|
class UserAwarePagerCallback(private val viewPager: ViewPager2, private val userCallback: (Int) -> Unit) : ViewPager2.OnPageChangeCallback() {
|
||||||
|
private var user = false
|
||||||
|
|
||||||
|
override fun onPageScrollStateChanged(state: Int) {
|
||||||
|
when (state) {
|
||||||
|
ViewPager2.SCROLL_STATE_DRAGGING -> {
|
||||||
|
user = !viewPager.isFakeDragging
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewPager2.SCROLL_STATE_IDLE -> {
|
||||||
|
user = false
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPageSelected(position: Int) {
|
||||||
|
if (user) {
|
||||||
|
userCallback(position)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attach this to the passed [viewPager].
|
||||||
|
*/
|
||||||
|
fun attach() {
|
||||||
|
viewPager.registerOnPageChangeCallback(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detach this from the passed [viewPager].
|
||||||
|
*/
|
||||||
|
fun release() {
|
||||||
|
viewPager.unregisterOnPageChangeCallback(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,11 +36,18 @@ import androidx.core.net.toUri
|
|||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import androidx.navigation.NavDirections
|
import androidx.navigation.NavDirections
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
|
import androidx.viewpager2.widget.ViewPager2
|
||||||
import java.lang.IllegalArgumentException
|
import java.lang.IllegalArgumentException
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
|
import org.oxycblt.auxio.ui.Spatial
|
||||||
import org.oxycblt.musikr.MusicParent
|
import org.oxycblt.musikr.MusicParent
|
||||||
import org.oxycblt.musikr.Song
|
import org.oxycblt.musikr.Song
|
||||||
|
import java.lang.reflect.Field
|
||||||
|
import kotlin.math.abs
|
||||||
|
import kotlin.math.sign
|
||||||
import timber.log.Timber as L
|
import timber.log.Timber as L
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -136,6 +143,26 @@ fun AppCompatButton.fixDoubleRipple() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val VP_RECYCLER_FIELD: Field by lazyReflectedField(ViewPager2::class, "mRecyclerView")
|
||||||
|
private val RV_TOUCH_SLOP_FIELD: Field by lazyReflectedField(RecyclerView::class, "mTouchSlop")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dampen a [ViewPager2] so that vertical scrolls can still easily occur.
|
||||||
|
*
|
||||||
|
* By default, ViewPager2's sensitivity is high enough to result in vertical scroll
|
||||||
|
* events being registered as horizontal scroll events. Reflect into the internal
|
||||||
|
* RecyclerView and change the touch slope so that touch actions will act more as a
|
||||||
|
* scroll than as a swipe. Derived from:
|
||||||
|
* https://al-e-shevelev.medium.com/how-to-reduce-scroll-sensitivity-of-viewpager2-widget-87797ad02414
|
||||||
|
*/
|
||||||
|
fun ViewPager2.dampen() {
|
||||||
|
val recycler = recycler()
|
||||||
|
val slop = RV_TOUCH_SLOP_FIELD.get(recycler) as Int
|
||||||
|
RV_TOUCH_SLOP_FIELD.set(recycler, slop * 3)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun ViewPager2.recycler() = (VP_RECYCLER_FIELD.get(this) as RecyclerView)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crash-safe wrapped around [NavController.navigate] that will not crash if multiple destinations
|
* Crash-safe wrapped around [NavController.navigate] that will not crash if multiple destinations
|
||||||
* are selected at once.
|
* are selected at once.
|
||||||
|
|||||||
@@ -20,14 +20,15 @@
|
|||||||
app:title="@string/lbl_playback"
|
app:title="@string/lbl_playback"
|
||||||
tools:subtitle="@string/lbl_all_songs" />
|
tools:subtitle="@string/lbl_all_songs" />
|
||||||
|
|
||||||
|
<androidx.viewpager2.widget.ViewPager2
|
||||||
<org.oxycblt.auxio.playback.ui.ControlledCoverView
|
android:id="@+id/playback_pager"
|
||||||
android:id="@+id/playback_cover"
|
android:layout_width="0dp"
|
||||||
style="@style/Widget.Auxio.Image.Full"
|
android:layout_height="0dp"
|
||||||
android:layout_marginStart="@dimen/spacing_medium"
|
android:layout_marginStart="@dimen/spacing_medium"
|
||||||
android:layout_marginTop="@dimen/spacing_medium"
|
android:layout_marginTop="@dimen/spacing_medium"
|
||||||
app:enablePlaybackIndicator="false"
|
android:clickable="true"
|
||||||
app:enableSelectionBadge="false"
|
android:focusable="true"
|
||||||
|
app:layout_constraintDimensionRatio="1"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/playback_seek_bar"
|
app:layout_constraintBottom_toTopOf="@+id/playback_seek_bar"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/playback_toolbar"
|
app:layout_constraintTop_toBottomOf="@+id/playback_toolbar"
|
||||||
@@ -41,11 +42,11 @@
|
|||||||
android:layout_marginStart="@dimen/spacing_medium"
|
android:layout_marginStart="@dimen/spacing_medium"
|
||||||
android:layout_marginEnd="@dimen/spacing_mid_medium"
|
android:layout_marginEnd="@dimen/spacing_mid_medium"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/playback_cover"
|
app:layout_constraintBottom_toBottomOf="@+id/playback_pager"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/playback_more"
|
app:layout_constraintEnd_toStartOf="@+id/playback_more"
|
||||||
app:layout_constraintHorizontal_bias="0.5"
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
app:layout_constraintStart_toEndOf="@+id/playback_cover"
|
app:layout_constraintStart_toEndOf="@+id/playback_pager"
|
||||||
app:layout_constraintTop_toTopOf="@+id/playback_cover"
|
app:layout_constraintTop_toTopOf="@+id/playback_pager"
|
||||||
app:layout_constraintVertical_chainStyle="packed">
|
app:layout_constraintVertical_chainStyle="packed">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|||||||
@@ -20,24 +20,14 @@
|
|||||||
app:titleTextAppearance="?attr/textAppearanceLabelLargeEmphasized"
|
app:titleTextAppearance="?attr/textAppearanceLabelLargeEmphasized"
|
||||||
tools:subtitle="@string/lbl_all_songs" />
|
tools:subtitle="@string/lbl_all_songs" />
|
||||||
|
|
||||||
<org.oxycblt.auxio.playback.ui.ControlledCoverView
|
<androidx.viewpager2.widget.ViewPager2
|
||||||
android:id="@+id/playback_cover"
|
android:id="@+id/playback_pager"
|
||||||
style="@style/Widget.Auxio.Image.Full"
|
|
||||||
android:layout_margin="@dimen/spacing_medium"
|
|
||||||
app:enablePlaybackIndicator="false"
|
|
||||||
app:enableSelectionBadge="false"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/playback_info_container"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/playback_toolbar"
|
|
||||||
app:layout_constraintVertical_chainStyle="packed" />
|
|
||||||
|
|
||||||
<org.oxycblt.auxio.playback.ui.stepper.PlayerFastSeekOverlay
|
|
||||||
android:id="@+id/playback_fast_seek_overlay"
|
|
||||||
style="@style/Widget.Auxio.Image.Full"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_margin="@dimen/spacing_medium"
|
android:layout_margin="@dimen/spacing_medium"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
app:layout_constraintDimensionRatio="1"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/playback_info_container"
|
app:layout_constraintBottom_toTopOf="@+id/playback_info_container"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
tools:subtitle="@string/lbl_all_songs" />
|
tools:subtitle="@string/lbl_all_songs" />
|
||||||
|
|
||||||
|
|
||||||
<org.oxycblt.auxio.playback.ui.ControlledCoverView
|
<androidx.viewpager2.widget.ViewPager2
|
||||||
android:id="@+id/playback_cover"
|
android:id="@+id/playback_pager"
|
||||||
style="@style/Widget.Auxio.Image.Full"
|
style="@style/Widget.Auxio.Image.Full"
|
||||||
android:layout_marginVertical="@dimen/spacing_small"
|
android:layout_marginVertical="@dimen/spacing_small"
|
||||||
app:enablePlaybackIndicator="false"
|
app:enablePlaybackIndicator="false"
|
||||||
@@ -43,8 +43,8 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/playback_controls_wrapper"
|
app:layout_constraintBottom_toTopOf="@+id/playback_controls_wrapper"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@+id/playback_cover"
|
app:layout_constraintStart_toEndOf="@+id/playback_pager"
|
||||||
app:layout_constraintTop_toTopOf="@+id/playback_cover"
|
app:layout_constraintTop_toTopOf="@+id/playback_pager"
|
||||||
app:layout_constraintVertical_chainStyle="packed">
|
app:layout_constraintVertical_chainStyle="packed">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -70,10 +70,10 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/spacing_mid_medium"
|
android:layout_marginStart="@dimen/spacing_mid_medium"
|
||||||
android:layout_marginEnd="@dimen/spacing_mid_medium"
|
android:layout_marginEnd="@dimen/spacing_mid_medium"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/playback_cover"
|
app:layout_constraintBottom_toBottomOf="@+id/playback_pager"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.5"
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
app:layout_constraintStart_toEndOf="@+id/playback_cover"
|
app:layout_constraintStart_toEndOf="@+id/playback_pager"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/playback_info_container">
|
app:layout_constraintTop_toBottomOf="@+id/playback_info_container">
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButtonGroup
|
<com.google.android.material.button.MaterialButtonGroup
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<org.oxycblt.auxio.ui.SquareMaskableFrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
app:shapeAppearance="@style/ShapeAppearance.Material3.Corner.ExtraLarge">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<org.oxycblt.auxio.image.CoverView
|
||||||
|
android:id="@+id/cover"
|
||||||
|
style="@style/Widget.Auxio.Image.Full"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:enablePlaybackIndicator="false"
|
||||||
|
app:enableSelectionBadge="false"
|
||||||
|
app:layout_constraintDimensionRatio="1"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
|
|
||||||
|
<org.oxycblt.auxio.playback.ui.stepper.PlayerFastSeekOverlay
|
||||||
|
android:id="@+id/cover_fast_seek_overlay"
|
||||||
|
style="@style/Widget.Auxio.Image.Full"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintDimensionRatio="1"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</org.oxycblt.auxio.ui.SquareMaskableFrameLayout>
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
~ Copyright (c) 2025 Auxio Project
|
|
||||||
~ player_swipe_indicator_overlay.xml is part of Auxio.
|
|
||||||
~
|
|
||||||
~ This program is free software: you can redistribute it and/or modify
|
|
||||||
~ it under the terms of the GNU General Public License as published by
|
|
||||||
~ the Free Software Foundation, either version 3 of the License, or
|
|
||||||
~ (at your option) any later version.
|
|
||||||
~
|
|
||||||
~ This program is distributed in the hope that it will be useful,
|
|
||||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
~ GNU General Public License for more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU General Public License
|
|
||||||
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/root_constraint_layout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<!-- Left indicator (for previous) with background -->
|
|
||||||
<org.oxycblt.auxio.playback.ui.swipe.SwipeClipView
|
|
||||||
android:id="@+id/left_swipe_clip_view"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:clickable="false"
|
|
||||||
android:focusable="false" />
|
|
||||||
|
|
||||||
<org.oxycblt.auxio.playback.ui.swipe.SwipeIndicatorView
|
|
||||||
android:id="@+id/left_swipe_indicator"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="@dimen/spacing_medium"
|
|
||||||
android:clickable="false"
|
|
||||||
android:focusable="false"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<!-- Right indicator (for next) with background -->
|
|
||||||
<org.oxycblt.auxio.playback.ui.swipe.SwipeClipView
|
|
||||||
android:id="@+id/right_swipe_clip_view"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:clickable="false"
|
|
||||||
android:focusable="false" />
|
|
||||||
|
|
||||||
<org.oxycblt.auxio.playback.ui.swipe.SwipeIndicatorView
|
|
||||||
android:id="@+id/right_swipe_indicator"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginEnd="@dimen/spacing_medium"
|
|
||||||
android:clickable="false"
|
|
||||||
android:focusable="false"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
~ Copyright (c) 2025 Auxio Project
|
|
||||||
~ player_swipe_indicator_view.xml is part of Auxio.
|
|
||||||
~
|
|
||||||
~ This program is free software: you can redistribute it and/or modify
|
|
||||||
~ it under the terms of the GNU General Public License as published by
|
|
||||||
~ the Free Software Foundation, either version 3 of the License, or
|
|
||||||
~ (at your option) any later version.
|
|
||||||
~
|
|
||||||
~ This program is distributed in the hope that it will be useful,
|
|
||||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
~ GNU General Public License for more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU General Public License
|
|
||||||
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
tools:ignore="ContentDescription"
|
|
||||||
tools:layout_height="wrap_content"
|
|
||||||
tools:layout_width="match_parent"
|
|
||||||
tools:orientation="horizontal"
|
|
||||||
tools:parentTag="android.widget.LinearLayout">
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
|
||||||
android:id="@+id/swipe_icon"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
tools:src="@drawable/ic_skip_next_24" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/swipe_text"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:padding="4dp"
|
|
||||||
android:textColor="@android:color/white"
|
|
||||||
android:textSize="14sp"
|
|
||||||
tools:text="Next" />
|
|
||||||
|
|
||||||
</merge>
|
|
||||||
Reference in New Issue
Block a user