mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
fix: uri handling, ci test setup (#4556)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
5061dc8262
commit
0f03492ac6
10 changed files with 115 additions and 34 deletions
|
|
@ -180,13 +180,16 @@
|
|||
</intent-filter>
|
||||
|
||||
<intent-filter android:autoVerify="true">
|
||||
<!-- The QR codes to share channel settings and contacts are shared as meshtastic URLS
|
||||
<!--
|
||||
The QR codes to share channel settings and contacts are shared as meshtastic URLS.
|
||||
We also support NFC NDEF Discovery for the same URLs.
|
||||
|
||||
an approximate example:
|
||||
https://meshtastic.org/e/YXNkZnF3ZXJhc2RmcXdlcmFzZGZxd2Vy
|
||||
https://meshtastic.org/v/#CNar9vwDEi0KCSEzZjgyOTVkNhIPV2F0ZXJmYWxsIDIg4piGGgPimaciBu2eP4KV1igJOAI
|
||||
An approximate example:
|
||||
https://meshtastic.org/e/YXNkZnF3ZXJhc2RmcXdlcmFzZGZxd2Vy
|
||||
https://meshtastic.org/v/#CNar9vwDEi0KCSEzZjgyOTVkNhIPV2F0ZXJmYWxsIDIg4piGGgPimaciBu2eP4KV1igJOAI
|
||||
-->
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
|
@ -199,18 +202,6 @@
|
|||
<data android:pathPrefix="/V/" />
|
||||
</intent-filter>
|
||||
|
||||
<!-- Support NFC NDEF Discovery for the same URLs -->
|
||||
<intent-filter>
|
||||
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:scheme="https" />
|
||||
<data android:host="meshtastic.org" />
|
||||
<data android:pathPrefix="/e/" />
|
||||
<data android:pathPrefix="/E/" />
|
||||
<data android:pathPrefix="/v/" />
|
||||
<data android:pathPrefix="/V/" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
|
||||
</intent-filter>
|
||||
|
|
|
|||
|
|
@ -104,7 +104,9 @@ class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
}
|
||||
handleIntent(intent)
|
||||
if (savedInstanceState == null) {
|
||||
handleIntent(intent)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
|
|
@ -156,6 +158,11 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
private fun handleMeshtasticUri(uri: Uri) {
|
||||
Logger.d { "Handling Meshtastic URI: $uri" }
|
||||
if (uri.toString().startsWith(DEEP_LINK_BASE_URI)) {
|
||||
model.handleNavigationDeepLink(uri)
|
||||
return
|
||||
}
|
||||
|
||||
uri.dispatchMeshtasticUri(
|
||||
onChannel = { model.setRequestChannelSet(it) },
|
||||
onContact = { model.setSharedContactRequested(it) },
|
||||
|
|
|
|||
|
|
@ -198,6 +198,13 @@ constructor(
|
|||
val unreadMessageCount =
|
||||
packetRepository.getUnreadCountTotal().map { it.coerceAtLeast(0) }.stateInWhileSubscribed(initialValue = 0)
|
||||
|
||||
private val _navigationDeepLink = MutableSharedFlow<Uri>(replay = 1)
|
||||
val navigationDeepLink = _navigationDeepLink.asSharedFlow()
|
||||
|
||||
fun handleNavigationDeepLink(uri: Uri) {
|
||||
_navigationDeepLink.tryEmit(uri)
|
||||
}
|
||||
|
||||
// hardware info about our local device (can be null)
|
||||
val myNodeInfo: StateFlow<MyNodeEntity?>
|
||||
get() = nodeDB.myNodeInfo
|
||||
|
|
|
|||
|
|
@ -166,6 +166,7 @@ enum class TopLevelDestination(val label: StringResource, val icon: ImageVector,
|
|||
@Composable
|
||||
fun MainScreen(uIViewModel: UIViewModel = hiltViewModel(), scanModel: BTScanModel = hiltViewModel()) {
|
||||
val navController = rememberNavController()
|
||||
LaunchedEffect(uIViewModel) { uIViewModel.navigationDeepLink.collectLatest { uri -> navController.navigate(uri) } }
|
||||
val connectionState by uIViewModel.connectionState.collectAsStateWithLifecycle()
|
||||
val requestChannelSet by uIViewModel.requestChannelSet.collectAsStateWithLifecycle()
|
||||
val sharedContactRequested by uIViewModel.sharedContactRequested.collectAsStateWithLifecycle()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue