Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Bug/#1512 - Storage location on API29 and above#1571

Merged
monsieurtanuki merged 26 commits intoosmdroid:masterfrom
cbalster:bug/#1512
Apr 30, 2020
Merged

Bug/#1512 - Storage location on API29 and above#1571
monsieurtanuki merged 26 commits intoosmdroid:masterfrom
cbalster:bug/#1512

Conversation

@cbalster
Copy link
Copy Markdown
Contributor

@cbalster cbalster commented Apr 28, 2020

#1512
Basically a complete overhaul of StorageUtils:

  • lot's of refactoring
  • < API19: Behaviour is untouched except fixing a minor bug, that lead to non-writable locations returned as writable
  • 19 <= API < 29: legacy behaviour + additional storage locations when a context is provided
  • >API29: Only new behviour with fallback for targetSdk < API29 apps on >API29 devices.
  • replacing references to now deprecated methods to the new alternatives.

On API29 and above a valid storage location can only be retrieved when a context is available. Therefore a hacky workaround has been implemented in MapView. This should cover most naive usages of the library.
In more advanced cases (e.g. own MapTileModuleProviderBase implementations) this can still lead to problems if the storage detection via getOsmdroidBasePath(Context) / getOsmdroidTileCache(Context) was not triggered before with a context or a valid directory was set via setOsmdroidBasePath() / setOsmdroidTileCache().
This is not easily fixed due to the Configuration being a static singleton. This should probably be changed in a future release since it also causes lots of other issues (testing, hard to reason about code), but will mean a breaking change.

cbalster added 26 commits April 19, 2020 12:49
no functional changes
no functional changes
no functional changes
Also sanity check if detected path is really available
API should be more consistent in the future. Deprecate old methods.
primarySharedStorage is already included in getStorageList()
…etection API level dependent

- for API<19 legacy behaviour is kept
- for 19=<API<20 legacy behaviour is kept but additional locations
  are returned when context is available
- for API0>=29 the new method is used. Compatibility for the case
  where targetAPI<29 is retained.

- improved javadoc and method naming
Call getOsmdroidBasePath(Context) on MapView construction to trigger
optimal default detection to make sure all following calls without
context receive the best or any (on >API29) storage location.
@monsieurtanuki monsieurtanuki self-requested a review April 30, 2020 13:14
Copy link
Copy Markdown
Collaborator

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbalster See my comments: if you don't feel like implementing the (small) changes just tell me, I won't fight about it.

@monsieurtanuki monsieurtanuki merged commit d21cb8e into osmdroid:master Apr 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants