diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index a33cee77..0897082f 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -4,16 +4,15 @@
diff --git a/app/src/main/java/com/cappielloantonio/tempo/ui/adapter/DownloadHorizontalAdapter.java b/app/src/main/java/com/cappielloantonio/tempo/ui/adapter/DownloadHorizontalAdapter.java
index d4f26e19..82c43231 100644
--- a/app/src/main/java/com/cappielloantonio/tempo/ui/adapter/DownloadHorizontalAdapter.java
+++ b/app/src/main/java/com/cappielloantonio/tempo/ui/adapter/DownloadHorizontalAdapter.java
@@ -33,6 +33,7 @@ public class DownloadHorizontalAdapter extends RecyclerView.Adapter songs;
+ private List shuffling;
private List grouped;
public DownloadHorizontalAdapter(ClickCallback click) {
@@ -82,6 +83,7 @@ public class DownloadHorizontalAdapter extends RecyclerView.Adapter(songs));
notifyDataSetChanged();
}
@@ -90,6 +92,10 @@ public class DownloadHorizontalAdapter extends RecyclerView.Adapter getShuffling() {
+ return shuffling;
+ }
+
@Override
public int getItemViewType(int position) {
return position;
@@ -136,6 +142,27 @@ public class DownloadHorizontalAdapter extends RecyclerView.Adapter shufflingSong(List songs) {
+ if (filterValue == null) {
+ return songs;
+ }
+
+ switch (filterKey) {
+ case Constants.DOWNLOAD_TYPE_TRACK:
+ return songs.stream().filter(child -> child.getId().equals(filterValue)).collect(Collectors.toList());
+ case Constants.DOWNLOAD_TYPE_ALBUM:
+ return songs.stream().filter(child -> Objects.equals(child.getAlbumId(), filterValue)).collect(Collectors.toList());
+ case Constants.DOWNLOAD_TYPE_GENRE:
+ return songs.stream().filter(child -> Objects.equals(child.getGenre(), filterValue)).collect(Collectors.toList());
+ case Constants.DOWNLOAD_TYPE_YEAR:
+ return songs.stream().filter(child -> Objects.equals(child.getYear(), Integer.valueOf(filterValue))).collect(Collectors.toList());
+ case Constants.DOWNLOAD_TYPE_ARTIST:
+ return songs.stream().filter(child -> Objects.equals(child.getArtistId(), filterValue)).collect(Collectors.toList());
+ default:
+ return songs;
+ }
+ }
+
private String countSong(String filterKey, String filterValue, List songs) {
if (filterValue != null) {
switch (filterKey) {
diff --git a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/DownloadFragment.java b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/DownloadFragment.java
index 83995d8a..2d2cef4e 100644
--- a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/DownloadFragment.java
+++ b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/DownloadFragment.java
@@ -33,6 +33,7 @@ import com.cappielloantonio.tempo.viewmodel.DownloadViewModel;
import com.google.android.material.appbar.MaterialToolbar;
import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -165,6 +166,19 @@ public class DownloadFragment extends Fragment implements ClickCallback {
bind.downloadedGoBackImageView.setVisibility(stack.size() > 1 ? View.VISIBLE : View.GONE);
setupBackPressing(stack.size());
+ setupShuffleButton();
+ });
+ }
+
+ private void setupShuffleButton() {
+ bind.shuffleDownloadedTextViewClickable.setOnClickListener(view -> {
+ List songs = downloadHorizontalAdapter.getShuffling();
+
+ if (songs != null && !songs.isEmpty()) {
+ Collections.shuffle(songs);
+ MediaManager.startQueue(mediaBrowserListenableFuture, songs, 0);
+ activity.setBottomSheetInPeek(true);
+ }
});
}
diff --git a/app/src/main/res/layout/fragment_download.xml b/app/src/main/res/layout/fragment_download.xml
index 0e048afe..d5844d5c 100644
--- a/app/src/main/res/layout/fragment_download.xml
+++ b/app/src/main/res/layout/fragment_download.xml
@@ -76,11 +76,20 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/download_title_section"
- android:layout_marginBottom="16dp"
app:layout_constraintEnd_toStartOf="@+id/downloaded_go_back_image_view"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
+
+
+ app:layout_constraintTop_toBottomOf="@id/shuffle_downloaded_text_view_clickable" />
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index dcb4e03c..4095540a 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -65,6 +65,7 @@
No downloads yet!
%1$s • %2$s items
%1$s items
+ Shuffle all
For the changes to take effect, restart the app.
Changing the destination of downloaded files from one storage to another will result in the immediate deletion of any previously downloaded files in the other storage.
Select storage option