forked from organicmaps/organicmaps
[android] Replace all tmp folders with "cache" (Like getExternalCacheDir() in API level 8).
This commit is contained in:
parent
5ac4f5ff02
commit
47eaed0f5e
6 changed files with 15 additions and 41 deletions
|
@ -26,14 +26,12 @@ extern "C"
|
|||
jstring apkPath,
|
||||
jstring storagePath,
|
||||
jstring tmpPath,
|
||||
jstring extTmpPath,
|
||||
jboolean isPro)
|
||||
{
|
||||
android::Platform::Instance().Initialize(env,
|
||||
apkPath,
|
||||
storagePath,
|
||||
tmpPath,
|
||||
extTmpPath,
|
||||
isPro);
|
||||
|
||||
LOG(LDEBUG, ("Creating android::Framework instance ..."));
|
||||
|
|
|
@ -55,7 +55,6 @@ namespace android
|
|||
jstring apkPath,
|
||||
jstring storagePath,
|
||||
jstring tmpPath,
|
||||
jstring extTmpPath,
|
||||
bool isPro)
|
||||
{
|
||||
m_resourcesDir = jni::ToNativeString(env, apkPath);
|
||||
|
@ -72,26 +71,18 @@ namespace android
|
|||
m_writableDir = m_settingsDir;
|
||||
}
|
||||
|
||||
m_localTmpPath = jni::ToNativeString(env, tmpPath);
|
||||
m_externalTmpPath = jni::ToNativeString(env, extTmpPath);
|
||||
// By default use external temporary folder
|
||||
m_tmpDir = m_externalTmpPath;
|
||||
m_tmpDir = jni::ToNativeString(env, tmpPath);
|
||||
|
||||
m_isPro = isPro;
|
||||
|
||||
LOG(LDEBUG, ("Apk path = ", m_resourcesDir));
|
||||
LOG(LDEBUG, ("Writable path = ", m_writableDir));
|
||||
LOG(LDEBUG, ("Local tmp path = ", m_localTmpPath));
|
||||
LOG(LDEBUG, ("External tmp path = ", m_externalTmpPath));
|
||||
LOG(LDEBUG, ("Temporary path = ", m_tmpDir));
|
||||
LOG(LDEBUG, ("Settings path = ", m_settingsDir));
|
||||
}
|
||||
|
||||
void Platform::OnExternalStorageStatusChanged(bool isAvailable)
|
||||
{
|
||||
if (isAvailable)
|
||||
m_tmpDir = m_externalTmpPath;
|
||||
else
|
||||
m_tmpDir = m_localTmpPath;
|
||||
}
|
||||
|
||||
string Platform::GetStoragePathPrefix() const
|
||||
|
|
|
@ -8,18 +8,12 @@ namespace android
|
|||
{
|
||||
class Platform : public ::Platform
|
||||
{
|
||||
/// External storage path for temporary files, used when external storage is available
|
||||
string m_externalTmpPath;
|
||||
/// The same but in device's internal memory (it's usually much smaller)
|
||||
string m_localTmpPath;
|
||||
|
||||
public:
|
||||
|
||||
void Initialize(JNIEnv * env,
|
||||
jstring apkPath,
|
||||
jstring storagePath,
|
||||
jstring tmpPath,
|
||||
jstring extTmpPath,
|
||||
bool isPro);
|
||||
|
||||
void OnExternalStorageStatusChanged(bool isAvailable);
|
||||
|
|
|
@ -398,7 +398,7 @@ public class DownloadResourcesActivity extends Activity implements LocationServi
|
|||
final String ext = getExtensionFromMime(resolver.getType(data));
|
||||
if (ext != null)
|
||||
{
|
||||
final String filePath = mApplication.getExtAppDirectoryPath("tmp") + "Attachment" + ext;
|
||||
final String filePath = mApplication.getTempPath() + "Attachment" + ext;
|
||||
|
||||
tmpFile = new File(filePath);
|
||||
output = new FileOutputStream(tmpFile);
|
||||
|
@ -453,18 +453,18 @@ public class DownloadResourcesActivity extends Activity implements LocationServi
|
|||
protected void onStart()
|
||||
{
|
||||
super.onStart();
|
||||
|
||||
|
||||
Statistics.INSTANCE.startActivity(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
super.onStop();
|
||||
|
||||
|
||||
Statistics.INSTANCE.stopActivity(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy()
|
||||
{
|
||||
|
|
|
@ -95,17 +95,15 @@ public class MWMApplication extends android.app.Application implements MapStorag
|
|||
}
|
||||
|
||||
final String extStoragePath = getDataStoragePath();
|
||||
final String extTmpPath = getExtAppDirectoryPath("caches");
|
||||
final String extTmpPath = getTempPath();
|
||||
|
||||
// Create folders if they don't exist
|
||||
new File(extStoragePath).mkdirs();
|
||||
new File(extTmpPath).mkdirs();
|
||||
new File(getExtAppDirectoryPath("tmp")).mkdir();
|
||||
|
||||
// init native framework
|
||||
nativeInit(getApkPath(),
|
||||
extStoragePath,
|
||||
getTmpPath(),
|
||||
extTmpPath,
|
||||
m_isProVersion);
|
||||
|
||||
|
@ -168,6 +166,12 @@ public class MWMApplication extends android.app.Application implements MapStorag
|
|||
return Environment.getExternalStorageDirectory().getAbsolutePath() + "/MapsWithMe/";
|
||||
}
|
||||
|
||||
public String getTempPath()
|
||||
{
|
||||
// Can't use getExternalCacheDir() here because of API level = 7.
|
||||
return getExtAppDirectoryPath("cache");
|
||||
}
|
||||
|
||||
public String getExtAppDirectoryPath(String folder)
|
||||
{
|
||||
final String storagePath = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
|
@ -187,18 +191,6 @@ public class MWMApplication extends android.app.Application implements MapStorag
|
|||
return m_proVersionURL;
|
||||
}
|
||||
|
||||
private String getTmpPath()
|
||||
{
|
||||
return getCacheDir().getAbsolutePath() + "/";
|
||||
}
|
||||
|
||||
/*
|
||||
private String getSettingsPath()
|
||||
{
|
||||
return getFilesDir().getAbsolutePath() + "/";
|
||||
}
|
||||
*/
|
||||
|
||||
static
|
||||
{
|
||||
System.loadLibrary("mapswithme");
|
||||
|
@ -207,7 +199,6 @@ public class MWMApplication extends android.app.Application implements MapStorag
|
|||
private native void nativeInit(String apkPath,
|
||||
String storagePath,
|
||||
String tmpPath,
|
||||
String extTmpPath,
|
||||
boolean isPro);
|
||||
|
||||
public native boolean nativeIsBenchmarking();
|
||||
|
|
|
@ -203,7 +203,7 @@ public class BookmarkListActivity extends AbstractBookmarkListActivity
|
|||
{
|
||||
assignCategoryParams();
|
||||
|
||||
String path = ((MWMApplication) getApplication()).getExtAppDirectoryPath("tmp");
|
||||
String path = ((MWMApplication) getApplication()).getTempPath();
|
||||
final String name = mManager.saveToKMZFile(mEditedSet.getId(), path);
|
||||
if (name == null)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue