playback: reformat
This commit is contained in:
@@ -299,7 +299,8 @@ class PlaybackPanelFragment :
|
|||||||
private fun updatePager(queue: PagerQueue) {
|
private fun updatePager(queue: PagerQueue) {
|
||||||
// Right now there's easily 140ms of frame skipping when going next/prev. This is primarily
|
// Right now there's easily 140ms of frame skipping when going next/prev. This is primarily
|
||||||
// the fault of specifically the nested bottom sheet UI setup, which is intractable to
|
// the fault of specifically the nested bottom sheet UI setup, which is intractable to
|
||||||
// optimize. If I don't do multiple remeasures/relayouts on every slightest state instability
|
// optimize. If I don't do multiple remeasures/relayouts on every slightest state
|
||||||
|
// instability
|
||||||
// I will suddenly encounter insane issues where the sheet fails to measure, appears below
|
// I will suddenly encounter insane issues where the sheet fails to measure, appears below
|
||||||
// the sidebar, flies away, not changing with ui scale, etc, often only on third-party OEM
|
// the sidebar, flies away, not changing with ui scale, etc, often only on third-party OEM
|
||||||
// ROMs that randomly mangle SDK APIs and the SystemUI chrome for no reason.
|
// ROMs that randomly mangle SDK APIs and the SystemUI chrome for no reason.
|
||||||
@@ -369,10 +370,7 @@ class PlaybackPanelFragment :
|
|||||||
if (command.update == null && abs(delta) == 1) {
|
if (command.update == null && abs(delta) == 1) {
|
||||||
binding.playbackPager.smoothScrollByPageTo(command.scroll)
|
binding.playbackPager.smoothScrollByPageTo(command.scroll)
|
||||||
} else {
|
} else {
|
||||||
binding.playbackPager.setCurrentItem(
|
binding.playbackPager.setCurrentItem(command.scroll, false)
|
||||||
command.scroll,
|
|
||||||
false,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2026 Auxio Project
|
||||||
|
* ScaledPlaybackButton.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.button
|
package org.oxycblt.auxio.playback.ui.button
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
@@ -13,9 +31,9 @@ import com.google.android.material.shape.RelativeCornerSize
|
|||||||
import com.google.android.material.shape.ShapeAppearance
|
import com.google.android.material.shape.ShapeAppearance
|
||||||
import com.google.android.material.shape.ShapeAppearanceModel
|
import com.google.android.material.shape.ShapeAppearanceModel
|
||||||
import com.google.android.material.shape.StateListShapeAppearanceModel
|
import com.google.android.material.shape.StateListShapeAppearanceModel
|
||||||
import org.oxycblt.auxio.util.lazyReflectedMethod
|
|
||||||
import java.lang.reflect.Method
|
import java.lang.reflect.Method
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
|
import org.oxycblt.auxio.util.lazyReflectedMethod
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Companion scalable button to [ScaledPlaybackButtonGroup], see that.
|
* Companion scalable button to [ScaledPlaybackButtonGroup], see that.
|
||||||
@@ -39,7 +57,8 @@ constructor(
|
|||||||
// so that our scaling applies to the correct dimens
|
// so that our scaling applies to the correct dimens
|
||||||
val contentWidth = paddingStart + paddingEnd + iconSize
|
val contentWidth = paddingStart + paddingEnd + iconSize
|
||||||
val contentHeight = paddingTop + paddingBottom + iconSize
|
val contentHeight = paddingTop + paddingBottom + iconSize
|
||||||
baseMetrics = BaseMetrics(
|
baseMetrics =
|
||||||
|
BaseMetrics(
|
||||||
width = max(minimumWidth, contentWidth),
|
width = max(minimumWidth, contentWidth),
|
||||||
height = max(minimumHeight, contentHeight),
|
height = max(minimumHeight, contentHeight),
|
||||||
minimumWidth = minimumWidth,
|
minimumWidth = minimumWidth,
|
||||||
@@ -50,7 +69,7 @@ constructor(
|
|||||||
paddingBottom = paddingBottom,
|
paddingBottom = paddingBottom,
|
||||||
iconSize = iconSize,
|
iconSize = iconSize,
|
||||||
strokeWidth = strokeWidth,
|
strokeWidth = strokeWidth,
|
||||||
shapeAppearance = shapeAppearance
|
shapeAppearance = shapeAppearance,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +118,8 @@ constructor(
|
|||||||
|
|
||||||
// Scale stroke width if necessary
|
// Scale stroke width if necessary
|
||||||
// A bit inaccurate (they actually step from 3, 2, 1) but better to interpolate honestly
|
// A bit inaccurate (they actually step from 3, 2, 1) but better to interpolate honestly
|
||||||
strokeWidth = if (baseMetrics.strokeWidth > 0) max(1, baseMetrics.strokeWidth.scale(scale)) else 0
|
strokeWidth =
|
||||||
|
if (baseMetrics.strokeWidth > 0) max(1, baseMetrics.strokeWidth.scale(scale)) else 0
|
||||||
|
|
||||||
shapeAppearance = baseMetrics.shapeAppearance.scale(scale)
|
shapeAppearance = baseMetrics.shapeAppearance.scale(scale)
|
||||||
}
|
}
|
||||||
@@ -108,11 +128,9 @@ constructor(
|
|||||||
|
|
||||||
private fun ShapeAppearance.scale(scale: Float): ShapeAppearance =
|
private fun ShapeAppearance.scale(scale: Float): ShapeAppearance =
|
||||||
when (this) {
|
when (this) {
|
||||||
is StateListShapeAppearanceModel ->
|
is StateListShapeAppearanceModel -> withTransformedCornerSizes { it.scale(scale) }
|
||||||
withTransformedCornerSizes { it.scale(scale) }
|
|
||||||
|
|
||||||
is ShapeAppearanceModel ->
|
is ShapeAppearanceModel -> withTransformedCornerSizes { it.scale(scale) }
|
||||||
withTransformedCornerSizes { it.scale(scale) }
|
|
||||||
|
|
||||||
else -> this
|
else -> this
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-4
@@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2026 Auxio Project
|
||||||
|
* ScaledPlaybackButtonGroup.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.button
|
package org.oxycblt.auxio.playback.ui.button
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -9,11 +27,11 @@ import com.google.android.material.button.MaterialButtonGroup
|
|||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A [com.google.android.material.button.MaterialButtonGroup] that scales playback controls down
|
* A [com.google.android.material.button.MaterialButtonGroup] that scales playback controls down to
|
||||||
* to actually fit mid-sized screens.
|
* actually fit mid-sized screens.
|
||||||
*
|
*
|
||||||
* M3 Expressive for some reason only has "Large" and then massively smaller "Medium"/"Small"
|
* M3 Expressive for some reason only has "Large" and then massively smaller "Medium"/"Small" size
|
||||||
* size classes. So either you clip on smaller phones or jump to an unusable button row sizing.
|
* classes. So either you clip on smaller phones or jump to an unusable button row sizing.
|
||||||
*
|
*
|
||||||
* Fix this by just force-scaling down buttons.
|
* Fix this by just force-scaling down buttons.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2026 Auxio Project
|
||||||
|
* WidthFixMaterialButton.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.button
|
package org.oxycblt.auxio.playback.ui.button
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -8,8 +26,8 @@ import com.google.android.material.R
|
|||||||
import org.oxycblt.auxio.ui.RippleFixMaterialButton
|
import org.oxycblt.auxio.ui.RippleFixMaterialButton
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [org.oxycblt.auxio.ui.RippleFixMaterialButton] that works around another bug where switching the icon during a press
|
* [org.oxycblt.auxio.ui.RippleFixMaterialButton] that works around another bug where switching the
|
||||||
* breaks width expansion animations.
|
* icon during a press breaks width expansion animations.
|
||||||
*
|
*
|
||||||
* @author Alexander Capehart (OxygenCobalt)
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -156,9 +156,7 @@ fun ViewPager2.dampen() {
|
|||||||
RV_TOUCH_SLOP_FIELD.set(recycler, slop * 3)
|
RV_TOUCH_SLOP_FIELD.set(recycler, slop * 3)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Reflect into a [ViewPager2]'s internal [RecyclerView]. */
|
||||||
* Reflect into a [ViewPager2]'s internal [RecyclerView].
|
|
||||||
*/
|
|
||||||
fun ViewPager2.recycler() = (VP_RECYCLER_FIELD.get(this) as RecyclerView)
|
fun ViewPager2.recycler() = (VP_RECYCLER_FIELD.get(this) as RecyclerView)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user