From f16760728b0a29b6472cd255748d1c6c82006968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E5=88=BA=E8=9E=88?= Date: Mon, 16 Dec 2024 21:20:16 +0800 Subject: [PATCH] feat: add qsTile intent (#823) --- app/src/main/AndroidManifest.xml | 3 ++ .../kotlin/li/songe/gkd/ui/home/HomePage.kt | 38 ++++++++++++++----- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index beb17782f..b6a231beb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -77,6 +77,9 @@ + + + { @@ -75,6 +76,25 @@ fun HomePage() { navController.toDestinationsNavigator().navigate(SnapshotPageDestination) } } + } else if (uri != null && intent.getStringExtra("source") == OpenFileActivity::class.qualifiedName) { + vm.viewModelScope.launchTry(Dispatchers.IO) { + toast("加载导入...") + vm.tabFlow.value = subsPage.navItem + importData(uri) + } + } else if (intent.action == TileService.ACTION_QS_TILE_PREFERENCES) { + val qsTileCpt = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + intent.getParcelableExtra(Intent.EXTRA_COMPONENT_NAME, ComponentName::class.java) + } else { + @Suppress("DEPRECATION") + intent.getParcelableExtra(Intent.EXTRA_COMPONENT_NAME) as ComponentName? + } ?: return@LaunchedEffect + delay(200) + if (qsTileCpt == HttpTileService::class.componentName || qsTileCpt == FloatingTileService::class.componentName) { + navController.toDestinationsNavigator().navigate(AdvancedPageDestination) + } else if (qsTileCpt == SnapshotTileService::class.componentName) { + navController.toDestinationsNavigator().navigate(SnapshotPageDestination) + } } })