ui: rework resource distribution

Try to remove the weird config file and replace it with more
conventional resource files in other places.
This commit is contained in:
OxygenCobalt 2022-08-05 09:58:20 -06:00
parent 7d04aad9b7
commit e12c7cb419
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
25 changed files with 59 additions and 156 deletions

View file

@ -44,6 +44,9 @@ import org.oxycblt.auxio.util.systemBarInsetsCompat
*
* TODO: Add multi-select
*
* LEFT-OFF: Add RecyclerView styles, queue issue is caused by tiny scroll and then replace op, not
* enough to change scroll apparently
*
* @author OxygenCobalt
*/
class MainActivity : AppCompatActivity() {

View file

@ -111,8 +111,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
this.titleAnimator =
ValueAnimator.ofFloat(from, to).apply {
addUpdateListener { titleView?.alpha = it.animatedValue as Float }
duration =
resources.getInteger(R.integer.detail_app_bar_title_anim_duration).toLong()
duration = TOOLBAR_FADE_DURATION
start()
}
}
@ -143,6 +142,8 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
}
companion object {
private const val TOOLBAR_FADE_DURATION = 150L
private val TOOLBAR_TITLE_TEXT_FIELD: Field by
lazyReflectedField(Toolbar::class, "mTitleTextView")
}

View file

@ -17,6 +17,7 @@
package org.oxycblt.auxio.settings
import android.os.Build
import android.os.Bundle
import android.view.View
import androidx.annotation.DrawableRes
@ -161,6 +162,10 @@ class SettingsListFragment : PreferenceFragmentCompat() {
preference.apply {
when (key) {
context.getString(R.string.set_key_theme) -> {
// Android 12 is the first version I deem to have universal dark and light
// mode toggles. No need for our setting.
isVisible = Build.VERSION.SDK_INT < Build.VERSION_CODES.S
onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _, value ->
AppCompatDelegate.setDefaultNightMode(value as Int)

View file

@ -1,97 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
<org.oxycblt.auxio.image.StyledImageView
android:id="@+id/playback_cover"
style="@style/Widget.Auxio.Image.Medium"
android:layout_margin="@dimen/spacing_small"
app:layout_constraintBottom_toTopOf="@+id/playback_progress_container"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:staticIcon="@drawable/ic_song_24" />
<TextView
android:id="@+id/playback_song"
style="@style/Widget.Auxio.TextView.Primary.Compact"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_small"
android:layout_marginEnd="@dimen/spacing_tiny"
app:layout_constraintBottom_toTopOf="@+id/playback_info"
app:layout_constraintEnd_toStartOf="@+id/playback_controls_wrapper"
app:layout_constraintStart_toEndOf="@+id/playback_cover"
app:layout_constraintTop_toTopOf="@+id/playback_cover"
app:layout_constraintVertical_chainStyle="packed"
tools:text="Song Name" />
<TextView
android:id="@+id/playback_info"
style="@style/Widget.Auxio.TextView.Secondary.Compact"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_small"
android:layout_marginEnd="@dimen/spacing_tiny"
android:ellipsize="end"
app:layout_constraintBottom_toBottomOf="@+id/playback_cover"
app:layout_constraintEnd_toStartOf="@+id/playback_controls_wrapper"
app:layout_constraintStart_toEndOf="@+id/playback_cover"
app:layout_constraintTop_toBottomOf="@+id/playback_song"
tools:text="Artist Name / Album Name" />
<org.oxycblt.auxio.playback.ForcedLTRFrameLayout
android:id="@+id/playback_controls_wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/spacing_tiny"
app:layout_constraintBottom_toTopOf="@+id/playback_progress_container"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:id="@+id/playback_controls_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/playback_play_pause"
style="@style/Widget.Auxio.Button.Icon.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/desc_play_pause"
app:icon="@drawable/sel_playing_state_24" />
<Button
android:id="@+id/playback_skip_next"
style="@style/Widget.Auxio.Button.Icon.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/desc_play_pause"
app:icon="@drawable/ic_skip_next_24" />
</LinearLayout>
</org.oxycblt.auxio.playback.ForcedLTRFrameLayout>
<org.oxycblt.auxio.playback.ForcedLTRFrameLayout
android:id="@+id/playback_progress_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/playback_progress_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_small"
android:layout_marginEnd="@dimen/spacing_small"
tools:progress="70" />
</org.oxycblt.auxio.playback.ForcedLTRFrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -14,13 +14,12 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/dirs_recycler"
style="@style/Widget.Auxio.RecyclerView.Linear"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:overScrollMode="never"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:itemCount="1"
tools:listitem="@layout/item_music_dir" />
<TextView
@ -34,7 +33,8 @@
android:text="@string/err_no_dirs"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.Auxio.LabelLarge"
android:textColor="?android:attr/textColorSecondary" />
android:textColor="?android:attr/textColorSecondary"
tools:visibility="gone" />
<TextView
style="@style/Widget.Auxio.TextView.Header"

View file

@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<org.oxycblt.auxio.ui.recycler.DialogRecyclerView 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"
android:id="@+id/tab_recycler"
style="@style/Widget.Auxio.RecyclerView.Linear"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:itemCount="5"
tools:listitem="@layout/item_tab" />

View file

@ -22,10 +22,9 @@
<org.oxycblt.auxio.ui.recycler.AuxioRecyclerView
android:id="@+id/detail_recycler"
style="@style/Widget.Auxio.RecyclerView.Grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:spanCount="@integer/recycler_spans"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
tools:listitem="@layout/item_detail" />

View file

@ -1,12 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<org.oxycblt.auxio.home.fastscroll.FastScrollRecyclerView 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"
android:id="@+id/home_recycler"
style="@style/Widget.Auxio.RecyclerView.WithAdaptiveFab"
style="@style/Widget.Auxio.RecyclerView.Grid.WithAdaptiveFab"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:spanCount="@integer/recycler_spans"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
tools:listitem="@layout/item_parent" />
tools:listitem="@layout/item_song" />

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
android:id="@+id/queue_layout"
android:layout_width="match_parent"
@ -8,10 +7,9 @@
<org.oxycblt.auxio.ui.recycler.AuxioRecyclerView
android:id="@+id/queue_recycler"
style="@style/Widget.Auxio.RecyclerView.Linear"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
tools:listitem="@layout/item_queue_song" />
<com.google.android.material.divider.MaterialDivider

View file

@ -47,10 +47,9 @@
<org.oxycblt.auxio.ui.recycler.AuxioRecyclerView
android:id="@+id/search_recycler"
style="@style/Widget.Auxio.RecyclerView.Grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:spanCount="@integer/recycler_spans"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
tools:listitem="@layout/item_song" />

View file

@ -20,7 +20,7 @@
android:paddingTop="@dimen/spacing_small"
android:paddingBottom="@dimen/spacing_small"
android:textAppearance="@style/TextAppearance.Auxio.BodyLarge"
tools:text="/storage/emulated/0/directory" />
tools:text="primary:path/to/music" />
<Button
android:id="@+id/dir_delete"

View file

@ -5,7 +5,7 @@
<item name="fabSize">normal</item>
</style>
<style name="Widget.Auxio.RecyclerView.WithAdaptiveFab" parent="">
<style name="Widget.Auxio.RecyclerView.Grid.WithAdaptiveFab" parent="Widget.Auxio.RecyclerView.Grid">
<item name="android:paddingBottom">@dimen/recycler_fab_space_large</item>
</style>
</resources>

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="recycler_spans">3</integer>
</resources>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Widget.Auxio.RecyclerView.Grid" parent="Widget.Auxio.RecyclerView.Grid.Base">
<item name="spanCount">3</item>
</style>
</resources>

View file

@ -5,5 +5,9 @@
<!-- Fix dumb default android behavior -->
<item name="colorControlHighlight">@color/sel_compat_ripple</item>
<!-- Work around hard-coded text highlight colors in the default Material3 theme -->
<item name="android:textColorHighlight">@color/overlay_text_highlight</item>
<item name="android:textColorHighlightInverse">@color/overlay_text_highlight_inverse</item>
</style>
</resources>

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="enable_theme_settings">false</bool>
</resources>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Use dynamic colors since that's assumed to be the setting used. -->
<style name="Theme.Auxio.App" parent="Theme.Auxio.Base" />
<style name="Theme.Auxio.Widget" parent="@android:style/Theme.DeviceDefault.DayNight">

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="recycler_spans">2</integer>
</resources>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Widget.Auxio.RecyclerView.Grid" parent="Widget.Auxio.RecyclerView.Grid.Base">
<item name="spanCount">2</item>
</style>
</resources>

View file

@ -1,5 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- This is for HomeFragment's AppBarLayout. Explanations for these can be found there. -->
<item name="home_song_list" type="id" />
<item name="home_album_list" type="id" />
<item name="home_artist_list" type="id" />
<item name="home_genre_list" type="id" />
<declare-styleable name="StyledImageView">
<attr name="cornerRadius" format="dimension" />
<attr name="staticIcon" format="reference" />

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="enable_theme_settings">true</bool>
<integer name="recycler_spans">1</integer>
<integer name="detail_app_bar_title_anim_duration">150</integer>
</resources>

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- This is for BottomSheetLayout -->
<item name="bottom_sheet_view" type="id" />
<!-- This is for HomeFragment's AppBarLayout. Explanations for these can be found there. -->
<item name="home_song_list" type="id" />
<item name="home_album_list" type="id" />
<item name="home_artist_list" type="id" />
<item name="home_genre_list" type="id" />
</resources>

View file

@ -42,10 +42,6 @@
<item name="textAppearanceBodyMedium">@style/TextAppearance.Auxio.BodyMedium</item>
<item name="textAppearanceBodySmall">@style/TextAppearance.Auxio.BodySmall</item>
<!-- Work around hard-coded text highlight colors in the default Material3 theme -->
<item name="android:textColorHighlight">@color/overlay_text_highlight</item>
<item name="android:textColorHighlightInverse">@color/overlay_text_highlight_inverse</item>
<!-- Fix dumb default android behavior -->
<item name="android:scrollbars">none</item>
<item name="windowActionBar">false</item>
@ -63,6 +59,7 @@
<item name="actionOverflowButtonStyle">@style/Widget.Auxio.Button.Overflow</item>
</style>
<!-- Make sure blue is the default style instead of material purple -->
<style name="Theme.Auxio.App" parent="@style/Theme.Auxio.Blue" />
<!--

View file

@ -79,7 +79,17 @@
<item name="android:focusable">true</item>
</style>
<style name="Widget.Auxio.RecyclerView.WithAdaptiveFab" parent="">
<style name="Widget.Auxio.RecyclerView.Linear" parent="">
<item name="layoutManager">androidx.recyclerview.widget.LinearLayoutManager</item>
</style>
<style name="Widget.Auxio.RecyclerView.Grid.Base" parent="">
<item name="layoutManager">androidx.recyclerview.widget.GridLayoutManager</item>
</style>
<style name="Widget.Auxio.RecyclerView.Grid" parent="Widget.Auxio.RecyclerView.Grid.Base" />
<style name="Widget.Auxio.RecyclerView.Grid.WithAdaptiveFab" parent="Widget.Auxio.RecyclerView.Grid">
<item name="android:paddingBottom">@dimen/recycler_fab_space_normal</item>
</style>

View file

@ -8,7 +8,6 @@
app:entryIcons="@array/icons_theme"
app:entryValues="@array/values_theme"
app:icon="@drawable/ic_light_24"
app:isPreferenceVisible="@bool/enable_theme_settings"
app:key="@string/set_key_theme"
app:title="@string/set_theme" />