Make library controls react to no media and empty queue states better

This commit is contained in:
Christopher Eby 2011-10-28 01:24:43 -05:00
parent a6c4c6c90f
commit fcad52ef5d
3 changed files with 29 additions and 2 deletions

View File

@ -26,6 +26,13 @@ THE SOFTWARE.
android:background="@drawable/music_bottom_playback_bg"
android:layout_width="fill_parent"
android:layout_height="80dip">
<TextView
android:id="@+id/empty_queue"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/empty_queue"
android:visibility="gone" />
<ImageView
android:id="@+id/cover"
android:scaleType="fitCenter"

View File

@ -25,7 +25,7 @@ THE SOFTWARE.
<!-- Playback Activity (main screen) -->
<string name="no_songs">No songs found on your device.</string>
<string name="empty_queue">No songs selected. Pick some from the library (search key) or enter random mode by tapping this message.</string>
<string name="empty_queue">No songs selected. Pick some from the library or enter random mode by tapping this message.</string>
<string name="settings">Settings</string>
<string name="library">Library</string>
<string name="no_shuffle">No shuffle</string>

View File

@ -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)
{