mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-19 00:35:26 +02:00
Added dynamic shortcut to epoch converter
This commit is contained in:
parent
790457cb6f
commit
df3794cad4
@ -17,6 +17,12 @@
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<intent-filter android:label="@string/epoch_converter">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="app" android:host="com.sadellie.unitto" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
|
@ -18,21 +18,45 @@
|
||||
|
||||
package com.sadellie.unitto.feature.epoch.navigation
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import androidx.core.content.pm.ShortcutInfoCompat
|
||||
import androidx.core.content.pm.ShortcutManagerCompat
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavGraphBuilder
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.navDeepLink
|
||||
import com.sadellie.unitto.feature.epoch.EpochRoute
|
||||
import com.sadellie.unitto.feature.epoch.R
|
||||
|
||||
private const val epochRoute = "epoch_route"
|
||||
|
||||
fun NavController.navigateToEpoch() {
|
||||
val shortcut = ShortcutInfoCompat
|
||||
.Builder(context, epochRoute)
|
||||
.setLongLabel(context.getString(R.string.epoch_converter))
|
||||
.setLongLabel(context.getString(R.string.epoch_converter))
|
||||
.setIntent(
|
||||
Intent(
|
||||
Intent.ACTION_VIEW,
|
||||
Uri.parse("app://com.sadellie.unitto/$epochRoute")
|
||||
)
|
||||
)
|
||||
.build()
|
||||
ShortcutManagerCompat.pushDynamicShortcut(context, shortcut)
|
||||
|
||||
navigate(epochRoute)
|
||||
}
|
||||
|
||||
fun NavGraphBuilder.epochScreen(
|
||||
navigateUpAction: () -> Unit
|
||||
) {
|
||||
composable(epochRoute) {
|
||||
composable(
|
||||
route = epochRoute,
|
||||
deepLinks = listOf(
|
||||
navDeepLink { uriPattern = "app://com.sadellie.unitto/$epochRoute" }
|
||||
)
|
||||
) {
|
||||
EpochRoute(
|
||||
navigateUpAction = navigateUpAction
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user