Feat(Tool): Launch tool by scheme
This commit is contained in:
@@ -28,6 +28,13 @@
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="oxygen" android:host="opentool"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import top.fatweb.oxygen.toolbox.model.userdata.LaunchPageConfig
|
||||
import top.fatweb.oxygen.toolbox.model.userdata.ThemeBrandConfig
|
||||
import top.fatweb.oxygen.toolbox.monitor.NetworkMonitor
|
||||
import top.fatweb.oxygen.toolbox.monitor.TimeZoneMonitor
|
||||
import top.fatweb.oxygen.toolbox.navigation.navigateToToolView
|
||||
import top.fatweb.oxygen.toolbox.repository.userdata.UserDataRepository
|
||||
import top.fatweb.oxygen.toolbox.ui.OxygenApp
|
||||
import top.fatweb.oxygen.toolbox.ui.rememberOxygenAppState
|
||||
@@ -119,6 +120,15 @@ class MainActivity : ComponentActivity() {
|
||||
OxygenApp(appState)
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(intent.data) {
|
||||
intent.data?.run {
|
||||
val pathSegments = pathSegments
|
||||
if (pathSegments.size == 2) {
|
||||
appState.navController.navigateToToolView(pathSegments[0], pathSegments[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,8 +43,8 @@ class TimeZoneBroadcastMonitor @Inject constructor(
|
||||
val zonIdFromIntent = if (Build.VERSION.SDK_INT < VERSION_CODES.R) {
|
||||
null
|
||||
} else {
|
||||
intent.getStringExtra(Intent.EXTRA_TIMEZONE)?.let { timeZoneId ->
|
||||
val zoneId = ZoneId.of(timeZoneId, ZoneId.SHORT_IDS)
|
||||
intent.getStringExtra(Intent.EXTRA_TIMEZONE)?.run {
|
||||
val zoneId = ZoneId.of(this, ZoneId.SHORT_IDS)
|
||||
zoneId.toKotlinTimeZone()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,11 +250,11 @@ fun Scrollbar(
|
||||
draggedOffset = offset
|
||||
}
|
||||
val onDragEnd: () -> Unit = {
|
||||
dragInteraction?.let { interactionSource?.tryEmit(DragInteraction.Stop(it)) }
|
||||
dragInteraction?.run { interactionSource?.tryEmit(DragInteraction.Stop(this)) }
|
||||
draggedOffset = Offset.Unspecified
|
||||
}
|
||||
val onDragCancel: () -> Unit = {
|
||||
dragInteraction?.let { interactionSource?.tryEmit(DragInteraction.Cancel(it)) }
|
||||
dragInteraction?.run { interactionSource?.tryEmit(DragInteraction.Cancel(this)) }
|
||||
draggedOffset = Offset.Unspecified
|
||||
}
|
||||
val onDrag: (change: PointerInputChange, dragAmount: Float) -> Unit =
|
||||
|
||||
@@ -9,11 +9,8 @@ import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.safeDrawingPadding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.windowInsetsPadding
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
@@ -45,7 +42,7 @@ internal fun ToolViewRoute(
|
||||
val toolViewUiState by viewModel.toolViewUiState.collectAsStateWithLifecycle()
|
||||
|
||||
ToolViewScreen(
|
||||
modifier = modifier.safeDrawingPadding(),
|
||||
modifier = modifier,
|
||||
onBackClick = onBackClick,
|
||||
toolViewUiState = toolViewUiState
|
||||
)
|
||||
@@ -63,7 +60,7 @@ internal fun ToolViewScreen(
|
||||
val infiniteTransition = rememberInfiniteTransition(label = "infiniteTransition")
|
||||
|
||||
Box(
|
||||
modifier = modifier.windowInsetsPadding(WindowInsets(0, 0, 0, 0)),
|
||||
modifier = modifier,
|
||||
) {
|
||||
OxygenTopAppBar(
|
||||
modifier = Modifier.zIndex(100f),
|
||||
|
||||
Reference in New Issue
Block a user