[Android] Add "Load last playlist" in launcher shortcuts

Geoffrey Métais git at videolan.org
Wed Nov 28 10:16:31 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Nov 28 10:16:11 2018 +0100| [6d5472299015c4975c616cd1420bc02fd4f55704] | committer: Geoffrey Métais

Add "Load last playlist" in launcher shortcuts

> https://code.videolan.org/videolan/vlc-android/commit/6d5472299015c4975c616cd1420bc02fd4f55704
---

 vlc-android/flavors/debug/res/xml/shortcuts.xml     | 14 +++++++++++++-
 vlc-android/res/xml/shortcuts.xml                   | 14 +++++++++++++-
 vlc-android/src/org/videolan/vlc/StartActivity.java | 20 +++++++++++++-------
 3 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/vlc-android/flavors/debug/res/xml/shortcuts.xml b/vlc-android/flavors/debug/res/xml/shortcuts.xml
index 72ac1ef95..a523a440c 100644
--- a/vlc-android/flavors/debug/res/xml/shortcuts.xml
+++ b/vlc-android/flavors/debug/res/xml/shortcuts.xml
@@ -41,7 +41,7 @@
     </shortcut>
     <shortcut
         android:shortcutId="network"
-        android:enabled="true"
+        android:enabled="false"
         android:icon="@drawable/ic_menu_network"
         android:shortcutShortLabel="@string/network_browsing"
         android:shortcutLongLabel="@string/network_browsing" >
@@ -51,4 +51,16 @@
             android:targetClass="org.videolan.vlc.StartActivity" />
         <categories android:name="vlc.shortcut.category" />
     </shortcut>
+    <shortcut
+        android:shortcutId="last_playlist"
+        android:enabled="true"
+        android:icon="@drawable/ic_menu_lastplaylist"
+        android:shortcutShortLabel="@string/last_playlist"
+        android:shortcutLongLabel="@string/last_playlist" >
+        <intent
+            android:action="vlc.shortcut.resume"
+            android:targetPackage="org.videolan.vlc.debug"
+            android:targetClass="org.videolan.vlc.StartActivity" />
+        <categories android:name="vlc.shortcut.category" />
+    </shortcut>
 </shortcuts>
diff --git a/vlc-android/res/xml/shortcuts.xml b/vlc-android/res/xml/shortcuts.xml
index 4004dc6e8..f9feaddf2 100644
--- a/vlc-android/res/xml/shortcuts.xml
+++ b/vlc-android/res/xml/shortcuts.xml
@@ -41,7 +41,7 @@
     </shortcut>
     <shortcut
         android:shortcutId="network"
-        android:enabled="true"
+        android:enabled="false"
         android:icon="@drawable/ic_menu_network"
         android:shortcutShortLabel="@string/network_browsing"
         android:shortcutLongLabel="@string/network_browsing" >
@@ -51,4 +51,16 @@
             android:targetClass="org.videolan.vlc.StartActivity" />
         <categories android:name="vlc.shortcut.category" />
     </shortcut>
+    <shortcut
+        android:shortcutId="last_playlist"
+        android:enabled="true"
+        android:icon="@drawable/ic_menu_lastplaylist"
+        android:shortcutShortLabel="@string/last_playlist"
+        android:shortcutLongLabel="@string/last_playlist" >
+        <intent
+            android:action="vlc.shortcut.resume"
+            android:targetPackage="org.videolan.vlc"
+            android:targetClass="org.videolan.vlc.StartActivity" />
+        <categories android:name="vlc.shortcut.category" />
+    </shortcut>
 </shortcuts>
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/StartActivity.java b/vlc-android/src/org/videolan/vlc/StartActivity.java
index f437baf12..75e055182 100644
--- a/vlc-android/src/org/videolan/vlc/StartActivity.java
+++ b/vlc-android/src/org/videolan/vlc/StartActivity.java
@@ -98,22 +98,26 @@ public class StartActivity extends FragmentActivity {
         } else if(Intent.ACTION_VIEW.equals(action) && intent.getData() != null) { //launch from TV Channel
             final Uri data = intent.getData();
             final String path = data.getPath();
-            if (TextUtils.equals(path,"/"+TvChannelUtilsKt.TV_CHANNEL_PATH_APP)) startApplication(tv, firstRun, upgrade);
+            if (TextUtils.equals(path,"/"+TvChannelUtilsKt.TV_CHANNEL_PATH_APP)) startApplication(tv, firstRun, upgrade, 0);
             else if (TextUtils.equals(path,"/"+TvChannelUtilsKt.TV_CHANNEL_PATH_VIDEO)) {
                 final long id = Long.valueOf(data.getQueryParameter(TvChannelUtilsKt.TV_CHANNEL_QUERY_VIDEO_ID));
                 MediaUtils.INSTANCE.openMediaNoUi(this, id);
             }
-        } else startApplication(tv, firstRun, upgrade);
+        } else {
+            final int target = getIdFromShortcut();
+            if (target == R.id.ml_menu_last_playlist) PlaybackService.Companion.loadLastAudio(this);
+            else startApplication(tv, firstRun, upgrade, target);
+        }
         finish();
     }
 
-    private void startApplication(boolean tv, boolean firstRun, boolean upgrade) {
+    private void startApplication(boolean tv, boolean firstRun, boolean upgrade, int target) {
         MediaParsingServiceKt.startMedialibrary(this, firstRun, upgrade, true);
+        final Intent intent = new Intent(this, tv ? MainTvActivity.class : MainActivity.class)
+                .putExtra(Constants.EXTRA_FIRST_RUN, firstRun);
+        if (target != 0) intent.putExtra(Constants.EXTRA_TARGET, target);
 
-        final int target = getIdFromShortcut();
-        startActivity(new Intent(this, tv ? MainTvActivity.class : MainActivity.class)
-                .putExtra(Constants.EXTRA_FIRST_RUN, firstRun)
-                .putExtra(Constants.EXTRA_TARGET, target));
+        startActivity(intent);
     }
 
     private void startPlaybackFromApp(Intent intent) {
@@ -142,6 +146,8 @@ public class StartActivity extends FragmentActivity {
                     return R.id.nav_directories;
                 case "vlc.shortcut.network":
                     return R.id.nav_network;
+                case "vlc.shortcut.resume":
+                    return R.id.ml_menu_last_playlist;
                 default:
                     return 0;
             }



More information about the Android mailing list