Satellite tracker and pass predictor for Android, inspired by Gpredict
Kotlin amsatcelestrakgpsham-radiohamlibhamradiokotlinnasaradiosatellitesatellite-datasatellite-positionsatellite-predictionsatellitessatnogssdrspacespacexstarlink
Added initial code for possible future deeplink nav support
Arty Bishopec1a55c93dbb
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xmlindex 5d6b6ccc..e8a8cf54 100644--- a/app/src/main/AndroidManifest.xml+++ b/app/src/main/AndroidManifest.xml@@ -29,6 +29,14 @@<action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter>+<!-- <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:host="github.com" />-->+<!-- <data android:pathPattern="/rt-bishop/Look4Sat/passes.*" />-->+<!-- </intent-filter>--></activity><meta-datadiff --git a/app/src/main/java/com/rtbishop/look4sat/MainScreen.kt b/app/src/main/java/com/rtbishop/look4sat/MainScreen.ktindex 2a2d8303..cab6e3c9 100644--- a/app/src/main/java/com/rtbishop/look4sat/MainScreen.kt+++ b/app/src/main/java/com/rtbishop/look4sat/MainScreen.kt@@ -25,6 +25,10 @@ import androidx.compose.animation.core.rememberInfiniteTransitionimport androidx.compose.animation.core.tweenimport androidx.compose.animation.fadeInimport androidx.compose.animation.fadeOut+import androidx.compose.animation.scaleIn+import androidx.compose.animation.scaleOut+import androidx.compose.animation.slideInHorizontally+import androidx.compose.animation.slideOutHorizontallyimport androidx.compose.animation.togetherWithimport androidx.compose.foundation.backgroundimport androidx.compose.foundation.clickable@@ -32,6 +36,7 @@ import androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.size@@ -39,11 +44,13 @@ import androidx.compose.foundation.layout.widthimport androidx.compose.foundation.shape.CircleShapeimport androidx.compose.material3.Iconimport androidx.compose.material3.MaterialTheme+import androidx.compose.material3.Scaffoldimport androidx.compose.material3.Textimport androidx.compose.material3.adaptive.navigationsuite.NavigationSuiteDefaultsimport androidx.compose.material3.adaptive.navigationsuite.NavigationSuiteScaffoldimport androidx.compose.material3.adaptive.navigationsuite.NavigationSuiteTypeimport androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffectimport androidx.compose.runtime.getValueimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifier@@ -62,6 +69,8 @@ import androidx.navigation3.runtime.rememberNavBackStackimport androidx.navigation3.runtime.rememberSaveableStateHolderNavEntryDecoratorimport androidx.navigation3.ui.NavDisplayimport com.rtbishop.look4sat.core.domain.repository.IContainerProvider+import com.rtbishop.look4sat.core.presentation.DeeplinkResolver+import com.rtbishop.look4sat.core.presentation.RadarDestinationimport com.rtbishop.look4sat.core.presentation.Screenimport com.rtbishop.look4sat.core.presentation.hasEnoughHeightimport com.rtbishop.look4sat.core.presentation.hasEnoughWidth@@ -72,13 +81,47 @@ import com.rtbishop.look4sat.feature.satellites.SatellitesDestinationimport com.rtbishop.look4sat.feature.settings.SettingsDestination@Composable-fun MainScreen() {+fun NavRoot(deeplink: String? = null) {+ val rootBackStack = rememberNavBackStack(Screen.Passes)+ val deeplinkResolver = DeeplinkResolver()+ LaunchedEffect(deeplink) {+ deeplink?.let {+ val destination = deeplinkResolver.resolve(it) // rootBackStack.clear()+ rootBackStack.add(destination)+ }+ }+ val navigateBack: () -> Unit = { rootBackStack.removeLastOrNull() }+ val slideInTransition = slideInHorizontally(initialOffsetX = { it }) togetherWith scaleOut(targetScale = 0.9f)+ val slideOutTransition = scaleIn(initialScale = 0.9f) togetherWith slideOutHorizontally(targetOffsetX = { it })+ NavDisplay(+ modifier = Modifier.fillMaxSize(),+ backStack = rootBackStack,+ onBack = navigateBack,+ transitionSpec = { slideInTransition },+ popTransitionSpec = { slideOutTransition },+ predictivePopTransitionSpec = { slideOutTransition },+ entryDecorators = listOf(+ rememberSaveableStateHolderNavEntryDecorator(), // Required for saving Compose state per entry+ rememberViewModelStoreNavEntryDecorator() // Required for ViewModel scoping per entry+ ),+ entryProvider = entryProvider {+ entry<Screen.Passes> { MainScreen(navigateToRadar = { rootBackStack.add(RadarDestination) }) }+ entry<RadarDestination> {+ Scaffold { innerPadding ->+ RadarDestination(navigateUp = navigateBack)+ innerPadding.calculateTopPadding()+ }+ }+ }+ )+}++@Composable+fun MainScreen(navigateToRadar: () -> Unit = {}) {val backStack = rememberNavBackStack(Screen.Passes)val currentKey = backStack.lastOrNull()- val navigateBack: () -> Unit = { if (backStack.size > 1) backStack.removeAt(backStack.size - 1) }+ val navigateBack: () -> Unit = { backStack.removeLastOrNull() }val fadeTransition = fadeIn(animationSpec = tween(350)) togetherWith fadeOut(animationSpec = tween(350))-// val slideInTransition = slideInHorizontally(initialOffsetX = { it }) togetherWith scaleOut(targetScale = 0.9f)-// val slideOutTransition = scaleIn(initialScale = 0.9f) togetherWith slideOutHorizontally(targetOffsetX = { it })val navItems = listOf(Screen.Satellites, Screen.Passes, Screen.Radar, Screen.Map, Screen.Settings)val context = LocalContext.current@@ -139,6 +182,7 @@ fun MainScreen() {PassesDestination { catNum, aosTime ->container.satelliteRepo.selectPass(catNum, aosTime)backStack.add(Screen.Radar)+// navigateToRadar()}}entry<Screen.Radar> {diff --git a/core/presentation/src/main/java/com/rtbishop/look4sat/core/presentation/Navigation.kt b/core/presentation/src/main/java/com/rtbishop/look4sat/core/presentation/Navigation.ktindex bf4349d8..b0ff0c1b 100644--- a/core/presentation/src/main/java/com/rtbishop/look4sat/core/presentation/Navigation.kt+++ b/core/presentation/src/main/java/com/rtbishop/look4sat/core/presentation/Navigation.kt@@ -38,3 +38,33 @@ sealed class Screen(val iconResId: Int, val titleResId: Int) : NavKey {@Serializabledata object Settings : Screen(R.drawable.ic_settings, R.string.nav_prefs)}++@Serializable+data object RadarDestination : NavKey++interface IDeeplinkMatcher {+ fun match(deeplink: String): NavKey?+}++object PassDetailsMatcher : IDeeplinkMatcher {+ val passDetailsRegex = """https://github.com/rt-bishop/Look4Sat/passes/(.*)""".toRegex()++ override fun match(deeplink: String): NavKey? {+ val passMatch = passDetailsRegex.find(deeplink)+ passMatch?.let { match ->+ val passId = match.groupValues[1]+ if (passId.isNotEmpty()) return RadarDestination+ }+ return null+ }+}++class DeeplinkResolver(private val fallbackDestination: NavKey = Screen.Passes) {++ private val matchers: List<IDeeplinkMatcher> = listOf(PassDetailsMatcher)++ fun resolve(deeplink: String): NavKey {+ matchers.forEach { it.match(deeplink)?.let { match -> return match } }+ return fallbackDestination+ }+}diff --git a/core/presentation/src/test/java/com/rtbishop/look4sat/core/presentation/DeeplinkResolverTest.kt b/core/presentation/src/test/java/com/rtbishop/look4sat/core/presentation/DeeplinkResolverTest.ktnew file mode 100644index 00000000..9c2738ae--- /dev/null+++ b/core/presentation/src/test/java/com/rtbishop/look4sat/core/presentation/DeeplinkResolverTest.kt@@ -0,0 +1,39 @@+/*+ * Look4Sat. Amateur radio satellite tracker and pass predictor.+ * Copyright (C) 2019-2026 Arty Bishop and contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */+package com.rtbishop.look4sat.core.presentation++import org.junit.Test++class DeeplinkResolverTest {++ @Test+ fun returnsDefaultDestination() {+ val deeplinkResolver = DeeplinkResolver()+ val result = deeplinkResolver.resolve("/deeplink")+ assert(result == Screen.Passes)+ }++ @Test+ fun returnsRadarDestination() {+ val passId = "some-pass-id"+ val passDeeplink = "https://github.com/rt-bishop/Look4Sat/passes/$passId"+ val deeplinkResolver = DeeplinkResolver()+ val result = deeplinkResolver.resolve(passDeeplink)+ assert(result == RadarDestination)+ }+}