ui: make default accent dynamic on api 31

Make the default accent the dynamic accent on API 31.

This is to make Auxio's Material You support obvious to the user.
This commit is contained in:
OxygenCobalt 2022-06-15 20:08:15 -06:00
parent e6f6d1ccf8
commit 668006724b
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
11 changed files with 46 additions and 39 deletions

View file

@ -9,7 +9,6 @@
- Added a new view for song properties (Such as Bitrate) - Added a new view for song properties (Such as Bitrate)
- The playback bar now has a new design, with an improved progress indicator and a - The playback bar now has a new design, with an improved progress indicator and a
skip action skip action
- When playing, covers now show an indicator
#### What's Improved #### What's Improved
- The toolbar in the home UI now collapses when scrolling - The toolbar in the home UI now collapses when scrolling
@ -19,6 +18,7 @@
- Added song actions to the playback panel - Added song actions to the playback panel
- Playback controls are now easier to reach when gesture navigation is enabled - Playback controls are now easier to reach when gesture navigation is enabled
- Added Play Next/Add to Queue options to artists and genres - Added Play Next/Add to Queue options to artists and genres
- Covers in the detail views now show an indicator when playing
#### What's Fixed #### What's Fixed
- Playback bar now picks the larger inset in case that gesture inset is missing [#149] - Playback bar now picks the larger inset in case that gesture inset is missing [#149]

View file

@ -81,8 +81,7 @@ fun handleAccentCompat(prefs: SharedPreferences): Accent {
} }
} }
// TODO: Default accent on android 12 should be dynamic colors return Accent.from(prefs.getInt(SettingsManager.KEY_ACCENT, Accent.DEFAULT))
return Accent.from(prefs.getInt(SettingsManager.KEY_ACCENT, 5))
} }
/** /**

View file

@ -19,7 +19,7 @@ package org.oxycblt.auxio.ui.accent
import android.os.Build import android.os.Build
import org.oxycblt.auxio.R import org.oxycblt.auxio.R
import org.oxycblt.auxio.util.logW import org.oxycblt.auxio.util.logEOrThrow
private val ACCENT_NAMES = private val ACCENT_NAMES =
intArrayOf( intArrayOf(
@ -131,13 +131,20 @@ class Accent private constructor(val index: Int) {
companion object { companion object {
fun from(index: Int): Accent { fun from(index: Int): Accent {
if (index > (MAX - 1)) { if (index > (MAX - 1)) {
logW("Account outside of bounds [idx: $index, max: $MAX]") logEOrThrow("Account outside of bounds [idx: $index, max: $MAX]")
return Accent(5) return Accent(5)
} }
return Accent(index) return Accent(index)
} }
val DEFAULT =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
ACCENT_THEMES.lastIndex
} else {
5
}
/** /**
* The maximum amount of accents that are valid. This excludes the dynamic accent on * The maximum amount of accents that are valid. This excludes the dynamic accent on
* versions that do not support it. * versions that do not support it.

View file

@ -1,13 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt" android:width="24dp"
android:width="24dp" android:height="24dp"
android:height="24dp" android:tint="?attr/colorControlNormal"
android:tint="?attr/colorControlNormal" android:viewportWidth="24"
android:viewportWidth="24" android:viewportHeight="24">
android:viewportHeight="24"> <path
<path android:fillColor="@android:color/white"
android:fillColor="@android:color/white" android:pathData="M10,20h4L14,4h-4v16zM4,20h4v-8L4,12v8zM16,9v11h4L20,9h-4z" />
android:pathData="M10,20h4L14,4h-4v16zM4,20h4v-8L4,12v8zM16,9v11h4L20,9h-4z" /> </vector>
</vector>

View file

@ -2,10 +2,10 @@
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
style="@style/Widget.Auxio.Dialog.NestedScrollView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical">
style="@style/Widget.Auxio.Dialog.NestedScrollView">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -37,11 +37,11 @@
android:textColor="?android:attr/textColorSecondary" /> android:textColor="?android:attr/textColorSecondary" />
<TextView <TextView
style="@style/Widget.Auxio.TextView.Header"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="@dimen/spacing_mid_large" android:paddingStart="@dimen/spacing_mid_large"
android:paddingEnd="@dimen/spacing_mid_large" android:paddingEnd="@dimen/spacing_mid_large"
style="@style/Widget.Auxio.TextView.Header"
android:text="@string/set_dirs_mode" /> android:text="@string/set_dirs_mode" />
<com.google.android.material.divider.MaterialDivider <com.google.android.material.divider.MaterialDivider
@ -53,28 +53,28 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_mid_large" android:layout_marginStart="@dimen/spacing_mid_large"
android:layout_marginEnd="@dimen/spacing_mid_large"
android:layout_marginTop="@dimen/spacing_medium" android:layout_marginTop="@dimen/spacing_medium"
android:layout_marginEnd="@dimen/spacing_mid_large"
android:gravity="center" android:gravity="center"
app:singleSelection="true" app:checkedButton="@+id/dirs_mode_exclude"
app:selectionRequired="true" app:selectionRequired="true"
app:checkedButton="@+id/dirs_mode_exclude"> app:singleSelection="true">
<Button <Button
android:id="@+id/dirs_mode_exclude" android:id="@+id/dirs_mode_exclude"
style="@style/Widget.Auxio.Button.Secondary"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/set_dirs_mode_exclude" android:layout_weight="1"
style="@style/Widget.Auxio.Button.Secondary" /> android:text="@string/set_dirs_mode_exclude" />
<Button <Button
android:id="@+id/dirs_mode_include" android:id="@+id/dirs_mode_include"
style="@style/Widget.Auxio.Button.Secondary"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/set_dirs_mode_include" android:layout_weight="1"
style="@style/Widget.Auxio.Button.Secondary" /> android:text="@string/set_dirs_mode_include" />
</com.google.android.material.button.MaterialButtonToggleGroup> </com.google.android.material.button.MaterialButtonToggleGroup>
@ -83,8 +83,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_mid_large" android:layout_marginStart="@dimen/spacing_mid_large"
android:layout_marginEnd="@dimen/spacing_mid_large"
android:layout_marginTop="@dimen/spacing_small" android:layout_marginTop="@dimen/spacing_small"
android:layout_marginEnd="@dimen/spacing_mid_large"
tools:text="Mode description" /> tools:text="Mode description" />
</LinearLayout> </LinearLayout>

View file

@ -2,9 +2,9 @@
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
style="@style/Widget.Auxio.Dialog.NestedScrollView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
style="@style/Widget.Auxio.Dialog.NestedScrollView">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -6,9 +6,9 @@
android:layout_height="match_parent"> android:layout_height="match_parent">
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
style="@style/Widget.Auxio.Dialog.NestedScrollView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
style="@style/Widget.Auxio.Dialog.NestedScrollView">
<LinearLayout <LinearLayout
android:id="@+id/detail_container" android:id="@+id/detail_container"
@ -17,9 +17,9 @@
android:orientation="vertical" android:orientation="vertical"
android:paddingStart="@dimen/spacing_mid_large" android:paddingStart="@dimen/spacing_mid_large"
android:paddingEnd="@dimen/spacing_mid_large" android:paddingEnd="@dimen/spacing_mid_large"
android:showDividers="middle"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible" tools:visibility="visible">
android:showDividers="middle">
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -69,8 +69,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_medium" android:layout_marginTop="@dimen/spacing_medium"
app:expandedHintEnabled="false" android:hint="@string/lbl_size"
android:hint="@string/lbl_size"> app:expandedHintEnabled="false">
<org.oxycblt.auxio.detail.ReadOnlyTextInput <org.oxycblt.auxio.detail.ReadOnlyTextInput
android:id="@+id/detail_size" android:id="@+id/detail_size"

View file

@ -34,7 +34,7 @@
android:imeOptions="actionSearch|flagNoExtractUi" android:imeOptions="actionSearch|flagNoExtractUi"
android:inputType="textFilter" android:inputType="textFilter"
android:paddingStart="@dimen/spacing_tiny" android:paddingStart="@dimen/spacing_tiny"
android:paddingEnd="0dp"/> android:paddingEnd="0dp" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>

View file

@ -10,10 +10,10 @@
android:id="@+id/disc_item" android:id="@+id/disc_item"
style="@style/Widget.Auxio.Image.Small" style="@style/Widget.Auxio.Image.Small"
android:scaleType="matrix" android:scaleType="matrix"
app:staticIcon="@drawable/ic_album"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:staticIcon="@drawable/ic_album"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<TextView <TextView

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<style name="Widget.Auxio.Toolbar.Actions" parent="Widget.Auxio.Toolbar.Base"> <style name="Widget.Auxio.Toolbar.Actions" parent="Widget.Auxio.Toolbar.Base">
<item name="android:layout_marginEnd">@dimen/spacing_tiny_inv</item> <item name="android:layout_marginEnd">@dimen/spacing_tiny_inv</item>
</style> </style>

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<style name="Widget.Auxio.Button.AppWidget.V31" parent="Widget.AppCompat.Button.Borderless"> <style name="Widget.Auxio.Button.AppWidget.V31" parent="Widget.AppCompat.Button.Borderless">
<item name="android:background">@drawable/ui_large_unbounded_ripple</item> <item name="android:background">@drawable/ui_large_unbounded_ripple</item>
</style> </style>