kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
refactor: move showDownloadButton logic into loadOnlineTileSourceBase()
rodzic
998aa6fcc4
commit
674d56cb1b
|
@ -435,7 +435,10 @@ fun MapView(model: UIViewModel = viewModel()) {
|
||||||
fun loadOnlineTileSourceBase(): ITileSource {
|
fun loadOnlineTileSourceBase(): ITileSource {
|
||||||
val id = mPrefs.getInt(mapStyleId, 1)
|
val id = mPrefs.getInt(mapStyleId, 1)
|
||||||
debug("mapStyleId from prefs: $id")
|
debug("mapStyleId from prefs: $id")
|
||||||
return CustomTileSource.getTileSource(id)
|
return CustomTileSource.getTileSource(id).also {
|
||||||
|
showDownloadButton =
|
||||||
|
if (it is OnlineTileSourceBase) it.tileSourcePolicy.acceptsBulkDownload() else false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -495,8 +498,6 @@ fun MapView(model: UIViewModel = viewModel()) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
showDownloadButton =
|
|
||||||
(tileProvider.tileSource as OnlineTileSourceBase).tileSourcePolicy.acceptsBulkDownload()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun startDownload() {
|
fun startDownload() {
|
||||||
|
@ -531,8 +532,6 @@ fun MapView(model: UIViewModel = viewModel()) {
|
||||||
mPrefs.edit().putInt(mapStyleId, which).apply()
|
mPrefs.edit().putInt(mapStyleId, which).apply()
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
map.setTileSource(loadOnlineTileSourceBase())
|
map.setTileSource(loadOnlineTileSourceBase())
|
||||||
showDownloadButton =
|
|
||||||
(map.tileProvider.tileSource as OnlineTileSourceBase).tileSourcePolicy.acceptsBulkDownload()
|
|
||||||
}
|
}
|
||||||
val dialog = builder.create()
|
val dialog = builder.create()
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
@ -553,7 +552,6 @@ fun MapView(model: UIViewModel = viewModel()) {
|
||||||
0 -> showCurrentCacheInfo = true
|
0 -> showCurrentCacheInfo = true
|
||||||
1 -> {
|
1 -> {
|
||||||
generateBoxOverlay(zoomLevelHighest)
|
generateBoxOverlay(zoomLevelHighest)
|
||||||
showDownloadButton = false
|
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,7 +563,7 @@ fun MapView(model: UIViewModel = viewModel()) {
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
floatingActionButton = {
|
floatingActionButton = {
|
||||||
DownloadButton(showDownloadButton) { showCacheManagerDialog() }
|
DownloadButton(showDownloadButton && downloadRegionBoundingBox == null) { showCacheManagerDialog() }
|
||||||
},
|
},
|
||||||
) { innerPadding ->
|
) { innerPadding ->
|
||||||
Box(
|
Box(
|
||||||
|
@ -592,7 +590,6 @@ fun MapView(model: UIViewModel = viewModel()) {
|
||||||
cacheEstimate = cacheEstimate,
|
cacheEstimate = cacheEstimate,
|
||||||
onExecuteJob = { startDownload() },
|
onExecuteJob = { startDownload() },
|
||||||
onCancelDownload = {
|
onCancelDownload = {
|
||||||
cacheEstimate = ""
|
|
||||||
downloadRegionBoundingBox = null
|
downloadRegionBoundingBox = null
|
||||||
defaultMapSettings()
|
defaultMapSettings()
|
||||||
},
|
},
|
||||||
|
|
Ładowanie…
Reference in New Issue