diff --git a/OsmAnd/res/layout/fragment_import.xml b/OsmAnd/res/layout/fragment_import.xml
index adb5757830..792f7db928 100644
--- a/OsmAnd/res/layout/fragment_import.xml
+++ b/OsmAnd/res/layout/fragment_import.xml
@@ -49,11 +49,7 @@
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium" />
-
+
+
+
+ layout="@layout/card_bottom_divider" />
+
+
+ Preparing
POI types
Nothing selected
Quick actions
diff --git a/OsmAnd/src/net/osmand/plus/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/SettingsHelper.java
index c0b5f1bb58..585077b358 100644
--- a/OsmAnd/src/net/osmand/plus/SettingsHelper.java
+++ b/OsmAnd/src/net/osmand/plus/SettingsHelper.java
@@ -2,6 +2,7 @@ package net.osmand.plus;
import android.annotation.SuppressLint;
import android.app.Activity;
+import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
@@ -23,6 +24,7 @@ import net.osmand.plus.ApplicationMode.ApplicationModeBuilder;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.poi.PoiUIFilter;
+import net.osmand.plus.profiles.ProfileIcons;
import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.quickaction.QuickActionFactory;
import net.osmand.util.Algorithms;
@@ -520,14 +522,29 @@ public class SettingsHelper {
@Override
public void apply() {
- if (appMode.isCustomProfile()) {
- if (!shouldReplace && exists()) {
- renameProfile();
- builder = ApplicationMode.fromModeBean(app, modeBean);
- }
- appMode = ApplicationMode.saveProfile(builder, getSettings().getContext());
- ApplicationMode.changeProfileAvailability(appMode, true, app);
+ if (!appMode.isCustomProfile() && !shouldReplace) {
+ ApplicationMode parent = ApplicationMode.valueOfStringKey(modeBean.stringKey, null);
+ renameProfile();
+ ApplicationMode.ApplicationModeBuilder builder = ApplicationMode
+ .createCustomMode(parent, modeBean.stringKey, app)
+ .setIconResName(modeBean.iconName)
+ .setUserProfileName(modeBean.userProfileName)
+ .setRoutingProfile(modeBean.routingProfile)
+ .setRouteService(modeBean.routeService)
+ .setIconColor(modeBean.iconColor)
+ .setLocationIcon(modeBean.locIcon)
+ .setNavigationIcon(modeBean.navIcon);
+ app.getSettings().copyPreferencesFromProfile(parent, builder.getApplicationMode());
+ appMode = ApplicationMode.saveProfile(builder, app);
+ } else if (!shouldReplace && exists()) {
+ renameProfile();
+ builder = ApplicationMode.fromModeBean(app, modeBean);
+ appMode = ApplicationMode.saveProfile(builder, app);
+ } else {
+ builder = ApplicationMode.fromModeBean(app, modeBean);
+ appMode = ApplicationMode.saveProfile(builder, app);
}
+ ApplicationMode.changeProfileAvailability(appMode, true, app);
}
@Override
@@ -1809,6 +1826,7 @@ public class SettingsHelper {
private SettingsExporter exporter;
private File file;
private SettingsExportListener listener;
+ private ProgressDialog progress;
ExportAsyncTask(@NonNull File settingsFile,
@Nullable SettingsExportListener listener,
@@ -1821,6 +1839,12 @@ public class SettingsHelper {
}
}
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ progress = ProgressDialog.show(activity, app.getString(R.string.export_profile), app.getString(R.string.shared_sting_preparing));
+ }
+
@Override
protected Boolean doInBackground(Void... voids) {
try {
@@ -1836,6 +1860,7 @@ public class SettingsHelper {
@Override
protected void onPostExecute(Boolean success) {
+ progress.dismiss();
if (listener != null) {
listener.onSettingsExportFinished(file, success);
}
diff --git a/OsmAnd/src/net/osmand/plus/settings/DuplicatesSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/DuplicatesSettingsAdapter.java
index 764b3d43f0..210b07a977 100644
--- a/OsmAnd/src/net/osmand/plus/settings/DuplicatesSettingsAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/settings/DuplicatesSettingsAdapter.java
@@ -1,6 +1,5 @@
package net.osmand.plus.settings;
-import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
@@ -9,13 +8,16 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
+import net.osmand.AndroidUtils;
import net.osmand.map.ITileSource;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.poi.PoiUIFilter;
+import net.osmand.plus.profiles.ProfileIconColors;
import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.render.RenderingIcons;
+import net.osmand.util.Algorithms;
import java.io.File;
@@ -59,45 +61,53 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter prepareDuplicates() {
List super Object> duplicates = new ArrayList<>();
- List profiles = new ArrayList<>();
+ List profiles = new ArrayList<>();
List actions = new ArrayList<>();
List filters = new ArrayList<>();
List tileSources = new ArrayList<>();
@@ -98,8 +99,8 @@ public class ImportDuplicatesFragment extends BaseOsmAndDialogFragment implement
List routingFilesList = new ArrayList<>();
for (Object object : duplicatesList) {
- if (object instanceof ApplicationMode) {
- profiles.add((ApplicationMode) object);
+ if (object instanceof ApplicationMode.ApplicationModeBean) {
+ profiles.add((ApplicationMode.ApplicationModeBean) object);
} else if (object instanceof QuickAction) {
actions.add((QuickAction) object);
} else if (object instanceof PoiUIFilter) {
diff --git a/OsmAnd/src/net/osmand/plus/settings/ImportSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/ImportSettingsFragment.java
index 8653c9cddd..f0e641c59e 100644
--- a/OsmAnd/src/net/osmand/plus/settings/ImportSettingsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/ImportSettingsFragment.java
@@ -1 +1 @@
-package net.osmand.plus.settings;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.SQLiteTileSource;
import net.osmand.plus.SettingsHelper;
import net.osmand.plus.SettingsHelper.SettingsItem;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.base.BaseOsmAndDialogFragment;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.profiles.AdditionalDataWrapper;
import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.widgets.TextViewEx;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class ImportSettingsFragment extends BaseOsmAndDialogFragment
implements View.OnClickListener {
public static final String TAG = ImportSettingsFragment.class.getSimpleName();
private OsmandApplication app;
private ExportImportSettingsAdapter adapter;
private ExpandableListView expandableList;
private TextViewEx selectBtn;
private List settingsItems;
private File file;
private boolean allSelected;
private boolean nightMode;
public static void showInstance(@NonNull FragmentManager fm, @NonNull List settingsItems, @NonNull File file) {
ImportSettingsFragment fragment = new ImportSettingsFragment();
fragment.setSettingsItems(settingsItems);
fragment.setFile(file);
fragment.show(fm, TAG);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = getMyApplication();
nightMode = !getSettings().isLightContent();
if (settingsItems == null) {
settingsItems = app.getSettingsHelper().getSettingsItems();
}
if (file == null) {
file = app.getSettingsHelper().getSettingsFile();
}
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
inflater = UiUtilities.getInflater(app, nightMode);
View root = inflater.inflate(R.layout.fragment_import, container, false);
setupToolbar((Toolbar) root.findViewById(R.id.toolbar));
TextViewEx continueBtn = root.findViewById(R.id.continue_button);
selectBtn = root.findViewById(R.id.select_button);
expandableList = root.findViewById(R.id.list);
continueBtn.setOnClickListener(this);
selectBtn.setOnClickListener(this);
return root;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
adapter = new ExportImportSettingsAdapter(getMyApplication(), getSettingsToOperate(), nightMode, true);
expandableList.setAdapter(adapter);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.select_button: {
allSelected = !allSelected;
selectBtn.setText(allSelected ? R.string.shared_string_deselect_all : R.string.shared_string_select_all);
adapter.selectAll(allSelected);
break;
}
case R.id.continue_button: {
if (adapter.getDataToOperate().isEmpty()) {
app.showShortToastMessage(getString(R.string.shared_sting_nothing_selected));
} else {
importItems();
}
break;
}
}
}
private void importItems() {
List settingsItems = getSettingsItemsFromData(adapter.getDataToOperate());
List