home: make fab adaptive
Use a large FAB on tablet layouts, as in general it's okay to make those elements bigger on large touchscreens.
This commit is contained in:
@@ -78,8 +78,10 @@ class MainFragment : Fragment() {
|
||||
// Auxio's layout completely breaks down when it's window is resized too small,
|
||||
// but for some insane reason google decided to cripple the window APIs one could use
|
||||
// to limit it's size. So, we just have our own special layout that is shown whenever
|
||||
// the screen is too small because nothing works the way it should and everything
|
||||
// is broken.
|
||||
// the screen is too small because of course we have to.
|
||||
// Another fun fact: smallestScreenWidthDp is completely bugged and uses the total
|
||||
// screen size, even when the window is smaller. This basically borks split screen
|
||||
// even more than it already does. Fun!
|
||||
|
||||
if (requireActivity().isInMultiWindowMode) {
|
||||
val config = resources.configuration
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.oxycblt.auxio.home
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.google.android.material.R as MaterialR
|
||||
|
||||
class AdaptiveFloatingActionButton @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = MaterialR.style.Widget_Material3_FloatingActionButton_Primary
|
||||
) : FloatingActionButton(context, attrs, defStyleAttr) {
|
||||
|
||||
init {
|
||||
size = SIZE_NORMAL
|
||||
|
||||
if (resources.configuration.smallestScreenWidthDp >= 640) {
|
||||
customSize = resources.getDimensionPixelSize(MaterialR.dimen.m3_large_fab_size)
|
||||
setMaxImageSize(
|
||||
resources.getDimensionPixelSize(MaterialR.dimen.m3_large_fab_max_image_size)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ class AdaptiveTabStrategy(
|
||||
tab.setIcon(tabMode.icon)
|
||||
.setContentDescription(tabMode.string)
|
||||
|
||||
width < 600 -> tab.setText(tabMode.string)
|
||||
width < 640 -> tab.setText(tabMode.string)
|
||||
|
||||
else ->
|
||||
tab.setIcon(tabMode.icon)
|
||||
|
||||
Reference in New Issue
Block a user