From 9e9bf6506f81d1ce846d2dbdad4e852ce7fe5f8e Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 6 May 2015 20:23:21 +0200 Subject: [PATCH] Fix pre19 moving to external sdcard --- .../plus/activities/SettingsGeneralActivity.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java index dede7a1ff7..d97f62eb56 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java @@ -453,8 +453,12 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { private void warnAboutChangingStorage(final String newValue) { - final String newDir = newValue != null ? newValue.trim() : newValue; - File path = new File(newDir); + String newDir = newValue != null ? newValue.trim() : newValue; + if(!newDir.replace('/', ' ').trim(). + toLowerCase().endsWith(IndexConstants.APP_DIR.replace('/', ' ').trim())) { + newDir += "/" +IndexConstants.APP_DIR; + } + final File path = new File(newDir); path.mkdirs(); if (!path.canRead() || !path.exists()) { AccessibleToast.makeText(this, R.string.specified_dir_doesnt_exist, Toast.LENGTH_LONG).show(); @@ -467,12 +471,11 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { public void onClick(DialogInterface dialog, int which) { MoveFilesToDifferentDirectory task = new MoveFilesToDifferentDirectory(SettingsGeneralActivity.this, - new File(settings.getExternalStorageDirectory(), IndexConstants.APP_DIR), new File(newDir, - IndexConstants.APP_DIR)); + settings.getExternalStorageDirectory(), path); task.setRunOnSuccess(new Runnable() { @Override public void run() { - updateSettingsToNewDir(newDir); + updateSettingsToNewDir(path.getParentFile().getAbsolutePath()); } }); task.execute(); @@ -482,7 +485,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { @Override public void onClick(DialogInterface dialog, int which) { - updateSettingsToNewDir(newDir); + updateSettingsToNewDir(path.getParentFile().getAbsolutePath()); } }); builder.setNegativeButton(R.string.shared_string_cancel, null); @@ -490,7 +493,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { } private void updateSettingsToNewDir(final String newDir) { - // TODO v19 // edit the preference settings.setExternalStorageDirectoryPre19(newDir); getMyApplication().getResourceManager().resetStoreDirectory();