Add shuffle all to every menu
This commit is contained in:
parent
07b9fbb599
commit
cb11044999
12 changed files with 112 additions and 46 deletions
|
|
@ -23,7 +23,6 @@ import com.kabouzeid.gramophone.loader.SongLoader;
|
|||
import com.kabouzeid.gramophone.misc.AppKeys;
|
||||
import com.kabouzeid.gramophone.model.DataBaseChangedEvent;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.service.MusicService;
|
||||
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
||||
import com.kabouzeid.gramophone.ui.activities.tageditor.SongTagEditorActivity;
|
||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||
|
|
@ -34,7 +33,6 @@ import com.squareup.picasso.Picasso;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Created by karim on 27.11.14.
|
||||
|
|
@ -69,7 +67,7 @@ public class SongAdapter extends RecyclerView.Adapter<SongAdapter.ViewHolder> {
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(final ViewHolder holder, int position) {
|
||||
if(getItemViewType(position) == SONG) {
|
||||
if (getItemViewType(position) == SONG) {
|
||||
final Song song = dataSet.get(position - 1);
|
||||
|
||||
holder.songTitle.setText(song.title);
|
||||
|
|
@ -88,6 +86,7 @@ public class SongAdapter extends RecyclerView.Adapter<SongAdapter.ViewHolder> {
|
|||
holder.albumArt.setPadding(48, 48, 48, 48);
|
||||
holder.albumArt.setColorFilter(accentColor);
|
||||
holder.albumArt.setImageResource(R.drawable.ic_shuffle_white_48dp);
|
||||
holder.separator.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -101,6 +100,7 @@ public class SongAdapter extends RecyclerView.Adapter<SongAdapter.ViewHolder> {
|
|||
TextView songInfo;
|
||||
ImageView overflowButton;
|
||||
ImageView albumArt;
|
||||
View separator;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
|
@ -108,13 +108,14 @@ public class SongAdapter extends RecyclerView.Adapter<SongAdapter.ViewHolder> {
|
|||
songInfo = (TextView) itemView.findViewById(R.id.song_info);
|
||||
albumArt = (ImageView) itemView.findViewById(R.id.album_art);
|
||||
overflowButton = (ImageView) itemView.findViewById(R.id.menu);
|
||||
separator = itemView.findViewById(R.id.separator);
|
||||
|
||||
overflowButton.setOnClickListener(this);
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (getItemViewType() == SHUFFLE_BUTTON) {
|
||||
MusicPlayerRemote.openQueue(dataSet, new Random().nextInt(dataSet.size()), true);
|
||||
MusicPlayerRemote.forceSetShuffleMode(activity, MusicService.SHUFFLE_MODE_SHUFFLE);
|
||||
MusicPlayerRemote.shuffleAllSongs(activity);
|
||||
} else {
|
||||
MusicPlayerRemote.openQueue(dataSet, getAdapterPosition() - 1, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import android.widget.Toast;
|
|||
|
||||
import com.kabouzeid.gramophone.App;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.loader.SongLoader;
|
||||
import com.kabouzeid.gramophone.misc.AppKeys;
|
||||
import com.kabouzeid.gramophone.model.MusicRemoteEvent;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
|
|
@ -20,6 +21,7 @@ import com.kabouzeid.gramophone.util.InternalStorageUtil;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Created by karim on 29.11.14.
|
||||
|
|
@ -233,6 +235,12 @@ public class MusicPlayerRemote {
|
|||
}
|
||||
}
|
||||
|
||||
public static void shuffleAllSongs(final Context context){
|
||||
List<Song> songs = SongLoader.getAllSongs(context);
|
||||
MusicPlayerRemote.openQueue(songs, new Random().nextInt(songs.size()), true);
|
||||
forceSetShuffleMode(context, MusicService.SHUFFLE_MODE_SHUFFLE);
|
||||
}
|
||||
|
||||
public static void playNext(Song song) {
|
||||
if (musicService != null) {
|
||||
musicService.addSong(getPosition() + 1, song);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.kabouzeid.gramophone.App;
|
|||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.adapter.songadapter.AlbumSongAdapter;
|
||||
import com.kabouzeid.gramophone.comparator.SongTrackNumberComparator;
|
||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||
import com.kabouzeid.gramophone.loader.AlbumLoader;
|
||||
import com.kabouzeid.gramophone.loader.AlbumSongLoader;
|
||||
import com.kabouzeid.gramophone.misc.AppKeys;
|
||||
|
|
@ -244,6 +245,9 @@ public class AlbumDetailActivity extends AbsFabActivity {
|
|||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
switch (id) {
|
||||
case R.id.action_shuffle_all:
|
||||
MusicPlayerRemote.shuffleAllSongs(this);
|
||||
return true;
|
||||
case android.R.id.home:
|
||||
super.onBackPressed();
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -304,6 +304,9 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
|||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
switch (id) {
|
||||
case R.id.action_shuffle_all:
|
||||
MusicPlayerRemote.shuffleAllSongs(this);
|
||||
return true;
|
||||
case android.R.id.home:
|
||||
super.onBackPressed();
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -236,6 +236,9 @@ public class MainActivity extends AbsFabActivity
|
|||
}
|
||||
int id = item.getItemId();
|
||||
switch (id) {
|
||||
case R.id.action_shuffle_all:
|
||||
MusicPlayerRemote.shuffleAllSongs(this);
|
||||
return true;
|
||||
case R.id.action_new_playlist:
|
||||
CreatePlaylistDialogHelper.getDialog(this).show();
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -387,6 +387,9 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
switch (id) {
|
||||
case R.id.action_shuffle_all:
|
||||
MusicPlayerRemote.shuffleAllSongs(this);
|
||||
return true;
|
||||
case R.id.action_settings:
|
||||
Toast.makeText(this, "This feature is not available yet", Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1,50 +1,63 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="72dp"
|
||||
<FrameLayout
|
||||
android:background="?rect_selector"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="16dp">
|
||||
|
||||
<com.kabouzeid.gramophone.view.SquareImageView
|
||||
android:id="@+id/album_art"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:scaleType="centerCrop"/>
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="72dp"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/song_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2"/>
|
||||
<com.kabouzeid.gramophone.view.SquareImageView
|
||||
android:id="@+id/album_art"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:scaleType="centerCrop"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/song_info"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Caption"/>
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/song_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/song_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Caption"/>
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/menu"
|
||||
style="@style/OverFlowButton"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="2dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/menu"
|
||||
style="@style/OverFlowButton"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="2dp"/>
|
||||
</LinearLayout>
|
||||
<View
|
||||
android:id="@+id/separator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="#0CFFFFFF"
|
||||
android:visibility="gone"/>
|
||||
</FrameLayout>
|
||||
|
|
@ -15,6 +15,12 @@
|
|||
android:title="@string/action_playing_queue"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_shuffle_all"
|
||||
android:icon="@drawable/ic_shuffle_white_48dp"
|
||||
android:title="@string/shuffle_all"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_go_to_artist"
|
||||
android:title="@string/action_go_to_artist"
|
||||
|
|
|
|||
|
|
@ -15,6 +15,12 @@
|
|||
android:title="@string/action_playing_queue"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_shuffle_all"
|
||||
android:icon="@drawable/ic_shuffle_white_48dp"
|
||||
android:title="@string/shuffle_all"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_biography"
|
||||
android:title="@string/biography"
|
||||
|
|
|
|||
|
|
@ -15,6 +15,12 @@
|
|||
android:title="@string/action_search"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_shuffle_all"
|
||||
android:icon="@drawable/ic_shuffle_white_48dp"
|
||||
android:title="@string/shuffle_all"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_playing_queue"
|
||||
android:icon="@drawable/ic_queue_music_white_24dp"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,13 @@
|
|||
android:icon="@drawable/ic_queue_music_white_24dp"
|
||||
android:title="@string/action_playing_queue"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_shuffle_all"
|
||||
android:icon="@drawable/ic_shuffle_white_48dp"
|
||||
android:title="@string/shuffle_all"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_add_to_playlist"
|
||||
android:title="@string/action_add_to_playlist"
|
||||
|
|
|
|||
|
|
@ -18,6 +18,12 @@
|
|||
android:title="@string/action_new_playlist"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_shuffle_all"
|
||||
android:icon="@drawable/ic_shuffle_white_48dp"
|
||||
android:title="@string/shuffle_all"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_playing_queue"
|
||||
android:icon="@drawable/ic_queue_music_white_24dp"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue