diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml
index 5fc4817c71..a18b62017b 100644
--- a/OsmAnd/AndroidManifest.xml
+++ b/OsmAnd/AndroidManifest.xml
@@ -58,6 +58,7 @@
+
diff --git a/OsmAnd/res/layout-land/map_hud_top.xml b/OsmAnd/res/layout-land/map_hud_top.xml
index d424d73611..bbd7ccd761 100644
--- a/OsmAnd/res/layout-land/map_hud_top.xml
+++ b/OsmAnd/res/layout-land/map_hud_top.xml
@@ -51,7 +51,10 @@
+ android:layout_marginLeft="5dp"
+ android:layout_marginRight="5dp"
+ android:layout_gravity="center"
+ >
@@ -72,6 +76,7 @@
android:layout_gravity="center"
android:ellipsize="end"
android:maxLines="1"
+ android:singleLine="true"
android:text="Long Street Name"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size" >
diff --git a/OsmAnd/res/layout/dash_search_fragment.xml b/OsmAnd/res/layout/dash_search_fragment.xml
index 32cad12bc2..5b58df247b 100644
--- a/OsmAnd/res/layout/dash_search_fragment.xml
+++ b/OsmAnd/res/layout/dash_search_fragment.xml
@@ -40,30 +40,36 @@
android:layout_height="@dimen/dashSearchBtnHeight"
android:orientation="horizontal" >
-
+ android:text="@string/poi"
+ osmand:textAllCapsCompat="false"
+ osmand:typeface="@string/font_roboto_medium" />
-
+ android:text="@string/address"
+ osmand:textAllCapsCompat="false"
+ osmand:typeface="@string/font_roboto_medium" />
-
+ android:text="@string/coordinates"
+ osmand:textAllCapsCompat="false"
+ osmand:typeface="@string/font_roboto_medium" />
\ No newline at end of file
diff --git a/OsmAnd/res/layout/dash_storage_type_fragment.xml b/OsmAnd/res/layout/dash_storage_type_fragment.xml
new file mode 100644
index 0000000000..03f1222e00
--- /dev/null
+++ b/OsmAnd/res/layout/dash_storage_type_fragment.xml
@@ -0,0 +1,119 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/map_hud_top.xml b/OsmAnd/res/layout/map_hud_top.xml
index 8a1d6c9729..5667504672 100644
--- a/OsmAnd/res/layout/map_hud_top.xml
+++ b/OsmAnd/res/layout/map_hud_top.xml
@@ -17,6 +17,8 @@
@@ -27,6 +29,7 @@
android:layout_gravity="center"
android:ellipsize="end"
android:maxLines="1"
+ android:singleLine="true"
android:text="Long Street Name"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size" >
@@ -39,6 +42,7 @@
android:layout_gravity="center"
android:ellipsize="end"
android:maxLines="1"
+ android:singleLine="true"
android:text="Long Street Name"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size" >
@@ -50,6 +54,7 @@
android:id="@+id/waypoint_info_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
+ android:visibility="gone"
android:orientation="horizontal" >
+ Maps could not be created in specified directory
+ Copying files failed
+ External storage
+ Multiuser storage
+ Internal application memory
+ Manually specified
+ Internal memory
+ Map Storage
+ Copy
Filter by name
Type to search all
Open
diff --git a/OsmAnd/res/values/styles.xml b/OsmAnd/res/values/styles.xml
index 96ef5bf63c..8406369d25 100644
--- a/OsmAnd/res/values/styles.xml
+++ b/OsmAnd/res/values/styles.xml
@@ -43,7 +43,7 @@
- match_parent
- 1
- ?android:textColorPrimary
- - @dimen/default_desc_text_size
+ - @dimen/default_sub_text_size
- bottom|center_horizontal
- @dimen/dashSearchPaddingBot
- ?attr/dashboard_button
diff --git a/OsmAnd/src/net/osmand/plus/GPXUtilities.java b/OsmAnd/src/net/osmand/plus/GPXUtilities.java
index 1371cf726f..4be3a3bb81 100644
--- a/OsmAnd/src/net/osmand/plus/GPXUtilities.java
+++ b/OsmAnd/src/net/osmand/plus/GPXUtilities.java
@@ -31,7 +31,6 @@ import net.osmand.Location;
import net.osmand.PlatformUtil;
import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription;
-import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
diff --git a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java
index a95e28ccc5..43a4aad50b 100644
--- a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java
+++ b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java
@@ -143,11 +143,6 @@ public class OsmAndAppCustomization {
}
- public File getExternalStorageDir() {
- return osmandSettings.getExternalStorageDirectory();
- }
-
-
public boolean onlyTourDownload() {
return false;
}
diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java
index ac227bc380..383244d72a 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java
@@ -6,6 +6,7 @@ import java.io.File;
import java.io.FileWriter;
import java.io.PrintStream;
import java.lang.Thread.UncaughtExceptionHandler;
+import java.util.ArrayList;
import java.util.Locale;
import net.osmand.IndexConstants;
@@ -18,6 +19,7 @@ import net.osmand.osm.MapPoiTypes;
import net.osmand.plus.AppInitializer.AppInitializeListener;
import net.osmand.plus.access.AccessibilityMode;
import net.osmand.plus.activities.DayNightHelper;
+import net.osmand.plus.activities.ExitActivity;
import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.api.SQLiteAPI;
@@ -100,6 +102,7 @@ public class OsmandApplication extends Application {
RoutingConfiguration.Builder defaultRoutingConfig;
private Locale defaultLocale;
+ private File externalStorageDirectory;
// Typeface
@@ -126,6 +129,7 @@ public class OsmandApplication extends Application {
}
appCustomization.setup(this);
osmandSettings = appCustomization.getOsmandSettings();
+ externalStorageDirectory = osmandSettings.getExternalStorageDirectory();
appInitializer.onCreateApplication();
// if(!osmandSettings.FOLLOW_THE_ROUTE.get()) {
@@ -395,27 +399,34 @@ public class OsmandApplication extends Application {
bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- closeApplicationAnyway(activity, true);
+ closeApplicationAnywayImpl(activity, true);
}
});
bld.setNegativeButton(R.string.shared_string_no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- closeApplicationAnyway(activity, false);
+ closeApplicationAnywayImpl(activity, false);
}
});
bld.show();
} else {
- closeApplicationAnyway(activity, true);
+ closeApplicationAnywayImpl(activity, true);
}
}
-
+
private void closeApplicationAnyway(final Activity activity, boolean disableService) {
+ activity.finish();
+ Intent newIntent = new Intent(activity, ExitActivity.class);
+ newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
+ newIntent.putExtra(ExitActivity.DISABLE_SERVICE, disableService);
+ startActivity(newIntent);
+ }
+
+ public void closeApplicationAnywayImpl(final Activity activity, boolean disableService) {
if (appInitializer.isAppInitializing()) {
resourceManager.close();
}
activity.finish();
-
if (getNavigationService() == null) {
fullExit();
} else if (disableService) {
@@ -568,8 +579,13 @@ public class OsmandApplication extends Application {
if(path == null) {
path = "";
}
-
- return new File(getAppCustomization().getExternalStorageDir(), IndexConstants.APP_DIR + path);
+ return new File(externalStorageDirectory, path);
+ }
+
+ public void setExternalStorageDirectory(int type, String directory){
+ osmandSettings.setExternalStorageDirectory(type, directory);
+ externalStorageDirectory = osmandSettings.getExternalStorageDirectory();
+ getResourceManager().resetStoreDirectory();
}
public void applyTheme(Context c) {
diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
index c4781d93b1..c7e81b9181 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
@@ -18,6 +18,7 @@ import java.util.StringTokenizer;
import net.osmand.IndexConstants;
import net.osmand.StateChangedListener;
+import net.osmand.ValueHolder;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.map.ITileSource;
@@ -31,7 +32,7 @@ import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.render.RenderingRulesStorage;
-import android.annotation.SuppressLint;
+import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Configuration;
import android.hardware.Sensor;
@@ -1151,116 +1152,91 @@ public class OsmandSettings {
public static final String EXTERNAL_STORAGE_DIR = "external_storage_dir"; //$NON-NLS-1$
+ public static final String EXTERNAL_STORAGE_DIR_V19 = "external_storage_dir_V19"; //$NON-NLS-1$
+ public static final String EXTERNAL_STORAGE_DIR_TYPE_V19 = "external_storage_dir_type_V19"; //$NON-NLS-1$
+ public static final int EXTERNAL_STORAGE_TYPE_DEFAULT = 0; // Environment.getExternalStorageDirectory()
+ public static final int EXTERNAL_STORAGE_TYPE_EXTERNAL_FILE = 1; // ctx.getExternalFilesDirs(null)
+ public static final int EXTERNAL_STORAGE_TYPE_INTERNAL_FILE = 2; // ctx.getFilesDir()
+ public static final int EXTERNAL_STORAGE_TYPE_OBB = 3; // ctx.getObbDirs
+ public static final int EXTERNAL_STORAGE_TYPE_SPECIFIED = 4;
+
+
public File getExternalStorageDirectory() {
- String defaultLocation =
- Environment.getExternalStorageDirectory().getAbsolutePath();
-// ctx.getExternalFilesDirs(type)
- return new File(settingsAPI.getString(globalPreferences, EXTERNAL_STORAGE_DIR,
- defaultLocation));
+ return getExternalStorageDirectory(null);
}
- public Object getGlobalPreferences() {
- return globalPreferences;
+ public File getExternalStorageDirectory(ValueHolder type) {
+ if(Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
+ return getExternalStorageDirectoryPre19();
+ } else {
+ return getExternalStorageDirectoryV19(type);
+ }
}
- public static final int VERSION_DEFAULTLOCATION_CHANGED = 19;
+ @TargetApi(19)
+ public File getInternalAppPath() {
+ if(Build.VERSION.SDK_INT >= 21) {
+ File fl = getNoBackupPath();
+ if(fl != null) {
+ return fl;
+ }
+ }
+ return ctx.getFilesDir();
+ }
+
+ @TargetApi(21)
+ private File getNoBackupPath() {
+ return ctx.getNoBackupFilesDir();
+ }
- public String getDefaultExternalStorageLocation() {
- String defaultLocation = Environment.getExternalStorageDirectory().getAbsolutePath();
- return defaultLocation;
- }
-
- private static List getWritableSecondaryStorages() {
- List writableSecondaryStorage = new ArrayList();
- try {
- String rawSecondaryStorage = System.getenv("SECONDARY_STORAGE");
- if (rawSecondaryStorage != null && rawSecondaryStorage.trim().length() > 0) {
- for (String secondaryPath : rawSecondaryStorage.split(":")) {
- File testFile = new File(secondaryPath);
- if (isWritable(testFile)) {
- writableSecondaryStorage.add(secondaryPath);
+ @TargetApi(Build.VERSION_CODES.KITKAT)
+ public File getExternalStorageDirectoryV19(ValueHolder tp) {
+ int type = settingsAPI.getInt(globalPreferences, EXTERNAL_STORAGE_DIR_TYPE_V19, -1);
+ File location = getDefaultLocationV19();
+ if (type == -1) {
+ if(isWritable(location)) {
+ if(tp != null) {
+ tp.value = settingsAPI.contains(globalPreferences, EXTERNAL_STORAGE_DIR_V19) ?
+ EXTERNAL_STORAGE_TYPE_SPECIFIED :
+ EXTERNAL_STORAGE_TYPE_DEFAULT;
+ }
+ return location;
+ }
+ File[] external = ctx.getExternalFilesDirs(null);
+ if(external != null && external.length > 0 && external[0] != null) {
+ location = external[0];
+ if(tp != null) {
+ tp.value = EXTERNAL_STORAGE_TYPE_EXTERNAL_FILE;
+ }
+ } else {
+ File[] obbDirs = ctx.getObbDirs();
+ if(obbDirs != null && obbDirs.length > 0 && obbDirs[0] != null) {
+ location = obbDirs[0];
+ if(tp != null) {
+ tp.value = EXTERNAL_STORAGE_TYPE_OBB;
+ }
+ } else {
+ location = getInternalAppPath();
+ if(tp != null) {
+ tp.value = EXTERNAL_STORAGE_TYPE_INTERNAL_FILE;
}
}
}
- } catch (RuntimeException e) {
- e.printStackTrace();
- }
- return writableSecondaryStorage;
- }
-
- @SuppressLint("NewApi")
- public String getMatchingExternalFilesDir(String dir) {
- // only API 19 !!
- try {
- File[] externalFilesDirs = ctx.getExternalFilesDirs(null);
- String rawSecondaryStorage = System.getenv("SECONDARY_STORAGE");
- if (rawSecondaryStorage != null && rawSecondaryStorage.trim().length() > 0 && externalFilesDirs != null) {
- for (String secondaryPath : rawSecondaryStorage.split(":")) {
- if (dir.startsWith(secondaryPath)) {
- for (File externFileDir : externalFilesDirs) {
- if (externFileDir != null && externFileDir.getAbsolutePath().startsWith(secondaryPath)) {
- return externFileDir.getAbsolutePath();
- }
- }
- }
- }
- }
- return null;
- } catch (Exception e) {
- e.printStackTrace();
- return null;
}
+ return location;
}
- @SuppressLint("NewApi")
- public List getWritableSecondaryStorageDirectorys() {
- // only API 19 !!
- // primary external storage directory
- String primaryExternalStorageDirectory = getDefaultExternalStorageLocation();
- // also creates directories, if they don't exist until now
- File[] externalFilesDirs = ctx.getExternalFilesDirs(null);
- List writableSecondaryStorages = getWritableSecondaryStorages();
- List writableSecondaryStorageDirectory = new ArrayList();
- try {
- boolean primaryExternalStorageFound = false;
- if(externalFilesDirs != null) {
- for (File externFileDir : externalFilesDirs) {
- if (externFileDir != null) {
- final String externalFilePath = externFileDir.getAbsolutePath();
- if (externalFilePath.startsWith(primaryExternalStorageDirectory) && !primaryExternalStorageFound) {
- // exclude primary external storage
- // no special location is required
- primaryExternalStorageFound = true;
- } else {
- // secondary storage
- // check if special location is required
- boolean specialPathRequired = true;
- for (String writableSecondaryStorage : writableSecondaryStorages) {
- if (externalFilePath.startsWith(writableSecondaryStorage)) {
- // no special location required
- writableSecondaryStorageDirectory.add(writableSecondaryStorage);
- specialPathRequired = false;
- break;
- }
- }
- if (specialPathRequired == true) {
- // special location required
- writableSecondaryStorageDirectory.add(externalFilePath);
- }
- }
- }
- }
- }
-
- } catch (RuntimeException e) {
- e.printStackTrace();
- }
- return writableSecondaryStorageDirectory;
+ public File getDefaultLocationV19() {
+ String location = settingsAPI.getString(globalPreferences, EXTERNAL_STORAGE_DIR_V19,
+ getExternalStorageDirectoryPre19().getAbsolutePath());
+ return new File(location);
}
+
public static boolean isWritable(File dirToTest) {
boolean isWriteable = false;
try {
+ dirToTest.mkdirs();
File writeTestFile = File.createTempFile("osmand_", ".tmp", dirToTest);
isWriteable = writeTestFile.exists();
writeTestFile.delete();
@@ -1270,10 +1246,54 @@ public class OsmandSettings {
return isWriteable;
}
- public boolean setExternalStorageDirectory(String externalStorageDir) {
+ public boolean isExternalStorageDirectorySpecifiedV19() {
+ return settingsAPI.contains(globalPreferences, EXTERNAL_STORAGE_DIR_TYPE_V19);
+ }
+
+ public int getExternalStorageDirectoryTypeV19() {
+ return settingsAPI.getInt(globalPreferences, EXTERNAL_STORAGE_DIR_TYPE_V19, -1);
+ }
+
+ public File getExternalStorageDirectoryPre19() {
+ String defaultLocation = Environment.getExternalStorageDirectory().getAbsolutePath();
+ File rootFolder = new File(settingsAPI.getString(globalPreferences, EXTERNAL_STORAGE_DIR,
+ defaultLocation));
+ return new File(rootFolder, IndexConstants.APP_DIR);
+ }
+
+ public File getDefaultInternalStorage() {
+ return new File(Environment.getExternalStorageDirectory(), IndexConstants.APP_DIR);
+ }
+
+ public boolean setExternalStorageDirectoryV19(int type, String externalStorageDir) {
+ return settingsAPI.edit(globalPreferences).
+ putInt(EXTERNAL_STORAGE_DIR_TYPE_V19, type).
+ putString(EXTERNAL_STORAGE_DIR_V19, externalStorageDir).commit();
+ }
+
+ public void setExternalStorageDirectory(int type, String directory) {
+ if(Build.VERSION.SDK_INT < 19) {
+ setExternalStorageDirectoryPre19(directory);
+ } else {
+ setExternalStorageDirectoryV19(type, directory);
+ }
+
+ }
+
+ public boolean isExternalStorageDirectorySpecifiedPre19() {
+ return settingsAPI.contains(globalPreferences, EXTERNAL_STORAGE_DIR);
+ }
+
+ public boolean setExternalStorageDirectoryPre19(String externalStorageDir) {
return settingsAPI.edit(globalPreferences).putString(EXTERNAL_STORAGE_DIR, externalStorageDir).commit();
}
+
+ public Object getGlobalPreferences() {
+ return globalPreferences;
+ }
+
+
// This value is a key for saving last known location shown on the map
public static final String LAST_KNOWN_MAP_LAT = "last_known_map_lat"; //$NON-NLS-1$
public static final String LAST_KNOWN_MAP_LON = "last_known_map_lon"; //$NON-NLS-1$
@@ -1951,4 +1971,8 @@ public class OsmandSettings {
+
+
+
+
}
diff --git a/OsmAnd/src/net/osmand/plus/activities/ExitActivity.java b/OsmAnd/src/net/osmand/plus/activities/ExitActivity.java
new file mode 100644
index 0000000000..67beabb1ad
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/activities/ExitActivity.java
@@ -0,0 +1,30 @@
+package net.osmand.plus.activities;
+
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.R;
+import android.app.Activity;
+import android.os.Bundle;
+
+
+public class ExitActivity extends Activity {
+ public final static String DISABLE_SERVICE = "DISABLE_SERVICE";
+ private boolean dis;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.help_activity);
+ dis = getIntent().getBooleanExtra(DISABLE_SERVICE, true);
+
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ getMyApplication().closeApplicationAnywayImpl(this, dis);
+ }
+
+ private OsmandApplication getMyApplication() {
+ return (OsmandApplication) getApplication();
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java
index 9481712d2c..c6af41dbbe 100644
--- a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java
@@ -2,15 +2,11 @@ package net.osmand.plus.activities;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
-import android.view.Window;
import net.osmand.CallbackWithObject;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
@@ -21,21 +17,18 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.DrivingRegion;
import net.osmand.plus.OsmandSettings.MetricsConstants;
-import net.osmand.plus.ProgressImplementation;
import net.osmand.plus.R;
import net.osmand.plus.Version;
-import net.osmand.plus.base.SuggestExternalDirectoryDialog;
+import net.osmand.plus.dashboard.DashChooseAppDirFragment;
+import net.osmand.plus.dashboard.DashChooseAppDirFragment.MoveFilesToDifferentDirectory;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.render.NativeOsmandLibrary;
import net.osmand.plus.voice.CommandPlayer;
import net.osmand.render.RenderingRulesStorage;
-import net.osmand.util.Algorithms;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
-import android.app.ProgressDialog;
-import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
@@ -326,10 +319,11 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
editalert.setTitle(R.string.application_dir);
final EditText input = new EditText(SettingsGeneralActivity.this);
input.setText(settings.getExternalStorageDirectory().getAbsolutePath());
- input.setPadding(3, 3, 3, 3);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
+ lp.leftMargin = lp.rightMargin = 5;
+ lp.bottomMargin = lp.topMargin = 5;
input.setLayoutParams(lp);
settings.getExternalStorageDirectory().getAbsolutePath();
editalert.setView(input);
@@ -343,20 +337,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
}
@Override
public boolean onPreferenceClick(Preference preference) {
- SuggestExternalDirectoryDialog.showDialog(SettingsGeneralActivity.this, new OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- showOtherDialog();
- }
- }, new CallbackWithObject() {
-
- @Override
- public boolean processResult(String result) {
- warnAboutChangingStorage(result);
- return true;
- }
- });
+ showOtherDialog();
return false;
}
});
@@ -432,7 +413,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
loadNativeLibrary();
}
} else if (preference == applicationDir) {
- warnAboutChangingStorage((String) newValue);
return false;
} else if (id.equals(settings.APPLICATION_MODE.getId())) {
settings.DEFAULT_APPLICATION_MODE.set(settings.APPLICATION_MODE.get());
@@ -453,99 +433,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
return true;
}
- public static class MoveFilesToDifferentDirectory extends AsyncTask {
-
- private File to;
- private Context ctx;
- private File from;
- protected ProgressImplementation progress;
- private Runnable runOnSuccess;
-
- public MoveFilesToDifferentDirectory(Context ctx, File from, File to) {
- this.ctx = ctx;
- this.from = from;
- this.to = to;
- }
-
- public void setRunOnSuccess(Runnable runOnSuccess) {
- this.runOnSuccess = runOnSuccess;
- }
-
- @Override
- protected void onPreExecute() {
- progress = ProgressImplementation.createProgressDialog(
- ctx, ctx.getString(R.string.copying_osmand_files),
- ctx.getString(R.string.copying_osmand_files_descr, to.getPath()),
- ProgressDialog.STYLE_HORIZONTAL);
- }
-
- @Override
- protected void onPostExecute(Boolean result) {
- if (result != null) {
- if (result.booleanValue() && runOnSuccess != null) {
- runOnSuccess.run();
- } else if (!result.booleanValue()) {
- Toast.makeText(ctx, R.string.shared_string_io_error, Toast.LENGTH_LONG).show();
- }
- }
- if(progress.getDialog().isShowing()) {
- progress.getDialog().dismiss();
- }
- }
-
- private void movingFiles(File f, File t, int depth) throws IOException {
- if(depth <= 2) {
- progress.startTask(ctx.getString(R.string.copying_osmand_one_file_descr, t.getName()), -1);
- }
- if (f.isDirectory()) {
- t.mkdirs();
- File[] lf = f.listFiles();
- if (lf != null) {
- for (int i = 0; i < lf.length; i++) {
- if (lf[i] != null) {
- movingFiles(lf[i], new File(t, lf[i].getName()), depth + 1);
- }
- }
- }
- f.delete();
- } else if (f.isFile()) {
- if(t.exists()) {
- Algorithms.removeAllFiles(t);
- }
- boolean rnm = false;
- try {
- rnm = f.renameTo(t);
- } catch(RuntimeException e) {
- }
- if (!rnm) {
- FileInputStream fin = new FileInputStream(f);
- FileOutputStream fout = new FileOutputStream(t);
- try {
- Algorithms.streamCopy(fin, fout);
- } finally {
- fin.close();
- fout.close();
- }
- f.delete();
- }
- }
- if(depth <= 2) {
- progress.finishTask();
- }
- }
-
- @Override
- protected Boolean doInBackground(Void... params) {
- to.mkdirs();
- try {
- movingFiles(from, to, 0);
- } catch (IOException e) {
- return false;
- }
- return true;
- }
-
- }
+
private void warnAboutChangingStorage(final String newValue) {
final String newDir = newValue != null ? newValue.trim() : newValue;
@@ -585,8 +473,9 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
}
private void updateSettingsToNewDir(final String newDir) {
+ // TODO v19
// edit the preference
- settings.setExternalStorageDirectory(newDir);
+ settings.setExternalStorageDirectoryPre19(newDir);
getMyApplication().getResourceManager().resetStoreDirectory();
reloadIndexes();
updateApplicationDirTextAndSummary();
diff --git a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoActivity.java b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoActivity.java
index d0a2384ad7..48631a273c 100644
--- a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoActivity.java
@@ -11,7 +11,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
-import net.osmand.IndexConstants;
import net.osmand.Location;
import net.osmand.data.PointDescription;
import net.osmand.plus.GPXUtilities;
@@ -310,9 +309,7 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
html.append("