mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
add provideLocation service start/stop
This commit is contained in:
parent
94ad6cf391
commit
2441e1bada
4 changed files with 60 additions and 57 deletions
|
|
@ -179,8 +179,7 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
)
|
||||
)
|
||||
|
||||
private
|
||||
val tabsAdapter = object : FragmentStateAdapter(this) {
|
||||
private val tabsAdapter = object : FragmentStateAdapter(this) {
|
||||
|
||||
override fun getItemCount(): Int = tabInfos.size
|
||||
|
||||
|
|
@ -200,7 +199,6 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
updateBluetoothEnabled()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Don't tell our app we have bluetooth until we have bluetooth _and_ location access
|
||||
*/
|
||||
|
|
@ -213,7 +211,6 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
Manifest.permission.BLUETOOTH_ADMIN
|
||||
)
|
||||
|
||||
|
||||
if (getMissingPermissions(requiredPerms).isEmpty()) {
|
||||
/// ask the adapter if we have access
|
||||
bluetoothAdapter?.apply {
|
||||
|
|
@ -532,7 +529,6 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
super.onNewIntent(intent)
|
||||
handleIntent(intent)
|
||||
|
|
@ -659,8 +655,7 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
} */
|
||||
}
|
||||
|
||||
private
|
||||
var receiverRegistered = false
|
||||
private var receiverRegistered = false
|
||||
|
||||
private fun registerMeshReceiver() {
|
||||
unregisterMeshReceiver()
|
||||
|
|
@ -680,7 +675,6 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// Pull our latest node db from the device
|
||||
private fun updateNodesFromDevice() {
|
||||
model.meshService?.let { service ->
|
||||
|
|
@ -724,7 +718,6 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
showSettingsPage() // Default to the settings page in this case
|
||||
}
|
||||
|
||||
|
||||
/// Called when we gain/lose a connection to our mesh radio
|
||||
private fun onMeshConnectionChanged(connected: MeshService.ConnectionState) {
|
||||
debug("connchange ${model.isConnected.value} -> $connected")
|
||||
|
|
@ -773,6 +766,9 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
warn("Abandoning connect $ex, because we probably just lost device connection")
|
||||
model.isConnected.value = oldConnection
|
||||
}
|
||||
// if provideLocation enabled: Start providing location (from phone GPS) to mesh
|
||||
if (model.provideLocation.value == true && (oldConnection != connected))
|
||||
service.setupProvideLocation()
|
||||
}
|
||||
} else {
|
||||
// For other connection states, just slam them in
|
||||
|
|
@ -842,8 +838,7 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
}
|
||||
}
|
||||
|
||||
private
|
||||
val meshServiceReceiver = object : BroadcastReceiver() {
|
||||
private val meshServiceReceiver = object : BroadcastReceiver() {
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) =
|
||||
exceptionReporter {
|
||||
|
|
@ -891,8 +886,7 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
|
||||
private var connectionJob: Job? = null
|
||||
|
||||
private
|
||||
val mesh = object :
|
||||
private val mesh = object :
|
||||
ServiceClient<com.geeksville.mesh.IMeshService>({
|
||||
com.geeksville.mesh.IMeshService.Stub.asInterface(it)
|
||||
}) {
|
||||
|
|
@ -1269,4 +1263,3 @@ class MainActivity : AppCompatActivity(), Logging,
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue