Added app icon shortcuts. Closes #1738.

This commit is contained in:
GilesMunn 2022-11-05 18:44:40 +00:00
parent 10c6e8610a
commit 093e138fa5
3 changed files with 53 additions and 0 deletions

View File

@ -67,6 +67,9 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" /> <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter> </intent-filter>
<meta-data android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity> </activity>
<activity-alias <activity-alias

View File

@ -108,6 +108,17 @@ class MainActivity : BaseActivity() {
// navigate to the default fragment // navigate to the default fragment
navController.navigate(startFragmentId) navController.navigate(startFragmentId)
// open appropriate fragment from shortcut
when (intent.extras?.getString("fragmentToOpen")) {
"subscriptions" ->
navController.navigate(R.id.subscriptionsFragment)
"library" ->
navController.navigate(R.id.libraryFragment)
else -> {
return
}
}
binding.bottomNav.setOnApplyWindowInsetsListener(null) binding.bottomNav.setOnApplyWindowInsetsListener(null)
binding.bottomNav.setOnItemSelectedListener { binding.bottomNav.setOnItemSelectedListener {

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:targetApi="25">
<shortcut
android:shortcutId="home"
android:enabled="true"
android:icon="@drawable/ic_home"
android:shortcutShortLabel="@string/startpage">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.github.libretube.debug"
android:targetClass="com.github.libretube.ui.activities.MainActivity" />
</shortcut>
<shortcut
android:shortcutId="subscriptions"
android:enabled="true"
android:icon="@drawable/ic_subscriptions"
android:shortcutShortLabel="@string/subscriptions">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.github.libretube.debug"
android:targetClass="com.github.libretube.ui.activities.MainActivity">
<extra android:name="fragmentToOpen" android:value="subscriptions"/>
</intent>
</shortcut>
<shortcut
android:shortcutId="library"
android:enabled="true"
android:icon="@drawable/ic_library"
android:shortcutShortLabel="@string/library">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.github.libretube.debug"
android:targetClass="com.github.libretube.ui.activities.MainActivity">
<extra android:name="fragmentToOpen" android:value="library"/>
</intent>
</shortcut>
</shortcuts>