detail: add layout for small screens
Add a layout for especially small screens so that they do not have to scroll as much.
This commit is contained in:
parent
8e1da1bfc7
commit
284108678b
3 changed files with 82 additions and 5 deletions
|
@ -3,23 +3,22 @@ package org.oxycblt.auxio.home
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.google.android.material.tabs.TabLayout
|
import com.google.android.material.tabs.TabLayout
|
||||||
import com.google.android.material.tabs.TabLayoutMediator
|
import com.google.android.material.tabs.TabLayoutMediator
|
||||||
import org.oxycblt.auxio.util.logD
|
|
||||||
|
|
||||||
class AdaptiveTabStrategy(
|
class AdaptiveTabStrategy(
|
||||||
context: Context,
|
context: Context,
|
||||||
private val homeModel: HomeViewModel
|
private val homeModel: HomeViewModel
|
||||||
) : TabLayoutMediator.TabConfigurationStrategy {
|
) : TabLayoutMediator.TabConfigurationStrategy {
|
||||||
private val screenSize = context.resources.configuration.screenWidthDp
|
private val width = context.resources.configuration.screenWidthDp
|
||||||
|
|
||||||
override fun onConfigureTab(tab: TabLayout.Tab, position: Int) {
|
override fun onConfigureTab(tab: TabLayout.Tab, position: Int) {
|
||||||
val tabMode = homeModel.tabs[position]
|
val tabMode = homeModel.tabs[position]
|
||||||
|
|
||||||
when {
|
when {
|
||||||
screenSize < 370 ->
|
width < 370 ->
|
||||||
tab.setIcon(tabMode.icon)
|
tab.setIcon(tabMode.icon)
|
||||||
.setContentDescription(tabMode.string)
|
.setContentDescription(tabMode.string)
|
||||||
|
|
||||||
screenSize < 600 -> tab.setText(tabMode.string)
|
width < 600 -> tab.setText(tabMode.string)
|
||||||
|
|
||||||
else ->
|
else ->
|
||||||
tab.setIcon(tabMode.icon)
|
tab.setIcon(tabMode.icon)
|
||||||
|
|
78
app/src/main/res/layout-h600dp/item_detail.xml
Normal file
78
app/src/main/res/layout-h600dp/item_detail.xml
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
<?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">
|
||||||
|
|
||||||
|
<!-- This layout is re-used across all detail fragments. Do not add databinding. -->
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="@dimen/spacing_medium">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/detail_cover"
|
||||||
|
style="@style/Widget.Auxio.Image.Huge"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:ignore="ContentDescription"
|
||||||
|
tools:src="@drawable/ic_artist" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/detail_name"
|
||||||
|
style="@style/Widget.Auxio.TextView.Detail"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/spacing_medium"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/detail_cover"
|
||||||
|
tools:text="Name" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/detail_subhead"
|
||||||
|
style="@style/Widget.Auxio.TextView.Secondary"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/detail_name"
|
||||||
|
tools:text="Info A" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/detail_info"
|
||||||
|
style="@style/Widget.Auxio.TextView.Secondary"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/detail_subhead"
|
||||||
|
tools:text="Info B" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/detail_play_button"
|
||||||
|
style="@style/Widget.Auxio.Button.Secondary"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/spacing_medium"
|
||||||
|
android:layout_marginEnd="@dimen/spacing_small"
|
||||||
|
android:text="@string/lbl_play"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/detail_shuffle_button"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/detail_info" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/detail_shuffle_button"
|
||||||
|
style="@style/Widget.Auxio.Button.Primary"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/spacing_small"
|
||||||
|
android:text="@string/lbl_shuffle"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/detail_play_button"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/detail_play_button"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/detail_play_button" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</layout>
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/detail_cover"
|
android:id="@+id/detail_cover"
|
||||||
style="@style/Widget.Auxio.Image.Huge"
|
style="@style/Widget.Auxio.Image.MidHuge"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
|
Loading…
Reference in a new issue