mirror of
https://github.com/gabehf/tempus.git
synced 2026-03-12 08:50:34 -07:00
- Removed middle layer of abstraction for subsonic classes
- Used kotlin for classes
This commit is contained in:
parent
917c0839de
commit
ca15f51c85
168 changed files with 2026 additions and 6588 deletions
|
|
@ -24,7 +24,7 @@ import com.cappielloantonio.play.ui.activity.base.BaseActivity;
|
|||
import com.cappielloantonio.play.ui.dialog.ConnectionAlertDialog;
|
||||
import com.cappielloantonio.play.ui.dialog.ServerUnreachableDialog;
|
||||
import com.cappielloantonio.play.ui.fragment.PlayerBottomSheetFragment;
|
||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||
import com.cappielloantonio.play.util.Preferences;
|
||||
import com.cappielloantonio.play.viewmodel.MainViewModel;
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
|
|
@ -98,7 +98,7 @@ public class MainActivity extends BaseActivity {
|
|||
initBottomSheet();
|
||||
initNavigation();
|
||||
|
||||
if (PreferenceUtil.getInstance(this).getPassword() != null || (PreferenceUtil.getInstance(this).getToken() != null && PreferenceUtil.getInstance(this).getSalt() != null)) {
|
||||
if (Preferences.getPassword() != null || (Preferences.getToken() != null && Preferences.getSalt() != null)) {
|
||||
goFromLogin();
|
||||
} else {
|
||||
goToLogin();
|
||||
|
|
@ -258,12 +258,12 @@ public class MainActivity extends BaseActivity {
|
|||
}
|
||||
|
||||
private void resetUserSession() {
|
||||
PreferenceUtil.getInstance(this).setServerId(null);
|
||||
PreferenceUtil.getInstance(this).setSalt(null);
|
||||
PreferenceUtil.getInstance(this).setToken(null);
|
||||
PreferenceUtil.getInstance(this).setPassword(null);
|
||||
PreferenceUtil.getInstance(this).setServer(null);
|
||||
PreferenceUtil.getInstance(this).setUser(null);
|
||||
Preferences.setServerId(null);
|
||||
Preferences.setSalt(null);
|
||||
Preferences.setToken(null);
|
||||
Preferences.setPassword(null);
|
||||
Preferences.setServer(null);
|
||||
Preferences.setUser(null);
|
||||
}
|
||||
|
||||
private void resetMusicSession() {
|
||||
|
|
@ -289,7 +289,7 @@ public class MainActivity extends BaseActivity {
|
|||
}
|
||||
|
||||
private void pingServer() {
|
||||
if (PreferenceUtil.getInstance(this).getToken() != null) {
|
||||
if (Preferences.getToken() != null) {
|
||||
mainViewModel.ping().observe(this, isPingSuccessfull -> {
|
||||
if (!isPingSuccessfull) {
|
||||
ServerUnreachableDialog dialog = new ServerUnreachableDialog();
|
||||
|
|
@ -300,7 +300,7 @@ public class MainActivity extends BaseActivity {
|
|||
}
|
||||
|
||||
private void checkConnectionType() {
|
||||
if (PreferenceUtil.getInstance(this).isWifiOnly()) {
|
||||
if (Preferences.isWifiOnly()) {
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
if (connectivityManager.getActiveNetworkInfo().getType() != ConnectivityManager.TYPE_WIFI) {
|
||||
ConnectionAlertDialog dialog = new ConnectionAlertDialog();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import androidx.fragment.app.DialogFragment;
|
|||
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.databinding.DialogConnectionAlertBinding;
|
||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||
import com.cappielloantonio.play.util.Preferences;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
|
@ -31,8 +31,9 @@ public class ConnectionAlertDialog extends DialogFragment {
|
|||
.setPositiveButton(R.string.connection_alert_dialog_positive_button, (dialog, id) -> dialog.cancel())
|
||||
.setNegativeButton(R.string.connection_alert_dialog_negative_button, (dialog, id) -> dialog.cancel());
|
||||
|
||||
if(!PreferenceUtil.getInstance(requireContext()).isDataSavingMode()) {
|
||||
builder.setNeutralButton(R.string.connection_alert_dialog_neutral_button, (dialog, id) -> { });
|
||||
if (!Preferences.isDataSavingMode()) {
|
||||
builder.setNeutralButton(R.string.connection_alert_dialog_neutral_button, (dialog, id) -> {
|
||||
});
|
||||
}
|
||||
|
||||
return builder.create();
|
||||
|
|
@ -53,7 +54,7 @@ public class ConnectionAlertDialog extends DialogFragment {
|
|||
|
||||
private void setButtonAction() {
|
||||
((AlertDialog) Objects.requireNonNull(getDialog())).getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener(v -> {
|
||||
PreferenceUtil.getInstance(requireContext()).setDataSavingMode(true);
|
||||
Preferences.setDataSavingMode(true);
|
||||
Objects.requireNonNull(getDialog()).dismiss();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import com.cappielloantonio.play.R;
|
|||
import com.cappielloantonio.play.adapter.PlaylistDialogHorizontalAdapter;
|
||||
import com.cappielloantonio.play.databinding.DialogPlaylistChooserBinding;
|
||||
import com.cappielloantonio.play.interfaces.ClickCallback;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.subsonic.models.Playlist;
|
||||
import com.cappielloantonio.play.viewmodel.PlaylistChooserViewModel;
|
||||
|
||||
import java.util.Objects;
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@ import com.cappielloantonio.play.R;
|
|||
import com.cappielloantonio.play.databinding.DialogRatingBinding;
|
||||
import com.cappielloantonio.play.viewmodel.RatingViewModel;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class RatingDialog extends DialogFragment {
|
||||
private static final String TAG = "ServerSignupDialog";
|
||||
|
||||
|
|
@ -63,7 +61,7 @@ public class RatingDialog extends DialogFragment {
|
|||
|
||||
private void setRating() {
|
||||
if (ratingViewModel.getSong() != null) {
|
||||
ratingViewModel.getLiveSong().observe(getViewLifecycleOwner(), song -> bind.ratingBar.setRating(song.getRating()));
|
||||
ratingViewModel.getLiveSong().observe(getViewLifecycleOwner(), song -> bind.ratingBar.setRating(song.getUserRating()));
|
||||
} else if (ratingViewModel.getAlbum() != null) {
|
||||
ratingViewModel.getLiveAlbum().observe(getViewLifecycleOwner(), album -> bind.ratingBar.setRating(/*album.getRating()*/ 0));
|
||||
} else if (ratingViewModel.getArtist() != null) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import com.cappielloantonio.play.R;
|
|||
import com.cappielloantonio.play.databinding.DialogConnectionAlertBinding;
|
||||
import com.cappielloantonio.play.util.DownloadUtil;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||
import com.cappielloantonio.play.util.Preferences;
|
||||
import com.cappielloantonio.play.viewmodel.StarredSyncViewModel;
|
||||
|
||||
import java.util.Objects;
|
||||
|
|
@ -71,7 +71,7 @@ public class StarredSyncDialog extends DialogFragment {
|
|||
});
|
||||
|
||||
((AlertDialog) Objects.requireNonNull(getDialog())).getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(v -> {
|
||||
PreferenceUtil.getInstance(requireContext()).setStarredSyncEnabled(false);
|
||||
Preferences.setStarredSyncEnabled(false);
|
||||
Objects.requireNonNull(getDialog()).dismiss();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.OptIn;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
|
|
@ -21,6 +23,7 @@ import com.cappielloantonio.play.ui.activity.MainActivity;
|
|||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
import com.cappielloantonio.play.viewmodel.AlbumListPageViewModel;
|
||||
|
||||
@OptIn(markerClass = UnstableApi.class)
|
||||
public class AlbumListPageFragment extends Fragment implements ClickCallback {
|
||||
private FragmentAlbumListPageBinding bind;
|
||||
|
||||
|
|
|
|||
|
|
@ -128,10 +128,10 @@ public class AlbumPageFragment extends Fragment implements ClickCallback {
|
|||
activity.getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
}
|
||||
|
||||
bind.animToolbar.setTitle(MusicUtil.getReadableString(albumPageViewModel.getAlbum().getTitle()));
|
||||
bind.animToolbar.setTitle(MusicUtil.getReadableString(albumPageViewModel.getAlbum().getName()));
|
||||
|
||||
bind.albumNameLabel.setText(MusicUtil.getReadableString(albumPageViewModel.getAlbum().getTitle()));
|
||||
bind.albumArtistLabel.setText(MusicUtil.getReadableString(albumPageViewModel.getAlbum().getArtistName()));
|
||||
bind.albumNameLabel.setText(MusicUtil.getReadableString(albumPageViewModel.getAlbum().getName()));
|
||||
bind.albumArtistLabel.setText(MusicUtil.getReadableString(albumPageViewModel.getAlbum().getArtist()));
|
||||
bind.albumReleaseYearLabel.setText(albumPageViewModel.getAlbum().getYear() != 0 ? String.valueOf(albumPageViewModel.getAlbum().getYear()) : "");
|
||||
|
||||
bind.animToolbar.setNavigationOnClickListener(v -> activity.navController.navigateUp());
|
||||
|
|
@ -174,7 +174,7 @@ public class AlbumPageFragment extends Fragment implements ClickCallback {
|
|||
|
||||
private void initBackCover() {
|
||||
CustomGlideRequest.Builder
|
||||
.from(requireContext(), albumPageViewModel.getAlbum().getPrimary(), CustomGlideRequest.ALBUM_PIC, null)
|
||||
.from(requireContext(), albumPageViewModel.getAlbum().getCoverArtId(), CustomGlideRequest.ALBUM_PIC, null)
|
||||
.build()
|
||||
.transform(new CenterCrop(), new RoundedCorners(CustomGlideRequest.CORNER_RADIUS))
|
||||
.into(bind.albumCoverImageView);
|
||||
|
|
|
|||
|
|
@ -108,20 +108,20 @@ public class ArtistPageFragment extends Fragment implements ClickCallback {
|
|||
}
|
||||
|
||||
private void initArtistInfo() {
|
||||
artistPageViewModel.getArtistInfo(artistPageViewModel.getArtist().getId()).observe(getViewLifecycleOwner(), artist -> {
|
||||
String normalizedBio = MusicUtil.forceReadableString(artist.getBio());
|
||||
artistPageViewModel.getArtistInfo(artistPageViewModel.getArtist().getId()).observe(getViewLifecycleOwner(), artistInfo -> {
|
||||
String normalizedBio = MusicUtil.forceReadableString(artistInfo.getBiography());
|
||||
|
||||
if (bind != null)
|
||||
bind.artistPageBioSector.setVisibility(!normalizedBio.trim().isEmpty() ? View.VISIBLE : View.GONE);
|
||||
if (bind != null)
|
||||
bind.bioMoreTextViewClickable.setVisibility(artist.getLastfm() != null ? View.VISIBLE : View.GONE);
|
||||
bind.bioMoreTextViewClickable.setVisibility(artistInfo.getLastFmUrl() != null ? View.VISIBLE : View.GONE);
|
||||
|
||||
if (getContext() != null && bind != null) CustomGlideRequest.Builder
|
||||
.from(
|
||||
requireContext(),
|
||||
artistPageViewModel.getArtist().getId(),
|
||||
CustomGlideRequest.ARTIST_PIC,
|
||||
artist.getImageUrl()
|
||||
artistInfo.getLargeImageUrl()
|
||||
)
|
||||
.build()
|
||||
.into(bind.artistBackdropImageView);
|
||||
|
|
@ -130,7 +130,7 @@ public class ArtistPageFragment extends Fragment implements ClickCallback {
|
|||
|
||||
if (bind != null) bind.bioMoreTextViewClickable.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(artist.getLastfm()));
|
||||
intent.setData(Uri.parse(artistInfo.getLastFmUrl()));
|
||||
startActivity(intent);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -179,7 +179,8 @@ public class DownloadFragment extends Fragment implements ClickCallback {
|
|||
if (bind != null)
|
||||
bind.downloadedArtistRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(artists.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||
|
||||
downloadedArtistAdapter.setItems(artists);
|
||||
// TODO
|
||||
// downloadedArtistAdapter.setItems(artists);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -214,7 +215,8 @@ public class DownloadFragment extends Fragment implements ClickCallback {
|
|||
if (bind != null)
|
||||
bind.downloadedAlbumRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(albums.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||
|
||||
downloadedAlbumAdapter.setItems(albums);
|
||||
// TODO
|
||||
//downloadedAlbumAdapter.setItems(albums);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -283,7 +285,8 @@ public class DownloadFragment extends Fragment implements ClickCallback {
|
|||
if (bind != null)
|
||||
bind.downloadDownloadedPlaylistSector.setVisibility(!playlists.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
|
||||
playlistHorizontalAdapter.setItems(playlists);
|
||||
// TODO
|
||||
// playlistHorizontalAdapter.setItems(playlists);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,19 +8,22 @@ import android.widget.Toast;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.OptIn;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.databinding.FragmentFilterBinding;
|
||||
import com.cappielloantonio.play.model.Genre;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.subsonic.models.Genre;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
import com.cappielloantonio.play.viewmodel.FilterViewModel;
|
||||
import com.google.android.material.chip.Chip;
|
||||
|
||||
@OptIn(markerClass = UnstableApi.class)
|
||||
public class FilterFragment extends Fragment {
|
||||
private static final String TAG = "FilterFragment";
|
||||
|
||||
|
|
@ -88,13 +91,13 @@ public class FilterFragment extends Fragment {
|
|||
bind.filterContainer.setVisibility(View.VISIBLE);
|
||||
for (Genre genre : genres) {
|
||||
Chip chip = (Chip) requireActivity().getLayoutInflater().inflate(R.layout.chip_search_filter_genre, null, false);
|
||||
chip.setText(MusicUtil.getReadableString(genre.getName()));
|
||||
chip.setChecked(filterViewModel.getFilters().contains(genre.getId()));
|
||||
chip.setText(MusicUtil.getReadableString(genre.getGenre()));
|
||||
chip.setChecked(filterViewModel.getFilters().contains(genre.getGenre()));
|
||||
chip.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
if (isChecked)
|
||||
filterViewModel.addFilter(genre.getId(), buttonView.getText().toString());
|
||||
filterViewModel.addFilter(genre.getGenre(), buttonView.getText().toString());
|
||||
else
|
||||
filterViewModel.removeFilter(genre.getId(), buttonView.getText().toString());
|
||||
filterViewModel.removeFilter(genre.getGenre(), buttonView.getText().toString());
|
||||
});
|
||||
bind.filtersChipsGroup.addView(chip);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,11 @@ import android.widget.SearchView;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.OptIn;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
|
@ -32,6 +34,7 @@ import com.cappielloantonio.play.model.Genre;
|
|||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.viewmodel.GenreCatalogueViewModel;
|
||||
|
||||
@OptIn(markerClass = UnstableApi.class)
|
||||
public class GenreCatalogueFragment extends Fragment implements ClickCallback {
|
||||
private FragmentGenreCatalogueBinding bind;
|
||||
private MainActivity activity;
|
||||
|
|
|
|||
|
|
@ -45,11 +45,11 @@ import com.cappielloantonio.play.interfaces.ClickCallback;
|
|||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.service.MediaManager;
|
||||
import com.cappielloantonio.play.service.MediaService;
|
||||
import com.cappielloantonio.play.subsonic.models.Child;
|
||||
import com.cappielloantonio.play.subsonic.models.Playlist;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
import com.cappielloantonio.play.util.UIUtil;
|
||||
import com.cappielloantonio.play.viewmodel.HomeViewModel;
|
||||
|
|
@ -752,7 +752,7 @@ public class HomeFragment extends Fragment implements ClickCallback {
|
|||
});
|
||||
}
|
||||
} else if (bundle.containsKey("is_chronology")) {
|
||||
List<Media> media = MappingUtil.mapChronology(bundle.getParcelableArrayList("songs_object"));
|
||||
List<Child> media = bundle.getParcelableArrayList("songs_object");
|
||||
MediaManager.startQueue(mediaBrowserListenableFuture, requireContext(), media, bundle.getInt("position"));
|
||||
activity.setBottomSheetInPeek(true);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import com.cappielloantonio.play.model.Server;
|
|||
import com.cappielloantonio.play.repository.SystemRepository;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.ui.dialog.ServerSignupDialog;
|
||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||
import com.cappielloantonio.play.util.Preferences;
|
||||
import com.cappielloantonio.play.viewmodel.LoginViewModel;
|
||||
|
||||
@UnstableApi
|
||||
|
|
@ -142,23 +142,23 @@ public class LoginFragment extends Fragment implements ClickCallback {
|
|||
}
|
||||
|
||||
private void saveServerPreference(String serverId, String server, String user, String password, boolean isLowSecurity) {
|
||||
PreferenceUtil.getInstance(requireContext()).setServerId(serverId);
|
||||
PreferenceUtil.getInstance(requireContext()).setServer(server);
|
||||
PreferenceUtil.getInstance(requireContext()).setUser(user);
|
||||
PreferenceUtil.getInstance(requireContext()).setPassword(password);
|
||||
PreferenceUtil.getInstance(requireContext()).setLowSecurity(isLowSecurity);
|
||||
Preferences.setServerId(serverId);
|
||||
Preferences.setServer(server);
|
||||
Preferences.setUser(user);
|
||||
Preferences.setPassword(password);
|
||||
Preferences.setLowSecurity(isLowSecurity);
|
||||
|
||||
App.getSubsonicClientInstance(requireContext(), true);
|
||||
}
|
||||
|
||||
private void resetServerPreference() {
|
||||
PreferenceUtil.getInstance(requireContext()).setServerId(null);
|
||||
PreferenceUtil.getInstance(requireContext()).setServer(null);
|
||||
PreferenceUtil.getInstance(requireContext()).setUser(null);
|
||||
PreferenceUtil.getInstance(requireContext()).setPassword(null);
|
||||
PreferenceUtil.getInstance(requireContext()).setToken(null);
|
||||
PreferenceUtil.getInstance(requireContext()).setSalt(null);
|
||||
PreferenceUtil.getInstance(requireContext()).setLowSecurity(false);
|
||||
Preferences.setServerId(null);
|
||||
Preferences.setServer(null);
|
||||
Preferences.setUser(null);
|
||||
Preferences.setPassword(null);
|
||||
Preferences.setToken(null);
|
||||
Preferences.setSalt(null);
|
||||
Preferences.setLowSecurity(false);
|
||||
|
||||
App.getSubsonicClientInstance(requireContext(), true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.cappielloantonio.play.ui.fragment;
|
|||
|
||||
import android.content.ComponentName;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -32,7 +31,7 @@ import com.cappielloantonio.play.ui.activity.MainActivity;
|
|||
import com.cappielloantonio.play.ui.dialog.RatingDialog;
|
||||
import com.cappielloantonio.play.ui.fragment.pager.PlayerControllerHorizontalPager;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||
import com.cappielloantonio.play.util.Preferences;
|
||||
import com.cappielloantonio.play.viewmodel.PlayerBottomSheetViewModel;
|
||||
import com.google.android.material.chip.Chip;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
|
@ -275,37 +274,37 @@ public class PlayerControllerFragment extends Fragment {
|
|||
|
||||
private void initPlaybackSpeedButton(MediaBrowser mediaBrowser) {
|
||||
playbackSpeedButton.setOnClickListener(view -> {
|
||||
float currentSpeed = PreferenceUtil.getInstance(requireContext()).getPlaybackSpeed();
|
||||
float currentSpeed = Preferences.getPlaybackSpeed();
|
||||
|
||||
if (currentSpeed == Media.MEDIA_PLAYBACK_SPEED_080) {
|
||||
mediaBrowser.setPlaybackParameters(new PlaybackParameters(Media.MEDIA_PLAYBACK_SPEED_100));
|
||||
playbackSpeedButton.setText(getString(R.string.player_playback_speed, Media.MEDIA_PLAYBACK_SPEED_100));
|
||||
PreferenceUtil.getInstance(requireContext()).setPlaybackSpeed(Media.MEDIA_PLAYBACK_SPEED_100);
|
||||
Preferences.setPlaybackSpeed(Media.MEDIA_PLAYBACK_SPEED_100);
|
||||
} else if (currentSpeed == Media.MEDIA_PLAYBACK_SPEED_100) {
|
||||
mediaBrowser.setPlaybackParameters(new PlaybackParameters(Media.MEDIA_PLAYBACK_SPEED_125));
|
||||
playbackSpeedButton.setText(getString(R.string.player_playback_speed, Media.MEDIA_PLAYBACK_SPEED_125));
|
||||
PreferenceUtil.getInstance(requireContext()).setPlaybackSpeed(Media.MEDIA_PLAYBACK_SPEED_125);
|
||||
Preferences.setPlaybackSpeed(Media.MEDIA_PLAYBACK_SPEED_125);
|
||||
} else if (currentSpeed == Media.MEDIA_PLAYBACK_SPEED_125) {
|
||||
mediaBrowser.setPlaybackParameters(new PlaybackParameters(Media.MEDIA_PLAYBACK_SPEED_150));
|
||||
playbackSpeedButton.setText(getString(R.string.player_playback_speed, Media.MEDIA_PLAYBACK_SPEED_150));
|
||||
PreferenceUtil.getInstance(requireContext()).setPlaybackSpeed(Media.MEDIA_PLAYBACK_SPEED_150);
|
||||
Preferences.setPlaybackSpeed(Media.MEDIA_PLAYBACK_SPEED_150);
|
||||
} else if (currentSpeed == Media.MEDIA_PLAYBACK_SPEED_150) {
|
||||
mediaBrowser.setPlaybackParameters(new PlaybackParameters(Media.MEDIA_PLAYBACK_SPEED_175));
|
||||
playbackSpeedButton.setText(getString(R.string.player_playback_speed, Media.MEDIA_PLAYBACK_SPEED_175));
|
||||
PreferenceUtil.getInstance(requireContext()).setPlaybackSpeed(Media.MEDIA_PLAYBACK_SPEED_175);
|
||||
Preferences.setPlaybackSpeed(Media.MEDIA_PLAYBACK_SPEED_175);
|
||||
} else if (currentSpeed == Media.MEDIA_PLAYBACK_SPEED_175) {
|
||||
mediaBrowser.setPlaybackParameters(new PlaybackParameters(Media.MEDIA_PLAYBACK_SPEED_200));
|
||||
playbackSpeedButton.setText(getString(R.string.player_playback_speed, Media.MEDIA_PLAYBACK_SPEED_200));
|
||||
PreferenceUtil.getInstance(requireContext()).setPlaybackSpeed(Media.MEDIA_PLAYBACK_SPEED_200);
|
||||
Preferences.setPlaybackSpeed(Media.MEDIA_PLAYBACK_SPEED_200);
|
||||
} else if (currentSpeed == Media.MEDIA_PLAYBACK_SPEED_200) {
|
||||
mediaBrowser.setPlaybackParameters(new PlaybackParameters(Media.MEDIA_PLAYBACK_SPEED_080));
|
||||
playbackSpeedButton.setText(getString(R.string.player_playback_speed, Media.MEDIA_PLAYBACK_SPEED_080));
|
||||
PreferenceUtil.getInstance(requireContext()).setPlaybackSpeed(Media.MEDIA_PLAYBACK_SPEED_080);
|
||||
Preferences.setPlaybackSpeed(Media.MEDIA_PLAYBACK_SPEED_080);
|
||||
}
|
||||
});
|
||||
|
||||
skipSilenceToggleButton.setOnClickListener(view -> {
|
||||
PreferenceUtil.getInstance(requireContext()).setSkipSilenceMode(!skipSilenceToggleButton.isChecked());
|
||||
Preferences.setSkipSilenceMode(!skipSilenceToggleButton.isChecked());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -319,8 +318,8 @@ public class PlayerControllerFragment extends Fragment {
|
|||
|
||||
private void setPlaybackParameters(MediaBrowser mediaBrowser) {
|
||||
Button playbackSpeedButton = bind.getRoot().findViewById(R.id.player_playback_speed_button);
|
||||
float currentSpeed = PreferenceUtil.getInstance(requireContext()).getPlaybackSpeed();
|
||||
boolean skipSilence = PreferenceUtil.getInstance(requireContext()).isSkipSilenceMode();
|
||||
float currentSpeed = Preferences.getPlaybackSpeed();
|
||||
boolean skipSilence = Preferences.isSkipSilenceMode();
|
||||
|
||||
mediaBrowser.setPlaybackParameters(new PlaybackParameters(currentSpeed));
|
||||
playbackSpeedButton.setText(getString(R.string.player_playback_speed, currentSpeed));
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
|||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.cappielloantonio.play.databinding.InnerFragmentPlayerCoverBinding;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.service.MediaManager;
|
||||
import com.cappielloantonio.play.service.MediaService;
|
||||
import com.cappielloantonio.play.ui.dialog.PlaylistChooserDialog;
|
||||
|
|
@ -32,8 +31,6 @@ import com.cappielloantonio.play.viewmodel.PlayerBottomSheetViewModel;
|
|||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@UnstableApi
|
||||
public class PlayerCoverFragment extends Fragment {
|
||||
private PlayerBottomSheetViewModel playerBottomSheetViewModel;
|
||||
|
|
@ -109,7 +106,7 @@ public class PlayerCoverFragment extends Fragment {
|
|||
|
||||
bind.innerButtonBottomLeft.setOnClickListener(view -> {
|
||||
playerBottomSheetViewModel.getMediaInstantMix(getViewLifecycleOwner(), song).observe(getViewLifecycleOwner(), media -> {
|
||||
MediaManager.enqueue(mediaBrowserListenableFuture, requireContext(), (List<Media>) media, true);
|
||||
MediaManager.enqueue(mediaBrowserListenableFuture, requireContext(), media, true);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -21,11 +21,12 @@ import com.cappielloantonio.play.databinding.InnerFragmentPlayerQueueBinding;
|
|||
import com.cappielloantonio.play.interfaces.ClickCallback;
|
||||
import com.cappielloantonio.play.service.MediaManager;
|
||||
import com.cappielloantonio.play.service.MediaService;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
import com.cappielloantonio.play.subsonic.models.Child;
|
||||
import com.cappielloantonio.play.viewmodel.PlayerBottomSheetViewModel;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@UnstableApi
|
||||
public class PlayerQueueFragment extends Fragment implements ClickCallback {
|
||||
|
|
@ -92,7 +93,7 @@ public class PlayerQueueFragment extends Fragment implements ClickCallback {
|
|||
bind.playerQueueRecyclerView.setAdapter(playerSongQueueAdapter);
|
||||
playerBottomSheetViewModel.getQueueSong().observe(getViewLifecycleOwner(), queue -> {
|
||||
if (queue != null) {
|
||||
playerSongQueueAdapter.setItems(MappingUtil.mapQueue(queue));
|
||||
playerSongQueueAdapter.setItems(queue.stream().map(item -> (Child) item).collect(Collectors.toList()));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import com.cappielloantonio.play.adapter.PlaylistHorizontalAdapter;
|
|||
import com.cappielloantonio.play.databinding.FragmentPlaylistCatalogueBinding;
|
||||
import com.cappielloantonio.play.interfaces.ClickCallback;
|
||||
import com.cappielloantonio.play.model.Genre;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.subsonic.models.Playlist;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.ui.dialog.PlaylistEditorDialog;
|
||||
import com.cappielloantonio.play.viewmodel.PlaylistCatalogueViewModel;
|
||||
|
|
@ -72,10 +72,10 @@ public class PlaylistCatalogueFragment extends Fragment implements ClickCallback
|
|||
}
|
||||
|
||||
private void init() {
|
||||
if (requireArguments().getString(Playlist.ALL) != null) {
|
||||
playlistCatalogueViewModel.setType(Playlist.ALL);
|
||||
} else if (requireArguments().getString(Playlist.DOWNLOADED) != null) {
|
||||
playlistCatalogueViewModel.setType(Playlist.DOWNLOADED);
|
||||
if (requireArguments().getString(com.cappielloantonio.play.model.Playlist.ALL) != null) {
|
||||
playlistCatalogueViewModel.setType(com.cappielloantonio.play.model.Playlist.ALL);
|
||||
} else if (requireArguments().getString(com.cappielloantonio.play.model.Playlist.DOWNLOADED) != null) {
|
||||
playlistCatalogueViewModel.setType(com.cappielloantonio.play.model.Playlist.DOWNLOADED);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -180,28 +180,28 @@ public class PlaylistPageFragment extends Fragment implements ClickCallback {
|
|||
|
||||
// Pic top-left
|
||||
CustomGlideRequest.Builder
|
||||
.from(requireContext(), songs.size() > 0 ? songs.get(0).getCoverArtId() : playlistPageViewModel.getPlaylist().getPrimary(), CustomGlideRequest.PLAYLIST_PIC, null)
|
||||
.from(requireContext(), songs.size() > 0 ? songs.get(0).getCoverArtId() : playlistPageViewModel.getPlaylist().getCoverArtId(), CustomGlideRequest.PLAYLIST_PIC, null)
|
||||
.build()
|
||||
.transform(new CenterCrop(), 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().getPrimary(), CustomGlideRequest.PLAYLIST_PIC, null)
|
||||
.from(requireContext(), songs.size() > 1 ? songs.get(1).getCoverArtId() : playlistPageViewModel.getPlaylist().getCoverArtId(), CustomGlideRequest.PLAYLIST_PIC, null)
|
||||
.build()
|
||||
.transform(new CenterCrop(), 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().getPrimary(), CustomGlideRequest.PLAYLIST_PIC, null)
|
||||
.from(requireContext(), songs.size() > 2 ? songs.get(2).getCoverArtId() : playlistPageViewModel.getPlaylist().getCoverArtId(), CustomGlideRequest.PLAYLIST_PIC, null)
|
||||
.build()
|
||||
.transform(new CenterCrop(), 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().getPrimary(), CustomGlideRequest.PLAYLIST_PIC, null)
|
||||
.from(requireContext(), songs.size() > 3 ? songs.get(3).getCoverArtId() : playlistPageViewModel.getPlaylist().getCoverArtId(), CustomGlideRequest.PLAYLIST_PIC, null)
|
||||
.build()
|
||||
.transform(new CenterCrop(), new GranularRoundedCorners(0, 0, CustomGlideRequest.CORNER_RADIUS, 0))
|
||||
.into(bind.playlistCoverImageViewBottomRight);
|
||||
|
|
|
|||
|
|
@ -177,22 +177,17 @@ public class SearchFragment extends Fragment implements ClickCallback {
|
|||
}
|
||||
|
||||
private void performSearch(String query) {
|
||||
searchViewModel.searchArtist(query).observe(getViewLifecycleOwner(), artists -> {
|
||||
if (bind != null)
|
||||
bind.searchArtistSector.setVisibility(!artists.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
artistAdapter.setItems(artists);
|
||||
});
|
||||
searchViewModel.search(query).observe(getViewLifecycleOwner(), result -> {
|
||||
if (bind != null) {
|
||||
bind.searchArtistSector.setVisibility(!result.getArtists().isEmpty() ? View.VISIBLE : View.GONE);
|
||||
artistAdapter.setItems(result.getArtists());
|
||||
|
||||
searchViewModel.searchAlbum(query).observe(getViewLifecycleOwner(), albums -> {
|
||||
if (bind != null)
|
||||
bind.searchAlbumSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
albumAdapter.setItems(albums);
|
||||
});
|
||||
bind.searchAlbumSector.setVisibility(!result.getAlbums().isEmpty() ? View.VISIBLE : View.GONE);
|
||||
albumAdapter.setItems(result.getAlbums());
|
||||
|
||||
searchViewModel.searchSong(query).observe(getViewLifecycleOwner(), songs -> {
|
||||
if (bind != null)
|
||||
bind.searchSongSector.setVisibility(!songs.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
songHorizontalAdapter.setItems(songs);
|
||||
bind.searchSongSector.setVisibility(!result.getSongs().isEmpty() ? View.VISIBLE : View.GONE);
|
||||
songHorizontalAdapter.setItems(result.getSongs());
|
||||
}
|
||||
});
|
||||
|
||||
bind.searchResultLayout.setVisibility(View.VISIBLE);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.cappielloantonio.play.ui.fragment;
|
|||
import android.content.Intent;
|
||||
import android.media.audiofx.AudioEffect;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -12,7 +11,9 @@ import androidx.activity.result.ActivityResultLauncher;
|
|||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.OptIn;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
|
|
@ -21,9 +22,10 @@ import com.cappielloantonio.play.helper.ThemeHelper;
|
|||
import com.cappielloantonio.play.interfaces.ScanCallback;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.ui.dialog.StarredSyncDialog;
|
||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||
import com.cappielloantonio.play.util.Preferences;
|
||||
import com.cappielloantonio.play.viewmodel.SettingViewModel;
|
||||
|
||||
@OptIn(markerClass = UnstableApi.class)
|
||||
public class SettingsFragment extends PreferenceFragmentCompat {
|
||||
private static final String TAG = "SettingsFragment";
|
||||
|
||||
|
|
@ -81,7 +83,8 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
@Override
|
||||
public void onSuccess(boolean isScanning, long count) {
|
||||
if (isScanning) getScanStatus();
|
||||
else findPreference("scan_library").setSummary("Scanning: counting " + count + " tracks");
|
||||
else
|
||||
findPreference("scan_library").setSummary("Scanning: counting " + count + " tracks");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -108,7 +111,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
setPreferencesFromResource(R.xml.global_preferences, rootKey);
|
||||
ListPreference themePreference = findPreference(PreferenceUtil.THEME);
|
||||
ListPreference themePreference = findPreference(Preferences.THEME);
|
||||
if (themePreference != null) {
|
||||
themePreference.setOnPreferenceChangeListener(
|
||||
(preference, newValue) -> {
|
||||
|
|
|
|||
|
|
@ -90,8 +90,8 @@ public class SongListPageFragment extends Fragment implements ClickCallback {
|
|||
} else if (requireArguments().getString(Media.BY_GENRE) != null) {
|
||||
songListPageViewModel.title = Media.BY_GENRE;
|
||||
songListPageViewModel.genre = requireArguments().getParcelable("genre_object");
|
||||
songListPageViewModel.toolbarTitle = MusicUtil.getReadableString(songListPageViewModel.genre.getName());
|
||||
bind.pageTitleLabel.setText(MusicUtil.getReadableString(songListPageViewModel.genre.getName()));
|
||||
songListPageViewModel.toolbarTitle = MusicUtil.getReadableString(songListPageViewModel.genre.getGenre());
|
||||
bind.pageTitleLabel.setText(MusicUtil.getReadableString(songListPageViewModel.genre.getGenre()));
|
||||
} else if (requireArguments().getString(Media.BY_ARTIST) != null) {
|
||||
songListPageViewModel.title = Media.BY_ARTIST;
|
||||
songListPageViewModel.artist = requireArguments().getParcelable("artist_object");
|
||||
|
|
@ -119,8 +119,8 @@ public class SongListPageFragment extends Fragment implements ClickCallback {
|
|||
} else if (requireArguments().getParcelable("album_object") != null) {
|
||||
songListPageViewModel.album = requireArguments().getParcelable("album_object");
|
||||
songListPageViewModel.title = Media.FROM_ALBUM;
|
||||
songListPageViewModel.toolbarTitle = MusicUtil.getReadableString(songListPageViewModel.album.getTitle());
|
||||
bind.pageTitleLabel.setText(MusicUtil.getReadableString(songListPageViewModel.album.getTitle()));
|
||||
songListPageViewModel.toolbarTitle = MusicUtil.getReadableString(songListPageViewModel.album.getName());
|
||||
bind.pageTitleLabel.setText(MusicUtil.getReadableString(songListPageViewModel.album.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@ import com.cappielloantonio.play.App;
|
|||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Download;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.AlbumRepository;
|
||||
import com.cappielloantonio.play.service.MediaManager;
|
||||
import com.cappielloantonio.play.service.MediaService;
|
||||
import com.cappielloantonio.play.subsonic.models.AlbumID3;
|
||||
import com.cappielloantonio.play.subsonic.models.Child;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.DownloadUtil;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
|
|
@ -45,7 +45,7 @@ import java.util.List;
|
|||
@UnstableApi
|
||||
public class AlbumBottomSheetDialog extends BottomSheetDialogFragment implements View.OnClickListener {
|
||||
private AlbumBottomSheetViewModel albumBottomSheetViewModel;
|
||||
private Album album;
|
||||
private AlbumID3 album;
|
||||
|
||||
private ListenableFuture<MediaBrowser> mediaBrowserListenableFuture;
|
||||
|
||||
|
|
@ -80,17 +80,17 @@ public class AlbumBottomSheetDialog extends BottomSheetDialogFragment implements
|
|||
private void init(View view) {
|
||||
ImageView coverAlbum = view.findViewById(R.id.album_cover_image_view);
|
||||
CustomGlideRequest.Builder
|
||||
.from(requireContext(), albumBottomSheetViewModel.getAlbum().getPrimary(), CustomGlideRequest.ALBUM_PIC, null)
|
||||
.from(requireContext(), albumBottomSheetViewModel.getAlbum().getCoverArtId(), CustomGlideRequest.ALBUM_PIC, null)
|
||||
.build()
|
||||
.transform(new CenterCrop(), new RoundedCorners(CustomGlideRequest.CORNER_RADIUS))
|
||||
.into(coverAlbum);
|
||||
|
||||
TextView titleAlbum = view.findViewById(R.id.album_title_text_view);
|
||||
titleAlbum.setText(MusicUtil.getReadableString(albumBottomSheetViewModel.getAlbum().getTitle()));
|
||||
titleAlbum.setText(MusicUtil.getReadableString(albumBottomSheetViewModel.getAlbum().getName()));
|
||||
titleAlbum.setSelected(true);
|
||||
|
||||
TextView artistAlbum = view.findViewById(R.id.album_artist_text_view);
|
||||
artistAlbum.setText(MusicUtil.getReadableString(albumBottomSheetViewModel.getAlbum().getArtistName()));
|
||||
artistAlbum.setText(MusicUtil.getReadableString(albumBottomSheetViewModel.getAlbum().getArtist()));
|
||||
|
||||
ToggleButton favoriteToggle = view.findViewById(R.id.button_favorite);
|
||||
favoriteToggle.setChecked(Boolean.TRUE.equals(albumBottomSheetViewModel.getAlbum().getStarred()));
|
||||
|
|
@ -111,7 +111,7 @@ public class AlbumBottomSheetDialog extends BottomSheetDialogFragment implements
|
|||
@Override
|
||||
public void onLoadMedia(List<?> media) {
|
||||
if (media.size() > 0) {
|
||||
MediaManager.startQueue(mediaBrowserListenableFuture, requireContext(), (ArrayList<Media>) media, 0);
|
||||
MediaManager.startQueue(mediaBrowserListenableFuture, requireContext(), (ArrayList<Child>) media, 0);
|
||||
((MainActivity) requireActivity()).setBottomSheetInPeek(true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.cappielloantonio.play.ui.fragment.bottomsheetdialog;
|
|||
|
||||
import android.content.ComponentName;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -22,27 +21,22 @@ import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
|||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
import com.cappielloantonio.play.service.MediaManager;
|
||||
import com.cappielloantonio.play.service.MediaService;
|
||||
import com.cappielloantonio.play.subsonic.models.ArtistID3;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
import com.cappielloantonio.play.viewmodel.ArtistBottomSheetViewModel;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@UnstableApi
|
||||
public class ArtistBottomSheetDialog extends BottomSheetDialogFragment implements View.OnClickListener {
|
||||
private static final String TAG = "AlbumBottomSheetDialog";
|
||||
|
||||
private ArtistBottomSheetViewModel artistBottomSheetViewModel;
|
||||
private Artist artist;
|
||||
private ArtistID3 artist;
|
||||
|
||||
private ListenableFuture<MediaBrowser> mediaBrowserListenableFuture;
|
||||
|
||||
|
|
@ -78,7 +72,7 @@ public class ArtistBottomSheetDialog extends BottomSheetDialogFragment implement
|
|||
private void init(View view) {
|
||||
ImageView coverArtist = view.findViewById(R.id.artist_cover_image_view);
|
||||
CustomGlideRequest.Builder
|
||||
.from(requireContext(), artistBottomSheetViewModel.getArtist().getPrimary(), CustomGlideRequest.ARTIST_PIC, null)
|
||||
.from(requireContext(), artistBottomSheetViewModel.getArtist().getCoverArtId(), CustomGlideRequest.ARTIST_PIC, null)
|
||||
.build()
|
||||
.transform(new CenterCrop(), new RoundedCorners(CustomGlideRequest.CORNER_RADIUS))
|
||||
.into(coverArtist);
|
||||
|
|
|
|||
|
|
@ -19,12 +19,9 @@ import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
|||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.service.MediaManager;
|
||||
import com.cappielloantonio.play.service.MediaService;
|
||||
import com.cappielloantonio.play.subsonic.models.PodcastEpisode;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.DownloadUtil;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
import com.cappielloantonio.play.viewmodel.PodcastBottomSheetViewModel;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
|
|
@ -33,7 +30,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
@UnstableApi
|
||||
public class PodcastBottomSheetDialog extends BottomSheetDialogFragment implements View.OnClickListener {
|
||||
private PodcastBottomSheetViewModel podcastBottomSheetViewModel;
|
||||
private Media podcast;
|
||||
private PodcastEpisode podcast;
|
||||
|
||||
private ListenableFuture<MediaBrowser> mediaBrowserListenableFuture;
|
||||
|
||||
|
|
@ -67,6 +64,7 @@ public class PodcastBottomSheetDialog extends BottomSheetDialogFragment implemen
|
|||
|
||||
private void init(View view) {
|
||||
ImageView coverPodcast = view.findViewById(R.id.podcast_cover_image_view);
|
||||
|
||||
CustomGlideRequest.Builder
|
||||
.from(requireContext(), podcastBottomSheetViewModel.getPodcast().getCoverArtId(), CustomGlideRequest.SONG_PIC, null)
|
||||
.build()
|
||||
|
|
@ -79,37 +77,41 @@ public class PodcastBottomSheetDialog extends BottomSheetDialogFragment implemen
|
|||
titlePodcast.setSelected(true);
|
||||
|
||||
TextView channel = view.findViewById(R.id.podcast_artist_text_view);
|
||||
channel.setText(MusicUtil.getReadableString(podcastBottomSheetViewModel.getPodcast().getArtistName()));
|
||||
channel.setText(MusicUtil.getReadableString(podcastBottomSheetViewModel.getPodcast().getArtist()));
|
||||
|
||||
TextView playNext = view.findViewById(R.id.play_next_text_view);
|
||||
playNext.setOnClickListener(v -> {
|
||||
MediaManager.enqueue(mediaBrowserListenableFuture, requireContext(), podcast, true);
|
||||
// TODO
|
||||
// MediaManager.enqueue(mediaBrowserListenableFuture, requireContext(), podcast, true);
|
||||
((MainActivity) requireActivity()).setBottomSheetInPeek(true);
|
||||
dismissBottomSheet();
|
||||
});
|
||||
|
||||
TextView addToQueue = view.findViewById(R.id.add_to_queue_text_view);
|
||||
addToQueue.setOnClickListener(v -> {
|
||||
MediaManager.enqueue(mediaBrowserListenableFuture, requireContext(), podcast, false);
|
||||
// TODO
|
||||
// MediaManager.enqueue(mediaBrowserListenableFuture, requireContext(), podcast, false);
|
||||
((MainActivity) requireActivity()).setBottomSheetInPeek(true);
|
||||
dismissBottomSheet();
|
||||
});
|
||||
|
||||
TextView download = view.findViewById(R.id.download_text_view);
|
||||
download.setOnClickListener(v -> {
|
||||
DownloadUtil.getDownloadTracker(requireContext()).download(
|
||||
// TODO
|
||||
/* DownloadUtil.getDownloadTracker(requireContext()).download(
|
||||
MappingUtil.mapMediaItem(requireContext(), podcast, false),
|
||||
MappingUtil.mapDownload(podcast, null, null)
|
||||
);
|
||||
); */
|
||||
dismissBottomSheet();
|
||||
});
|
||||
|
||||
TextView remove = view.findViewById(R.id.remove_text_view);
|
||||
remove.setOnClickListener(v -> {
|
||||
DownloadUtil.getDownloadTracker(requireContext()).remove(
|
||||
// TODO
|
||||
/* DownloadUtil.getDownloadTracker(requireContext()).remove(
|
||||
MappingUtil.mapMediaItem(requireContext(), podcast, false),
|
||||
MappingUtil.mapDownload(podcast, null, null)
|
||||
);
|
||||
); */
|
||||
dismissBottomSheet();
|
||||
});
|
||||
|
||||
|
|
@ -132,13 +134,14 @@ public class PodcastBottomSheetDialog extends BottomSheetDialogFragment implemen
|
|||
}
|
||||
|
||||
private void initDownloadUI(TextView download, TextView remove) {
|
||||
if (DownloadUtil.getDownloadTracker(requireContext()).isDownloaded(MappingUtil.mapMediaItem(requireContext(), podcast, false))) {
|
||||
// TODO
|
||||
/* if (DownloadUtil.getDownloadTracker(requireContext()).isDownloaded(MappingUtil.mapMediaItem(requireContext(), podcast, false))) {
|
||||
download.setVisibility(View.GONE);
|
||||
remove.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
download.setVisibility(View.VISIBLE);
|
||||
remove.setVisibility(View.GONE);
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
private void initializeMediaBrowser() {
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
|||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.service.MediaManager;
|
||||
import com.cappielloantonio.play.service.MediaService;
|
||||
import com.cappielloantonio.play.subsonic.models.Child;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.ui.dialog.PlaylistChooserDialog;
|
||||
import com.cappielloantonio.play.ui.dialog.RatingDialog;
|
||||
|
|
@ -41,7 +41,7 @@ public class SongBottomSheetDialog extends BottomSheetDialogFragment implements
|
|||
private static final String TAG = "SongBottomSheetDialog";
|
||||
|
||||
private SongBottomSheetViewModel songBottomSheetViewModel;
|
||||
private Media song;
|
||||
private Child song;
|
||||
|
||||
private ListenableFuture<MediaBrowser> mediaBrowserListenableFuture;
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ public class SongBottomSheetDialog extends BottomSheetDialogFragment implements
|
|||
titleSong.setSelected(true);
|
||||
|
||||
TextView artistSong = view.findViewById(R.id.song_artist_text_view);
|
||||
artistSong.setText(MusicUtil.getReadableString(songBottomSheetViewModel.getSong().getArtistName()));
|
||||
artistSong.setText(MusicUtil.getReadableString(songBottomSheetViewModel.getSong().getArtist()));
|
||||
|
||||
ToggleButton favoriteToggle = view.findViewById(R.id.button_favorite);
|
||||
favoriteToggle.setChecked(Boolean.TRUE.equals(songBottomSheetViewModel.getSong().getStarred()));
|
||||
|
|
@ -119,7 +119,7 @@ public class SongBottomSheetDialog extends BottomSheetDialogFragment implements
|
|||
}
|
||||
|
||||
if (songs.size() > 0) {
|
||||
MediaManager.enqueue(mediaBrowserListenableFuture, requireContext(), (List<Media>) songs, true);
|
||||
MediaManager.enqueue(mediaBrowserListenableFuture, requireContext(), (List<Child>) songs, true);
|
||||
dismissBottomSheet();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue