Add intent filter to deep link settings pages
This commit is contained in:
parent
2c07895386
commit
84a62ae8e0
@ -65,6 +65,15 @@
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.mm20.launcher2.ui.launcher.LauncherActivity" />
|
||||
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="https"/>
|
||||
<data android:path="/in-app"/>
|
||||
<data android:host="kvaesitso.mm20.de"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".launcher.sheets.BindAndConfigureAppWidgetActivity" />
|
||||
|
||||
@ -83,18 +83,26 @@ class SettingsActivity : BaseActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
|
||||
val newRoute = intent?.getStringExtra(EXTRA_ROUTE)
|
||||
val newRoute = getStartRoute(intent)
|
||||
route = newRoute
|
||||
|
||||
setContent {
|
||||
val navController = rememberNavController()
|
||||
|
||||
LaunchedEffect(route) {
|
||||
try {
|
||||
navController.navigate(route ?: "settings") {
|
||||
popUpTo("settings") {
|
||||
inclusive = true
|
||||
}
|
||||
}
|
||||
} catch (e: IllegalArgumentException) {
|
||||
navController.navigate("settings") {
|
||||
popUpTo("settings") {
|
||||
inclusive = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val wallpaperColors by wallpaperColorsAsState()
|
||||
CompositionLocalProvider(
|
||||
@ -288,10 +296,18 @@ class SettingsActivity : BaseActivity() {
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
super.onNewIntent(intent)
|
||||
val newRoute = intent.getStringExtra(EXTRA_ROUTE)
|
||||
val newRoute = getStartRoute(intent)
|
||||
route = newRoute
|
||||
}
|
||||
|
||||
private fun getStartRoute(intent: Intent): String? {
|
||||
if (intent.data?.host == "kvaesitso.mm20.de") {
|
||||
return intent.data?.getQueryParameter("route")
|
||||
} else {
|
||||
return intent.getStringExtra(EXTRA_ROUTE)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val EXTRA_ROUTE = "de.mm20.launcher2.settings.ROUTE"
|
||||
const val ROUTE_WEATHER_INTEGRATION = "settings/integrations/weather"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user