diff --git a/OsmAnd/res/layout/fragment_import.xml b/OsmAnd/res/layout/fragment_import.xml
index 792f7db928..b9e45abd12 100644
--- a/OsmAnd/res/layout/fragment_import.xml
+++ b/OsmAnd/res/layout/fragment_import.xml
@@ -46,8 +46,7 @@
android:paddingBottom="@dimen/list_header_settings_top_margin"
android:text="@string/select_data_to_import"
android:textColor="?android:textColorPrimary"
- android:textSize="@dimen/default_list_text_size"
- osmand:typeface="@string/font_roboto_medium" />
+ android:textSize="@dimen/default_list_text_size" />
@@ -62,7 +61,7 @@
android:groupIndicator="@android:color/transparent"
android:listSelector="@android:color/transparent" />
-
+
+ android:textSize="@dimen/default_list_text_size" />
-
+
+ android:gravity="center_vertical">
+ android:orientation="vertical"
+ android:paddingTop="@dimen/content_padding_small"
+ android:paddingBottom="@dimen/content_padding_small">
@@ -37,6 +41,8 @@
android:id="@+id/sub_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
tools:text="Navigation type: Car" />
diff --git a/OsmAnd/res/layout/profile_data_list_item_child.xml b/OsmAnd/res/layout/profile_data_list_item_child.xml
index e0a04a1892..265cdd4275 100644
--- a/OsmAnd/res/layout/profile_data_list_item_child.xml
+++ b/OsmAnd/res/layout/profile_data_list_item_child.xml
@@ -4,6 +4,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
+ android:minHeight="@dimen/setting_list_item_small_height"
android:orientation="vertical">
+ android:gravity="center_vertical">
+ android:orientation="vertical"
+ android:paddingTop="@dimen/content_padding_small"
+ android:paddingBottom="@dimen/content_padding_small">
@@ -44,6 +48,8 @@
android:id="@+id/sub_title_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
android:visibility="gone"
diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml
index 020d67735b..6e72c38b4d 100644
--- a/OsmAnd/res/values/sizes.xml
+++ b/OsmAnd/res/values/sizes.xml
@@ -353,5 +353,6 @@
18dp
72dp
72dp
+ 42dp
\ No newline at end of file
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 577fbd1a68..1552a0bf46 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -72,7 +72,7 @@
Sunset at %1$s
Sunrise at %1$s
Routing
- Custom rendering style
+ Rendering styles
Include additional data
The imported profile contains additional data. Click Import to import only profile data or select additional data to import.
You can select additional data to export along with the profile.
diff --git a/OsmAnd/src/net/osmand/plus/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/SettingsHelper.java
index bc299d6e10..72f7bc1179 100644
--- a/OsmAnd/src/net/osmand/plus/SettingsHelper.java
+++ b/OsmAnd/src/net/osmand/plus/SettingsHelper.java
@@ -805,7 +805,7 @@ public class SettingsHelper {
@Override
public void readFromStream(@NonNull InputStream inputStream) throws IOException, IllegalArgumentException {
OutputStream output;
- if (shouldReplace || !file.exists()) {
+ if (!file.exists() || file.exists() && shouldReplace) {
output = new FileOutputStream(file);
} else {
output = new FileOutputStream(renameFile(file));
@@ -847,6 +847,7 @@ public class SettingsHelper {
this.app = app;
actionRegistry = app.getQuickActionRegistry();
existingItems = actionRegistry.getQuickActions();
+ duplicateItems = new ArrayList<>();
}
QuickActionSettingsItem(@NonNull OsmandApplication app,
@@ -855,6 +856,7 @@ public class SettingsHelper {
this.app = app;
actionRegistry = app.getQuickActionRegistry();
existingItems = actionRegistry.getQuickActions();
+ duplicateItems = new ArrayList<>();
}
@Override
@@ -871,7 +873,6 @@ public class SettingsHelper {
@NonNull
@Override
public List excludeDuplicateItems() {
- duplicateItems = new ArrayList<>();
for (QuickAction item : items) {
if (isDuplicate(item)) {
duplicateItems.add(item);
@@ -1026,12 +1027,14 @@ public class SettingsHelper {
super(SettingsItemType.POI_UI_FILTERS, items);
this.app = app;
existingItems = app.getPoiFilters().getUserDefinedPoiFilters(false);
+ duplicateItems = new ArrayList<>();
}
PoiUiFilterSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException {
super(SettingsItemType.POI_UI_FILTERS, json);
this.app = app;
existingItems = app.getPoiFilters().getUserDefinedPoiFilters(false);
+ duplicateItems = new ArrayList<>();
}
@Override
@@ -1061,7 +1064,6 @@ public class SettingsHelper {
@NonNull
@Override
public List excludeDuplicateItems() {
- duplicateItems = new ArrayList<>();
if (!items.isEmpty()) {
for (PoiUIFilter item : items) {
if (isDuplicate(item)) {
@@ -1212,6 +1214,7 @@ public class SettingsHelper {
this.app = app;
Collection values = new LinkedHashMap<>(app.getSettings().getTileSourceEntries(true)).values();
existingItemsNames = new ArrayList(values);
+ duplicateItems = new ArrayList<>();
}
MapSourcesSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException {
@@ -1219,6 +1222,7 @@ public class SettingsHelper {
this.app = app;
Collection values = new LinkedHashMap<>(app.getSettings().getTileSourceEntries(true)).values();
existingItemsNames = new ArrayList(values);
+ duplicateItems = new ArrayList<>();
}
@Override
@@ -1261,7 +1265,6 @@ public class SettingsHelper {
@NonNull
@Override
public List excludeDuplicateItems() {
- duplicateItems = new ArrayList<>();
for (String name : existingItemsNames) {
for (ITileSource tileSource : items) {
if (name.equals(tileSource.getName())) {
@@ -1456,6 +1459,7 @@ public class SettingsHelper {
settings = app.getSettings();
specificRoads = app.getAvoidSpecificRoads();
existingItems = new ArrayList<>(specificRoads.getImpassableRoads().values());
+ duplicateItems = new ArrayList<>();
}
AvoidRoadsSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException {
@@ -1464,6 +1468,7 @@ public class SettingsHelper {
settings = app.getSettings();
specificRoads = app.getAvoidSpecificRoads();
existingItems = new ArrayList<>(specificRoads.getImpassableRoads().values());
+ duplicateItems = new ArrayList<>();
}
@NonNull
@@ -1486,27 +1491,28 @@ public class SettingsHelper {
@Override
public void apply() {
- for (AvoidRoadInfo duplicate : duplicateItems) {
- if (shouldReplace) {
- LatLon latLon = new LatLon(duplicate.latitude, duplicate.longitude);
- if (settings.removeImpassableRoad(latLon)) {
- settings.addImpassableRoad(duplicate);
+ if (!items.isEmpty() || !duplicateItems.isEmpty()) {
+ for (AvoidRoadInfo duplicate : duplicateItems) {
+ if (shouldReplace) {
+ LatLon latLon = new LatLon(duplicate.latitude, duplicate.longitude);
+ if (settings.removeImpassableRoad(latLon)) {
+ settings.addImpassableRoad(duplicate);
+ }
+ } else {
+ settings.addImpassableRoad(renameItem(duplicate));
}
- } else {
- settings.addImpassableRoad(duplicate);
}
+ for (AvoidRoadInfo avoidRoad : items) {
+ settings.addImpassableRoad(avoidRoad);
+ }
+ specificRoads.loadImpassableRoads();
+ specificRoads.initRouteObjects(true);
}
- for (AvoidRoadInfo avoidRoad : items) {
- settings.addImpassableRoad(avoidRoad);
- }
- specificRoads.loadImpassableRoads();
- specificRoads.initRouteObjects(true);
}
@NonNull
@Override
public List excludeDuplicateItems() {
- duplicateItems = new ArrayList<>();
for (AvoidRoadInfo item : items) {
if (isDuplicate(item)) {
duplicateItems.add(item);
@@ -1517,9 +1523,11 @@ public class SettingsHelper {
}
@Override
- public boolean isDuplicate(AvoidRoadInfo item) {
+ public boolean isDuplicate(@NonNull AvoidRoadInfo item) {
for (AvoidRoadInfo existingItem : existingItems) {
- if (item.latitude == existingItem.latitude && item.longitude == existingItem.longitude) {
+ if (item.latitude == existingItem.latitude
+ && item.longitude == existingItem.longitude
+ && item.name.equals(existingItem.name)) {
return true;
}
}
@@ -1537,9 +1545,13 @@ public class SettingsHelper {
int number = 0;
while (true) {
number++;
- AvoidRoadInfo renamedItem = item;
- renamedItem.name = renamedItem.name + "_" + number;
+ AvoidRoadInfo renamedItem = new AvoidRoadInfo();
+ renamedItem.name = item.name + "_" + number;
if (!isDuplicate(renamedItem)) {
+ renamedItem.id = item.id;
+ renamedItem.latitude = item.latitude;
+ renamedItem.longitude = item.longitude;
+ renamedItem.appModeKey = item.appModeKey;
return renamedItem;
}
}
@@ -1581,7 +1593,11 @@ public class SettingsHelper {
roadInfo.latitude = latitude;
roadInfo.longitude = longitude;
roadInfo.name = name;
- roadInfo.appModeKey = appModeKey;
+ if (ApplicationMode.valueOfStringKey(appModeKey, null) != null) {
+ roadInfo.appModeKey = appModeKey;
+ } else {
+ roadInfo.appModeKey = app.getRoutingHelper().getAppMode().getStringKey();
+ }
items.add(roadInfo);
}
} catch (JSONException e) {
@@ -1814,7 +1830,12 @@ public class SettingsHelper {
if (item != null && collecting && item.shouldReadOnCollecting()
|| item != null && !collecting && !item.shouldReadOnCollecting()) {
try {
- item.getReader().readFromStream(ois);
+ for (SettingsItem settingsItem : items) {
+ if (item.getFileName().equals(settingsItem.getFileName())) {
+ item.setShouldReplace(settingsItem.shouldReplace);
+ item.getReader().readFromStream(ois);
+ }
+ }
} catch (IllegalArgumentException e) {
LOG.error("Error reading item data: " + item.getName(), e);
} catch (IOException e) {
diff --git a/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java
index b93a803b8a..d599458d78 100644
--- a/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java
+++ b/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java
@@ -782,7 +782,7 @@ public class ImportHelper {
if (fragmentManager != null) {
ImportSettingsFragment.showInstance(fragmentManager, items, file);
}
- } else {
+ } else if (empty) {
app.showShortToastMessage(app.getString(R.string.file_import_error, name, app.getString(R.string.shared_string_unexpected_error)));
}
}
diff --git a/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java b/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java
index 64d091269c..a5bfc2d7bc 100644
--- a/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java
+++ b/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java
@@ -239,9 +239,20 @@ public class RendererRegistry {
}
public void initRenderers(IProgress progress) {
+ updateExternalRenderers();
+ String r = app.getSettings().RENDERER.get();
+ if(r != null){
+ RenderingRulesStorage obj = getRenderer(r);
+ if(obj != null){
+ setCurrentSelectedRender(obj);
+ }
+ }
+ }
+
+ public void updateExternalRenderers() {
File file = app.getAppPath(IndexConstants.RENDERERS_DIR);
file.mkdirs();
- Map externalRenderers = new LinkedHashMap();
+ Map externalRenderers = new LinkedHashMap();
if (file.exists() && file.canRead()) {
File[] lf = file.listFiles();
if (lf != null) {
@@ -256,13 +267,6 @@ public class RendererRegistry {
}
}
this.externalRenderers = externalRenderers;
- String r = app.getSettings().RENDERER.get();
- if(r != null){
- RenderingRulesStorage obj = getRenderer(r);
- if(obj != null){
- setCurrentSelectedRender(obj);
- }
- }
}
public Collection getRendererNames(){
diff --git a/OsmAnd/src/net/osmand/plus/settings/DuplicatesSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/DuplicatesSettingsAdapter.java
index 44f4beb613..ff49348940 100644
--- a/OsmAnd/src/net/osmand/plus/settings/DuplicatesSettingsAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/settings/DuplicatesSettingsAdapter.java
@@ -121,7 +121,7 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter items) {
if (succeed) {
app.showShortToastMessage(app.getString(R.string.file_imported_successfully, file.getName()));
+ app.getRendererRegistry().updateExternalRenderers();
+ AppInitializer.loadRoutingFiles(app, new AppInitializer.LoadRoutingFilesCallback() {
+ @Override
+ public void onRoutingFilesLoaded() {
+ }
+ });
} else if (empty) {
app.showShortToastMessage(app.getString(R.string.file_import_error, file.getName(), app.getString(R.string.shared_string_unexpected_error)));
}
@@ -191,6 +229,10 @@ public class ImportDuplicatesFragment extends BaseOsmAndDialogFragment implement
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+ FragmentManager fm = getFragmentManager();
+ if (fm != null) {
+ ImportSettingsFragment.showInstance(fm, null, file);
+ }
dismiss();
}
});
diff --git a/OsmAnd/src/net/osmand/plus/settings/ImportSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/ImportSettingsFragment.java
index 6b671de15a..2f01c1adf4 100644
--- a/OsmAnd/src/net/osmand/plus/settings/ImportSettingsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/ImportSettingsFragment.java
@@ -1,9 +1,13 @@
package net.osmand.plus.settings;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
+import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
@@ -12,6 +16,7 @@ import android.widget.ExpandableListView;
import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager;
+import net.osmand.plus.AppInitializer;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
@@ -43,7 +48,7 @@ public class ImportSettingsFragment extends BaseOsmAndDialogFragment
private boolean allSelected;
private boolean nightMode;
- public static void showInstance(@NonNull FragmentManager fm, @NonNull List settingsItems, @NonNull File file) {
+ public static void showInstance(@NonNull FragmentManager fm, List settingsItems, @NonNull File file) {
ImportSettingsFragment fragment = new ImportSettingsFragment();
fragment.setSettingsItems(settingsItems);
fragment.setFile(file);
@@ -57,9 +62,15 @@ public class ImportSettingsFragment extends BaseOsmAndDialogFragment
nightMode = !getSettings().isLightContent();
if (settingsItems == null) {
settingsItems = app.getSettingsHelper().getSettingsItems();
+ if (settingsItems == null) {
+ dismiss();
+ }
}
if (file == null) {
file = app.getSettingsHelper().getSettingsFile();
+ if (file == null) {
+ dismiss();
+ }
}
}
@@ -84,6 +95,17 @@ public class ImportSettingsFragment extends BaseOsmAndDialogFragment
expandableList.setAdapter(adapter);
}
+ @NonNull
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ return new Dialog(requireActivity(), getTheme()) {
+ @Override
+ public void onBackPressed() {
+ showExitDialog();
+ }
+ };
+ }
+
@Override
public void onClick(View view) {
switch (view.getId()) {
@@ -113,6 +135,12 @@ public class ImportSettingsFragment extends BaseOsmAndDialogFragment
public void onSettingsImportFinished(boolean succeed, boolean empty, @NonNull List items) {
if (succeed) {
app.showShortToastMessage(app.getString(R.string.file_imported_successfully, file.getName()));
+ app.getRendererRegistry().updateExternalRenderers();
+ AppInitializer.loadRoutingFiles(app, new AppInitializer.LoadRoutingFilesCallback() {
+ @Override
+ public void onRoutingFilesLoaded() {
+ }
+ });
} else if (empty) {
app.showShortToastMessage(app.getString(R.string.file_import_error, file.getName(), app.getString(R.string.shared_string_unexpected_error)));
}
@@ -125,7 +153,7 @@ public class ImportSettingsFragment extends BaseOsmAndDialogFragment
}
}
- private List