Fix pre19 moving to external sdcard
This commit is contained in:
parent
dd601c6b72
commit
583f58f480
1 changed files with 9 additions and 7 deletions
|
@ -453,8 +453,12 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
|
||||||
|
|
||||||
|
|
||||||
private void warnAboutChangingStorage(final String newValue) {
|
private void warnAboutChangingStorage(final String newValue) {
|
||||||
final String newDir = newValue != null ? newValue.trim() : newValue;
|
String newDir = newValue != null ? newValue.trim() : newValue;
|
||||||
File path = new File(newDir);
|
if(!newDir.replace('/', ' ').trim().
|
||||||
|
toLowerCase().endsWith(IndexConstants.APP_DIR.replace('/', ' ').trim())) {
|
||||||
|
newDir += "/" +IndexConstants.APP_DIR;
|
||||||
|
}
|
||||||
|
final File path = new File(newDir);
|
||||||
path.mkdirs();
|
path.mkdirs();
|
||||||
if (!path.canRead() || !path.exists()) {
|
if (!path.canRead() || !path.exists()) {
|
||||||
AccessibleToast.makeText(this, R.string.specified_dir_doesnt_exist, Toast.LENGTH_LONG).show();
|
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) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
MoveFilesToDifferentDirectory task =
|
MoveFilesToDifferentDirectory task =
|
||||||
new MoveFilesToDifferentDirectory(SettingsGeneralActivity.this,
|
new MoveFilesToDifferentDirectory(SettingsGeneralActivity.this,
|
||||||
new File(settings.getExternalStorageDirectory(), IndexConstants.APP_DIR), new File(newDir,
|
settings.getExternalStorageDirectory(), path);
|
||||||
IndexConstants.APP_DIR));
|
|
||||||
task.setRunOnSuccess(new Runnable() {
|
task.setRunOnSuccess(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
updateSettingsToNewDir(newDir);
|
updateSettingsToNewDir(path.getParentFile().getAbsolutePath());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
task.execute();
|
task.execute();
|
||||||
|
@ -482,7 +485,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
updateSettingsToNewDir(newDir);
|
updateSettingsToNewDir(path.getParentFile().getAbsolutePath());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
|
@ -490,7 +493,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSettingsToNewDir(final String newDir) {
|
private void updateSettingsToNewDir(final String newDir) {
|
||||||
// TODO v19
|
|
||||||
// edit the preference
|
// edit the preference
|
||||||
settings.setExternalStorageDirectoryPre19(newDir);
|
settings.setExternalStorageDirectoryPre19(newDir);
|
||||||
getMyApplication().getResourceManager().resetStoreDirectory();
|
getMyApplication().getResourceManager().resetStoreDirectory();
|
||||||
|
|
Loading…
Reference in a new issue