diff --git a/src/ch/blinkenlights/android/vanilla/FourLongWidget.java b/src/ch/blinkenlights/android/vanilla/FourLongWidget.java index 8a837241..48501fb4 100644 --- a/src/ch/blinkenlights/android/vanilla/FourLongWidget.java +++ b/src/ch/blinkenlights/android/vanilla/FourLongWidget.java @@ -123,21 +123,19 @@ public class FourLongWidget extends AppWidgetProvider { Intent intent; PendingIntent pendingIntent; + int flags = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME; - ComponentName service = new ComponentName(context, PlaybackService.class); - - intent = new Intent(context, LibraryActivity.class); - intent.setAction(Intent.ACTION_MAIN); + intent = new Intent(context, LibraryActivity.class).setAction(Intent.ACTION_MAIN); pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.cover, pendingIntent); views.setOnClickPendingIntent(R.id.text_layout, pendingIntent); - intent = new Intent(PlaybackService.ACTION_TOGGLE_PLAYBACK).setComponent(service); - pendingIntent = PendingIntent.getService(context, 0, intent, 0); + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(PlaybackService.ACTION_TOGGLE_PLAYBACK); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.play_pause, pendingIntent); - intent = new Intent(PlaybackService.ACTION_NEXT_SONG).setComponent(service); - pendingIntent = PendingIntent.getService(context, 0, intent, 0); + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(PlaybackService.ACTION_NEXT_SONG); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.next, pendingIntent); manager.updateAppWidget(new ComponentName(context, FourLongWidget.class), views); diff --git a/src/ch/blinkenlights/android/vanilla/FourSquareWidget.java b/src/ch/blinkenlights/android/vanilla/FourSquareWidget.java index e6f2b9ce..f7718405 100644 --- a/src/ch/blinkenlights/android/vanilla/FourSquareWidget.java +++ b/src/ch/blinkenlights/android/vanilla/FourSquareWidget.java @@ -126,21 +126,19 @@ public class FourSquareWidget extends AppWidgetProvider { Intent intent; PendingIntent pendingIntent; + int flags = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME; - ComponentName service = new ComponentName(context, PlaybackService.class); - - intent = new Intent(context, LibraryActivity.class); - intent.setAction(Intent.ACTION_MAIN); + intent = new Intent(context, LibraryActivity.class).setAction(Intent.ACTION_MAIN); pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.title, pendingIntent); views.setOnClickPendingIntent(R.id.artist, pendingIntent); - intent = new Intent(PlaybackService.ACTION_TOGGLE_PLAYBACK).setComponent(service); - pendingIntent = PendingIntent.getService(context, 0, intent, 0); + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(PlaybackService.ACTION_TOGGLE_PLAYBACK); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.play_pause, pendingIntent); - intent = new Intent(PlaybackService.ACTION_NEXT_SONG).setComponent(service); - pendingIntent = PendingIntent.getService(context, 0, intent, 0); + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(PlaybackService.ACTION_NEXT_SONG); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.next, pendingIntent); manager.updateAppWidget(new ComponentName(context, FourSquareWidget.class), views); diff --git a/src/ch/blinkenlights/android/vanilla/FourWhiteWidget.java b/src/ch/blinkenlights/android/vanilla/FourWhiteWidget.java index fb705cdd..b5f0ef19 100644 --- a/src/ch/blinkenlights/android/vanilla/FourWhiteWidget.java +++ b/src/ch/blinkenlights/android/vanilla/FourWhiteWidget.java @@ -1,4 +1,5 @@ /* + * Copyright (C) 2017 Adrian Ulrich * Copyright (C) 2012 Ferenc Nagy * Copyright (C) 2010, 2011 Christopher Eby * @@ -127,27 +128,25 @@ public class FourWhiteWidget extends AppWidgetProvider { Intent intent; PendingIntent pendingIntent; + int flags = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME; - ComponentName service = new ComponentName(context, PlaybackService.class); - - intent = new Intent(context, LibraryActivity.class); - intent.setAction(Intent.ACTION_MAIN); + intent = new Intent(context, LibraryActivity.class).setAction(Intent.ACTION_MAIN); pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.cover, pendingIntent); views.setOnClickPendingIntent(R.id.text_layout, pendingIntent); - intent = new Intent(PlaybackService.ACTION_TOGGLE_PLAYBACK).setComponent(service); - pendingIntent = PendingIntent.getService(context, 0, intent, 0); + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(PlaybackService.ACTION_TOGGLE_PLAYBACK); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.play_pause, pendingIntent); - intent = new Intent(PlaybackService.ACTION_NEXT_SONG).setComponent(service); - pendingIntent = PendingIntent.getService(context, 0, intent, 0); + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(PlaybackService.ACTION_NEXT_SONG); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.next, pendingIntent); - intent = new Intent(PlaybackService.ACTION_PREVIOUS_SONG).setComponent(service); - pendingIntent = PendingIntent.getService(context, 0, intent, 0); + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(PlaybackService.ACTION_PREVIOUS_SONG); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.previous, pendingIntent); - + manager.updateAppWidget(new ComponentName(context, FourWhiteWidget.class), views); } } diff --git a/src/ch/blinkenlights/android/vanilla/OneCellWidget.java b/src/ch/blinkenlights/android/vanilla/OneCellWidget.java index 88e4a0db..9bd85ad3 100644 --- a/src/ch/blinkenlights/android/vanilla/OneCellWidget.java +++ b/src/ch/blinkenlights/android/vanilla/OneCellWidget.java @@ -97,15 +97,19 @@ public class OneCellWidget extends AppWidgetProvider { boolean playing = (state & PlaybackService.FLAG_PLAYING) != 0; views.setImageViewResource(R.id.play_pause, playing ? R.drawable.hidden_pause : R.drawable.hidden_play); - ComponentName service = new ComponentName(context, PlaybackService.class); - Intent playPause = new Intent(doubleTap ? PlaybackService.ACTION_TOGGLE_PLAYBACK_DELAYED : PlaybackService.ACTION_TOGGLE_PLAYBACK); - playPause.setComponent(service); - views.setOnClickPendingIntent(R.id.play_pause, PendingIntent.getService(context, 0, playPause, 0)); + Intent intent; + PendingIntent pendingIntent; + int flags = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME; + + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(doubleTap ? PlaybackService.ACTION_TOGGLE_PLAYBACK_DELAYED : PlaybackService.ACTION_TOGGLE_PLAYBACK); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); + views.setOnClickPendingIntent(R.id.play_pause, pendingIntent); + + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(doubleTap ? PlaybackService.ACTION_NEXT_SONG_DELAYED : PlaybackService.ACTION_NEXT_SONG); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); + views.setOnClickPendingIntent(R.id.next, pendingIntent); - Intent next = new Intent(doubleTap ? PlaybackService.ACTION_NEXT_SONG_DELAYED : PlaybackService.ACTION_NEXT_SONG); - next.setComponent(service); - views.setOnClickPendingIntent(R.id.next, PendingIntent.getService(context, 0, next, 0)); Bitmap cover = null; if ((state & PlaybackService.FLAG_NO_MEDIA) != 0) { diff --git a/src/ch/blinkenlights/android/vanilla/ShortcutPseudoActivity.java b/src/ch/blinkenlights/android/vanilla/ShortcutPseudoActivity.java index c37ed53f..6720f63c 100644 --- a/src/ch/blinkenlights/android/vanilla/ShortcutPseudoActivity.java +++ b/src/ch/blinkenlights/android/vanilla/ShortcutPseudoActivity.java @@ -12,7 +12,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ package ch.blinkenlights.android.vanilla; @@ -32,7 +32,13 @@ public class ShortcutPseudoActivity extends Activity { final String action = getIntent().getAction(); switch (action) { case PlaybackService.ACTION_TOGGLE_PLAYBACK: + case PlaybackService.ACTION_TOGGLE_PLAYBACK_DELAYED: case PlaybackService.ACTION_RANDOM_MIX_AUTOPLAY: + case PlaybackService.ACTION_NEXT_SONG: + case PlaybackService.ACTION_NEXT_SONG_DELAYED: + case PlaybackService.ACTION_PREVIOUS_SONG: + case PlaybackService.ACTION_CYCLE_SHUFFLE: + case PlaybackService.ACTION_CYCLE_REPEAT: Intent intent = new Intent(this, PlaybackService.class); intent.setAction(action); startService(intent); diff --git a/src/ch/blinkenlights/android/vanilla/WidgetD.java b/src/ch/blinkenlights/android/vanilla/WidgetD.java index 27d800d6..1da7173d 100644 --- a/src/ch/blinkenlights/android/vanilla/WidgetD.java +++ b/src/ch/blinkenlights/android/vanilla/WidgetD.java @@ -121,32 +121,30 @@ public class WidgetD extends AppWidgetProvider { Intent intent; PendingIntent pendingIntent; + int flags = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME; - ComponentName service = new ComponentName(context, PlaybackService.class); - - intent = new Intent(context, LibraryActivity.class); - intent.setAction(Intent.ACTION_MAIN); + intent = new Intent(context, LibraryActivity.class).setAction(Intent.ACTION_MAIN); pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.cover, pendingIntent); - intent = new Intent(PlaybackService.ACTION_TOGGLE_PLAYBACK).setComponent(service); - pendingIntent = PendingIntent.getService(context, 0, intent, 0); + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(PlaybackService.ACTION_TOGGLE_PLAYBACK); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.play_pause, pendingIntent); - intent = new Intent(PlaybackService.ACTION_NEXT_SONG).setComponent(service); - pendingIntent = PendingIntent.getService(context, 0, intent, 0); + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(PlaybackService.ACTION_NEXT_SONG); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.next, pendingIntent); - intent = new Intent(PlaybackService.ACTION_PREVIOUS_SONG).setComponent(service); - pendingIntent = PendingIntent.getService(context, 0, intent, 0); + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(PlaybackService.ACTION_PREVIOUS_SONG); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.previous, pendingIntent); - intent = new Intent(PlaybackService.ACTION_CYCLE_SHUFFLE).setComponent(service); - pendingIntent = PendingIntent.getService(context, 0, intent, 0); + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(PlaybackService.ACTION_CYCLE_SHUFFLE); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.shuffle, pendingIntent); - intent = new Intent(PlaybackService.ACTION_CYCLE_REPEAT).setComponent(service); - pendingIntent = PendingIntent.getService(context, 0, intent, 0); + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(PlaybackService.ACTION_CYCLE_REPEAT); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.end_action, pendingIntent); manager.updateAppWidget(new ComponentName(context, WidgetD.class), views); diff --git a/src/ch/blinkenlights/android/vanilla/WidgetE.java b/src/ch/blinkenlights/android/vanilla/WidgetE.java index 75311cff..119e5894 100644 --- a/src/ch/blinkenlights/android/vanilla/WidgetE.java +++ b/src/ch/blinkenlights/android/vanilla/WidgetE.java @@ -111,33 +111,31 @@ public class WidgetE extends AppWidgetProvider { Intent intent; PendingIntent pendingIntent; + int flags = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME; - ComponentName service = new ComponentName(context, PlaybackService.class); - - intent = new Intent(context, LibraryActivity.class); - intent.setAction(Intent.ACTION_MAIN); + intent = new Intent(context, LibraryActivity.class).setAction(Intent.ACTION_MAIN); pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.title, pendingIntent); views.setOnClickPendingIntent(R.id.artist, pendingIntent); - intent = new Intent(PlaybackService.ACTION_TOGGLE_PLAYBACK).setComponent(service); - pendingIntent = PendingIntent.getService(context, 0, intent, 0); + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(PlaybackService.ACTION_TOGGLE_PLAYBACK); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.play_pause, pendingIntent); - intent = new Intent(PlaybackService.ACTION_NEXT_SONG).setComponent(service); - pendingIntent = PendingIntent.getService(context, 0, intent, 0); + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(PlaybackService.ACTION_NEXT_SONG); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.next, pendingIntent); - intent = new Intent(PlaybackService.ACTION_PREVIOUS_SONG).setComponent(service); - pendingIntent = PendingIntent.getService(context, 0, intent, 0); + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(PlaybackService.ACTION_PREVIOUS_SONG); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.previous, pendingIntent); - intent = new Intent(PlaybackService.ACTION_CYCLE_SHUFFLE).setComponent(service); - pendingIntent = PendingIntent.getService(context, 0, intent, 0); + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(PlaybackService.ACTION_CYCLE_SHUFFLE); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.shuffle, pendingIntent); - intent = new Intent(PlaybackService.ACTION_CYCLE_REPEAT).setComponent(service); - pendingIntent = PendingIntent.getService(context, 0, intent, 0); + intent = new Intent(context, ShortcutPseudoActivity.class).setFlags(flags).setAction(PlaybackService.ACTION_CYCLE_REPEAT); + pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.end_action, pendingIntent); manager.updateAppWidget(new ComponentName(context, WidgetE.class), views);