Repository navigation
Android: Use cache folder/subfolder to cache SVG files - #1643
Conversation
|
|
||
| public static final Config MONO_ALPHA_BITMAP = Config.ALPHA_8; | ||
|
|
||
| public final String LibraryFolderName = "mapsforge"; |
There was a problem hiding this comment.
@Sublimis Please use a variable that starts with lowercase letters.
There was a problem hiding this comment.
Hm, this is not a variable but a (non-static) constant...?
In fact, maybe this should be put into the Constants class in some way.
There was a problem hiding this comment.
@Sublimis This is not declared as static. Then it should be LIBRARY_FOLDER_NAME.
There was a problem hiding this comment.
What's the final suggestion then? Make it static, uppercase, and include in Constants, or something else?
There was a problem hiding this comment.
@Sublimis If it is a constant then it should be like the other constants, static with uppercase letters.
The location is not important. It can stay here, as it is not a global constant.
There was a problem hiding this comment.
@Sublimis We could put something in Constants when it is used outside its class.
There was a problem hiding this comment.
When the time comes for someone to use such a constant, no one will remember that there is already one buried in the android svg cache 🥲
There was a problem hiding this comment.
@Sublimis Does it matter?
It should not be a constant, but a variable, as other users may prefer a different folder name.
Apps may want to store there svg, png, tiles, etc. Each app may want different folder names.
There was a problem hiding this comment.
If by "other users" you mean other applications (not other classes in the library), then you seem to be confusing the purpose of this constant. If an application wants to change the cache folder that the library uses, it already has the means to do so, like you noticed below.
It matters for future maintainer. It could be you, me, or someone else. It's strange that something like this doesn't already exist, for any purpose. Like for example when we were naming hill shading threads we hard-coded "Mapsforge" into the name, when it would have been more elegant to have some global "library name" constant to pull from.
Also note the unfortunate naming of methods there. E.g. openFileInput() uses the folder set by setSvgCacheDir(), so it's not a general-purpose method.
But you know, whatever, as usual, these kinds of discussions take up too much time 😃
There was a problem hiding this comment.
Also note the unfortunate naming of methods there. E.g. openFileInput() uses the folder set by setSvgCacheDir(), so it's not a general-purpose method.
Mapsforge has a very long history of too many years and many developers.
It is difficult to rename the whole public API without serious reason. 🙂
|
@Sublimis Note that there is the |
That doesn't affect what was done here at all. |
|
While at this, is there still a purpose for this folder? https://github.com/mapsforge/mapsforge/tree/a2a59a6d313a33345182cc50e41882415f573067/mapsforge-themes/icons |
It contains the collection of the original svg icons. |
|
@Sublimis My only comment here is to rename the constant, then we can merge it. |
|
Two commits, the previous one is just to show you what we had in mind: package org.mapsforge.core.util;
public final class Constants {
/**
* Display-friendly, human readable name of the library.
*/
public static final String LIBRARY_DISPLAY_NAME = "Mapsforge";
/**
* Filename-friendly, machine readable name of the library.
* To be used when there's a need to name a file, folder, or similar.
*/
public static final String LIBRARY_FILE_NAME = "mapsforge";
/**
* Maximum amount of memory that the Java virtual machine will attempt to use, in megabytes.
*/
public static final long MAX_MEMORY_MB = Runtime.getRuntime().maxMemory() / 1000 / 1000;
private Constants() {
throw new IllegalStateException();
}
}It's a little strange that the library doesn't "know" its name all these years 🙂 |
|
@Sublimis There is no perfect library! I implemented map rotation only recently, after so many years. If it is so important, we can move the constants in the |
|
It's not important, it's just practical and aesthetic 🙂 We can leave this for the future if it's easier that way. |
|
@Sublimis Thanks! |
On Android there is an elegant concept of a "cache folder" which should be used to cache SVG files. No application wants thousands of files in the root of its private folder, which is currently done. Even in the cache folder we create a separate subfolder for that.