@@ -55,6 +55,7 @@ import androidx.compose.ui.graphics.Color
5555import androidx.compose.ui.Alignment
5656import androidx.compose.ui.Modifier
5757import androidx.compose.ui.platform.LocalConfiguration
58+ import androidx.compose.ui.platform.LocalContext
5859import androidx.compose.ui.res.stringResource
5960import androidx.compose.ui.text.style.TextOverflow
6061import androidx.compose.ui.unit.dp
@@ -82,6 +83,7 @@ import com.anatdx.icepatch.ui.theme.rememberBackgroundConfig
8283import com.anatdx.icepatch.ui.viewmodel.SuperUserViewModel
8384import com.ramcosta.composedestinations.generated.destinations.InstallModeSelectScreenDestination
8485import com.ramcosta.composedestinations.generated.destinations.InstallScreenDestination
86+ import com.ramcosta.composedestinations.generated.destinations.ExecuteAPMActionScreenDestination
8587import com.anatdx.icepatch.ui.screen.MODULE_TYPE
8688import com.anatdx.icepatch.util.KpmInfo
8789import com.anatdx.icepatch.util.KpmInfoReader
@@ -92,6 +94,7 @@ import androidx.lifecycle.lifecycleScope
9294import kotlinx.coroutines.launch
9395import me.zhanghai.android.appiconloader.coil.AppIconFetcher
9496import me.zhanghai.android.appiconloader.coil.AppIconKeyer
97+ import androidx.core.net.toUri
9598
9699class MainActivity : AppCompatActivity () {
97100
@@ -239,6 +242,8 @@ class MainActivity : AppCompatActivity() {
239242 }
240243 }
241244
245+ ShortcutIntentHandler (currentIntent = currentIntent, navigator = navigator)
246+
242247 LaunchedEffect (Unit ) {
243248 if (SuperUserViewModel .apps.isEmpty()) {
244249 SuperUserViewModel ().fetchAppList()
@@ -397,6 +402,42 @@ class MainActivity : AppCompatActivity() {
397402 }
398403}
399404
405+ @Composable
406+ private fun ShortcutIntentHandler (
407+ currentIntent : Intent ? ,
408+ navigator : com.ramcosta.composedestinations.navigation.DestinationsNavigator
409+ ) {
410+ val context = LocalContext .current
411+ var handled by remember(currentIntent) { mutableStateOf(false ) }
412+
413+ LaunchedEffect (currentIntent, handled) {
414+ if (handled) return @LaunchedEffect
415+ val intent = currentIntent ? : return @LaunchedEffect
416+ when (intent.getStringExtra(" shortcut_type" )) {
417+ " module_action" -> {
418+ val moduleId = intent.getStringExtra(" module_id" ) ? : return @LaunchedEffect
419+ navigator.navigate(ExecuteAPMActionScreenDestination (moduleId)) {
420+ launchSingleTop = true
421+ }
422+ handled = true
423+ }
424+
425+ " module_webui" -> {
426+ val moduleId = intent.getStringExtra(" module_id" ) ? : return @LaunchedEffect
427+ val moduleName = intent.getStringExtra(" module_name" ) ? : moduleId
428+ val webIntent = Intent (context, WebUIActivity ::class .java)
429+ .setData(" apatch://webui/$moduleId " .toUri())
430+ .putExtra(" id" , moduleId)
431+ .putExtra(" name" , moduleName)
432+ .putExtra(" from_webui_shortcut" , true )
433+ .addFlags(Intent .FLAG_ACTIVITY_NEW_TASK or Intent .FLAG_ACTIVITY_CLEAR_TASK )
434+ context.startActivity(webIntent)
435+ handled = true
436+ }
437+ }
438+ }
439+ }
440+
400441
401442@Composable
402443private fun BottomBar (navController : NavHostController , visibleDestinations : Set <BottomBarDestination >) {
0 commit comments