Add 'shortcuts' support

This commit is contained in:
Adrian Ulrich 2017-08-11 21:49:31 +02:00
parent 1b9bb0596d
commit 2b36ff3114
14 changed files with 69 additions and 2 deletions

View File

@ -38,8 +38,8 @@ THE SOFTWARE.
android:label="@string/app_name">
<meta-data
android:name="com.mirrorlink.android.rockscout.allow-offline-access"
android:value="true" />
android:name="com.mirrorlink.android.rockscout.allow-offline-access"
android:value="true" />
<activity
android:name="FullPlaybackActivity"
@ -54,6 +54,11 @@ THE SOFTWARE.
<category android:name="android.intent.category.APP_MUSIC" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts"/>
</activity>
<activity
android:name="PlaylistActivity"
@ -158,6 +163,10 @@ THE SOFTWARE.
android:name="PermissionRequestActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity
android:name="ShortcutPseudoActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity android:name="AudioPickerActivity" android:theme="@style/PopupDialog"
android:excludeFromRecents="true" android:exported="true" >
<intent-filter>

Binary file not shown.

BIN
orig/shortcut_play.svgz Normal file

Binary file not shown.

BIN
orig/shortcut_random.svgz Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

@ -161,6 +161,10 @@ public final class PlaybackService extends Service
* when this is called.
*/
public static final String ACTION_PREVIOUS_SONG_AUTOPLAY = "ch.blinkenlights.android.vanilla.action.PREVIOUS_SONG_AUTOPLAY";
/**
* Flushes the queue, switches to random mode and starts playing.
*/
public static final String ACTION_RANDOM_MIX_AUTOPLAY = "ch.blinkenlights.android.vanilla.action.RANDOM_MIX_AUTOPLAY";
/**
* Change the shuffle mode.
*/
@ -559,6 +563,14 @@ public final class PlaybackService extends Service
cycleFinishAction();
} else if (ACTION_CYCLE_SHUFFLE.equals(action)) {
cycleShuffle();
} else if (ACTION_RANDOM_MIX_AUTOPLAY.equals(action)) {
pause();
emptyQueue();
setFinishAction(SongTimeline.FINISH_RANDOM);
// We can't use play() here as setFinishAction() is handled in the background.
// We therefore send a GO message to the same queue, so it will get handled as
// soon as the queue is ready.
mHandler.sendEmptyMessage(MSG_CALL_GO);
} else if (ACTION_CLOSE_NOTIFICATION.equals(action)) {
mForceNotificationVisible = false;
pause();

View File

@ -0,0 +1,46 @@
/*
* Copyright (C) 2017 Adrian Ulrich <adrian@blinkenlights.ch>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* 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 <http://www.gnu.org/licenses/>.
*/
package ch.blinkenlights.android.vanilla;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
public class ShortcutPseudoActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final String action = getIntent().getAction();
switch (action) {
case PlaybackService.ACTION_TOGGLE_PLAYBACK:
case PlaybackService.ACTION_RANDOM_MIX_AUTOPLAY:
Intent intent = new Intent(this, PlaybackService.class);
intent.setAction(action);
startService(intent);
break;
default:
throw new IllegalArgumentException("No such action: " + action);
}
finish();
}
}