fix: forgot sync album dialog, bump version for release

This commit is contained in:
eddyizm 2025-08-30 10:58:38 -07:00
parent eaf2710054
commit 6a16159cf0
No known key found for this signature in database
GPG key ID: CF5F671829E8158A
7 changed files with 184 additions and 2 deletions

View file

@ -316,6 +316,7 @@ public class MainActivity extends BaseActivity {
Preferences.setSkipSilenceMode(false);
Preferences.setDataSavingMode(false);
Preferences.setStarredSyncEnabled(false);
Preferences.setStarredAlbumsSyncEnabled(false);
}
private void resetMusicSession() {

View file

@ -39,6 +39,7 @@ import com.cappielloantonio.tempo.service.MediaManager;
import com.cappielloantonio.tempo.service.MediaService;
import com.cappielloantonio.tempo.subsonic.models.Child;
import com.cappielloantonio.tempo.subsonic.models.Share;
import com.cappielloantonio.tempo.subsonic.models.AlbumID3;
import com.cappielloantonio.tempo.ui.activity.MainActivity;
import com.cappielloantonio.tempo.ui.adapter.AlbumAdapter;
import com.cappielloantonio.tempo.ui.adapter.AlbumHorizontalAdapter;
@ -111,6 +112,7 @@ public class HomeTabMusicFragment extends Fragment implements ClickCallback {
super.onViewCreated(view, savedInstanceState);
initSyncStarredView();
initSyncStarredAlbumsView();
initDiscoverSongSlideView();
initSimilarSongView();
initArtistRadio();
@ -314,6 +316,63 @@ public class HomeTabMusicFragment extends Fragment implements ClickCallback {
});
}
private void initSyncStarredAlbumsView() {
if (Preferences.isStarredAlbumsSyncEnabled()) {
homeViewModel.getStarredAlbums(getViewLifecycleOwner()).observeForever(new Observer<List<AlbumID3>>() {
@Override
public void onChanged(List<AlbumID3> albums) {
if (albums != null) {
DownloaderManager manager = DownloadUtil.getDownloadTracker(requireContext());
List<String> albumsToSync = new ArrayList<>();
int albumCount = 0;
for (AlbumID3 album : albums) {
boolean needsSync = false;
albumCount++;
albumsToSync.add(album.getName());
}
if (albumCount > 0) {
bind.homeSyncStarredAlbumsCard.setVisibility(View.VISIBLE);
String message = getResources().getQuantityString(
R.plurals.home_sync_starred_albums_count,
albumCount,
albumCount
);
bind.homeSyncStarredAlbumsToSync.setText(message);
}
}
homeViewModel.getStarredAlbums(getViewLifecycleOwner()).removeObserver(this);
}
});
}
bind.homeSyncStarredAlbumsCancel.setOnClickListener(v -> {
bind.homeSyncStarredAlbumsCard.setVisibility(View.GONE);
});
bind.homeSyncStarredAlbumsDownload.setOnClickListener(v -> {
homeViewModel.getAllStarredAlbumSongs().observeForever(new Observer<List<Child>>() {
@Override
public void onChanged(List<Child> allSongs) {
if (allSongs != null) {
DownloaderManager manager = DownloadUtil.getDownloadTracker(requireContext());
for (Child song : allSongs) {
if (!manager.isDownloaded(song.getId())) {
manager.download(MappingUtil.mapDownload(song), new Download(song));
}
}
}
homeViewModel.getAllStarredAlbumSongs().removeObserver(this);
bind.homeSyncStarredAlbumsCard.setVisibility(View.GONE);
}
});
});
}
private void initDiscoverSongSlideView() {
if (homeViewModel.checkHomeSectorVisibility(Constants.HOME_SECTOR_DISCOVERY)) return;

View file

@ -47,6 +47,8 @@ public class HomeViewModel extends AndroidViewModel {
private final PlaylistRepository playlistRepository;
private final SharingRepository sharingRepository;
private final StarredAlbumsSyncViewModel albumsSyncViewModel;
private final MutableLiveData<List<Child>> dicoverSongSample = new MutableLiveData<>(null);
private final MutableLiveData<List<AlbumID3>> newReleasedAlbum = new MutableLiveData<>(null);
private final MutableLiveData<List<Child>> starredTracksSample = new MutableLiveData<>(null);
@ -82,6 +84,8 @@ public class HomeViewModel extends AndroidViewModel {
playlistRepository = new PlaylistRepository();
sharingRepository = new SharingRepository();
albumsSyncViewModel = new StarredAlbumsSyncViewModel(application);
setOfflineFavorite();
}
@ -166,6 +170,10 @@ public class HomeViewModel extends AndroidViewModel {
return starredAlbums;
}
public LiveData<List<Child>> getAllStarredAlbumSongs() {
return albumsSyncViewModel.getAllStarredAlbumSongs();
}
public LiveData<List<ArtistID3>> getStarredArtists(LifecycleOwner owner) {
if (starredArtists.getValue() == null) {
artistRepository.getStarredArtists(true, 20).observe(owner, starredArtists::postValue);

View file

@ -34,6 +34,22 @@ public class StarredAlbumsSyncViewModel extends AndroidViewModel {
return starredAlbums;
}
public LiveData<List<Child>> getAllStarredAlbumSongs() {
albumRepository.getStarredAlbums(false, -1).observeForever(new Observer<List<AlbumID3>>() {
@Override
public void onChanged(List<AlbumID3> albums) {
if (albums != null && !albums.isEmpty()) {
collectAllAlbumSongs(albums, starredAlbumSongs::postValue);
} else {
starredAlbumSongs.postValue(new ArrayList<>());
}
albumRepository.getStarredAlbums(false, -1).removeObserver(this);
}
});
return starredAlbumSongs;
}
public LiveData<List<Child>> getStarredAlbumSongs(Activity activity) {
albumRepository.getStarredAlbums(false, -1).observe((LifecycleOwner) activity, albums -> {
if (albums != null && !albums.isEmpty()) {