Add a "last used action" preference to the song selector

This commit is contained in:
Christopher Eby 2010-03-10 23:48:43 -06:00
parent 4a5bbb3582
commit 1d6ca04568
2 changed files with 15 additions and 2 deletions

View File

@ -3,5 +3,6 @@
<string-array name="default_action_entries">
<item>Play</item>
<item>Enqueue</item>
<item>Last Used Action</item>
</string-array>
</resources>

View File

@ -51,6 +51,7 @@ public class SongSelector extends TabActivity implements AdapterView.OnItemClick
private MediaAdapter[] mAdapters = new MediaAdapter[3];
private int mDefaultAction;
private boolean mDefaultIsLastAction;
private void initializeListView(int id, BaseAdapter adapter)
{
@ -92,7 +93,15 @@ public class SongSelector extends TabActivity implements AdapterView.OnItemClick
inputType = InputType.TYPE_CLASS_TEXT;
mTextFilter.setInputType(inputType);
mDefaultAction = settings.getString("default_action", "Play").equals("Play") ? PlaybackService.ACTION_PLAY : PlaybackService.ACTION_ENQUEUE;
String action = settings.getString("default_action", "Play");
if (action.equals("Last Used Action")) {
mDefaultIsLastAction = true;
mDefaultAction = PlaybackService.ACTION_PLAY;
} else if (action.equals("Enqueue")) {
mDefaultAction = PlaybackService.ACTION_ENQUEUE;
} else {
mDefaultAction = PlaybackService.ACTION_PLAY;
}
new Handler().post(new Runnable() {
public void run()
@ -186,7 +195,10 @@ public class SongSelector extends TabActivity implements AdapterView.OnItemClick
@Override
public boolean onContextItemSelected(MenuItem item)
{
sendSongIntent(item.getIntent());
Intent intent = item.getIntent();
if (mDefaultIsLastAction)
mDefaultAction = intent.getIntExtra("action", PlaybackService.ACTION_PLAY);
sendSongIntent(intent);
return true;
}
}