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:
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,
|
// 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
|
// 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
|
// 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
|
// the screen is too small because of course we have to.
|
||||||
// is broken.
|
// 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) {
|
if (requireActivity().isInMultiWindowMode) {
|
||||||
val config = resources.configuration
|
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)
|
tab.setIcon(tabMode.icon)
|
||||||
.setContentDescription(tabMode.string)
|
.setContentDescription(tabMode.string)
|
||||||
|
|
||||||
width < 600 -> tab.setText(tabMode.string)
|
width < 640 -> tab.setText(tabMode.string)
|
||||||
|
|
||||||
else ->
|
else ->
|
||||||
tab.setIcon(tabMode.icon)
|
tab.setIcon(tabMode.icon)
|
||||||
|
|
15
app/src/main/res/layout-sw640dp/fragment_home_list.xml
Normal file
15
app/src/main/res/layout-sw640dp/fragment_home_list.xml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<org.oxycblt.auxio.home.fastscroll.FastScrollRecyclerView
|
||||||
|
android:id="@+id/home_recycler"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:paddingBottom="@dimen/recycler_fab_space_large"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
|
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
|
||||||
|
tools:listitem="@layout/item_artist" />
|
||||||
|
</layout>
|
|
@ -49,10 +49,11 @@
|
||||||
app:layout_anchor="@id/home_pager"
|
app:layout_anchor="@id/home_pager"
|
||||||
app:layout_anchorGravity="bottom|end">
|
app:layout_anchorGravity="bottom|end">
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<org.oxycblt.auxio.home.AdaptiveFloatingActionButton
|
||||||
android:id="@+id/home_fab"
|
android:id="@+id/home_fab"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
style="@style/Widget.Material3.FloatingActionButton.Primary"
|
||||||
android:layout_margin="@dimen/spacing_medium"
|
android:layout_margin="@dimen/spacing_medium"
|
||||||
android:contentDescription="@string/desc_shuffle_all"
|
android:contentDescription="@string/desc_shuffle_all"
|
||||||
android:src="@drawable/ic_shuffle"
|
android:src="@drawable/ic_shuffle"
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:paddingBottom="88dp"
|
android:paddingBottom="@dimen/recycler_fab_space_normal"
|
||||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
|
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
|
||||||
tools:listitem="@layout/item_artist" />
|
tools:listitem="@layout/item_artist" />
|
||||||
|
|
|
@ -32,6 +32,9 @@
|
||||||
<dimen name="slider_thumb_radius">6dp</dimen>
|
<dimen name="slider_thumb_radius">6dp</dimen>
|
||||||
<dimen name="slider_halo_radius">12dp</dimen>
|
<dimen name="slider_halo_radius">12dp</dimen>
|
||||||
|
|
||||||
|
<dimen name="recycler_fab_space_normal">88dp</dimen>
|
||||||
|
<dimen name="recycler_fab_space_large">128dp</dimen>
|
||||||
|
|
||||||
<dimen name="widget_width_min">176dp</dimen>
|
<dimen name="widget_width_min">176dp</dimen>
|
||||||
<dimen name="widget_height_min">110dp</dimen>
|
<dimen name="widget_height_min">110dp</dimen>
|
||||||
<dimen name="widget_width_def">@dimen/widget_width_min</dimen>
|
<dimen name="widget_width_def">@dimen/widget_width_min</dimen>
|
||||||
|
|
|
@ -107,7 +107,7 @@
|
||||||
<string name="err_no_perms">Auxio needs permission to read your music library</string>
|
<string name="err_no_perms">Auxio needs permission to read your music library</string>
|
||||||
<string name="err_no_app">No app can open this link</string>
|
<string name="err_no_app">No app can open this link</string>
|
||||||
<string name="err_bad_dir">This directory is not supported</string>
|
<string name="err_bad_dir">This directory is not supported</string>
|
||||||
<string name="err_too_small">Auxio does not support this screen size</string>
|
<string name="err_too_small">Auxio does not support this window size</string>
|
||||||
|
|
||||||
<!-- Hint Namespace | EditText Hints -->
|
<!-- Hint Namespace | EditText Hints -->
|
||||||
<string name="hint_search_library">Search your library…</string>
|
<string name="hint_search_library">Search your library…</string>
|
||||||
|
|
Loading…
Reference in a new issue