all: reformat
This commit is contained in:
@@ -38,14 +38,13 @@ import androidx.core.graphics.withSave
|
|||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.dynamicanimation.animation.FloatValueHolder
|
import androidx.dynamicanimation.animation.FloatValueHolder
|
||||||
import androidx.dynamicanimation.animation.SpringAnimation
|
import androidx.dynamicanimation.animation.SpringAnimation
|
||||||
|
import com.google.android.material.R as MR
|
||||||
import com.google.android.material.motion.MotionUtils
|
import com.google.android.material.motion.MotionUtils
|
||||||
import org.oxycblt.auxio.R
|
|
||||||
import timber.log.Timber
|
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.atan2
|
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
import com.google.android.material.R as MR
|
import org.oxycblt.auxio.R
|
||||||
|
import timber.log.Timber
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Slider with active-track wave rendering that ports MDC LinearProgressIndicator's wavy draw
|
* Slider with active-track wave rendering that ports MDC LinearProgressIndicator's wavy draw
|
||||||
@@ -153,19 +152,24 @@ constructor(
|
|||||||
strokeCap = Paint.Cap.BUTT
|
strokeCap = Paint.Cap.BUTT
|
||||||
strokeWidth = trackHeight.toFloat()
|
strokeWidth = trackHeight.toFloat()
|
||||||
isAntiAlias = true
|
isAntiAlias = true
|
||||||
color = trackActiveTintList.getColorForState(
|
color =
|
||||||
|
trackActiveTintList.getColorForState(
|
||||||
drawableState,
|
drawableState,
|
||||||
trackActiveTintList.defaultColor
|
trackActiveTintList.defaultColor,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
updateActiveTrackSuppression()
|
updateActiveTrackSuppression()
|
||||||
|
|
||||||
if (trackCornerSize < trackHeight) {
|
if (trackCornerSize < trackHeight) {
|
||||||
Timber.w("WavySlider can only be fully rounded. Clamping corner size down to trackHeight / 2")
|
Timber.w(
|
||||||
|
"WavySlider can only be fully rounded. Clamping corner size down to trackHeight / 2"
|
||||||
|
)
|
||||||
trackCornerSize = trackHeight
|
trackCornerSize = trackHeight
|
||||||
}
|
}
|
||||||
if (trackInsideCornerSize < trackHeight) {
|
if (trackInsideCornerSize < trackHeight) {
|
||||||
Timber.w("WavySlider can only be fully rounded. Clamping inner corner size down to trackHeight / 2")
|
Timber.w(
|
||||||
|
"WavySlider can only be fully rounded. Clamping inner corner size down to trackHeight / 2"
|
||||||
|
)
|
||||||
trackInsideCornerSize = trackHeight
|
trackInsideCornerSize = trackHeight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,10 +255,7 @@ constructor(
|
|||||||
|
|
||||||
displayedTrackThickness = trackHeight.toFloat()
|
displayedTrackThickness = trackHeight.toFloat()
|
||||||
displayedCornerRadius =
|
displayedCornerRadius =
|
||||||
min(
|
min(min(displayedTrackThickness / 2f, trackCornerSize.toFloat()), trackLength / 2f)
|
||||||
min(displayedTrackThickness / 2f, trackCornerSize.toFloat()),
|
|
||||||
trackLength / 2f,
|
|
||||||
)
|
|
||||||
displayedInnerCornerRadius = displayedCornerRadius
|
displayedInnerCornerRadius = displayedCornerRadius
|
||||||
|
|
||||||
// Calculate the actual wave path or re-use it
|
// Calculate the actual wave path or re-use it
|
||||||
@@ -357,9 +358,7 @@ constructor(
|
|||||||
startPoint.translate(startBlockCenterX + originX, trackCenterY)
|
startPoint.translate(startBlockCenterX + originX, trackCenterY)
|
||||||
endPoint.translate(endBlockCenterX + originX, trackCenterY)
|
endPoint.translate(endBlockCenterX + originX, trackCenterY)
|
||||||
|
|
||||||
if (
|
if (startBound <= 0f && endBlockCenterX < startBlockCenterX) {
|
||||||
startBound <= 0f && endBlockCenterX < startBlockCenterX
|
|
||||||
) {
|
|
||||||
drawRoundedBlock(
|
drawRoundedBlock(
|
||||||
canvas = canvas,
|
canvas = canvas,
|
||||||
drawCenter = startPoint,
|
drawCenter = startPoint,
|
||||||
@@ -392,13 +391,7 @@ constructor(
|
|||||||
)
|
)
|
||||||
canvas.drawPath(displayedWavePath, wavePaint)
|
canvas.drawPath(displayedWavePath, wavePaint)
|
||||||
} else {
|
} else {
|
||||||
canvas.drawLine(
|
canvas.drawLine(startPoint.x, startPoint.y, endPoint.x, endPoint.y, wavePaint)
|
||||||
startPoint.x,
|
|
||||||
startPoint.y,
|
|
||||||
endPoint.x,
|
|
||||||
endPoint.y,
|
|
||||||
wavePaint,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,15 +416,14 @@ constructor(
|
|||||||
canvas: Canvas,
|
canvas: Canvas,
|
||||||
drawCenter: PointF,
|
drawCenter: PointF,
|
||||||
clipCenter: PointF,
|
clipCenter: PointF,
|
||||||
clipRight: Boolean
|
clipRight: Boolean,
|
||||||
) {
|
) {
|
||||||
wavePaint.style = Paint.Style.FILL
|
wavePaint.style = Paint.Style.FILL
|
||||||
canvas.withSave {
|
canvas.withSave {
|
||||||
var clipWidth = trackHeight.toFloat()
|
var clipWidth = trackHeight.toFloat()
|
||||||
val halfHeight = trackHeight / 2f
|
val halfHeight = trackHeight / 2f
|
||||||
if (clipRight) {
|
if (clipRight) {
|
||||||
val leftEdgeDiff =
|
val leftEdgeDiff = (clipCenter.x - trackHeight / 2f) - (drawCenter.x - trackHeight)
|
||||||
(clipCenter.x - trackHeight / 2f) - (drawCenter.x - trackHeight)
|
|
||||||
if (leftEdgeDiff > 0f) {
|
if (leftEdgeDiff > 0f) {
|
||||||
clipCenter.translate(-leftEdgeDiff / 2f, 0f)
|
clipCenter.translate(-leftEdgeDiff / 2f, 0f)
|
||||||
clipWidth += leftEdgeDiff
|
clipWidth += leftEdgeDiff
|
||||||
@@ -443,8 +435,7 @@ constructor(
|
|||||||
drawCenter.y + halfHeight,
|
drawCenter.y + halfHeight,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
val rightEdgeDiff =
|
val rightEdgeDiff = (clipCenter.x + trackHeight / 2f) - (drawCenter.x + trackHeight)
|
||||||
(clipCenter.x + trackHeight / 2f) - (drawCenter.x + trackHeight)
|
|
||||||
if (rightEdgeDiff < 0f) {
|
if (rightEdgeDiff < 0f) {
|
||||||
clipCenter.translate(-rightEdgeDiff / 2f, 0f)
|
clipCenter.translate(-rightEdgeDiff / 2f, 0f)
|
||||||
clipWidth -= rightEdgeDiff
|
clipWidth -= rightEdgeDiff
|
||||||
@@ -477,7 +468,7 @@ constructor(
|
|||||||
clipRect,
|
clipRect,
|
||||||
trackHeight.toFloat(),
|
trackHeight.toFloat(),
|
||||||
trackHeight.toFloat(),
|
trackHeight.toFloat(),
|
||||||
Path.Direction.CCW
|
Path.Direction.CCW,
|
||||||
)
|
)
|
||||||
clipPath(roundedRectPath)
|
clipPath(roundedRectPath)
|
||||||
|
|
||||||
|
|||||||
@@ -32,14 +32,12 @@ import androidx.fragment.app.FragmentManager
|
|||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.lifecycle.LifecycleOwner
|
import androidx.lifecycle.LifecycleOwner
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||||
import androidx.viewpager2.widget.ViewPager2
|
import androidx.viewpager2.widget.ViewPager2
|
||||||
import com.google.android.material.appbar.AppBarLayout
|
import com.google.android.material.appbar.AppBarLayout
|
||||||
import com.google.android.material.tabs.TabLayoutMediator
|
import com.google.android.material.tabs.TabLayoutMediator
|
||||||
import com.google.android.material.transition.MaterialSharedAxis
|
import com.google.android.material.transition.MaterialSharedAxis
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import java.lang.reflect.Field
|
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
import org.oxycblt.auxio.databinding.FragmentHomeBinding
|
import org.oxycblt.auxio.databinding.FragmentHomeBinding
|
||||||
import org.oxycblt.auxio.detail.DetailViewModel
|
import org.oxycblt.auxio.detail.DetailViewModel
|
||||||
@@ -65,7 +63,6 @@ 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.dampen
|
||||||
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
|
||||||
import org.oxycblt.musikr.IndexingProgress
|
import org.oxycblt.musikr.IndexingProgress
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import androidx.dynamicanimation.animation.SpringForce
|
|||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import kotlin.math.abs
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
import org.oxycblt.auxio.databinding.FragmentPlaybackPanelBinding
|
import org.oxycblt.auxio.databinding.FragmentPlaybackPanelBinding
|
||||||
import org.oxycblt.auxio.detail.DetailViewModel
|
import org.oxycblt.auxio.detail.DetailViewModel
|
||||||
@@ -43,11 +44,11 @@ import org.oxycblt.auxio.music.resolveNames
|
|||||||
import org.oxycblt.auxio.playback.queue.QueueViewModel
|
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.stepper.Direction
|
||||||
|
import org.oxycblt.auxio.playback.ui.stepper.PlayerFastSeekOverlay
|
||||||
import org.oxycblt.auxio.playback.ui.swiper.CarouselTransformer
|
import org.oxycblt.auxio.playback.ui.swiper.CarouselTransformer
|
||||||
import org.oxycblt.auxio.playback.ui.swiper.CoverPagerAdapter
|
import org.oxycblt.auxio.playback.ui.swiper.CoverPagerAdapter
|
||||||
import org.oxycblt.auxio.playback.ui.swiper.UserAwarePagerCallback
|
import org.oxycblt.auxio.playback.ui.swiper.UserAwarePagerCallback
|
||||||
import org.oxycblt.auxio.playback.ui.stepper.Direction
|
|
||||||
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.dampen
|
||||||
@@ -56,7 +57,6 @@ 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
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,11 +112,13 @@ class PlaybackPanelFragment :
|
|||||||
|
|
||||||
binding.playbackPager?.apply {
|
binding.playbackPager?.apply {
|
||||||
adapter = coverPagerAdapter
|
adapter = coverPagerAdapter
|
||||||
userAwarePagerCallback = UserAwarePagerCallback(this) {
|
userAwarePagerCallback =
|
||||||
|
UserAwarePagerCallback(this) {
|
||||||
// Posting the queue goto command prevents the seekbar pos from desyncing
|
// Posting the queue goto command prevents the seekbar pos from desyncing
|
||||||
// from the song's duration, which creates a visual flicker in the seekbar.
|
// from the song's duration, which creates a visual flicker in the seekbar.
|
||||||
post { queueModel.goto(it) }
|
post { queueModel.goto(it) }
|
||||||
}.also { it.attach() }
|
}
|
||||||
|
.also { it.attach() }
|
||||||
setPageTransformer(CarouselTransformer())
|
setPageTransformer(CarouselTransformer())
|
||||||
recycler().apply {
|
recycler().apply {
|
||||||
// Make it possible to collapse the bottom sheet from the ViewPager's touch area.
|
// Make it possible to collapse the bottom sheet from the ViewPager's touch area.
|
||||||
@@ -323,7 +325,10 @@ class PlaybackPanelFragment :
|
|||||||
// user scroll, carry on
|
// user scroll, carry on
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
binding.playbackPager.setCurrentItem(command.scroll, command.update == null && abs(delta) == 1)
|
binding.playbackPager.setCurrentItem(
|
||||||
|
command.scroll,
|
||||||
|
command.update == null && abs(delta) == 1,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,7 +351,5 @@ class PlaybackPanelFragment :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
private companion object {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,12 +143,7 @@ constructor(
|
|||||||
_positionDs.value = playbackManager.progression.calculateElapsedPositionMs().msToDs()
|
_positionDs.value = playbackManager.progression.calculateElapsedPositionMs().msToDs()
|
||||||
_song.value = playbackManager.currentSong
|
_song.value = playbackManager.currentSong
|
||||||
|
|
||||||
_pagerCommand.put(
|
_pagerCommand.put(PagerCommand(update = null, scroll = index))
|
||||||
PagerCommand(
|
|
||||||
update = null,
|
|
||||||
scroll = index
|
|
||||||
)
|
|
||||||
)
|
|
||||||
_pagerQueue.value = _pagerQueue.value.copy(index = index)
|
_pagerQueue.value = _pagerQueue.value.copy(index = index)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,29 +157,18 @@ constructor(
|
|||||||
_pagerCommand.put(
|
_pagerCommand.put(
|
||||||
PagerCommand(
|
PagerCommand(
|
||||||
update = change.instructions,
|
update = change.instructions,
|
||||||
scroll = index.takeIf { change.type != QueueChange.Type.MAPPING }
|
scroll = index.takeIf { change.type != QueueChange.Type.MAPPING },
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
_pagerQueue.value = PagerQueue(
|
_pagerQueue.value = PagerQueue(queue = queue, index = index)
|
||||||
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.put(PagerCommand(update = UpdateInstructions.Replace(0), scroll = index))
|
||||||
PagerCommand(
|
_pagerQueue.value = PagerQueue(queue = queue, index = index)
|
||||||
update = UpdateInstructions.Replace(0),
|
|
||||||
scroll = index
|
|
||||||
)
|
|
||||||
)
|
|
||||||
_pagerQueue.value = PagerQueue(
|
|
||||||
queue = queue,
|
|
||||||
index = index
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNewPlayback(
|
override fun onNewPlayback(
|
||||||
@@ -198,16 +182,8 @@ constructor(
|
|||||||
_parent.value = parent
|
_parent.value = parent
|
||||||
_isShuffled.value = isShuffled
|
_isShuffled.value = isShuffled
|
||||||
|
|
||||||
_pagerCommand.put(
|
_pagerCommand.put(PagerCommand(update = UpdateInstructions.Replace(0), scroll = index))
|
||||||
PagerCommand(
|
_pagerQueue.value = PagerQueue(queue = queue, index = index)
|
||||||
update = UpdateInstructions.Replace(0),
|
|
||||||
scroll = index
|
|
||||||
)
|
|
||||||
)
|
|
||||||
_pagerQueue.value = PagerQueue(
|
|
||||||
queue = queue,
|
|
||||||
index = index
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onProgressionChanged(progression: Progression) {
|
override fun onProgressionChanged(progression: Progression) {
|
||||||
@@ -493,7 +469,8 @@ constructor(
|
|||||||
val currentPositionMs = playbackManager.progression.calculateElapsedPositionMs()
|
val currentPositionMs = playbackManager.progression.calculateElapsedPositionMs()
|
||||||
val currentSong = playbackManager.currentSong
|
val currentSong = playbackManager.currentSong
|
||||||
if (currentSong != null) {
|
if (currentSong != null) {
|
||||||
val newPositionMs = (currentPositionMs + STEP_INCREMENT).coerceAtMost(currentSong.durationMs)
|
val newPositionMs =
|
||||||
|
(currentPositionMs + STEP_INCREMENT).coerceAtMost(currentSong.durationMs)
|
||||||
playbackManager.seekTo(newPositionMs)
|
playbackManager.seekTo(newPositionMs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -684,16 +661,9 @@ constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class PagerQueue(val queue: List<Song>, val index: Int)
|
||||||
|
|
||||||
data class PagerQueue(
|
data class PagerCommand(val update: UpdateInstructions?, val scroll: Int?)
|
||||||
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.
|
||||||
|
|||||||
@@ -31,14 +31,14 @@ import androidx.dynamicanimation.animation.SpringAnimation
|
|||||||
import com.google.android.material.shape.MaterialShapeDrawable
|
import com.google.android.material.shape.MaterialShapeDrawable
|
||||||
import com.google.android.material.shape.ShapeAppearanceModel
|
import com.google.android.material.shape.ShapeAppearanceModel
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import javax.inject.Inject
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
import org.oxycblt.auxio.ui.Effect
|
import org.oxycblt.auxio.ui.Effect
|
||||||
import org.oxycblt.auxio.ui.UISettings
|
import org.oxycblt.auxio.ui.UISettings
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
enum class Direction {
|
enum class Direction {
|
||||||
FORWARDS,
|
FORWARDS,
|
||||||
BACKWARDS
|
BACKWARDS,
|
||||||
}
|
}
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
@@ -46,8 +46,11 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) :
|
|||||||
ConstraintLayout(context, attrs), GestureDetector.OnDoubleTapListener {
|
ConstraintLayout(context, attrs), GestureDetector.OnDoubleTapListener {
|
||||||
private sealed interface OverlayState {
|
private sealed interface OverlayState {
|
||||||
data object Invisible : OverlayState
|
data object Invisible : OverlayState
|
||||||
|
|
||||||
data class Entering(val tap: SpringAnimation, val seconds: SpringAnimation) : OverlayState
|
data class Entering(val tap: SpringAnimation, val seconds: SpringAnimation) : OverlayState
|
||||||
|
|
||||||
data class Wait(val runnable: Runnable) : OverlayState
|
data class Wait(val runnable: Runnable) : OverlayState
|
||||||
|
|
||||||
data class Exiting(val tap: SpringAnimation, val seconds: SpringAnimation) : OverlayState
|
data class Exiting(val tap: SpringAnimation, val seconds: SpringAnimation) : OverlayState
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +66,6 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) :
|
|||||||
|
|
||||||
private val alphaSpring = Effect.FAST
|
private val alphaSpring = Effect.FAST
|
||||||
|
|
||||||
|
|
||||||
private var leftOverlayState: OverlayState = OverlayState.Invisible
|
private var leftOverlayState: OverlayState = OverlayState.Invisible
|
||||||
private var rightOverlayState: OverlayState = OverlayState.Invisible
|
private var rightOverlayState: OverlayState = OverlayState.Invisible
|
||||||
|
|
||||||
@@ -79,13 +81,13 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) :
|
|||||||
val shapeAppearanceRes =
|
val shapeAppearanceRes =
|
||||||
getResourceId(
|
getResourceId(
|
||||||
R.styleable.PlayerFastSeekOverlay_shapeAppearance,
|
R.styleable.PlayerFastSeekOverlay_shapeAppearance,
|
||||||
com.google.android.material.R.style
|
com.google.android.material.R.style.ShapeAppearance_Material3_Corner_Medium,
|
||||||
.ShapeAppearance_Material3_Corner_Medium
|
|
||||||
)
|
)
|
||||||
|
|
||||||
background =
|
background =
|
||||||
MaterialShapeDrawable().apply {
|
MaterialShapeDrawable().apply {
|
||||||
shapeAppearanceModel = if (uiSettings.roundMode) {
|
shapeAppearanceModel =
|
||||||
|
if (uiSettings.roundMode) {
|
||||||
ShapeAppearanceModel.builder(context, shapeAppearanceRes, -1).build()
|
ShapeAppearanceModel.builder(context, shapeAppearanceRes, -1).build()
|
||||||
} else {
|
} else {
|
||||||
ShapeAppearanceModel.builder().build()
|
ShapeAppearanceModel.builder().build()
|
||||||
@@ -131,22 +133,22 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) :
|
|||||||
rightTapView.setDirection(Direction.FORWARDS) // isLeft = false for right side
|
rightTapView.setDirection(Direction.FORWARDS) // isLeft = false for right side
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onTouchEvent(event: MotionEvent): Boolean =
|
override fun onTouchEvent(event: MotionEvent): Boolean =
|
||||||
gestureDetector.onTouchEvent(event) || super.onTouchEvent(event)
|
gestureDetector.onTouchEvent(event) || super.onTouchEvent(event)
|
||||||
|
|
||||||
override fun onSingleTapConfirmed(e: MotionEvent) = false
|
override fun onSingleTapConfirmed(e: MotionEvent) = false
|
||||||
|
|
||||||
|
private fun enter(
|
||||||
private fun enter(secondsView: SecondsView, tapView: TapView, overlayState: (OverlayState) -> Unit) {
|
secondsView: SecondsView,
|
||||||
|
tapView: TapView,
|
||||||
|
overlayState: (OverlayState) -> Unit,
|
||||||
|
) {
|
||||||
// start animating the seconds icon
|
// start animating the seconds icon
|
||||||
secondsView.startAnimation()
|
secondsView.startAnimation()
|
||||||
val secondsIn = alphaSpring.alpha(secondsView, 1.0f)
|
val secondsIn = alphaSpring.alpha(secondsView, 1.0f)
|
||||||
val tapIn = alphaSpring.alpha(tapView, 1.0f)
|
val tapIn = alphaSpring.alpha(tapView, 1.0f)
|
||||||
// will execute after a delay
|
// will execute after a delay
|
||||||
val out = Runnable {
|
val out = Runnable { exit(secondsView, tapView, overlayState) }
|
||||||
exit(secondsView, tapView, overlayState)
|
|
||||||
}
|
|
||||||
tapIn.addEndListener { _, cancelled, _, _ ->
|
tapIn.addEndListener { _, cancelled, _, _ ->
|
||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
postDelayed(out, EXIT_DELAY_MS)
|
postDelayed(out, EXIT_DELAY_MS)
|
||||||
@@ -156,7 +158,11 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) :
|
|||||||
overlayState(OverlayState.Entering(secondsIn, tapIn))
|
overlayState(OverlayState.Entering(secondsIn, tapIn))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun exit(secondsView: SecondsView, tapView: TapView, overlayState: (OverlayState) -> Unit) {
|
private fun exit(
|
||||||
|
secondsView: SecondsView,
|
||||||
|
tapView: TapView,
|
||||||
|
overlayState: (OverlayState) -> Unit,
|
||||||
|
) {
|
||||||
val secondsOut = alphaSpring.alpha(secondsView, 0.0f)
|
val secondsOut = alphaSpring.alpha(secondsView, 0.0f)
|
||||||
val tapOut = alphaSpring.alpha(tapView, 0.0f)
|
val tapOut = alphaSpring.alpha(tapView, 0.0f)
|
||||||
tapOut.addEndListener { _, cancelled, _, _ ->
|
tapOut.addEndListener { _, cancelled, _, _ ->
|
||||||
@@ -257,7 +263,7 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) :
|
|||||||
rightSecondsView,
|
rightSecondsView,
|
||||||
rightTapView,
|
rightTapView,
|
||||||
rightOverlayState,
|
rightOverlayState,
|
||||||
{ rightOverlayState = it }
|
{ rightOverlayState = it },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,13 +18,11 @@
|
|||||||
|
|
||||||
package org.oxycblt.auxio.playback.ui.stepper
|
package org.oxycblt.auxio.playback.ui.stepper
|
||||||
|
|
||||||
import android.animation.ValueAnimator
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.core.animation.addListener
|
|
||||||
import androidx.dynamicanimation.animation.DynamicAnimation
|
import androidx.dynamicanimation.animation.DynamicAnimation
|
||||||
import androidx.dynamicanimation.animation.SpringAnimation
|
import androidx.dynamicanimation.animation.SpringAnimation
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
@@ -100,12 +98,23 @@ class SecondsView(context: Context, attrs: AttributeSet?) : LinearLayout(context
|
|||||||
}
|
}
|
||||||
|
|
||||||
// cycle animation for the 3 icons
|
// cycle animation for the 3 icons
|
||||||
private val cyclicAlpha = floatArrayOf(
|
private val cyclicAlpha =
|
||||||
1.00f, 0.25f, 0.25f,
|
floatArrayOf(
|
||||||
1.00f, 1.00f, 0.25f,
|
1.00f,
|
||||||
0.25f, 1.00f, 1.00f,
|
0.25f,
|
||||||
0.25f, 0.25f, 1.00f,
|
0.25f,
|
||||||
0.25f, 0.25f, 0.25f,
|
1.00f,
|
||||||
|
1.00f,
|
||||||
|
0.25f,
|
||||||
|
0.25f,
|
||||||
|
1.00f,
|
||||||
|
1.00f,
|
||||||
|
0.25f,
|
||||||
|
0.25f,
|
||||||
|
1.00f,
|
||||||
|
0.25f,
|
||||||
|
0.25f,
|
||||||
|
0.25f,
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun cycle(at: Int = 0) {
|
private fun cycle(at: Int = 0) {
|
||||||
@@ -114,7 +123,8 @@ class SecondsView(context: Context, attrs: AttributeSet?) : LinearLayout(context
|
|||||||
val one = alphaSpring.alpha(binding.icon1, cyclicAlpha[row])
|
val one = alphaSpring.alpha(binding.icon1, cyclicAlpha[row])
|
||||||
val two = alphaSpring.alpha(binding.icon2, cyclicAlpha[row + 1])
|
val two = alphaSpring.alpha(binding.icon2, cyclicAlpha[row + 1])
|
||||||
val three = alphaSpring.alpha(binding.icon3, cyclicAlpha[row + 2])
|
val three = alphaSpring.alpha(binding.icon3, cyclicAlpha[row + 2])
|
||||||
val endListener = DynamicAnimation.OnAnimationEndListener { _, cancelled, _, _ ->
|
val endListener =
|
||||||
|
DynamicAnimation.OnAnimationEndListener { _, cancelled, _, _ ->
|
||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
cycle((at + 1) % 5)
|
cycle((at + 1) % 5)
|
||||||
}
|
}
|
||||||
@@ -132,5 +142,4 @@ class SecondsView(context: Context, attrs: AttributeSet?) : LinearLayout(context
|
|||||||
}
|
}
|
||||||
animations = listOf(one, two, three)
|
animations = listOf(one, two, three)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2025 Auxio Project
|
* Copyright (c) 2025 Auxio Project
|
||||||
* CircleClipTapView.kt is part of Auxio.
|
* TapView.kt is part of Auxio.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -25,9 +25,7 @@ import android.graphics.Path
|
|||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
|
||||||
/**
|
/** Cricle */
|
||||||
* Cricle
|
|
||||||
*/
|
|
||||||
class TapView(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
class TapView(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
||||||
|
|
||||||
private var backgroundPaint = Paint()
|
private var backgroundPaint = Paint()
|
||||||
|
|||||||
@@ -1,12 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2026 Auxio Project
|
||||||
|
* CarouselTransformer.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.swiper
|
package org.oxycblt.auxio.playback.ui.swiper
|
||||||
|
|
||||||
import android.graphics.RectF
|
import android.graphics.RectF
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.viewpager2.widget.ViewPager2
|
import androidx.viewpager2.widget.ViewPager2
|
||||||
import com.google.android.material.carousel.MaskableFrameLayout
|
import com.google.android.material.carousel.MaskableFrameLayout
|
||||||
import com.google.android.material.math.MathUtils.lerp
|
|
||||||
import kotlin.math.abs
|
|
||||||
|
|
||||||
class CarouselTransformer : ViewPager2.PageTransformer {
|
class CarouselTransformer : ViewPager2.PageTransformer {
|
||||||
override fun transformPage(page: View, position: Float) {
|
override fun transformPage(page: View, position: Float) {
|
||||||
@@ -54,17 +69,14 @@ class CarouselTransformer : ViewPager2.PageTransformer {
|
|||||||
when {
|
when {
|
||||||
// gap is not fully grown yet, so we do the gap size * how close we are to a fully
|
// gap is not fully grown yet, so we do the gap size * how close we are to a fully
|
||||||
// grown gap
|
// grown gap
|
||||||
p < gapEnterBreakpoint ->
|
p < gapEnterBreakpoint -> maxGap * (p / gapEnterBreakpoint)
|
||||||
maxGap * (p / gapEnterBreakpoint)
|
|
||||||
|
|
||||||
// gap should be shrinking, so we need to downscale maxgap by how close we are
|
// gap should be shrinking, so we need to downscale maxgap by how close we are
|
||||||
// actually to the end
|
// actually to the end
|
||||||
p > gapExitBreakpoint ->
|
p > gapExitBreakpoint -> maxGap * ((1f - p) / (1f - gapExitBreakpoint))
|
||||||
maxGap * ((1f - p) / (1f - gapExitBreakpoint))
|
|
||||||
|
|
||||||
// not growing or shrinking
|
// not growing or shrinking
|
||||||
else ->
|
else -> maxGap
|
||||||
maxGap
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// then we need to get how much we actually want to reveal the incoming covers post-gap
|
// then we need to get how much we actually want to reveal the incoming covers post-gap
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2026 Auxio Project
|
||||||
|
* CoverPagerAdapter.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.swiper
|
package org.oxycblt.auxio.playback.ui.swiper
|
||||||
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@@ -15,12 +33,10 @@ import org.oxycblt.musikr.Song
|
|||||||
*
|
*
|
||||||
* @param listener The [PlayerFastSeekOverlay.PerformListener] that step gesture events will be
|
* @param listener The [PlayerFastSeekOverlay.PerformListener] that step gesture events will be
|
||||||
* forwarded to
|
* forwarded to
|
||||||
*
|
|
||||||
* @author Alexander Capehart (OxygenCobalt)
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
*/
|
*/
|
||||||
class CoverPagerAdapter(
|
class CoverPagerAdapter(private val listener: PlayerFastSeekOverlay.PerformListener) :
|
||||||
private val listener: PlayerFastSeekOverlay.PerformListener
|
FlexibleListAdapter<Song, CoverViewHolder>(CoverViewHolder.DIFF_CALLBACK) {
|
||||||
) : FlexibleListAdapter<Song, CoverViewHolder>(CoverViewHolder.DIFF_CALLBACK) {
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, pos: Int) = CoverViewHolder.from(parent)
|
override fun onCreateViewHolder(parent: ViewGroup, pos: Int) = CoverViewHolder.from(parent)
|
||||||
|
|
||||||
@@ -54,7 +70,8 @@ class CoverViewHolder private constructor(private val binding: ItemCoverBinding)
|
|||||||
* @param parent The parent to inflate this instance from.
|
* @param parent The parent to inflate this instance from.
|
||||||
* @return A new instance.
|
* @return A new instance.
|
||||||
*/
|
*/
|
||||||
fun from(parent: ViewGroup) = CoverViewHolder(ItemCoverBinding.inflate(parent.context.inflater, parent, false))
|
fun from(parent: ViewGroup) =
|
||||||
|
CoverViewHolder(ItemCoverBinding.inflate(parent.context.inflater, parent, false))
|
||||||
|
|
||||||
/** A comparator that can be used with DiffUtil. */
|
/** A comparator that can be used with DiffUtil. */
|
||||||
val DIFF_CALLBACK =
|
val DIFF_CALLBACK =
|
||||||
|
|||||||
@@ -1,18 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2026 Auxio Project
|
||||||
|
* UserAwarePagerCallback.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.swiper
|
package org.oxycblt.auxio.playback.ui.swiper
|
||||||
|
|
||||||
import androidx.viewpager2.widget.ViewPager2
|
import androidx.viewpager2.widget.ViewPager2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A [ViewPager2.OnPageChangeCallback] that only fires [userCallback] when a user actually
|
* A [ViewPager2.OnPageChangeCallback] that only fires [userCallback] when a user actually enagages
|
||||||
* enagages in a swipe action. [ViewPager2] doesn't normally supply this so we have to do it
|
* in a swipe action. [ViewPager2] doesn't normally supply this so we have to do it via a stateful
|
||||||
* via a stateful object.
|
* object.
|
||||||
*
|
*
|
||||||
* @param viewPager [ViewPager2] that this will be attached to (must do this separately)
|
* @param viewPager [ViewPager2] that this will be attached to (must do this separately)
|
||||||
* @param userCallback The callback to run on a user-driven swipe
|
* @param userCallback The callback to run on a user-driven swipe
|
||||||
*
|
|
||||||
* @author Alexander Capehart (OxygenCobalt), Idea from GPT-5.5 (Rewritten)
|
* @author Alexander Capehart (OxygenCobalt), Idea from GPT-5.5 (Rewritten)
|
||||||
*/
|
*/
|
||||||
class UserAwarePagerCallback(private val viewPager: ViewPager2, private val userCallback: (Int) -> Unit) : ViewPager2.OnPageChangeCallback() {
|
class UserAwarePagerCallback(
|
||||||
|
private val viewPager: ViewPager2,
|
||||||
|
private val userCallback: (Int) -> Unit,
|
||||||
|
) : ViewPager2.OnPageChangeCallback() {
|
||||||
private var user = false
|
private var user = false
|
||||||
|
|
||||||
override fun onPageScrollStateChanged(state: Int) {
|
override fun onPageScrollStateChanged(state: Int) {
|
||||||
@@ -37,16 +57,12 @@ class UserAwarePagerCallback(private val viewPager: ViewPager2, private val user
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Attach this to the passed [viewPager]. */
|
||||||
* Attach this to the passed [viewPager].
|
|
||||||
*/
|
|
||||||
fun attach() {
|
fun attach() {
|
||||||
viewPager.registerOnPageChangeCallback(this)
|
viewPager.registerOnPageChangeCallback(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Detach this from the passed [viewPager]. */
|
||||||
* Detach this from the passed [viewPager].
|
|
||||||
*/
|
|
||||||
fun release() {
|
fun release() {
|
||||||
viewPager.unregisterOnPageChangeCallback(this)
|
viewPager.unregisterOnPageChangeCallback(this)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,18 +36,14 @@ 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.recyclerview.widget.RecyclerView
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
import androidx.viewpager2.widget.ViewPager2
|
import androidx.viewpager2.widget.ViewPager2
|
||||||
import java.lang.IllegalArgumentException
|
import java.lang.IllegalArgumentException
|
||||||
|
import java.lang.reflect.Field
|
||||||
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
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -149,10 +145,9 @@ private val RV_TOUCH_SLOP_FIELD: Field by lazyReflectedField(RecyclerView::class
|
|||||||
/**
|
/**
|
||||||
* Dampen a [ViewPager2] so that vertical scrolls can still easily occur.
|
* Dampen a [ViewPager2] so that vertical scrolls can still easily occur.
|
||||||
*
|
*
|
||||||
* By default, ViewPager2's sensitivity is high enough to result in vertical scroll
|
* By default, ViewPager2's sensitivity is high enough to result in vertical scroll events being
|
||||||
* events being registered as horizontal scroll events. Reflect into the internal
|
* registered as horizontal scroll events. Reflect into the internal RecyclerView and change the
|
||||||
* RecyclerView and change the touch slope so that touch actions will act more as a
|
* touch slope so that touch actions will act more as a scroll than as a swipe. Derived from:
|
||||||
* scroll than as a swipe. Derived from:
|
|
||||||
* https://al-e-shevelev.medium.com/how-to-reduce-scroll-sensitivity-of-viewpager2-widget-87797ad02414
|
* https://al-e-shevelev.medium.com/how-to-reduce-scroll-sensitivity-of-viewpager2-widget-87797ad02414
|
||||||
*/
|
*/
|
||||||
fun ViewPager2.dampen() {
|
fun ViewPager2.dampen() {
|
||||||
|
|||||||
Reference in New Issue
Block a user