main: band-aid split screen mode layouts
Split screen layouts in android are completely borked. You can resize Auxio down to the point where the UI is completely unusable, and there is NO WAY TO SET A MINIMUM HEIGHT. This is also not to mention that smallestScreenWidthDp is completely busted too and still uses the size of the whole screen! Just band-aid the first issue so that when the layout becomes so small as to result in a messed up UI, just show a splash that says that the app can't work at the specific window size.
This commit is contained in:
parent
bae997018d
commit
2d3fc47d7c
7 changed files with 77 additions and 16 deletions
|
@ -28,6 +28,7 @@ import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.databinding.DataBindingUtil
|
import androidx.databinding.DataBindingUtil
|
||||||
|
import androidx.viewbinding.ViewBinding
|
||||||
import org.oxycblt.auxio.accent.Accent
|
import org.oxycblt.auxio.accent.Accent
|
||||||
import org.oxycblt.auxio.databinding.ActivityMainBinding
|
import org.oxycblt.auxio.databinding.ActivityMainBinding
|
||||||
import org.oxycblt.auxio.playback.PlaybackViewModel
|
import org.oxycblt.auxio.playback.PlaybackViewModel
|
||||||
|
@ -114,7 +115,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun applyEdgeToEdgeWindow(binding: ActivityMainBinding) {
|
private fun applyEdgeToEdgeWindow(binding: ViewBinding) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
// Do modern edge to edge, which happens to be around twice the size of the
|
// Do modern edge to edge, which happens to be around twice the size of the
|
||||||
// old way of doing things. Thanks android, very cool!
|
// old way of doing things. Thanks android, very cool!
|
||||||
|
@ -147,7 +148,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun WindowInsets.applyLeftRightInsets(binding: ActivityMainBinding): WindowInsets {
|
private fun WindowInsets.applyLeftRightInsets(binding: ViewBinding): WindowInsets {
|
||||||
val bars = systemBarsCompat
|
val bars = systemBarsCompat
|
||||||
|
|
||||||
binding.root.updatePadding(
|
binding.root.updatePadding(
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.oxycblt.auxio
|
package org.oxycblt.auxio
|
||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
@ -73,6 +74,22 @@ class MainFragment : Fragment() {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
if (requireActivity().isInMultiWindowMode) {
|
||||||
|
val config = resources.configuration
|
||||||
|
|
||||||
|
if (config.screenHeightDp < 250 || config.screenWidthDp < 250) {
|
||||||
|
binding.layoutTooSmall.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// --- VIEWMODEL SETUP ---
|
// --- VIEWMODEL SETUP ---
|
||||||
|
|
||||||
// We have to control the bar view from here since using a Fragment in PlaybackLayout
|
// We have to control the bar view from here since using a Fragment in PlaybackLayout
|
||||||
|
|
|
@ -164,9 +164,15 @@ class PlaybackLayout @JvmOverloads constructor(
|
||||||
// Make sure we add our fragment to this view. This is actually a replace operation
|
// Make sure we add our fragment to this view. This is actually a replace operation
|
||||||
// since we don't want to stack fragments but we can't ensure that this view doesn't
|
// since we don't want to stack fragments but we can't ensure that this view doesn't
|
||||||
// already have a fragment attached.
|
// already have a fragment attached.
|
||||||
(context as AppCompatActivity).supportFragmentManager.beginTransaction()
|
try {
|
||||||
.replace(R.id.playback_panel, playbackFragment)
|
(context as AppCompatActivity).supportFragmentManager.beginTransaction()
|
||||||
.commit()
|
.replace(R.id.playback_panel, playbackFragment)
|
||||||
|
.commit()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// Band-aid to stop the app crashing if we have to swap out the content view
|
||||||
|
// without warning (which we have to do sometimes because android is the worst
|
||||||
|
// thing ever
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,9 @@
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/playback_cover"
|
android:id="@+id/playback_cover"
|
||||||
style="@style/Widget.Auxio.Image.Large"
|
style="@style/Widget.Auxio.Image.Full"
|
||||||
android:layout_marginStart="@dimen/spacing_mid_large"
|
android:layout_marginStart="@dimen/spacing_mid_large"
|
||||||
|
android:layout_marginTop="@dimen/spacing_mid_large"
|
||||||
android:contentDescription="@{@string/desc_album_cover(song.name)}"
|
android:contentDescription="@{@string/desc_album_cover(song.name)}"
|
||||||
app:albumArt="@{song}"
|
app:albumArt="@{song}"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/playback_seek_bar"
|
app:layout_constraintBottom_toTopOf="@+id/playback_seek_bar"
|
||||||
|
@ -156,6 +157,7 @@
|
||||||
app:layout_constraintEnd_toEndOf="@+id/playback_seek_bar"
|
app:layout_constraintEnd_toEndOf="@+id/playback_seek_bar"
|
||||||
app:layout_constraintStart_toStartOf="@+id/playback_seek_bar"
|
app:layout_constraintStart_toStartOf="@+id/playback_seek_bar"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/playback_seek_bar"
|
app:layout_constraintTop_toBottomOf="@+id/playback_seek_bar"
|
||||||
|
android:layout_marginBottom="@dimen/spacing_mid_large"
|
||||||
tools:src="@drawable/ic_play" />
|
tools:src="@drawable/ic_play" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
|
|
|
@ -104,8 +104,8 @@
|
||||||
android:id="@+id/playback_seek_bar"
|
android:id="@+id/playback_seek_bar"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="-8dp"
|
android:layout_marginStart="-16dp"
|
||||||
android:layout_marginEnd="-8dp"
|
android:layout_marginEnd="-16dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/playback_play_pause"
|
app:layout_constraintBottom_toTopOf="@+id/playback_play_pause"
|
||||||
app:layout_constraintHorizontal_bias="0.5"
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
app:layout_constraintStart_toStartOf="@+id/playback_song_container"
|
app:layout_constraintStart_toStartOf="@+id/playback_song_container"
|
||||||
|
|
|
@ -4,18 +4,52 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context=".MainFragment">
|
tools:context=".MainFragment">
|
||||||
|
|
||||||
<org.oxycblt.auxio.playback.PlaybackLayout
|
<FrameLayout
|
||||||
android:id="@+id/playback_layout"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<org.oxycblt.auxio.playback.PlaybackLayout
|
||||||
android:id="@+id/explore_nav_host"
|
android:id="@+id/playback_layout"
|
||||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<androidx.fragment.app.FragmentContainerView
|
||||||
|
android:id="@+id/explore_nav_host"
|
||||||
|
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:navGraph="@navigation/nav_explore"
|
||||||
|
tools:layout="@layout/fragment_home" />
|
||||||
|
|
||||||
|
</org.oxycblt.auxio.playback.PlaybackLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/layout_too_small"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:navGraph="@navigation/nav_explore"
|
android:background="?attr/colorSurface"
|
||||||
tools:layout="@layout/fragment_home" />
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:alpha="0.275"
|
||||||
|
android:contentDescription="@string/desc_auxio_icon"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:src="@drawable/ic_auxio" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="@dimen/spacing_medium"
|
||||||
|
android:text="@string/err_too_small"
|
||||||
|
android:textAppearance="@style/TextAppearance.Auxio.TitleMidLarge"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
</org.oxycblt.auxio.playback.PlaybackLayout>
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -107,6 +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>
|
||||||
|
|
||||||
<!-- 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