Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
4576980ab4
25 changed files with 850 additions and 433 deletions
|
@ -58,6 +58,7 @@
|
|||
<meta-data android:name="com.sec.minimode.icon.portrait.normal" android:resource="@drawable/icon" android:value="" />
|
||||
<meta-data android:name="com.sec.minimode.icon.landscape.normal" android:resource="@drawable/icon" android:value="" />
|
||||
<activity android:name="net.osmand.plus.activities.HelpActivity" />
|
||||
<activity android:name="net.osmand.plus.activities.ExitActivity" />
|
||||
|
||||
<activity android:name="net.osmand.plus.activities.MapActivity" android:label="@string/app_name"
|
||||
android:screenOrientation="unspecified" android:launchMode="singleTop">
|
||||
|
|
|
@ -51,7 +51,10 @@
|
|||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center" >
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_gravity="center"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/map_address_text_shadow"
|
||||
|
@ -60,6 +63,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" >
|
||||
|
@ -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" >
|
||||
|
|
|
@ -40,30 +40,36 @@
|
|||
android:layout_height="@dimen/dashSearchBtnHeight"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<Button
|
||||
<net.osmand.plus.widgets.ButtonEx
|
||||
android:id="@+id/poi"
|
||||
style="@style/DashboardSearchButton"
|
||||
android:text="@string/poi" />
|
||||
android:text="@string/poi"
|
||||
osmand:textAllCapsCompat="false"
|
||||
osmand:typeface="@string/font_roboto_medium" />
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/dashboard_divider" />
|
||||
|
||||
<Button
|
||||
<net.osmand.plus.widgets.ButtonEx
|
||||
android:id="@+id/address"
|
||||
style="@style/DashboardSearchButton"
|
||||
android:text="@string/address" />
|
||||
android:text="@string/address"
|
||||
osmand:textAllCapsCompat="false"
|
||||
osmand:typeface="@string/font_roboto_medium" />
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/dashboard_divider" />
|
||||
|
||||
<Button
|
||||
<net.osmand.plus.widgets.ButtonEx
|
||||
android:id="@+id/coord"
|
||||
style="@style/DashboardSearchButton"
|
||||
android:text="@string/coordinates" />
|
||||
android:text="@string/coordinates"
|
||||
osmand:textAllCapsCompat="false"
|
||||
osmand:typeface="@string/font_roboto_medium" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
119
OsmAnd/res/layout/dash_storage_type_fragment.xml
Normal file
119
OsmAnd/res/layout/dash_storage_type_fragment.xml
Normal file
|
@ -0,0 +1,119 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/dash_margin"
|
||||
android:layout_marginLeft="@dimen/dash_margin_h"
|
||||
android:layout_marginRight="@dimen/dash_margin_h"
|
||||
android:layout_marginTop="@dimen/dash_margin"
|
||||
android:background="?attr/card_bg"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/osmand_orange"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/list_content_padding"
|
||||
android:paddingRight="@dimen/list_content_padding"
|
||||
android:paddingTop="@dimen/list_content_padding" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/list_header_bottom_margin"
|
||||
android:text="@string/storage_directory"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/default_list_text_size_large" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/location_path"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Location path"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/default_list_text_size" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/location_desc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Location path \u2022 300 MB"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/default_sub_text_size" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/edit_icon"
|
||||
android:layout_width="@dimen/list_item_height"
|
||||
android:layout_height="@dimen/list_item_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="?attr/dashboard_button"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_action_edit_dark" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingBottom="3dp"
|
||||
android:paddingLeft="@dimen/list_content_padding"
|
||||
android:paddingRight="@dimen/list_content_padding"
|
||||
android:paddingTop="3dp"
|
||||
android:id="@+id/android_19_location_changed"
|
||||
android:text="@string/android_19_location_disabled"
|
||||
android:textSize="@dimen/default_sub_text_size" />
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/list_item_height"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<net.osmand.plus.widgets.ButtonEx
|
||||
android:id="@+id/copy_maps"
|
||||
style="@style/DashboardGeneralButton"
|
||||
android:gravity="center"
|
||||
android:text="@string/shared_string_copy"
|
||||
osmand:textAllCapsCompat="true"
|
||||
osmand:typeface="@string/font_roboto_medium" />
|
||||
|
||||
<net.osmand.plus.widgets.ButtonEx
|
||||
android:id="@+id/confirm"
|
||||
style="@style/DashboardGeneralButton"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:text="@string/shared_string_ok"
|
||||
osmand:textAllCapsCompat="true"
|
||||
osmand:typeface="@string/font_roboto_medium" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -17,6 +17,8 @@
|
|||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_gravity="center" >
|
||||
|
||||
|
||||
|
@ -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" >
|
||||
|
||||
<ImageView
|
||||
|
|
|
@ -9,6 +9,15 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="specified_directiory_not_writeable">Maps could not be created in specified directory</string>
|
||||
<string name="copying_osmand_file_failed">Copying files failed</string>
|
||||
<string name="storage_directory_external">External storage</string>
|
||||
<string name="storage_directory_multiuser">Multiuser storage</string>
|
||||
<string name="storage_directory_internal_app">Internal application memory</string>
|
||||
<string name="storage_directory_manual">Manually specified</string>
|
||||
<string name="storage_directory_default">Internal memory</string>
|
||||
<string name="storage_directory">Map Storage</string>
|
||||
<string name="shared_string_copy">Copy</string>
|
||||
<string name="filter_poi_hint">Filter by name</string>
|
||||
<string name="search_poi_category_hint">Type to search all</string>
|
||||
<string name="shared_string_open">Open</string>
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<item name="android:layout_height">match_parent</item>
|
||||
<item name="android:layout_weight">1</item>
|
||||
<item name="android:textColor">?android:textColorPrimary</item>
|
||||
<item name="android:textSize">@dimen/default_desc_text_size</item>
|
||||
<item name="android:textSize">@dimen/default_sub_text_size</item>
|
||||
<item name="android:gravity">bottom|center_horizontal</item>
|
||||
<item name="android:paddingBottom">@dimen/dashSearchPaddingBot</item>
|
||||
<item name="android:background">?attr/dashboard_button</item>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -143,11 +143,6 @@ public class OsmAndAppCustomization {
|
|||
}
|
||||
|
||||
|
||||
public File getExternalStorageDir() {
|
||||
return osmandSettings.getExternalStorageDirectory();
|
||||
}
|
||||
|
||||
|
||||
public boolean onlyTourDownload() {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -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(externalStorageDirectory, path);
|
||||
}
|
||||
|
||||
return new File(getAppCustomization().getExternalStorageDir(), IndexConstants.APP_DIR + path);
|
||||
public void setExternalStorageDirectory(int type, String directory){
|
||||
osmandSettings.setExternalStorageDirectory(type, directory);
|
||||
externalStorageDirectory = osmandSettings.getExternalStorageDirectory();
|
||||
getResourceManager().resetStoreDirectory();
|
||||
}
|
||||
|
||||
public void applyTheme(Context c) {
|
||||
|
|
|
@ -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 static final int VERSION_DEFAULTLOCATION_CHANGED = 19;
|
||||
|
||||
public String getDefaultExternalStorageLocation() {
|
||||
String defaultLocation = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
return defaultLocation;
|
||||
}
|
||||
|
||||
private static List<String> getWritableSecondaryStorages() {
|
||||
List<String> writableSecondaryStorage = new ArrayList<String>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public List<String> 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<String> writableSecondaryStorages = getWritableSecondaryStorages();
|
||||
List<String> writableSecondaryStorageDirectory = new ArrayList<String>();
|
||||
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;
|
||||
public File getExternalStorageDirectory(ValueHolder<Integer> type) {
|
||||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
return getExternalStorageDirectoryPre19();
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
return getExternalStorageDirectoryV19(type);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
@TargetApi(19)
|
||||
public File getInternalAppPath() {
|
||||
if(Build.VERSION.SDK_INT >= 21) {
|
||||
File fl = getNoBackupPath();
|
||||
if(fl != null) {
|
||||
return fl;
|
||||
}
|
||||
return writableSecondaryStorageDirectory;
|
||||
}
|
||||
return ctx.getFilesDir();
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
private File getNoBackupPath() {
|
||||
return ctx.getNoBackupFilesDir();
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
public File getExternalStorageDirectoryV19(ValueHolder<Integer> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
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 {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
30
OsmAnd/src/net/osmand/plus/activities/ExitActivity.java
Normal file
30
OsmAnd/src/net/osmand/plus/activities/ExitActivity.java
Normal file
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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<String>() {
|
||||
|
||||
@Override
|
||||
public boolean processResult(String result) {
|
||||
warnAboutChangingStorage(result);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
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<Void, Void, Boolean> {
|
||||
|
||||
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();
|
||||
|
|
|
@ -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("</body>");
|
||||
html.append("</html>");
|
||||
|
||||
file = new File(((OsmandApplication) getApplication())
|
||||
.getAppCustomization().getExternalStorageDir(),
|
||||
IndexConstants.APP_DIR + FILE_NAME);
|
||||
file = ((OsmandApplication) getApplication()).getAppPath(FILE_NAME);
|
||||
fos = new FileOutputStream(file);
|
||||
fos.write(html.toString().getBytes("UTF-8"));
|
||||
fos.flush();
|
||||
|
|
|
@ -1,108 +0,0 @@
|
|||
package net.osmand.plus.base;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.os.Build;
|
||||
|
||||
public class SuggestExternalDirectoryDialog {
|
||||
|
||||
|
||||
public static boolean showDialog(Activity a, final DialogInterface.OnClickListener otherListener,
|
||||
final CallbackWithObject<String> selector){
|
||||
final boolean showOther = otherListener != null;
|
||||
final OsmandApplication app = (OsmandApplication) a.getApplication();
|
||||
Builder bld = new AlertDialog.Builder(a);
|
||||
HashSet<String> externalMounts;
|
||||
if(Build.VERSION.SDK_INT < OsmandSettings.VERSION_DEFAULTLOCATION_CHANGED) {
|
||||
externalMounts = getExternalMounts();
|
||||
} else {
|
||||
externalMounts = new HashSet<String>(app.getSettings().getWritableSecondaryStorageDirectorys());
|
||||
}
|
||||
String apath = app.getSettings().getExternalStorageDirectory().getAbsolutePath();
|
||||
externalMounts.add(app.getSettings().getDefaultExternalStorageLocation());
|
||||
externalMounts.add(apath);
|
||||
final String[] extMounts = new String[showOther ? externalMounts.size()+1 : externalMounts.size()];
|
||||
externalMounts.toArray(extMounts);
|
||||
if (showOther) {
|
||||
extMounts[extMounts.length - 1] = a.getString(R.string.other_location);
|
||||
}
|
||||
if (extMounts.length > 1) {
|
||||
int checkedItem = 0;
|
||||
for (int j = 0; j < extMounts.length; j++) {
|
||||
if (extMounts[j].equals(apath)) {
|
||||
checkedItem = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bld.setTitle(R.string.application_dir);
|
||||
bld.setSingleChoiceItems(extMounts, checkedItem, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if(showOther && which == extMounts.length -1) {
|
||||
otherListener.onClick(dialog, which);
|
||||
} else {
|
||||
dialog.dismiss();
|
||||
if(selector != null) {
|
||||
selector.processResult(extMounts[which]);
|
||||
} else {
|
||||
app.getSettings().setExternalStorageDirectory(extMounts[which]);
|
||||
app.getResourceManager().resetStoreDirectory();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
bld.setPositiveButton(R.string.shared_string_ok, null);
|
||||
bld.show();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static HashSet<String> getExternalMounts() {
|
||||
final HashSet<String> out = new HashSet<String>();
|
||||
String reg = "(?i).*vold.*(vfat|ntfs|exfat|fat32|ext3|ext4).*rw.*";
|
||||
String s = "";
|
||||
try {
|
||||
final Process process = new ProcessBuilder().command("mount")
|
||||
.redirectErrorStream(true).start();
|
||||
process.waitFor();
|
||||
final InputStream is = process.getInputStream();
|
||||
final byte[] buffer = new byte[1024];
|
||||
while (is.read(buffer) != -1) {
|
||||
s = s + new String(buffer);
|
||||
}
|
||||
is.close();
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// parse output
|
||||
final String[] lines = s.split("\n");
|
||||
for (String line : lines) {
|
||||
if (!line.toLowerCase(Locale.US).contains("asec")) {
|
||||
if (line.matches(reg)) {
|
||||
String[] parts = line.split(" ");
|
||||
for (String part : parts) {
|
||||
if (part.startsWith("/"))
|
||||
if (!part.toLowerCase(Locale.US).contains("vold"))
|
||||
out.add(part);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,480 @@
|
|||
package net.osmand.plus.dashboard;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.ValueHolder;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.ProgressImplementation;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.util.Algorithms;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.StatFs;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class DashChooseAppDirFragment extends DashBaseFragment {
|
||||
|
||||
public static final String TAG = "DASH_CHOOSE_APP_DIR_FRAGMENT";
|
||||
public static final int VERSION_DEFAULTLOCATION_CHANGED = 19;
|
||||
private TextView locationPath;
|
||||
private TextView locationDesc;
|
||||
MessageFormat formatGb = new MessageFormat("{0, number,#.##} GB", Locale.US);
|
||||
private View copyMapsBtn;
|
||||
private ImageView editBtn;
|
||||
private View confirmBtn;
|
||||
private boolean mapsCopied = false;
|
||||
private TextView warningReadonly;
|
||||
private int type = -1;
|
||||
private File selectedFile = new File("/");
|
||||
private File currentAppFile;
|
||||
private OsmandSettings settings;
|
||||
|
||||
@Override
|
||||
public void onOpenDash() {
|
||||
}
|
||||
|
||||
private String getFreeSpace(File dir) {
|
||||
if(dir.canRead()){
|
||||
StatFs fs = new StatFs(dir.getAbsolutePath());
|
||||
return formatGb.format(new Object[]{(float) (fs.getAvailableBlocks()) * fs.getBlockSize() / (1 << 30) });
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public void updateView() {
|
||||
if (type == OsmandSettings.EXTERNAL_STORAGE_TYPE_DEFAULT ) {
|
||||
locationPath.setText(R.string.storage_directory_default);
|
||||
} else if (type == OsmandSettings.EXTERNAL_STORAGE_TYPE_EXTERNAL_FILE) {
|
||||
locationPath.setText(R.string.storage_directory_external);
|
||||
} else if (type == OsmandSettings.EXTERNAL_STORAGE_TYPE_OBB) {
|
||||
locationPath.setText(R.string.storage_directory_multiuser);
|
||||
} else if (type == OsmandSettings.EXTERNAL_STORAGE_TYPE_SPECIFIED) {
|
||||
locationPath.setText(R.string.storage_directory_manual);
|
||||
} else if (type == OsmandSettings.EXTERNAL_STORAGE_TYPE_SPECIFIED) {
|
||||
locationPath.setText(R.string.storage_directory_manual);
|
||||
}
|
||||
locationDesc.setText(selectedFile.getAbsolutePath() + " \u2022 " + getFreeSpace(selectedFile));
|
||||
boolean readOnlyAndFileExist = !currentAppFile.getAbsolutePath().equals(selectedFile.getAbsolutePath()) &&
|
||||
!OsmandSettings.isWritable(currentAppFile) && !mapsCopied;
|
||||
if (readOnlyAndFileExist) {
|
||||
readOnlyAndFileExist = false;
|
||||
File[] lf = currentAppFile.listFiles();
|
||||
if (lf != null) {
|
||||
for (File f : lf) {
|
||||
if (f != null) {
|
||||
if (f.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
|
||||
readOnlyAndFileExist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
warningReadonly.setVisibility(readOnlyAndFileExist ? View.VISIBLE : View.GONE);
|
||||
warningReadonly.setText(getString(R.string.android_19_location_disabled, currentAppFile.getAbsolutePath()));
|
||||
copyMapsBtn.setVisibility(readOnlyAndFileExist ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_storage_type_fragment, container, false);
|
||||
settings = getMyApplication().getSettings();
|
||||
locationPath = (TextView) view.findViewById(R.id.location_path);
|
||||
locationDesc = (TextView) view.findViewById(R.id.location_desc);
|
||||
warningReadonly = (TextView) view.findViewById(R.id.android_19_location_changed);
|
||||
currentAppFile = settings.getExternalStorageDirectory();
|
||||
selectedFile = currentAppFile;
|
||||
if (settings.getExternalStorageDirectoryTypeV19() >= 0) {
|
||||
type = settings.getExternalStorageDirectoryTypeV19();
|
||||
} else {
|
||||
ValueHolder<Integer> vh = new ValueHolder<Integer>();
|
||||
settings.getExternalStorageDirectory(vh);
|
||||
if (vh.value != null && vh.value >= 0) {
|
||||
type = vh.value;
|
||||
} else {
|
||||
type = 0;
|
||||
}
|
||||
}
|
||||
editBtn = (ImageView) view.findViewById(R.id.edit_icon);
|
||||
copyMapsBtn = view.findViewById(R.id.copy_maps);
|
||||
confirmBtn = view.findViewById(R.id.confirm);
|
||||
addListeners();
|
||||
updateView();
|
||||
return view;
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
protected void showSelectDialog19() {
|
||||
AlertDialog.Builder editalert = new AlertDialog.Builder(getActivity());
|
||||
editalert.setTitle(R.string.application_dir);
|
||||
final List<String> items = new ArrayList<String>();
|
||||
final List<String> paths = new ArrayList<String>();
|
||||
final TIntArrayList types = new TIntArrayList();
|
||||
int selected = -1;
|
||||
if(type == OsmandSettings.EXTERNAL_STORAGE_TYPE_SPECIFIED) {
|
||||
items.add(getString(R.string.storage_directory_manual));
|
||||
paths.add(selectedFile.getAbsolutePath());
|
||||
types.add(OsmandSettings.EXTERNAL_STORAGE_TYPE_SPECIFIED);
|
||||
}
|
||||
File df = settings.getDefaultInternalStorage();
|
||||
if(type == OsmandSettings.EXTERNAL_STORAGE_TYPE_DEFAULT ||
|
||||
OsmandSettings.isWritable(df)) {
|
||||
if(type == OsmandSettings.EXTERNAL_STORAGE_TYPE_DEFAULT) {
|
||||
selected = items.size();
|
||||
}
|
||||
items.add(getString(R.string.storage_directory_default));
|
||||
paths.add(df.getAbsolutePath());
|
||||
types.add(OsmandSettings.EXTERNAL_STORAGE_TYPE_DEFAULT);
|
||||
}
|
||||
|
||||
|
||||
File[] externals = getMyApplication().getExternalFilesDirs(null);
|
||||
if(externals != null) {
|
||||
int i = 1;
|
||||
for(File external : externals) {
|
||||
if(external != null) {
|
||||
if(selectedFile.getAbsolutePath().equals(external.getAbsolutePath()) ) {
|
||||
selected = items.size();
|
||||
}
|
||||
items.add(getString(R.string.storage_directory_external) + " " + (i++));
|
||||
paths.add(external.getAbsolutePath());
|
||||
types.add(OsmandSettings.EXTERNAL_STORAGE_TYPE_EXTERNAL_FILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File[] obbDirs = getMyApplication().getObbDirs();
|
||||
if(obbDirs != null) {
|
||||
int i = 1;
|
||||
for(File obb : obbDirs) {
|
||||
if(obb != null) {
|
||||
if(selectedFile.getAbsolutePath().equals(obb.getAbsolutePath()) ) {
|
||||
selected = items.size();
|
||||
}
|
||||
items.add(getString(R.string.storage_directory_multiuser) + " " + (i++));
|
||||
paths.add(obb.getAbsolutePath());
|
||||
types.add(OsmandSettings.EXTERNAL_STORAGE_TYPE_OBB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String pth = settings.getInternalAppPath().getAbsolutePath();
|
||||
if(selectedFile.getAbsolutePath().equals(pth) ) {
|
||||
selected = items.size();
|
||||
}
|
||||
items.add(getString(R.string.storage_directory_internal_app));
|
||||
paths.add(pth);
|
||||
types.add(OsmandSettings.EXTERNAL_STORAGE_TYPE_INTERNAL_FILE);
|
||||
|
||||
items.add(getString(R.string.storage_directory_manual) + getString(R.string.shared_string_ellipsis));
|
||||
paths.add("");
|
||||
types.add(OsmandSettings.EXTERNAL_STORAGE_TYPE_SPECIFIED);
|
||||
|
||||
editalert.setSingleChoiceItems(items.toArray(new String[items.size()]),
|
||||
selected, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == items.size() - 1) {
|
||||
dialog.dismiss();
|
||||
showOtherDialog();
|
||||
} else {
|
||||
mapsCopied = false;
|
||||
type = types.get(which);
|
||||
selectedFile = new File(paths.get(which));
|
||||
dialog.dismiss();
|
||||
updateView();
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
editalert.setNegativeButton(R.string.shared_string_dismiss, null);
|
||||
editalert.show();
|
||||
}
|
||||
|
||||
public void showOtherDialog(){
|
||||
AlertDialog.Builder editalert = new AlertDialog.Builder(getActivity());
|
||||
editalert.setTitle(R.string.application_dir);
|
||||
final EditText input = new EditText(getActivity());
|
||||
input.setText(selectedFile.getAbsolutePath());
|
||||
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);
|
||||
editalert.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
editalert.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
selectedFile = new File(input.getText().toString());
|
||||
mapsCopied = false;
|
||||
updateView();
|
||||
}
|
||||
});
|
||||
editalert.show();
|
||||
}
|
||||
|
||||
private void addListeners() {
|
||||
editBtn.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
showOtherDialog();
|
||||
} else {
|
||||
showSelectDialog19();
|
||||
}
|
||||
}
|
||||
});
|
||||
copyMapsBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MoveFilesToDifferentDirectory task = new MoveFilesToDifferentDirectory(getActivity(), currentAppFile,
|
||||
selectedFile) {
|
||||
protected Boolean doInBackground(Void[] params) {
|
||||
Boolean result = super.doInBackground(params);
|
||||
if (result) {
|
||||
mapsCopied = true;
|
||||
getMyApplication().getResourceManager().resetStoreDirectory();
|
||||
} else {
|
||||
AccessibleToast.makeText(getActivity(), R.string.copying_osmand_file_failed,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
updateView();
|
||||
return result;
|
||||
}
|
||||
};
|
||||
task.execute();
|
||||
}
|
||||
});
|
||||
confirmBtn.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean wr = OsmandSettings.isWritable(selectedFile);
|
||||
if(wr) {
|
||||
boolean changed = !currentAppFile.getAbsolutePath().equals(selectedFile.getAbsolutePath());
|
||||
getMyApplication().setExternalStorageDirectory(type, currentAppFile.getAbsolutePath());
|
||||
if(changed) {
|
||||
reloadData();
|
||||
}
|
||||
ActionBarActivity dashboardActivity = ((ActionBarActivity) getActivity());
|
||||
if (dashboardActivity != null) {
|
||||
dashboardActivity.getSupportFragmentManager().beginTransaction().remove(DashChooseAppDirFragment.this)
|
||||
.commit();
|
||||
}
|
||||
} else {
|
||||
AccessibleToast.makeText(getActivity(), R.string.specified_directiory_not_writeable,
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void reloadData() {
|
||||
new ReloadData(getActivity(), getMyApplication()).execute((Void)null );
|
||||
}
|
||||
|
||||
public static class ReloadData extends AsyncTask<Void, Void, Boolean> {
|
||||
private Context ctx;
|
||||
protected ProgressImplementation progress;
|
||||
private OsmandApplication app;
|
||||
|
||||
public ReloadData(Context ctx, OsmandApplication app) {
|
||||
this.ctx = ctx;
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
progress = ProgressImplementation.createProgressDialog(ctx, ctx.getString(R.string.loading_data),
|
||||
ctx.getString(R.string.loading_data), ProgressDialog.STYLE_HORIZONTAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
if (progress.getDialog().isShowing()) {
|
||||
progress.getDialog().dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
app.getResourceManager().reloadIndexes(progress, new ArrayList<String>());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isDashNeeded(OsmandSettings settings) {
|
||||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
return false;
|
||||
}
|
||||
return !settings.isExternalStorageDirectorySpecifiedV19();
|
||||
}
|
||||
|
||||
public static HashSet<String> getExternalMounts() {
|
||||
final HashSet<String> out = new HashSet<String>();
|
||||
String reg = "(?i).*vold.*(vfat|ntfs|exfat|fat32|ext3|ext4).*rw.*";
|
||||
String s = "";
|
||||
try {
|
||||
final Process process = new ProcessBuilder().command("mount")
|
||||
.redirectErrorStream(true).start();
|
||||
process.waitFor();
|
||||
final InputStream is = process.getInputStream();
|
||||
final byte[] buffer = new byte[1024];
|
||||
while (is.read(buffer) != -1) {
|
||||
s = s + new String(buffer);
|
||||
}
|
||||
is.close();
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// parse output
|
||||
final String[] lines = s.split("\n");
|
||||
for (String line : lines) {
|
||||
if (!line.toLowerCase(Locale.US).contains("asec")) {
|
||||
if (line.matches(reg)) {
|
||||
String[] parts = line.split(" ");
|
||||
for (String part : parts) {
|
||||
if (part.startsWith("/"))
|
||||
if (!part.toLowerCase(Locale.US).contains("vold"))
|
||||
out.add(part);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class MoveFilesToDifferentDirectory extends AsyncTask<Void, Void, Boolean> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -645,6 +645,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
|||
FragmentTransaction fragmentTransaction = manager.beginTransaction();
|
||||
|
||||
showFragment(manager, fragmentTransaction, DashFirstTimeFragment.TAG, DashFirstTimeFragment.class, firstTime);
|
||||
showFragment(manager, fragmentTransaction, DashChooseAppDirFragment.TAG, DashChooseAppDirFragment.class,
|
||||
DashChooseAppDirFragment.isDashNeeded(getMyApplication().getSettings()));
|
||||
|
||||
showFragment(manager, fragmentTransaction, DashErrorFragment.TAG, DashErrorFragment.class,
|
||||
mapActivity.getMyApplication().getAppInitializer().checkPreviousRunsForExceptions(mapActivity) && showCards);
|
||||
|
|
|
@ -19,6 +19,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.activities.TransportRouteHelper;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
||||
import net.osmand.plus.poi.PoiLegacyFilter;
|
||||
import net.osmand.plus.render.RendererRegistry;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
@ -58,6 +59,15 @@ public class ConfigureMapMenu {
|
|||
});
|
||||
createLayersItems(adapter, ma);
|
||||
createRenderingAttributeItems(adapter, ma);
|
||||
adapter.item(R.string.layer_map_appearance).
|
||||
iconColor(R.drawable.ic_configure_screen_dark).listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
ma.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN);
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
|
||||
return adapter;
|
||||
}
|
||||
|
||||
|
|
|
@ -175,6 +175,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
measurementPoints.add(new LinkedList<GPXUtilities.WptPt>());
|
||||
} else if (id == R.string.distance_measurement_clear_route) {
|
||||
distanceMeasurementMode = 0;
|
||||
originalGPX = null;
|
||||
measurementPoints.clear();
|
||||
calculateDistance();
|
||||
} else if (id == R.string.shared_string_save_as_gpx) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.osmand.plus.download;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
|
@ -8,23 +7,18 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.access.AccessibleAlertBuilder;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.ActionBarProgressActivity;
|
||||
import net.osmand.plus.activities.SettingsGeneralActivity;
|
||||
import net.osmand.plus.base.BasicProgressAsyncTask;
|
||||
import net.osmand.plus.base.SuggestExternalDirectoryDialog;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.widget.Toast;
|
||||
|
@ -235,52 +229,9 @@ public class BaseDownloadActivity extends ActionBarProgressActivity {
|
|||
}
|
||||
|
||||
private void prepareDownloadDirectory() {
|
||||
if (getMyApplication().getResourceManager().getIndexFileNames().isEmpty()) {
|
||||
boolean showedDialog = false;
|
||||
if (Build.VERSION.SDK_INT < OsmandSettings.VERSION_DEFAULTLOCATION_CHANGED) {
|
||||
SuggestExternalDirectoryDialog.showDialog(this, null, null);
|
||||
}
|
||||
if (!showedDialog) {
|
||||
if (!getMyApplication().getResourceManager().getIndexFileNames().isEmpty()) {
|
||||
showDialogOfFreeDownloadsIfNeeded();
|
||||
}
|
||||
} else {
|
||||
showDialogOfFreeDownloadsIfNeeded();
|
||||
}
|
||||
|
||||
|
||||
if (Build.VERSION.SDK_INT >= OsmandSettings.VERSION_DEFAULTLOCATION_CHANGED) {
|
||||
final String currentStorage = settings.getExternalStorageDirectory().getAbsolutePath();
|
||||
String primaryStorage = settings.getDefaultExternalStorageLocation();
|
||||
if (!currentStorage.startsWith(primaryStorage)) {
|
||||
// secondary storage
|
||||
boolean currentDirectoryNotWritable = true;
|
||||
for (String writeableDirectory : settings.getWritableSecondaryStorageDirectorys()) {
|
||||
if (currentStorage.startsWith(writeableDirectory)) {
|
||||
currentDirectoryNotWritable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (currentDirectoryNotWritable) {
|
||||
currentDirectoryNotWritable = !OsmandSettings.isWritable(settings.getExternalStorageDirectory());
|
||||
}
|
||||
if (currentDirectoryNotWritable) {
|
||||
final String newLoc = settings.getMatchingExternalFilesDir(currentStorage);
|
||||
if (newLoc != null && newLoc.length() != 0) {
|
||||
AccessibleAlertBuilder ab = new AccessibleAlertBuilder(this);
|
||||
ab.setMessage(getString(R.string.android_19_location_disabled,
|
||||
settings.getExternalStorageDirectory()));
|
||||
ab.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
copyFilesForAndroid19(newLoc);
|
||||
}
|
||||
});
|
||||
ab.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
ab.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showDialogOfFreeDownloadsIfNeeded() {
|
||||
|
@ -307,25 +258,6 @@ public class BaseDownloadActivity extends ActionBarProgressActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private void copyFilesForAndroid19(final String newLoc) {
|
||||
SettingsGeneralActivity.MoveFilesToDifferentDirectory task =
|
||||
new SettingsGeneralActivity.MoveFilesToDifferentDirectory(this,
|
||||
new File(settings.getExternalStorageDirectory(), IndexConstants.APP_DIR),
|
||||
new File(newLoc, IndexConstants.APP_DIR)) {
|
||||
protected Boolean doInBackground(Void[] params) {
|
||||
Boolean result = super.doInBackground(params);
|
||||
if (result) {
|
||||
settings.setExternalStorageDirectory(newLoc);
|
||||
getMyApplication().getResourceManager().resetStoreDirectory();
|
||||
getMyApplication().getResourceManager().reloadIndexes(progress, new ArrayList<String>());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
;
|
||||
};
|
||||
task.execute();
|
||||
}
|
||||
|
||||
public boolean isInQueue(IndexItem item) {
|
||||
return downloadQueue.contains(item);
|
||||
|
|
|
@ -52,8 +52,8 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
|
|||
pointAtUI.setColor(0xa0FF3344);
|
||||
pointAtUI.setStyle(Paint.Style.FILL);
|
||||
|
||||
poi = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_origin);
|
||||
bug = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_destination);
|
||||
poi = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_poi);
|
||||
bug = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_poi);
|
||||
|
||||
paintIcon = new Paint();
|
||||
|
||||
|
|
|
@ -354,8 +354,7 @@ public class RouteProvider {
|
|||
// get the closest point to start and to end
|
||||
GPXRouteParams gpxParams = routeParams.gpxRoute;
|
||||
if(routeParams.gpxRoute.useIntermediatePointsRTE){
|
||||
final List<Location> intermediates = gpxParams.points;
|
||||
return calculateOsmAndRouteWithIntermediatePoints(routeParams, intermediates);
|
||||
return calculateOsmAndRouteWithIntermediatePoints(routeParams, gpxParams.points);
|
||||
}
|
||||
List<Location> gpxRoute ;
|
||||
int[] startI = new int[]{0};
|
||||
|
@ -399,7 +398,19 @@ public class RouteProvider {
|
|||
rp.onlyStartPointChanged = routeParams.onlyStartPointChanged;
|
||||
rp.previousToRecalculate = routeParams.previousToRecalculate;
|
||||
rp.intermediates = new ArrayList<LatLon>();
|
||||
for(Location w : intermediates) {
|
||||
int closest = 0;
|
||||
double maxDist = Double.POSITIVE_INFINITY;
|
||||
for (int i = 0; i < intermediates.size(); i++) {
|
||||
Location loc = intermediates.get(i);
|
||||
double dist = MapUtils.getDistance(loc.getLatitude(), loc.getLongitude(), rp.start.getLatitude(),
|
||||
rp.start.getLongitude());
|
||||
if (dist <= maxDist) {
|
||||
closest = i;
|
||||
maxDist = dist;
|
||||
}
|
||||
}
|
||||
for(int i = closest; i< intermediates.size() ; i++ ){
|
||||
Location w = intermediates.get(i);
|
||||
rp.intermediates.add(new LatLon(w.getLatitude(), w.getLongitude()));
|
||||
}
|
||||
return findVectorMapsRoute(rp, false);
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import android.support.v7.app.ActionBar;
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.Location;
|
||||
|
@ -33,7 +32,6 @@ import net.osmand.plus.TargetPointsHelper;
|
|||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.MapActivityLayers;
|
||||
import net.osmand.plus.myplaces.SelectedGPXFragment;
|
||||
import net.osmand.plus.activities.actions.ShareLocation;
|
||||
import net.osmand.plus.api.FileSettingsAPIImpl;
|
||||
import net.osmand.plus.api.SettingsAPI;
|
||||
|
@ -41,6 +39,7 @@ import net.osmand.plus.download.DownloadActivity;
|
|||
import net.osmand.plus.download.DownloadActivityType;
|
||||
import net.osmand.plus.download.DownloadIndexFragment;
|
||||
import net.osmand.plus.helpers.WaypointHelper;
|
||||
import net.osmand.plus.myplaces.SelectedGPXFragment;
|
||||
import net.osmand.plus.routing.RouteCalculationResult;
|
||||
import net.osmand.plus.sherpafy.TourInformation.StageFavorite;
|
||||
import net.osmand.plus.sherpafy.TourInformation.StageInformation;
|
||||
|
@ -54,10 +53,10 @@ import android.content.DialogInterface;
|
|||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -94,16 +93,11 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
|
|||
osmandSettings.OSMAND_THEME.set(OsmandSettings.OSMAND_LIGHT_THEME);
|
||||
}
|
||||
accessCodePref = osmandSettings.registerStringPreference(ACCESS_CODE, "").makeGlobal();
|
||||
toursFolder = new File(osmandSettings.getExternalStorageDirectory(), "osmand/tours");
|
||||
toursFolder = app.getAppPath("tours");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getExternalStorageDir() {
|
||||
final String defaultLocation = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
return new File(originalApi.getString(originalGlobal, OsmandSettings.EXTERNAL_STORAGE_DIR,
|
||||
defaultLocation));
|
||||
}
|
||||
|
||||
|
||||
public boolean setAccessCode(String acCode) {
|
||||
acCode = acCode.toUpperCase();
|
||||
|
|
|
@ -92,7 +92,7 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu
|
|||
int locationY = tb.getPixYFromLatNoRot(ip.getLatitude());
|
||||
canvas.rotate(-tb.getRotate(), locationX, locationY);
|
||||
canvas.drawBitmap(intermediatePoint, locationX - marginX, locationY - marginY, bitmapPaint);
|
||||
marginX = intermediatePoint.getWidth() / 5;
|
||||
marginX = intermediatePoint.getWidth() / 3;
|
||||
canvas.drawText(index + "", locationX + marginX, locationY - 3 * marginY / 5, textPaint);
|
||||
canvas.rotate(tb.getRotate(), locationX, locationY);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class NextTurnInfoWidget extends TextInfoWidget {
|
|||
setImageDrawable(turnDrawable, false);
|
||||
setTopImageDrawable(null, null);
|
||||
} else {
|
||||
setImageDrawable(null, false);
|
||||
setImageDrawable(null, true);
|
||||
setTopImageDrawable(turnDrawable, "");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue