Skip to content

Commit

Permalink
Add intent filter to deep link settings pages
Browse files Browse the repository at this point in the history
  • Loading branch information
MM2-0 committed Aug 13, 2024
1 parent 2c07895 commit 84a62ae
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
9 changes: 9 additions & 0 deletions app/ui/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,24 @@ 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) {
navController.navigate(route ?: "settings") {
popUpTo("settings") {
inclusive = true
try {
navController.navigate(route ?: "settings") {
popUpTo("settings") {
inclusive = true
}
}
} catch (e: IllegalArgumentException) {
navController.navigate("settings") {
popUpTo("settings") {
inclusive = true
}
}
}
}
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 84a62ae

Please sign in to comment.