Remove the double-press-launches-activity functionality in the widget

This feature causes a delay after pressing either of the buttons and is not
really obvious to begin with
This commit is contained in:
Christopher Eby 2010-04-21 10:24:42 -05:00
parent 846b1aad76
commit 966a02f5c6
2 changed files with 7 additions and 13 deletions

View File

@ -65,11 +65,9 @@ public class OneCellWidget extends AppWidgetProvider {
views.setImageViewResource(R.id.play_pause, playing ? R.drawable.hidden_pause : R.drawable.hidden_play);
Intent playPause = new Intent(context, PlaybackService.class);
playPause.putExtra("double", true);
playPause.setAction(PlaybackService.TOGGLE_PLAYBACK);
views.setOnClickPendingIntent(R.id.play_pause, PendingIntent.getService(context, 0, playPause, 0));
Intent next = new Intent(context, PlaybackService.class);
next.putExtra("double", true);
next.setAction(PlaybackService.NEXT_SONG);
views.setOnClickPendingIntent(R.id.next, PendingIntent.getService(context, 0, next, 0));

View File

@ -165,7 +165,7 @@ public final class PlaybackService extends Service implements Handler.Callback,
if (delta == 10)
handleMediaKey((KeyEvent)intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT));
else
go(delta, intent.getBooleanExtra("double", false), false);
go(delta, false);
}
}
@ -640,7 +640,7 @@ public final class PlaybackService extends Service implements Handler.Callback,
PlaybackServiceState.saveState(this, mSongTimeline, mTimelinePos, savePosition && mMediaPlayer != null ? mMediaPlayer.getCurrentPosition() : 0, mState & (FLAG_REPEAT + FLAG_SHUFFLE), mRepeatStart);
}
private void go(int delta, boolean doubleLaunchesActivity, boolean autoPlay)
private void go(int delta, boolean autoPlay)
{
if (autoPlay) {
synchronized (mStateLock) {
@ -648,17 +648,13 @@ public final class PlaybackService extends Service implements Handler.Callback,
}
}
// check for double click
if (doubleLaunchesActivity && mHandler.hasMessages(GO)) {
mHandler.removeMessages(GO);
startActivity(new Intent(this, FullPlaybackActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
} else if (!doubleLaunchesActivity && mLoaded) {
if (mLoaded) {
if (delta == 0)
toggleFlag(FLAG_PLAYING);
else
setCurrentSong(delta);
} else {
mHandler.sendMessageDelayed(mHandler.obtainMessage(GO, delta, 0), DOUBLE_CLICK_DELAY);
mHandler.sendMessage(mHandler.obtainMessage(GO, delta, 0));
}
}
@ -686,7 +682,7 @@ public final class PlaybackService extends Service implements Handler.Callback,
if (action == KeyEvent.ACTION_DOWN) {
mHandler.removeMessages(MEDIA_BUTTON);
mIgnoreNextUp = true;
go(1, false, true);
go(1, true);
}
} else {
// single press
@ -696,11 +692,11 @@ public final class PlaybackService extends Service implements Handler.Callback,
break;
case KeyEvent.KEYCODE_MEDIA_NEXT:
if (action == KeyEvent.ACTION_DOWN)
go(1, false, true);
go(1, true);
break;
case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
if (action == KeyEvent.ACTION_DOWN)
go(-1, false, true);
go(-1, true);
break;
default:
return false;