mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-03 03:17:21 +00:00
fix(gps,data): official-code fixes - real GPS result callback, no fake update success (4.5.2, release pending)
Official code issues found during review (user-reported):
1. GPS "success" was shown instantly even when no fix was obtained:
- setStationPosition() always returned true (permissions exception
swallowed, async requestLocationUpdates without waiting)
- now: suspend + LocationManagerCompat.getCurrentLocation (GPS
first, network fallback), permission check upfront, 15s timeout,
success only when onLocationChanged fires; SettingsRepo takes
Context for the permission check; ViewModel waits for the real
result and shows "Unable to get location - check permission and
GPS/network signal" on failure (4 locales)
2. Data update faked success on total failure:
- updateFromRemote now counts successful sources; 0 success throws
IOException -> timestamp NOT refreshed, Toast "Update failed -
check your network" (4 locales, new IShowToast resId overload)
- OkHttp timeouts widened: connect 15s / read 20s / write 20s
Verified: check_strings OK; all modules compile.
Release intentionally NOT triggered (user: fix everything first, then
one release).
This commit is contained in:
1 parent
c09e87fa4e
commit
cda6cf8583
11 files changed
+81
-26
No files matched your search
+11
-1
@@ -164,7 +164,16 @@ class SettingsViewModel(
|
||||
// region Position helpers — consolidated from 3 near-identical functions
|
||||
|
||||
private fun setGpsPosition() {
|
||||
updatePosition(R.string.prefs_loc_gps_error) { settingsRepo.setStationPosition() }
|
||||
viewModelScope.launch {
|
||||
_uiState.update { it.copy(positionSettings = it.positionSettings.copy(isUpdating = true)) }
|
||||
val success = settingsRepo.setStationPosition()
|
||||
_uiState.update {
|
||||
it.copy(positionSettings = it.positionSettings.copy(
|
||||
isUpdating = false,
|
||||
messageResId = if (success) R.string.prefs_loc_success else R.string.prefs_loc_gps_error
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setGeoPosition(latitude: Double, longitude: Double) {
|
||||
@@ -212,6 +221,7 @@ class SettingsViewModel(
|
||||
it.copy(dataSettings = it.dataSettings.copy(isUpdating = false))
|
||||
}
|
||||
println(exception)
|
||||
showToast(R.string.prefs_data_update_failed)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user