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:
OxygenCobalt
2021-12-18 11:15:28 -07:00
parent 2d3fc47d7c
commit b92b08f8ab
9 changed files with 51 additions and 6 deletions
@@ -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)