add Delete in Now Playing menu (closes #103)
This commit is contained in:
parent
c0fc289d36
commit
0832a0175d
@ -47,6 +47,8 @@ import android.widget.TableLayout;
|
||||
import android.widget.TableRow;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
|
||||
/**
|
||||
* The primary playback screen with playback controls and large cover display.
|
||||
@ -362,6 +364,7 @@ public class FullPlaybackActivity extends PlaybackActivity
|
||||
menu.add(0, MENU_ENQUEUE_ARTIST, 0, R.string.enqueue_current_artist).setIcon(R.drawable.ic_menu_add);
|
||||
menu.add(0, MENU_ENQUEUE_GENRE, 0, R.string.enqueue_current_genre).setIcon(R.drawable.ic_menu_add);
|
||||
menu.add(0, MENU_SONG_FAVORITE, 0, R.string.add_to_favorites);
|
||||
menu.add(0, MENU_DELETE, 0, R.string.delete);
|
||||
menu.add(0, MENU_SHOW_QUEUE, 0, R.string.show_queue);
|
||||
return true;
|
||||
}
|
||||
@ -395,6 +398,29 @@ public class FullPlaybackActivity extends PlaybackActivity
|
||||
mHandler.sendMessage(mHandler.obtainMessage(MSG_ADD_TO_PLAYLIST, playlistTask));
|
||||
}
|
||||
break;
|
||||
case MENU_DELETE:
|
||||
final PlaybackService playbackService = PlaybackService.get(this);
|
||||
final Song sng = playbackService.getSong(0);
|
||||
final PlaybackActivity activity = this;
|
||||
String delete_message = getString(R.string.delete_item, sng.title);
|
||||
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
||||
dialog.setTitle(R.string.delete);
|
||||
dialog
|
||||
.setMessage(delete_message)
|
||||
.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
shiftCurrentSong(SongTimeline.SHIFT_NEXT_SONG);
|
||||
int count = playbackService.deleteMedia(MediaUtils.TYPE_SONG, sng.id);
|
||||
String msg = getResources().getQuantityString(R.plurals.deleted, count, count);
|
||||
Toast.makeText(activity, msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
}
|
||||
});
|
||||
dialog.create().show();
|
||||
break;
|
||||
case MENU_SHOW_QUEUE:
|
||||
startActivity(new Intent(this, ShowQueueActivity.class));
|
||||
break;
|
||||
@ -526,17 +552,17 @@ public class FullPlaybackActivity extends PlaybackActivity
|
||||
mComposer = null;
|
||||
mFormat = null;
|
||||
mReplayGain = null;
|
||||
|
||||
|
||||
if(song != null) {
|
||||
|
||||
|
||||
MediaMetadataRetriever data = new MediaMetadataRetriever();
|
||||
|
||||
|
||||
try {
|
||||
data.setDataSource(song.path);
|
||||
} catch (Exception e) {
|
||||
Log.w("VanillaMusic", "Failed to extract metadata from " + song.path);
|
||||
}
|
||||
|
||||
|
||||
mGenre = data.extractMetadata(MediaMetadataRetriever.METADATA_KEY_GENRE);
|
||||
mTrack = data.extractMetadata(MediaMetadataRetriever.METADATA_KEY_CD_TRACK_NUMBER);
|
||||
String composer = data.extractMetadata(MediaMetadataRetriever.METADATA_KEY_COMPOSER);
|
||||
@ -563,12 +589,12 @@ public class FullPlaybackActivity extends PlaybackActivity
|
||||
sb.append("kbps");
|
||||
}
|
||||
mFormat = sb.toString();
|
||||
|
||||
|
||||
if(song.path != null) { /* ICS bug? */
|
||||
float[] rg = PlaybackService.get(this).getReplayGainValues(song.path);
|
||||
mReplayGain = "track="+rg[0]+"dB, album="+rg[1]+"dB";
|
||||
}
|
||||
|
||||
|
||||
data.release();
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2010, 2011 Christopher Eby <kreed@kreed.org>
|
||||
* Copyright (C) 2014 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
@ -283,7 +283,7 @@ public abstract class PlaybackActivity extends Activity
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called by FileSystem adapter to get the start folder
|
||||
* for browsing directories
|
||||
@ -294,7 +294,7 @@ public abstract class PlaybackActivity extends Activity
|
||||
File fs_start = new File( folder.equals("") ? Environment.getExternalStorageDirectory().getAbsolutePath() : folder );
|
||||
return fs_start;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called by PlaybackService to update the current song.
|
||||
*/
|
||||
@ -347,6 +347,7 @@ public abstract class PlaybackActivity extends Activity
|
||||
static final int MENU_SONG_FAVORITE = 12;
|
||||
static final int MENU_SHOW_QUEUE = 13;
|
||||
static final int MENU_SAVE_AS_PLAYLIST = 14;
|
||||
static final int MENU_DELETE = 15;
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu)
|
||||
|
Loading…
x
Reference in New Issue
Block a user