Build song subtitle string via android getString() parameters

This commit is contained in:
CappielloAntonio 2021-09-13 15:43:00 +02:00
parent 159562f9e3
commit d108c1b6a5
6 changed files with 35 additions and 58 deletions

4
.idea/misc.xml generated
View file

@ -83,7 +83,7 @@
<entry key="app/src/main/res/layout/item_horizontal_artist.xml" value="0.3229166666666667" /> <entry key="app/src/main/res/layout/item_horizontal_artist.xml" value="0.3229166666666667" />
<entry key="app/src/main/res/layout/item_horizontal_playlist.xml" value="0.3229166666666667" /> <entry key="app/src/main/res/layout/item_horizontal_playlist.xml" value="0.3229166666666667" />
<entry key="app/src/main/res/layout/item_horizontal_playlist_dialog_track.xml" value="0.3229166666666667" /> <entry key="app/src/main/res/layout/item_horizontal_playlist_dialog_track.xml" value="0.3229166666666667" />
<entry key="app/src/main/res/layout/item_horizontal_track.xml" value="0.5557163531114327" /> <entry key="app/src/main/res/layout/item_horizontal_track.xml" value="0.1" />
<entry key="app/src/main/res/layout/item_library_album.xml" value="0.3229166666666667" /> <entry key="app/src/main/res/layout/item_library_album.xml" value="0.3229166666666667" />
<entry key="app/src/main/res/layout/item_library_artist.xml" value="0.3229166666666667" /> <entry key="app/src/main/res/layout/item_library_artist.xml" value="0.3229166666666667" />
<entry key="app/src/main/res/layout/item_library_artist_page_or_similar_album.xml" value="0.3229166666666667" /> <entry key="app/src/main/res/layout/item_library_artist_page_or_similar_album.xml" value="0.3229166666666667" />
@ -100,7 +100,7 @@
<entry key="app/src/main/res/layout/item_placeholder_horizontal.xml" value="0.3229166666666667" /> <entry key="app/src/main/res/layout/item_placeholder_horizontal.xml" value="0.3229166666666667" />
<entry key="app/src/main/res/layout/item_placeholder_year.xml" value="0.3229166666666667" /> <entry key="app/src/main/res/layout/item_placeholder_year.xml" value="0.3229166666666667" />
<entry key="app/src/main/res/layout/item_player_now_playing_song.xml" value="0.3229166666666667" /> <entry key="app/src/main/res/layout/item_player_now_playing_song.xml" value="0.3229166666666667" />
<entry key="app/src/main/res/layout/item_player_queue_song.xml" value="0.3229166666666667" /> <entry key="app/src/main/res/layout/item_player_queue_song.xml" value="0.1" />
<entry key="app/src/main/res/layout/player_body_bottom_sheet.xml" value="0.3229166666666667" /> <entry key="app/src/main/res/layout/player_body_bottom_sheet.xml" value="0.3229166666666667" />
<entry key="app/src/main/res/layout/player_header_bottom_sheet.xml" value="0.3229166666666667" /> <entry key="app/src/main/res/layout/player_header_bottom_sheet.xml" value="0.3229166666666667" />
<entry key="app/src/main/res/menu/bottom_nav_menu.xml" value="0.3229166666666667" /> <entry key="app/src/main/res/menu/bottom_nav_menu.xml" value="0.3229166666666667" />

View file

@ -21,9 +21,6 @@ import com.cappielloantonio.play.util.MusicUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
* Adapter per i brani ritrovati nella ricerca
*/
public class PlayerSongQueueAdapter extends RecyclerView.Adapter<PlayerSongQueueAdapter.ViewHolder> { public class PlayerSongQueueAdapter extends RecyclerView.Adapter<PlayerSongQueueAdapter.ViewHolder> {
private static final String TAG = "SongResultSearchAdapter"; private static final String TAG = "SongResultSearchAdapter";
@ -52,7 +49,7 @@ public class PlayerSongQueueAdapter extends RecyclerView.Adapter<PlayerSongQueue
Song song = songs.get(position); Song song = songs.get(position);
holder.songTitle.setText(MusicUtil.getReadableString(song.getTitle())); holder.songTitle.setText(MusicUtil.getReadableString(song.getTitle()));
holder.songArtist.setText(MusicUtil.getReadableString(song.getArtistName())); holder.songSubtitle.setText(context.getString(R.string.song_subtitle_formatter, MusicUtil.getReadableString(song.getArtistName()), MusicUtil.getReadableDurationString(song.getDuration(), false)));
CustomGlideRequest.Builder CustomGlideRequest.Builder
.from(context, song.getPrimary(), CustomGlideRequest.SONG_PIC, null) .from(context, song.getPrimary(), CustomGlideRequest.SONG_PIC, null)
@ -62,7 +59,7 @@ public class PlayerSongQueueAdapter extends RecyclerView.Adapter<PlayerSongQueue
if (position < MusicPlayerRemote.getPosition()) { if (position < MusicPlayerRemote.getPosition()) {
holder.songTitle.setTextColor(context.getResources().getColor(R.color.songToPlayTextColor, null)); holder.songTitle.setTextColor(context.getResources().getColor(R.color.songToPlayTextColor, null));
holder.songArtist.setTextColor(context.getResources().getColor(R.color.songToPlayTextColor, null)); holder.songSubtitle.setTextColor(context.getResources().getColor(R.color.songToPlayTextColor, null));
} }
} }
@ -86,19 +83,20 @@ public class PlayerSongQueueAdapter extends RecyclerView.Adapter<PlayerSongQueue
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView songTitle; TextView songTitle;
TextView songArtist; TextView songSubtitle;
ImageView cover; ImageView cover;
ViewHolder(View itemView) { ViewHolder(View itemView) {
super(itemView); super(itemView);
songTitle = itemView.findViewById(R.id.queue_song_title_text_view); songTitle = itemView.findViewById(R.id.queue_song_title_text_view);
songArtist = itemView.findViewById(R.id.queue_song_artist_text_view); songSubtitle = itemView.findViewById(R.id.queue_song_subtitle_text_view);
cover = itemView.findViewById(R.id.queue_song_cover_image_view); cover = itemView.findViewById(R.id.queue_song_cover_image_view);
itemView.setOnClickListener(this); itemView.setOnClickListener(this);
songTitle.setSelected(true); songTitle.setSelected(true);
songSubtitle.setSelected(true);
} }
@Override @Override

View file

@ -56,8 +56,7 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAd
Song song = songs.get(position); Song song = songs.get(position);
holder.songTitle.setText(MusicUtil.getReadableString(song.getTitle())); holder.songTitle.setText(MusicUtil.getReadableString(song.getTitle()));
holder.songArtist.setText(MusicUtil.getReadableString(song.getArtistName())); holder.songSubtitle.setText(context.getString(R.string.song_subtitle_formatter, MusicUtil.getReadableString(song.getArtistName()), MusicUtil.getReadableDurationString(song.getDuration(), false)));
holder.songDuration.setText(MusicUtil.getReadableDurationString(song.getDuration(), false));
holder.trackNumber.setText(String.valueOf(song.getTrackNumber())); holder.trackNumber.setText(String.valueOf(song.getTrackNumber()));
if (DownloadUtil.getDownloadTracker(context).isDownloaded(song)) { if (DownloadUtil.getDownloadTracker(context).isDownloaded(song)) {
@ -93,8 +92,7 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAd
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener { public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
TextView songTitle; TextView songTitle;
TextView songArtist; TextView songSubtitle;
TextView songDuration;
TextView trackNumber; TextView trackNumber;
View downloadIndicator; View downloadIndicator;
View coverSeparator; View coverSeparator;
@ -105,8 +103,7 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAd
super(itemView); super(itemView);
songTitle = itemView.findViewById(R.id.search_result_song_title_text_view); songTitle = itemView.findViewById(R.id.search_result_song_title_text_view);
songArtist = itemView.findViewById(R.id.album_artist_text_view); songSubtitle = itemView.findViewById(R.id.search_result_song_subtitle_text_view);
songDuration = itemView.findViewById(R.id.search_result_song_duration_text_view);
trackNumber = itemView.findViewById(R.id.track_number_text_view); trackNumber = itemView.findViewById(R.id.track_number_text_view);
downloadIndicator = itemView.findViewById(R.id.search_result_dowanload_indicator_image_view); downloadIndicator = itemView.findViewById(R.id.search_result_dowanload_indicator_image_view);
more = itemView.findViewById(R.id.search_result_song_more_button); more = itemView.findViewById(R.id.search_result_song_more_button);
@ -119,6 +116,7 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAd
more.setOnClickListener(this::openMore); more.setOnClickListener(this::openMore);
songTitle.setSelected(true); songTitle.setSelected(true);
songSubtitle.setSelected(true);
} }
@Override @Override

View file

@ -24,8 +24,8 @@
style="@style/TrackNumberTextView" style="@style/TrackNumberTextView"
android:layout_width="52dp" android:layout_width="52dp"
android:layout_height="52dp" android:layout_height="52dp"
android:gravity="center"
android:layout_margin="2dp" android:layout_margin="2dp"
android:gravity="center"
android:text="1" android:text="1"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@ -37,7 +37,7 @@
android:layout_height="52dp" android:layout_height="52dp"
app:layout_constraintEnd_toStartOf="@+id/search_result_song_title_text_view" app:layout_constraintEnd_toStartOf="@+id/search_result_song_title_text_view"
app:layout_constraintStart_toEndOf="@+id/song_cover_image_view" app:layout_constraintStart_toEndOf="@+id/song_cover_image_view"
app:layout_constraintTop_toTopOf="parent"/> app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/search_result_song_title_text_view" android:id="@+id/search_result_song_title_text_view"
@ -57,45 +57,22 @@
app:layout_constraintStart_toEndOf="@+id/cover_image_separator" app:layout_constraintStart_toEndOf="@+id/cover_image_separator"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingEnd="12dp"
app:layout_constrainedWidth="true"
app:layout_constraintEnd_toStartOf="@+id/search_result_dowanload_indicator_image_view"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/cover_image_separator"
app:layout_constraintTop_toBottomOf="@+id/search_result_song_title_text_view">
<TextView <TextView
android:id="@+id/album_artist_text_view" android:id="@+id/search_result_song_subtitle_text_view"
style="@style/ItemSubtitleTextView" style="@style/ItemSubtitleTextView"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:ellipsize="marquee"
android:ellipsize="end" android:focusable="true"
android:maxLines="1" android:focusableInTouchMode="true"
android:paddingEnd="4dp" android:marqueeRepeatLimit="marquee_forever"
android:text="@string/label_placeholder" />
<TextView
android:id="@+id/queue_separator_text_view"
style="@style/ItemSubtitleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_dot_separator" />
<TextView
android:id="@+id/search_result_song_duration_text_view"
style="@style/ItemSubtitleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:paddingStart="4dp"
android:paddingEnd="12dp" android:paddingEnd="12dp"
android:text="@string/label_placeholder" /> android:scrollHorizontally="true"
</LinearLayout> android:singleLine="true"
android:text="@string/label_placeholder"
app:layout_constraintEnd_toStartOf="@+id/search_result_dowanload_indicator_image_view"
app:layout_constraintStart_toEndOf="@+id/cover_image_separator"
app:layout_constraintTop_toBottomOf="@+id/search_result_song_title_text_view" />
<ImageView <ImageView
android:id="@+id/search_result_dowanload_indicator_image_view" android:id="@+id/search_result_dowanload_indicator_image_view"

View file

@ -41,18 +41,21 @@
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/queue_song_artist_text_view" android:id="@+id/queue_song_subtitle_text_view"
style="@style/ItemSubtitleTextView" style="@style/ItemSubtitleTextView"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end" android:ellipsize="marquee"
android:maxLines="1" android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:paddingStart="12dp" android:paddingStart="12dp"
android:paddingEnd="4dp" android:paddingEnd="4dp"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="@string/label_placeholder" android:text="@string/label_placeholder"
app:layout_constraintEnd_toStartOf="@+id/queue_song_holder_image"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constrainedWidth="true" app:layout_constrainedWidth="true"
app:layout_constraintEnd_toStartOf="@+id/queue_song_holder_image"
app:layout_constraintStart_toEndOf="@+id/queue_song_cover_image_view" app:layout_constraintStart_toEndOf="@+id/queue_song_cover_image_view"
app:layout_constraintTop_toBottomOf="@+id/queue_song_title_text_view" /> app:layout_constraintTop_toBottomOf="@+id/queue_song_title_text_view" />

View file

@ -196,6 +196,7 @@
<string name="song_list_page_title">Songs</string> <string name="song_list_page_title">Songs</string>
<string name="song_list_page_top">%1$s\'s top tracks</string> <string name="song_list_page_top">%1$s\'s top tracks</string>
<string name="song_list_page_year">Year %1$d</string> <string name="song_list_page_year">Year %1$d</string>
<string name="song_subtitle_formatter">%1$s • %2$s</string>
<string name="starred_sync_dialog_negative_button">Cancel</string> <string name="starred_sync_dialog_negative_button">Cancel</string>
<string name="starred_sync_dialog_positive_button">Continue</string> <string name="starred_sync_dialog_positive_button">Continue</string>
<string name="starred_sync_dialog_summary">Tracks will be downloaded in their original format. Standard data rates may apply.</string> <string name="starred_sync_dialog_summary">Tracks will be downloaded in their original format. Standard data rates may apply.</string>