music: refactor model usage
Refactor the way music models are constructed to achieve the following: - Add a unified interface for resolving display names of artists - Disambiguate the role of Header in the music objects - Eliminate the need to load strings in with a context when creating Header instances
This commit is contained in:
@@ -80,7 +80,7 @@
|
||||
android:layout_marginStart="@dimen/spacing_mid_large"
|
||||
android:layout_marginEnd="@dimen/spacing_mid_large"
|
||||
android:onClick="@{() -> detailModel.navToItem(playbackModel.song.album.artist)}"
|
||||
android:text="@{song.album.artist.name}"
|
||||
android:text="@{song.album.artist.resolvedName}"
|
||||
app:layout_constraintBottom_toTopOf="@+id/playback_album"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
android:layout_marginStart="@dimen/spacing_mid_large"
|
||||
android:layout_marginEnd="@dimen/spacing_mid_large"
|
||||
android:onClick="@{() -> detailModel.navToItem(playbackModel.song.album.artist)}"
|
||||
android:text="@{song.album.artist.name}"
|
||||
android:text="@{song.album.artist.resolvedName}"
|
||||
app:layout_constraintBottom_toTopOf="@+id/playback_album"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
android:layout_marginStart="@dimen/spacing_mid_huge"
|
||||
android:layout_marginEnd="@dimen/spacing_mid_huge"
|
||||
android:onClick="@{() -> detailModel.navToItem(playbackModel.song.album.artist)}"
|
||||
android:text="@{song.album.artist.name}"
|
||||
android:text="@{song.album.artist.resolvedName}"
|
||||
app:layout_constraintBottom_toTopOf="@+id/playback_album"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
android:layout_marginStart="@dimen/spacing_small"
|
||||
android:layout_marginEnd="@dimen/spacing_small"
|
||||
android:ellipsize="end"
|
||||
android:text="@{@string/fmt_two(song.album.artist.name, song.album.name)}"
|
||||
android:text="@{@string/fmt_two(song.album.artist.resolvedName, song.album.name)}"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/playback_cover"
|
||||
app:layout_constraintEnd_toStartOf="@+id/playback_play_pause"
|
||||
app:layout_constraintStart_toEndOf="@+id/playback_cover"
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
android:layout_marginStart="@dimen/spacing_mid_large"
|
||||
android:layout_marginEnd="@dimen/spacing_mid_large"
|
||||
android:onClick="@{() -> detailModel.navToItem(playbackModel.song.album.artist)}"
|
||||
android:text="@{song.album.artist.name}"
|
||||
android:text="@{song.album.artist.resolvedName}"
|
||||
app:layout_constraintBottom_toTopOf="@+id/playback_album"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
style="@style/Widget.Auxio.TextView.Header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@{header.name}"
|
||||
android:text="@{header.string.resolve(context)}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
style="@style/Widget.Auxio.TextView.Item.Secondary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@{@string/fmt_two(album.artist.name, @plurals/fmt_song_count(album.songs.size, album.songs.size))}"
|
||||
android:text="@{@string/fmt_two(album.artist.resolvedName, @plurals/fmt_song_count(album.songs.size, album.songs.size))}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/album_cover"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<ImageView
|
||||
android:id="@+id/artist_image"
|
||||
style="@style/Widget.Auxio.Image.Normal"
|
||||
android:contentDescription="@{@string/desc_artist_image(artist.name)}"
|
||||
android:contentDescription="@{@string/desc_artist_image(artist.resolvedName)}"
|
||||
app:artistImage="@{artist}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -28,7 +28,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Widget.Auxio.TextView.Item.Primary"
|
||||
android:text="@{artist.name}"
|
||||
android:text="@{artist.resolvedName}"
|
||||
app:layout_constraintBottom_toTopOf="@+id/artist_details"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/artist_image"
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/album_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Widget.Auxio.TextView.Item.Primary"
|
||||
android:textColor="@color/sel_accented_primary"
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/album_year"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Widget.Auxio.TextView.Item.Secondary"
|
||||
android:text="@{album.year != 0 ? String.valueOf(album.year) : @string/def_date}"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<ImageView
|
||||
android:id="@+id/genre_image"
|
||||
style="@style/Widget.Auxio.Image.Normal"
|
||||
android:contentDescription="@{@string/desc_genre_image(genre.name)}"
|
||||
android:contentDescription="@{@string/desc_genre_image(genre.resolvedName)}"
|
||||
app:genreImage="@{genre}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/spacing_medium"
|
||||
android:text="@{@string/fmt_two(song.album.artist.name, song.album.name)}"
|
||||
android:text="@{@string/fmt_two(song.album.artist.resolvedName, song.album.name)}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/song_duration"
|
||||
app:layout_constraintStart_toEndOf="@+id/album_cover"
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/song_duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Widget.Auxio.TextView.Item.Secondary"
|
||||
android:ellipsize="none"
|
||||
|
||||
@@ -15,6 +15,6 @@
|
||||
style="@style/Widget.Auxio.TextView.Header"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:text="@{header.name}"
|
||||
android:text="@{header.string.resolve(context)}"
|
||||
tools:text="Songs" />
|
||||
</layout>
|
||||
@@ -69,7 +69,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/spacing_medium"
|
||||
android:text="@{@string/fmt_two(song.album.artist.name, song.album.name)}"
|
||||
android:text="@{@string/fmt_two(song.album.artist.resolvedName, song.album.name)}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/song_drag_handle"
|
||||
app:layout_constraintStart_toEndOf="@+id/album_cover"
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
style="@style/Widget.Auxio.TextView.Item.Secondary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@{@string/fmt_two(song.album.artist.name, song.album.name)}"
|
||||
android:text="@{@string/fmt_two(song.album.artist.resolvedName, song.album.name)}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/album_cover"
|
||||
|
||||
@@ -82,4 +82,4 @@
|
||||
|
||||
</android.widget.LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -41,4 +41,9 @@
|
||||
|
||||
<dimen name="popup_min_width">78dp</dimen>
|
||||
<dimen name="popup_padding_end">28dp</dimen>
|
||||
|
||||
<dimen name="widget_width_min">176dp</dimen>
|
||||
<dimen name="widget_height_min">180dp</dimen>
|
||||
<dimen name="widget_width_def">@dimen/widget_width_min</dimen>
|
||||
<dimen name="widget_height_def">180dp</dimen>
|
||||
</resources>
|
||||
@@ -134,8 +134,8 @@
|
||||
<string name="desc_artist_image">Artist Image for %s</string>
|
||||
<string name="desc_genre_image">Genre Image for %s</string>
|
||||
|
||||
|
||||
<!-- Default Namespace | Placeholder values -->
|
||||
<string name="def_artist">Unknown Artist</string>
|
||||
<string name="def_genre">Unknown Genre</string>
|
||||
<string name="def_date">No Date</string>
|
||||
<string name="def_playback">No music playing</string>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:description="@string/info_widget_desc"
|
||||
android:initialLayout="@layout/widget_small"
|
||||
android:minResizeWidth="176dp"
|
||||
android:minResizeHeight="152dp"
|
||||
android:previewLayout="@layout/widget_small"
|
||||
android:initialLayout="@layout/widget_minimal"
|
||||
android:minResizeWidth="@dimen/widget_width_min"
|
||||
android:minResizeHeight="@dimen/widget_height_min"
|
||||
android:previewLayout="@layout/widget_minimal"
|
||||
android:previewImage="@drawable/ui_widget_preview"
|
||||
android:resizeMode="horizontal|vertical"
|
||||
android:minWidth="176dp"
|
||||
android:minHeight="180dp"
|
||||
android:minWidth="@dimen/widget_width_def"
|
||||
android:minHeight="@dimen/widget_height_def"
|
||||
android:targetCellWidth="3"
|
||||
android:targetCellHeight="3"
|
||||
android:updatePeriodMillis="0"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:initialLayout="@layout/widget_small"
|
||||
android:minWidth="176dp"
|
||||
android:minHeight="180dp"
|
||||
android:minResizeWidth="176dp"
|
||||
android:minResizeHeight="152dp"
|
||||
android:initialLayout="@layout/widget_minimal"
|
||||
android:minWidth="@dimen/widget_width_min"
|
||||
android:minHeight="@dimen/widget_height_min"
|
||||
android:minResizeWidth="@dimen/widget_width_def"
|
||||
android:minResizeHeight="@dimen/widget_height_def"
|
||||
android:previewImage="@drawable/ui_widget_preview"
|
||||
android:resizeMode="horizontal|vertical"
|
||||
android:updatePeriodMillis="0"
|
||||
|
||||
Reference in New Issue
Block a user