Make clicking the song info open that song in the library
This commit is contained in:
parent
8d4629472c
commit
731b7afed3
@ -26,6 +26,7 @@ THE SOFTWARE.
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_width="fill_parent" />
|
||||
<LinearLayout
|
||||
android:id="@+id/controls_top"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_gravity="top|left"
|
||||
|
@ -87,6 +87,10 @@ public class FullPlaybackActivity extends PlaybackActivity
|
||||
* Cached StringBuilder for formatting track position.
|
||||
*/
|
||||
private final StringBuilder mTimeBuilder = new StringBuilder();
|
||||
/**
|
||||
* The currently playing song.
|
||||
*/
|
||||
private Song mCurrentSong;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle)
|
||||
@ -136,6 +140,9 @@ public class FullPlaybackActivity extends PlaybackActivity
|
||||
View nextButton = findViewById(R.id.next);
|
||||
nextButton.setOnClickListener(this);
|
||||
|
||||
View controlsTop = findViewById(R.id.controls_top);
|
||||
controlsTop.setOnClickListener(this);
|
||||
|
||||
mTitle = (TextView)findViewById(R.id.title);
|
||||
mAlbum = (TextView)findViewById(R.id.album);
|
||||
mArtist = (TextView)findViewById(R.id.artist);
|
||||
@ -243,7 +250,7 @@ public class FullPlaybackActivity extends PlaybackActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSongChange(final Song song)
|
||||
protected void onSongChange(Song song)
|
||||
{
|
||||
super.onSongChange(song);
|
||||
|
||||
@ -261,6 +268,7 @@ public class FullPlaybackActivity extends PlaybackActivity
|
||||
}
|
||||
}
|
||||
|
||||
mCurrentSong = song;
|
||||
updateProgress();
|
||||
}
|
||||
|
||||
@ -287,7 +295,7 @@ public class FullPlaybackActivity extends PlaybackActivity
|
||||
{
|
||||
switch (item.getItemId()) {
|
||||
case MENU_LIBRARY:
|
||||
openLibrary();
|
||||
openLibrary(null);
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
@ -297,7 +305,7 @@ public class FullPlaybackActivity extends PlaybackActivity
|
||||
@Override
|
||||
public boolean onSearchRequested()
|
||||
{
|
||||
openLibrary();
|
||||
openLibrary(null);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -440,6 +448,8 @@ public class FullPlaybackActivity extends PlaybackActivity
|
||||
setState(PlaybackService.get(this).setFinishAction(SongTimeline.FINISH_RANDOM));
|
||||
} else if (view == mCoverView) {
|
||||
performAction(mCoverPressAction);
|
||||
} else if (view.getId() == R.id.controls_top) {
|
||||
openLibrary(mCurrentSong);
|
||||
} else {
|
||||
super.onClick(view);
|
||||
}
|
||||
|
@ -220,6 +220,8 @@ public class LibraryActivity
|
||||
|
||||
if (filter != null)
|
||||
mTextFilter.setText(filter);
|
||||
|
||||
onNewIntent(getIntent());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -237,6 +239,21 @@ public class LibraryActivity
|
||||
updateHeaders();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewIntent(Intent intent)
|
||||
{
|
||||
if (intent == null)
|
||||
return;
|
||||
|
||||
long albumId = intent.getLongExtra("albumId", -1);
|
||||
if (albumId != -1) {
|
||||
String[] fields = { intent.getStringExtra("artist"), intent.getStringExtra("album") };
|
||||
String data = String.format("album_id=%d", albumId);
|
||||
Limiter limiter = new Limiter(MediaUtils.TYPE_ALBUM, fields, data);
|
||||
setLimiter(limiter, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle out)
|
||||
{
|
||||
@ -356,12 +373,7 @@ public class LibraryActivity
|
||||
{
|
||||
int type = intent.getIntExtra("type", 1);
|
||||
long id = intent.getLongExtra("id", -1);
|
||||
int tab = setLimiter(mAdapters[type - 1].buildLimiter(id));
|
||||
if (tab == -1 || mTabHost.getCurrentTab() == tab) {
|
||||
updateLimiterViews();
|
||||
} else {
|
||||
mTabHost.setCurrentTab(tab);
|
||||
}
|
||||
setLimiter(mAdapters[type - 1].buildLimiter(id), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -382,14 +394,16 @@ public class LibraryActivity
|
||||
requestRequery(mSongAdapter);
|
||||
requestRequery(mAlbumAdapter);
|
||||
}
|
||||
updateLimiterViews();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the adapters with the given limiter.
|
||||
*
|
||||
* @return The tab to "expand" to
|
||||
* @param switchTab If true, will switch to the tab appropriate for
|
||||
* expanding a row.
|
||||
*/
|
||||
private int setLimiter(Limiter limiter)
|
||||
private void setLimiter(Limiter limiter, boolean switchTab)
|
||||
{
|
||||
int tab;
|
||||
|
||||
@ -398,32 +412,40 @@ public class LibraryActivity
|
||||
mSongAdapter.setLimiter(limiter);
|
||||
loadSortOrder(mSongAdapter);
|
||||
requestRequery(mSongAdapter);
|
||||
return 2;
|
||||
tab = 2;
|
||||
break;
|
||||
case MediaUtils.TYPE_ARTIST:
|
||||
mAlbumAdapter.setLimiter(limiter);
|
||||
mSongAdapter.setLimiter(limiter);
|
||||
loadSortOrder(mSongAdapter);
|
||||
loadSortOrder(mAlbumAdapter);
|
||||
requestRequery(mSongAdapter);
|
||||
requestRequery(mAlbumAdapter);
|
||||
tab = 1;
|
||||
break;
|
||||
case MediaUtils.TYPE_GENRE:
|
||||
mSongAdapter.setLimiter(limiter);
|
||||
mAlbumAdapter.setLimiter(null);
|
||||
loadSortOrder(mSongAdapter);
|
||||
loadSortOrder(mAlbumAdapter);
|
||||
requestRequery(mSongAdapter);
|
||||
requestRequery(mAlbumAdapter);
|
||||
tab = 2;
|
||||
break;
|
||||
case MediaUtils.TYPE_FILE:
|
||||
mFilesAdapter.setLimiter(limiter);
|
||||
requestRequery(mFilesAdapter);
|
||||
return 5;
|
||||
tab = 5;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported limiter type: " + limiter.type);
|
||||
}
|
||||
|
||||
loadSortOrder(mSongAdapter);
|
||||
loadSortOrder(mAlbumAdapter);
|
||||
|
||||
requestRequery(mSongAdapter);
|
||||
requestRequery(mAlbumAdapter);
|
||||
|
||||
return tab;
|
||||
if (switchTab && mTabHost.getCurrentTab() != tab) {
|
||||
mTabHost.setCurrentTab(tab);
|
||||
} else {
|
||||
updateLimiterViews();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -535,7 +557,7 @@ public class LibraryActivity
|
||||
Cursor cursor = resolver.query(uri, projection, limiter.data.toString(), null, null);
|
||||
if (cursor != null) {
|
||||
if (cursor.moveToNext()) {
|
||||
setLimiter(mArtistAdapter.buildLimiter(cursor.getLong(0)));
|
||||
setLimiter(mArtistAdapter.buildLimiter(cursor.getLong(0)), false);
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
@ -546,12 +568,10 @@ public class LibraryActivity
|
||||
while (--diff != -1) {
|
||||
file = file.getParentFile();
|
||||
}
|
||||
setLimiter(FileSystemAdapter.buildLimiter(file));
|
||||
setLimiter(FileSystemAdapter.buildLimiter(file), false);
|
||||
} else {
|
||||
clearLimiter(type);
|
||||
}
|
||||
|
||||
updateLimiterViews();
|
||||
} else {
|
||||
super.onClick(view);
|
||||
}
|
||||
|
@ -395,11 +395,18 @@ public class PlaybackActivity extends Activity
|
||||
|
||||
/**
|
||||
* Open the library activity.
|
||||
*
|
||||
* @param song If non-null, will open the library focused on this song.
|
||||
*/
|
||||
public void openLibrary()
|
||||
public void openLibrary(Song song)
|
||||
{
|
||||
Intent intent = new Intent(this, LibraryActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
if (song != null) {
|
||||
intent.putExtra("albumId", song.albumId);
|
||||
intent.putExtra("album", song.album);
|
||||
intent.putExtra("artist", song.artist);
|
||||
}
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@ -414,7 +421,7 @@ public class PlaybackActivity extends Activity
|
||||
case Nothing:
|
||||
break;
|
||||
case Library:
|
||||
openLibrary();
|
||||
openLibrary(null);
|
||||
break;
|
||||
case PlayPause:
|
||||
playPause();
|
||||
|
Loading…
x
Reference in New Issue
Block a user