mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-02 18:31:40 +00:00
feat: added additional information about the album on the dedicated detail page
This commit is contained in:
parent
dd085a2cdb
commit
302458e76b
6 changed files with 139 additions and 5 deletions
|
|
@ -8,6 +8,7 @@ import com.cappielloantonio.tempo.interfaces.DecadesCallback;
|
||||||
import com.cappielloantonio.tempo.interfaces.MediaCallback;
|
import com.cappielloantonio.tempo.interfaces.MediaCallback;
|
||||||
import com.cappielloantonio.tempo.subsonic.base.ApiResponse;
|
import com.cappielloantonio.tempo.subsonic.base.ApiResponse;
|
||||||
import com.cappielloantonio.tempo.subsonic.models.AlbumID3;
|
import com.cappielloantonio.tempo.subsonic.models.AlbumID3;
|
||||||
|
import com.cappielloantonio.tempo.subsonic.models.AlbumInfo;
|
||||||
import com.cappielloantonio.tempo.subsonic.models.Child;
|
import com.cappielloantonio.tempo.subsonic.models.Child;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -170,6 +171,29 @@ public class AlbumRepository {
|
||||||
return album;
|
return album;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<AlbumInfo> getAlbumInfo(String id) {
|
||||||
|
MutableLiveData<AlbumInfo> albumInfo = new MutableLiveData<>();
|
||||||
|
|
||||||
|
App.getSubsonicClientInstance(false)
|
||||||
|
.getBrowsingClient()
|
||||||
|
.getAlbumInfo2(id)
|
||||||
|
.enqueue(new Callback<ApiResponse>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<ApiResponse> call, @NonNull Response<ApiResponse> response) {
|
||||||
|
if (response.isSuccessful() && response.body() != null && response.body().getSubsonicResponse().getAlbumInfo() != null) {
|
||||||
|
albumInfo.setValue(response.body().getSubsonicResponse().getAlbumInfo());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<ApiResponse> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return albumInfo;
|
||||||
|
}
|
||||||
|
|
||||||
public void getInstantMix(AlbumID3 album, int count, MediaCallback callback) {
|
public void getInstantMix(AlbumID3 album, int count, MediaCallback callback) {
|
||||||
App.getSubsonicClientInstance(false)
|
App.getSubsonicClientInstance(false)
|
||||||
.getBrowsingClient()
|
.getBrowsingClient()
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import com.cappielloantonio.tempo.util.DownloadUtil;
|
||||||
import com.cappielloantonio.tempo.util.MappingUtil;
|
import com.cappielloantonio.tempo.util.MappingUtil;
|
||||||
import com.cappielloantonio.tempo.util.MusicUtil;
|
import com.cappielloantonio.tempo.util.MusicUtil;
|
||||||
import com.cappielloantonio.tempo.viewmodel.AlbumPageViewModel;
|
import com.cappielloantonio.tempo.viewmodel.AlbumPageViewModel;
|
||||||
|
import com.google.android.material.chip.Chip;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
@ -73,6 +74,7 @@ public class AlbumPageFragment extends Fragment implements ClickCallback {
|
||||||
init();
|
init();
|
||||||
initAppBar();
|
initAppBar();
|
||||||
initAlbumInfoTextButton();
|
initAlbumInfoTextButton();
|
||||||
|
initAlbumNotes();
|
||||||
initMusicButton();
|
initMusicButton();
|
||||||
initBackCover();
|
initBackCover();
|
||||||
initSongsView();
|
initSongsView();
|
||||||
|
|
@ -131,10 +133,20 @@ public class AlbumPageFragment extends Fragment implements ClickCallback {
|
||||||
bind.albumNameLabel.setText(MusicUtil.getReadableString(albumPageViewModel.getAlbum().getName()));
|
bind.albumNameLabel.setText(MusicUtil.getReadableString(albumPageViewModel.getAlbum().getName()));
|
||||||
bind.albumArtistLabel.setText(MusicUtil.getReadableString(albumPageViewModel.getAlbum().getArtist()));
|
bind.albumArtistLabel.setText(MusicUtil.getReadableString(albumPageViewModel.getAlbum().getArtist()));
|
||||||
bind.albumReleaseYearLabel.setText(albumPageViewModel.getAlbum().getYear() != 0 ? String.valueOf(albumPageViewModel.getAlbum().getYear()) : "");
|
bind.albumReleaseYearLabel.setText(albumPageViewModel.getAlbum().getYear() != 0 ? String.valueOf(albumPageViewModel.getAlbum().getYear()) : "");
|
||||||
|
bind.albumSongCountDurationTextview.setText(getString(R.string.album_page_tracks_count_and_duration, albumPageViewModel.getAlbum().getSongCount(), albumPageViewModel.getAlbum().getDuration() != null ? albumPageViewModel.getAlbum().getDuration() / 60 : 0));
|
||||||
|
bind.albumGenresTextview.setText(albumPageViewModel.getAlbum().getGenre());
|
||||||
|
|
||||||
bind.animToolbar.setNavigationOnClickListener(v -> activity.navController.navigateUp());
|
bind.animToolbar.setNavigationOnClickListener(v -> activity.navController.navigateUp());
|
||||||
|
|
||||||
Objects.requireNonNull(bind.animToolbar.getOverflowIcon()).setTint(requireContext().getResources().getColor(R.color.titleTextColor, null));
|
Objects.requireNonNull(bind.animToolbar.getOverflowIcon()).setTint(requireContext().getResources().getColor(R.color.titleTextColor, null));
|
||||||
|
|
||||||
|
bind.albumOtherInfoButton.setOnClickListener(v -> {
|
||||||
|
if (bind.albumDetailView.getVisibility() == View.GONE) {
|
||||||
|
bind.albumDetailView.setVisibility(View.VISIBLE);
|
||||||
|
} else if (bind.albumDetailView.getVisibility() == View.VISIBLE) {
|
||||||
|
bind.albumDetailView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initAlbumInfoTextButton() {
|
private void initAlbumInfoTextButton() {
|
||||||
|
|
@ -148,6 +160,18 @@ public class AlbumPageFragment extends Fragment implements ClickCallback {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initAlbumNotes() {
|
||||||
|
albumPageViewModel.getAlbumInfo().observe(getViewLifecycleOwner(), albumInfo -> {
|
||||||
|
if (albumInfo != null) {
|
||||||
|
if (bind != null) bind.albumNotesTextview.setVisibility(View.VISIBLE);
|
||||||
|
if (bind != null)
|
||||||
|
bind.albumNotesTextview.setText(MusicUtil.getReadableString(albumInfo.getNotes()));
|
||||||
|
} else {
|
||||||
|
if (bind != null) bind.albumNotesTextview.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void initMusicButton() {
|
private void initMusicButton() {
|
||||||
albumPageViewModel.getAlbumSongLiveList().observe(getViewLifecycleOwner(), songs -> {
|
albumPageViewModel.getAlbumSongLiveList().observe(getViewLifecycleOwner(), songs -> {
|
||||||
if (bind != null && !songs.isEmpty()) {
|
if (bind != null && !songs.isEmpty()) {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import androidx.lifecycle.LiveData;
|
||||||
import com.cappielloantonio.tempo.repository.AlbumRepository;
|
import com.cappielloantonio.tempo.repository.AlbumRepository;
|
||||||
import com.cappielloantonio.tempo.repository.ArtistRepository;
|
import com.cappielloantonio.tempo.repository.ArtistRepository;
|
||||||
import com.cappielloantonio.tempo.subsonic.models.AlbumID3;
|
import com.cappielloantonio.tempo.subsonic.models.AlbumID3;
|
||||||
|
import com.cappielloantonio.tempo.subsonic.models.AlbumInfo;
|
||||||
import com.cappielloantonio.tempo.subsonic.models.ArtistID3;
|
import com.cappielloantonio.tempo.subsonic.models.ArtistID3;
|
||||||
import com.cappielloantonio.tempo.subsonic.models.Child;
|
import com.cappielloantonio.tempo.subsonic.models.Child;
|
||||||
|
|
||||||
|
|
@ -42,4 +43,8 @@ public class AlbumPageViewModel extends AndroidViewModel {
|
||||||
public LiveData<ArtistID3> getArtist() {
|
public LiveData<ArtistID3> getArtist() {
|
||||||
return artistRepository.getArtistInfo(album.getArtistId());
|
return artistRepository.getArtistInfo(album.getArtistId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LiveData<AlbumInfo> getAlbumInfo() {
|
||||||
|
return albumRepository.getAlbumInfo(album.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
9
app/src/main/res/drawable/ic_arrow_down.xml
Normal file
9
app/src/main/res/drawable/ic_arrow_down.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="960"
|
||||||
|
android:viewportHeight="960">
|
||||||
|
<path
|
||||||
|
android:fillColor="@color/titleTextColor"
|
||||||
|
android:pathData="M480,600L280,400L680,400L480,600Z"/>
|
||||||
|
</vector>
|
||||||
|
|
@ -48,18 +48,33 @@
|
||||||
style="@style/LabelExtraLarge"
|
style="@style/LabelExtraLarge"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="18dp"
|
|
||||||
android:layout_marginEnd="18dp"
|
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="2"
|
android:maxLines="2"
|
||||||
android:paddingTop="8dp"
|
android:paddingTop="8dp"
|
||||||
android:singleLine="false"
|
android:singleLine="false"
|
||||||
android:text="@string/label_placeholder"
|
android:text="@string/label_placeholder"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="@+id/album_cover_image_view"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="@+id/album_cover_image_view"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/album_cover_image_view" />
|
app:layout_constraintTop_toBottomOf="@+id/album_cover_image_view" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/album_other_info_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/album_name_label"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/album_name_label"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/album_name_label"
|
||||||
|
android:foreground="?android:attr/selectableItemBackgroundBorderless">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:background="@drawable/ic_arrow_down" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/album_artist_label"
|
android:id="@+id/album_artist_label"
|
||||||
style="@style/LabelMedium"
|
style="@style/LabelMedium"
|
||||||
|
|
@ -88,6 +103,62 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/album_artist_label" />
|
app:layout_constraintTop_toBottomOf="@+id/album_artist_label" />
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/album_detail_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/album_release_year_label"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingBottom="8dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:animateLayoutChanges="true">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/album_genres_textview"
|
||||||
|
style="@style/LabelSmall"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="18dp"
|
||||||
|
android:layout_marginEnd="18dp"
|
||||||
|
android:text="@string/label_placeholder"
|
||||||
|
android:textAlignment="center"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/album_song_count_duration_textview"
|
||||||
|
style="@style/LabelSmall"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingVertical="2dp"
|
||||||
|
android:layout_marginStart="18dp"
|
||||||
|
android:layout_marginEnd="18dp"
|
||||||
|
android:text="@string/label_placeholder"
|
||||||
|
android:textAlignment="center"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/album_genres_textview" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/album_notes_textview"
|
||||||
|
style="@style/LabelSmall"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="18dp"
|
||||||
|
android:layout_marginEnd="18dp"
|
||||||
|
android:text="@string/label_placeholder"
|
||||||
|
android:justificationMode="inter_word"
|
||||||
|
android:textAlignment="center"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/album_song_count_duration_textview" />
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/upper_button_divider"
|
android:id="@+id/upper_button_divider"
|
||||||
style="@style/Divider"
|
style="@style/Divider"
|
||||||
|
|
@ -96,7 +167,7 @@
|
||||||
android:layout_marginEnd="18dp"
|
android:layout_marginEnd="18dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/album_release_year_label" />
|
app:layout_constraintTop_toBottomOf="@+id/album_detail_view" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/album_page_button_layout"
|
android:id="@+id/album_page_button_layout"
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
<string name="album_page_extra_info_button">More like this</string>
|
<string name="album_page_extra_info_button">More like this</string>
|
||||||
<string name="album_page_play_button">Play</string>
|
<string name="album_page_play_button">Play</string>
|
||||||
<string name="album_page_shuffle_button">Shuffle</string>
|
<string name="album_page_shuffle_button">Shuffle</string>
|
||||||
|
<string name="album_page_tracks_count_and_duration">%1$d songs • %2$d minutes</string>
|
||||||
<string name="app_name">Tempo</string>
|
<string name="app_name">Tempo</string>
|
||||||
<string name="artist_adapter_radio_station_starting">Searching…</string>
|
<string name="artist_adapter_radio_station_starting">Searching…</string>
|
||||||
<string name="artist_bottom_sheet_instant_mix">Instant mix</string>
|
<string name="artist_bottom_sheet_instant_mix">Instant mix</string>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue