From 0fd623049765fbc987c72b76a1534469673cf2c8 Mon Sep 17 00:00:00 2001 From: Christopher Eby Date: Sat, 17 Sep 2011 03:03:10 -0500 Subject: [PATCH] Show quantity of picked songs in toast --- res/values/strings.xml | 14 ++++++++------ src/org/kreed/vanilla/PlaybackActivity.java | 2 +- src/org/kreed/vanilla/PlaybackService.java | 18 +++++++++++------- src/org/kreed/vanilla/SongSelector.java | 13 ++++++++----- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index ed9b60e3..58fff5cd 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -38,10 +38,6 @@ THE SOFTWARE. Repeat enabled. The current song and any songs you have added after it will be repeated. Repeat disabled Failed to load song %s. It may be corrupt or missing. - - 1 song enqueued. - %d songs enqueued. - Queue cleared. @@ -65,8 +61,14 @@ THE SOFTWARE. Now Playing Search - Enqueued %s - Playing %s + + 1 song playing. + %d songs playing. + + + 1 song enqueued. + %d songs enqueued. + 1 song added to playlist %2$s. %1$d songs added to playlist %2$s. diff --git a/src/org/kreed/vanilla/PlaybackActivity.java b/src/org/kreed/vanilla/PlaybackActivity.java index 9096e5b4..b6a916a0 100644 --- a/src/org/kreed/vanilla/PlaybackActivity.java +++ b/src/org/kreed/vanilla/PlaybackActivity.java @@ -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(); } diff --git a/src/org/kreed/vanilla/PlaybackService.java b/src/org/kreed/vanilla/PlaybackService.java index 216ed396..b0a17510 100644 --- a/src/org/kreed/vanilla/PlaybackService.java +++ b/src/org/kreed/vanilla/PlaybackService.java @@ -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; } /** diff --git a/src/org/kreed/vanilla/SongSelector.java b/src/org/kreed/vanilla/SongSelector.java index 3a8c7b79..1cc7477f 100644 --- a/src/org/kreed/vanilla/SongSelector.java +++ b/src/org/kreed/vanilla/SongSelector.java @@ -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; }