Show quantity of picked songs in toast

This commit is contained in:
Christopher Eby 2011-09-17 03:03:10 -05:00
parent 7621c9312e
commit 0fd6230497
4 changed files with 28 additions and 19 deletions

View File

@ -38,10 +38,6 @@ THE SOFTWARE.
<string name="repeat_enabling">Repeat enabled. The current song and any songs you have added after it will be repeated.</string>
<string name="repeat_disabling">Repeat disabled</string>
<string name="song_load_failed">Failed to load song %s. It may be corrupt or missing.</string>
<plurals name="enqueued_count">
<item quantity="one">1 song enqueued.</item>
<item quantity="other">%d songs enqueued.</item>
</plurals>
<string name="queue_cleared">Queue cleared.</string>
<!-- Widgets -->
@ -65,8 +61,14 @@ THE SOFTWARE.
<string name="playback_view">Now Playing</string>
<string name="search">Search</string>
<string name="enqueued">Enqueued %s</string>
<string name="playing">Playing %s</string>
<plurals name="playing">
<item quantity="one">1 song playing.</item>
<item quantity="other">%d songs playing.</item>
</plurals>
<plurals name="enqueued">
<item quantity="one">1 song enqueued.</item>
<item quantity="other">%d songs enqueued.</item>
</plurals>
<plurals name="added_to_playlist">
<item quantity="one">1 song added to playlist %2$s.</item>
<item quantity="other">%1$d songs added to playlist %2$s.</item>

View File

@ -378,7 +378,7 @@ public class PlaybackActivity extends Activity implements Handler.Callback, View
public void enqueue(int type)
{
int count = ContextApplication.getService().enqueueFromCurrent(type);
String text = getResources().getQuantityString(R.plurals.enqueued_count, count, count);
String text = getResources().getQuantityString(R.plurals.enqueued, count, count);
Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
}

View File

@ -604,7 +604,8 @@ public final class PlaybackService extends Service implements Handler.Callback,
{
if (mTimeline == null)
return null;
if (delta == 0)
return mCurrentSong;
return mTimeline.getSong(delta);
}
@ -912,12 +913,13 @@ public final class PlaybackService extends Service implements Handler.Callback,
*
* @param type The media type, one of MediaUtils.TYPE_*
* @param id The MediaStore id of the media
* @return The song that is playing after this method is called
* @return The number of songs that were enqueued.
*/
public Song playSongs(int type, long id)
public int playSongs(int type, long id)
{
mTimeline.chooseSongs(false, type, id, null);
return setCurrentSong(+1);
int count = mTimeline.chooseSongs(false, type, id, null);
setCurrentSong(+1);
return count;
}
/**
@ -931,12 +933,14 @@ public final class PlaybackService extends Service implements Handler.Callback,
*
* @param type The media type, one of MediaUtils.TYPE_*
* @param id The MediaStore id of the media
* @return The number of songs that were enqueued.
*/
public void enqueueSongs(int type, long id)
public int enqueueSongs(int type, long id)
{
mTimeline.chooseSongs(true, type, id, null);
int count = mTimeline.chooseSongs(true, type, id, null);
mHandler.removeMessages(SAVE_STATE);
mHandler.sendEmptyMessageDelayed(SAVE_STATE, 5000);
return count;
}
/**

View File

@ -245,9 +245,10 @@ public class SongSelector extends PlaybackActivity implements AdapterView.OnItem
private void pickSongs(MediaAdapter.MediaView view, int action)
{
PlaybackService service = ContextApplication.getService();
Resources res = getResources();
int type = view.getMediaType();
long id = view.getMediaId();
int count;
int text;
if (action == ACTION_LAST_USED)
action = mLastAction;
@ -256,17 +257,19 @@ public class SongSelector extends PlaybackActivity implements AdapterView.OnItem
switch (action) {
case ACTION_PLAY:
Toast.makeText(this, getString(R.string.playing, view.getTitle()), Toast.LENGTH_SHORT).show();
setSong(service.playSongs(type, id));
count = service.playSongs(type, id);
text = R.plurals.playing;
break;
case ACTION_ENQUEUE:
Toast.makeText(this, getString(R.string.enqueued, view.getTitle()), Toast.LENGTH_SHORT).show();
service.enqueueSongs(type, id);
count = service.enqueueSongs(type, id);
text = R.plurals.enqueued;
break;
default:
return;
}
setSong(service.getSong(0));
Toast.makeText(this, getResources().getQuantityString(text, count, count), Toast.LENGTH_SHORT).show();
mLastActedId = id;
}