From fcad52ef5db14c669bddbd79f0124bb46c7c7018 Mon Sep 17 00:00:00 2001 From: Christopher Eby Date: Fri, 28 Oct 2011 01:24:43 -0500 Subject: [PATCH] Make library controls react to no media and empty queue states better --- res/layout/library_controls.xml | 7 +++++++ res/values/translatable.xml | 2 +- src/org/kreed/vanilla/LibraryActivity.java | 22 +++++++++++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/res/layout/library_controls.xml b/res/layout/library_controls.xml index 03477518..66f80e02 100644 --- a/res/layout/library_controls.xml +++ b/res/layout/library_controls.xml @@ -26,6 +26,13 @@ THE SOFTWARE. android:background="@drawable/music_bottom_playback_bg" android:layout_width="fill_parent" android:layout_height="80dip"> + No songs found on your device. - No songs selected. Pick some from the library (search key) or enter random mode by tapping this message. + No songs selected. Pick some from the library or enter random mode by tapping this message. Settings Library No shuffle diff --git a/src/org/kreed/vanilla/LibraryActivity.java b/src/org/kreed/vanilla/LibraryActivity.java index 6c7da057..17aeefd9 100644 --- a/src/org/kreed/vanilla/LibraryActivity.java +++ b/src/org/kreed/vanilla/LibraryActivity.java @@ -86,6 +86,7 @@ public class LibraryActivity private TextView mTitle; private TextView mArtist; private ImageView mCover; + private View mEmptyQueue; private ViewGroup mLimiterViews; @@ -143,6 +144,9 @@ public class LibraryActivity mEndButton = (ImageButton)findViewById(R.id.end_action); mEndButton.setOnClickListener(this); registerForContextMenu(mEndButton); + + mEmptyQueue = findViewById(R.id.empty_queue); + mEmptyQueue.setOnClickListener(this); } mSearchBox = findViewById(R.id.search_box); @@ -445,6 +449,8 @@ public class LibraryActivity mTextFilter.setText(""); } else if (view == mCover) { startActivity(new Intent(this, FullPlaybackActivity.class)); + } else if (view == mEmptyQueue) { + setState(PlaybackService.get(this).setFinishAction(SongTimeline.FINISH_RANDOM)); } else if (view.getTag() != null) { // a limiter view was clicked int i = (Integer)view.getTag(); @@ -865,11 +871,25 @@ public class LibraryActivity mSearchBoxVisible = visible; mSearchBox.setVisibility(visible ? View.VISIBLE : View.GONE); if (mControls != null) - mControls.setVisibility(visible ? View.GONE : View.VISIBLE); + mControls.setVisibility(visible || (mState & PlaybackService.FLAG_NO_MEDIA) != 0 ? View.GONE : View.VISIBLE); if (visible) mSearchBox.requestFocus(); } + @Override + protected void onStateChange(int state, int toggled) + { + super.onStateChange(state, toggled); + + if ((toggled & PlaybackService.FLAG_NO_MEDIA) != 0) { + // update visibility of controls + setSearchBoxVisible(mSearchBoxVisible); + } + if ((toggled & PlaybackService.FLAG_EMPTY_QUEUE) != 0 && mEmptyQueue != null) { + mEmptyQueue.setVisibility((state & PlaybackService.FLAG_EMPTY_QUEUE) == 0 ? View.GONE : View.VISIBLE); + } + } + @Override protected void onSongChange(final Song song) {