Commit e2359c1d authored by Geoffrey Métais's avatar Geoffrey Métais

static shortcuts

parent 3a3d3b51
......@@ -74,13 +74,16 @@
android:name="android.max_aspect"
android:value="2.1" />
<activity
android:name=".StartActivity">
android:name=".StartActivity"
android:icon="@drawable/icon">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts" />
<!-- This filter captures protocols without type info -->
<intent-filter>
......@@ -427,7 +430,6 @@
</activity>
<activity
android:name=".gui.MainActivity"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustPan"
......
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="video"
android:enabled="true"
android:icon="@drawable/ic_menu_video"
android:shortcutShortLabel="@string/video"
android:shortcutLongLabel="@string/video"
tools:targetApi="n_mr1">
<intent
android:action="vlc.shortcut.video"
android:targetPackage="org.videolan.vlc.debug"
android:targetClass="org.videolan.vlc.gui.MainActivity" />
<!-- If your shortcut is associated with multiple intents, include them
here. The last intent in the list determines what the user sees when
they launch this shortcut. -->
<categories android:name="vlc.shortcut.category" />
</shortcut>
<shortcut
android:shortcutId="audio"
android:enabled="true"
android:icon="@drawable/ic_menu_audio"
android:shortcutShortLabel="@string/audio"
android:shortcutLongLabel="@string/audio" >
<intent
android:action="vlc.shortcut.audio"
android:targetPackage="org.videolan.vlc.debug"
android:targetClass="org.videolan.vlc.gui.MainActivity" />
<!-- If your shortcut is associated with multiple intents, include them
here. The last intent in the list determines what the user sees when
they launch this shortcut. -->
<categories android:name="vlc.shortcut.category" />
</shortcut>
<shortcut
android:shortcutId="browser"
android:enabled="true"
android:icon="@drawable/ic_menu_folder"
android:shortcutShortLabel="@string/directories"
android:shortcutLongLabel="@string/directories" >
<intent
android:action="vlc.shortcut.browser"
android:targetPackage="org.videolan.vlc.debug"
android:targetClass="org.videolan.vlc.gui.MainActivity" />
<!-- If your shortcut is associated with multiple intents, include them
here. The last intent in the list determines what the user sees when
they launch this shortcut. -->
<categories android:name="vlc.shortcut.category" />
</shortcut>
<shortcut
android:shortcutId="network"
android:enabled="true"
android:icon="@drawable/ic_menu_network"
android:shortcutShortLabel="@string/network_browsing"
android:shortcutLongLabel="@string/network_browsing" >
<intent
android:action="vlc.shortcut.network"
android:targetPackage="org.videolan.vlc.debug"
android:targetClass="org.videolan.vlc.gui.MainActivity" />
<!-- If your shortcut is associated with multiple intents, include them
here. The last intent in the list determines what the user sees when
they launch this shortcut. -->
<categories android:name="vlc.shortcut.category" />
</shortcut>
<!-- Specify more shortcuts here. -->
</shortcuts>
\ No newline at end of file
......@@ -43,6 +43,7 @@ import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.view.ActionMode;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
......@@ -231,8 +232,10 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
@Override
protected void onStart() {
super.onStart();
if (mCurrentFragment == null && !currentIdIsExtension())
if (mCurrentFragment == null && !currentIdIsExtension()) {
mCurrentFragmentId = getIdFromShortcut();
showFragment(mCurrentFragmentId);
}
if (mMediaLibrary.isInitiated()) {
/* Load media items from database and storage */
if (mScanNeeded && Permissions.canReadStorage())
......@@ -245,6 +248,27 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
createExtensionServiceConnection();
}
private int getIdFromShortcut() {
if (!AndroidUtil.isNougatMr1OrLater) return 0;
final Intent intent = getIntent();
final String action = intent != null ? intent.getAction() : null;
if (!TextUtils.isEmpty(action)) {
switch (action) {
case "vlc.shortcut.video":
return R.id.nav_video;
case "vlc.shortcut.audio":
return R.id.nav_audio;
case "vlc.shortcut.browser":
return R.id.nav_directories;
case "vlc.shortcut.network":
return R.id.nav_network;
default:
return 0;
}
}
return 0;
}
@Override
protected void onStop() {
super.onStop();
......@@ -710,7 +734,7 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
}
public boolean idIsExtension(int id) {
return id <= 100;
return id <= 100 && id > 0;
}
public int getCurrentFragmentId() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment