Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support non square cover art #255

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,9 @@ public RequestBuilder<Drawable> build() {
.load(item)
.transition(DrawableTransitionOptions.withCrossFade());
}

public RequestBuilder<Drawable> build(boolean fitCenter) {
return fitCenter ? build().optionalFitCenter() : build();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), album.getCoverArtId(), CustomGlideRequest.ResourceType.Album)
.build()
.build(true)
.into(holder.item.albumCoverImageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), album.getCoverArtId(), CustomGlideRequest.ResourceType.Album)
.build()
.build(true)
.into(holder.item.artistPageAlbumCoverImageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), album.getCoverArtId(), CustomGlideRequest.ResourceType.Album)
.build()
.build(true)
.into(holder.item.albumCatalogueCoverImageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), album.getCoverArtId(), CustomGlideRequest.ResourceType.Album)
.build()
.build(true)
.into(holder.item.albumCoverImageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), artist.getCoverArtId(), CustomGlideRequest.ResourceType.Artist)
.build()
.build(true)
.into(holder.item.artistCoverImageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), artist.getCoverArtId(), CustomGlideRequest.ResourceType.Artist)
.build()
.build(true)
.into(holder.item.artistCatalogueCoverImageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), artist.getCoverArtId(), CustomGlideRequest.ResourceType.Artist)
.build()
.build(true)
.into(holder.item.artistCoverImageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), artist.getCoverArtId(), CustomGlideRequest.ResourceType.Artist)
.build()
.build(true)
.into(holder.item.similarArtistCoverImageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private void initTrackLayout(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), song.getCoverArtId(), CustomGlideRequest.ResourceType.Song)
.build()
.build(true)
.into(holder.item.itemCoverImageView);

holder.item.itemCoverImageView.setVisibility(View.VISIBLE);
Expand All @@ -222,7 +222,7 @@ private void initAlbumLayout(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), song.getCoverArtId(), CustomGlideRequest.ResourceType.Song)
.build()
.build(true)
.into(holder.item.itemCoverImageView);

holder.item.itemCoverImageView.setVisibility(View.VISIBLE);
Expand All @@ -244,7 +244,7 @@ private void initArtistLayout(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), song.getCoverArtId(), CustomGlideRequest.ResourceType.Song)
.build()
.build(true)
.into(holder.item.itemCoverImageView);

holder.item.itemCoverImageView.setVisibility(View.VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), item.getCoverArtId(), CustomGlideRequest.ResourceType.Song)
.build()
.build(true)
.into(holder.item.trackCoverImageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), internetRadioStation.getStreamUrl(), CustomGlideRequest.ResourceType.Radio)
.build()
.build(true)
.into(holder.item.internetRadioStationCoverImageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), child.getCoverArtId(), type)
.build()
.build(true)
.into(holder.item.musicDirectoryCoverImageView);

holder.item.musicDirectoryMoreButton.setVisibility(child.isDir() ? View.VISIBLE : View.INVISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), artist.getName(), CustomGlideRequest.ResourceType.Directory)
.build()
.build(true)
.into(holder.item.musicIndexCoverImageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), song.getCoverArtId(), CustomGlideRequest.ResourceType.Song)
.build()
.build(true)
.into(holder.item.queueSongCoverImageView);

MediaManager.getCurrentIndex(mediaBrowserListenableFuture, new MediaIndexCallback() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), song.getCoverArtId(), CustomGlideRequest.ResourceType.Song)
.build()
.build(true)
.into(holder.item.playlistDialogSongCoverImageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), playlist.getCoverArtId(), CustomGlideRequest.ResourceType.Playlist)
.build()
.build(true)
.into(holder.item.playlistCoverImageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), podcastChannel.getCoverArtId(), CustomGlideRequest.ResourceType.Podcast)
.build()
.build(true)
.into(holder.item.podcastChannelCatalogueCoverImageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), podcastChannel.getCoverArtId(), CustomGlideRequest.ResourceType.Podcast)
.build()
.build(true)
.into(holder.item.podcastChannelCoverImageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), podcastEpisode.getCoverArtId(), CustomGlideRequest.ResourceType.Podcast)
.build()
.build(true)
.into(holder.item.podcastCoverImageView);

holder.item.podcastPlayButton.setEnabled(podcastEpisode.getStatus().equals("completed"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

if (share.getEntries() != null && !share.getEntries().isEmpty()) CustomGlideRequest.Builder
.from(holder.itemView.getContext(), share.getEntries().get(0).getCoverArtId(), CustomGlideRequest.ResourceType.Album)
.build()
.build(true)
.into(holder.item.shareCoverImageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

CustomGlideRequest.Builder
.from(holder.itemView.getContext(), song.getCoverArtId(), CustomGlideRequest.ResourceType.Song)
.build()
.build(true)
.into(holder.item.trackCoverImageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {

if (showCoverArt) CustomGlideRequest.Builder
.from(holder.itemView.getContext(), song.getCoverArtId(), CustomGlideRequest.ResourceType.Song)
.build()
.build(true)
.into(holder.item.songCoverImageView);

holder.item.trackNumberTextView.setVisibility(showCoverArt ? View.INVISIBLE : View.VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void setTrackInfo() {
if (mediaMetadata.extras != null) {
CustomGlideRequest.Builder
.from(requireContext(), mediaMetadata.extras.getString("coverArtId", ""), CustomGlideRequest.ResourceType.Song)
.build()
.build(true)
.into(bind.trackCoverInfoImageView);

bind.titleValueSector.setText(mediaMetadata.extras.getString("title", getString(R.string.label_placeholder)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private void initMusicButton() {
private void initBackCover() {
albumPageViewModel.getAlbum().observe(getViewLifecycleOwner(), album -> {
if (bind != null && album != null) {
CustomGlideRequest.Builder.from(requireContext(), album.getCoverArtId(), CustomGlideRequest.ResourceType.Album).build().into(bind.albumCoverImageView);
CustomGlideRequest.Builder.from(requireContext(), album.getCoverArtId(), CustomGlideRequest.ResourceType.Album).build(true).into(bind.albumCoverImageView);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private void initArtistInfo() {

if (getContext() != null && bind != null) CustomGlideRequest.Builder
.from(requireContext(), artistPageViewModel.getArtist().getId(), CustomGlideRequest.ResourceType.Artist)
.build()
.build(true)
.into(bind.artistBackdropImageView);

if (bind != null) bind.bioTextView.setText(normalizedBio);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private void setMetadata(MediaMetadata mediaMetadata) {

CustomGlideRequest.Builder
.from(requireContext(), mediaMetadata.extras.getString("coverArtId"), CustomGlideRequest.ResourceType.Song)
.build()
.build(true)
.into(bind.playerHeaderLayout.playerHeaderMediaCoverImage);

bind.playerHeaderLayout.playerHeaderMediaTitleLabel.setVisibility(mediaMetadata.extras.getString("title") != null && !Objects.equals(mediaMetadata.extras.getString("title"), "") ? View.VISIBLE : View.GONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public void onMediaMetadataChanged(@NonNull MediaMetadata mediaMetadata) {
private void setCover(MediaMetadata mediaMetadata) {
CustomGlideRequest.Builder
.from(requireContext(), mediaMetadata.extras != null ? mediaMetadata.extras.getString("coverArtId") : null, CustomGlideRequest.ResourceType.Song)
.build()
.build(true)
.into(bind.nowPlayingSongCoverImageView);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,28 +182,28 @@ private void initBackCover() {
// Pic top-left
CustomGlideRequest.Builder
.from(requireContext(), !songs.isEmpty() ? songs.get(0).getCoverArtId() : playlistPageViewModel.getPlaylist().getCoverArtId(), CustomGlideRequest.ResourceType.Song)
.build()
.build(true)
.transform(new GranularRoundedCorners(CustomGlideRequest.CORNER_RADIUS, 0, 0, 0))
.into(bind.playlistCoverImageViewTopLeft);

// Pic top-right
CustomGlideRequest.Builder
.from(requireContext(), songs.size() > 1 ? songs.get(1).getCoverArtId() : playlistPageViewModel.getPlaylist().getCoverArtId(), CustomGlideRequest.ResourceType.Song)
.build()
.build(true)
.transform(new GranularRoundedCorners(0, CustomGlideRequest.CORNER_RADIUS, 0, 0))
.into(bind.playlistCoverImageViewTopRight);

// Pic bottom-left
CustomGlideRequest.Builder
.from(requireContext(), songs.size() > 2 ? songs.get(2).getCoverArtId() : playlistPageViewModel.getPlaylist().getCoverArtId(), CustomGlideRequest.ResourceType.Song)
.build()
.build(true)
.transform(new GranularRoundedCorners(0, 0, 0, CustomGlideRequest.CORNER_RADIUS))
.into(bind.playlistCoverImageViewBottomLeft);

// Pic bottom-right
CustomGlideRequest.Builder
.from(requireContext(), songs.size() > 3 ? songs.get(3).getCoverArtId() : playlistPageViewModel.getPlaylist().getCoverArtId(), CustomGlideRequest.ResourceType.Song)
.build()
.build(true)
.transform(new GranularRoundedCorners(0, 0, CustomGlideRequest.CORNER_RADIUS, 0))
.into(bind.playlistCoverImageViewBottomRight);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void init(View view) {
ImageView coverAlbum = view.findViewById(R.id.album_cover_image_view);
CustomGlideRequest.Builder
.from(requireContext(), albumBottomSheetViewModel.getAlbum().getCoverArtId(), CustomGlideRequest.ResourceType.Album)
.build()
.build(true)
.into(coverAlbum);

TextView titleAlbum = view.findViewById(R.id.album_title_text_view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void init(View view) {
ImageView coverArtist = view.findViewById(R.id.artist_cover_image_view);
CustomGlideRequest.Builder
.from(requireContext(), artistBottomSheetViewModel.getArtist().getCoverArtId(), CustomGlideRequest.ResourceType.Artist)
.build()
.build(true)
.into(coverArtist);

TextView nameArtist = view.findViewById(R.id.song_title_text_view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void initUI(View view) {

private void init(View view) {
ImageView coverAlbum = view.findViewById(R.id.group_cover_image_view);
CustomGlideRequest.Builder.from(requireContext(), songs.get(new Random().nextInt(songs.size())).getCoverArtId(), CustomGlideRequest.ResourceType.Unknown).build().into(coverAlbum);
CustomGlideRequest.Builder.from(requireContext(), songs.get(new Random().nextInt(songs.size())).getCoverArtId(), CustomGlideRequest.ResourceType.Unknown).build(true).into(coverAlbum);

TextView groupTitleView = view.findViewById(R.id.group_title_text_view);
groupTitleView.setText(this.groupTitle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private void init(View view) {

CustomGlideRequest.Builder
.from(requireContext(), podcastChannelBottomSheetViewModel.getPodcastChannel().getCoverArtId(), CustomGlideRequest.ResourceType.Podcast)
.build()
.build(true)
.into(coverPodcast);

TextView titlePodcast = view.findViewById(R.id.podcast_title_text_view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void init(View view) {

CustomGlideRequest.Builder
.from(requireContext(), podcastEpisodeBottomSheetViewModel.getPodcastEpisode().getCoverArtId(), CustomGlideRequest.ResourceType.Podcast)
.build()
.build(true)
.into(coverPodcast);

TextView titlePodcast = view.findViewById(R.id.podcast_title_text_view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void init(View view) {

CustomGlideRequest.Builder
.from(requireContext(), shareBottomSheetViewModel.getShare().getEntries().get(0).getCoverArtId(), CustomGlideRequest.ResourceType.Unknown)
.build()
.build(true)
.into(shareCover);

TextView shareTitle = view.findViewById(R.id.share_title_text_view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private void init(View view) {
ImageView coverSong = view.findViewById(R.id.song_cover_image_view);
CustomGlideRequest.Builder
.from(requireContext(), songBottomSheetViewModel.getSong().getCoverArtId(), CustomGlideRequest.ResourceType.Song)
.build()
.build(true)
.into(coverSong);

TextView titleSong = view.findViewById(R.id.song_title_text_view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ object Preferences {

@JvmStatic
fun isInUseServerAddressLocal(): Boolean {
return getInUseServerAddress() == getLocalAddress()
return getInUseServerAddress() == getLocalAddress() && !getLocalAddress().isNullOrEmpty()
}

@JvmStatic
Expand All @@ -187,7 +187,7 @@ object Preferences {
fun isServerSwitchable(): Boolean {
return App.getInstance().preferences.getLong(
NEXT_SERVER_SWITCH, 0
) + 15000 < System.currentTimeMillis()
) + 15000 < System.currentTimeMillis() && !getServer().isNullOrEmpty() && !getLocalAddress().isNullOrEmpty()
}

@JvmStatic
Expand Down