mirror of
https://github.com/rt-bishop/Look4Sat.git
synced 2026-10-02 03:15:37 +00:00
v4.4.3 - Added required tweaks to support Android 17 (API 37)
This commit is contained in:
1 parent
976fdfd949
commit
b17ea2d918
18 files changed
+135
-69
No files matched your search
@@ -32,6 +32,7 @@ import com.rtbishop.look4sat.core.domain.repository.ISettingsRepo
|
||||
import com.rtbishop.look4sat.core.domain.utility.clipLat
|
||||
import com.rtbishop.look4sat.core.domain.utility.clipLon
|
||||
import com.rtbishop.look4sat.core.domain.utility.positionToQth
|
||||
import com.rtbishop.look4sat.core.domain.utility.toMapGeoPos
|
||||
import com.rtbishop.look4sat.core.domain.utility.toDegrees
|
||||
import com.rtbishop.look4sat.core.domain.utility.toTimerString
|
||||
import com.rtbishop.look4sat.core.presentation.getDefaultPass
|
||||
@@ -166,9 +167,7 @@ class MapViewModel(
|
||||
var localSelectedPos: OrbitalPos? = null
|
||||
for (satellite in chunk) {
|
||||
val satPos = satelliteRepo.getPosition(satellite, pos, date.time)
|
||||
val osmLat = clipLat(satPos.latitude.toDegrees())
|
||||
val osmLon = clipLon(satPos.longitude.toDegrees())
|
||||
localPositions.add(satellite to GeoPos(osmLat, osmLon))
|
||||
localPositions.add(satellite to satPos.toMapGeoPos())
|
||||
if (satellite === selected) {
|
||||
localSelectedPos = satPos
|
||||
}
|
||||
@@ -242,9 +241,7 @@ class MapViewModel(
|
||||
}
|
||||
val azimuth = satPos.azimuth.toDegrees()
|
||||
val elevation = satPos.elevation.toDegrees()
|
||||
val osmLat = clipLat(satPos.latitude.toDegrees())
|
||||
val osmLon = clipLon(satPos.longitude.toDegrees())
|
||||
val osmPos = GeoPos(osmLat, osmLon)
|
||||
val osmPos = satPos.toMapGeoPos()
|
||||
val qthLoc = positionToQth(osmPos.latitude, osmPos.longitude) ?: "-- --"
|
||||
val velocity = satPos.getOrbitalVelocity()
|
||||
val phase = satPos.phase.toDegrees()
|
||||
@@ -274,18 +271,16 @@ class MapViewModel(
|
||||
val endDate = Date(date.time + (orbitalObject.data.orbitalPeriod * 2.4 * 60000L).toLong())
|
||||
var oldLongitude = 0.0
|
||||
satelliteRepo.getTrack(orbitalObject, pos, date.time, endDate.time).forEach { satPos ->
|
||||
val osmLat = clipLat(satPos.latitude.toDegrees())
|
||||
val osmLon = clipLon(satPos.longitude.toDegrees())
|
||||
val currentPosition = GeoPos(osmLat, osmLon)
|
||||
val currentPosition = satPos.toMapGeoPos()
|
||||
if (oldLongitude < -170.0 && currentPosition.longitude > 170.0) {
|
||||
// adding left terminal position
|
||||
currentTrack.add(GeoPos(osmLat, -180.0))
|
||||
currentTrack.add(GeoPos(currentPosition.latitude, -180.0))
|
||||
val finishedTrack = mutableListOf<GeoPos>().apply { addAll(currentTrack) }
|
||||
satTracks.add(finishedTrack)
|
||||
currentTrack.clear()
|
||||
} else if (oldLongitude > 170.0 && currentPosition.longitude < -170.0) {
|
||||
// adding right terminal position
|
||||
currentTrack.add(GeoPos(osmLat, 180.0))
|
||||
currentTrack.add(GeoPos(currentPosition.latitude, 180.0))
|
||||
val finishedTrack = mutableListOf<GeoPos>().apply { addAll(currentTrack) }
|
||||
satTracks.add(finishedTrack)
|
||||
currentTrack.clear()
|
||||
|
||||
+21
-5
@@ -91,7 +91,8 @@ private fun SettingsScreen(uiState: SettingsState, onAction: (SettingsAction) ->
|
||||
val dialogs = rememberDialogVisibility()
|
||||
val permissions = rememberSettingsPermissions(
|
||||
sendAction = onAction,
|
||||
onBluetoothGranted = { dialogs.bluetooth = true }
|
||||
onBluetoothGranted = { dialogs.bluetooth = true },
|
||||
onNetworkGranted = { dialogs.network = true }
|
||||
)
|
||||
|
||||
// Dialogs
|
||||
@@ -273,7 +274,7 @@ private fun SettingsScreen(uiState: SettingsState, onAction: (SettingsAction) ->
|
||||
}
|
||||
item(span = { GridItemSpan(maxLineSpan) }) {
|
||||
OutputCard(
|
||||
onNetworkClick = { dialogs.network = true },
|
||||
onNetworkClick = permissions.launchNetwork,
|
||||
onBluetoothClick = permissions.launchBluetooth,
|
||||
onRadioControlClick = { dialogs.radioControl = true }
|
||||
)
|
||||
@@ -651,13 +652,15 @@ private class SettingsPermissions(
|
||||
val launchLocation: () -> Unit,
|
||||
val launchTleImport: () -> Unit,
|
||||
val launchTransceiverImport: () -> Unit,
|
||||
val launchBluetooth: () -> Unit
|
||||
val launchBluetooth: () -> Unit,
|
||||
val launchNetwork: () -> Unit
|
||||
)
|
||||
|
||||
@Composable
|
||||
private fun rememberSettingsPermissions(
|
||||
sendAction: (SettingsAction) -> Unit,
|
||||
onBluetoothGranted: () -> Unit
|
||||
onBluetoothGranted: () -> Unit,
|
||||
onNetworkGranted: () -> Unit
|
||||
): SettingsPermissions {
|
||||
val locationError = stringResource(R.string.prefs_loc_gps_error)
|
||||
val locationRequest = rememberLauncherForActivityResult(
|
||||
@@ -685,6 +688,12 @@ private fun rememberSettingsPermissions(
|
||||
else sendAction(SettingsAction.ShowToast(bluetoothError))
|
||||
}
|
||||
|
||||
val networkError = stringResource(R.string.prefs_net_perm_error)
|
||||
val networkRequest = rememberLauncherForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
|
||||
if (granted) onNetworkGranted()
|
||||
else sendAction(SettingsAction.ShowToast(networkError))
|
||||
}
|
||||
|
||||
return remember {
|
||||
SettingsPermissions(
|
||||
launchLocation = {
|
||||
@@ -694,7 +703,14 @@ private fun rememberSettingsPermissions(
|
||||
},
|
||||
launchTleImport = { tleRequest.launch("*/*") },
|
||||
launchTransceiverImport = { transceiversRequest.launch("*/*") },
|
||||
launchBluetooth = { bluetoothRequest.launch(bluetoothPerm) }
|
||||
launchBluetooth = { bluetoothRequest.launch(bluetoothPerm) },
|
||||
launchNetwork = {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.CINNAMON_BUN) {
|
||||
networkRequest.launch(Manifest.permission.ACCESS_LOCAL_NETWORK)
|
||||
} else {
|
||||
onNetworkGranted()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user