wip
This commit is contained in:
parent
224cc71ce7
commit
8294a0f08b
4 changed files with 194 additions and 78 deletions
|
@ -22,8 +22,7 @@
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/title_tv"
|
android:id="@+id/title_tv"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textAppearance="@style/TextAppearance.ListItemCategoryTitle"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
tools:text="Quick actions" />
|
tools:text="Quick actions" />
|
||||||
|
@ -42,7 +41,7 @@
|
||||||
android:id="@+id/divider"
|
android:id="@+id/divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:background="?attr/divider_color"
|
android:background="?attr/divider_color_basic"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
|
|
@ -30,14 +30,14 @@
|
||||||
android:id="@+id/title_tv"
|
android:id="@+id/title_tv"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textAppearance="@style/TextAppearance.ListItemCategoryTitle"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
|
||||||
tools:text="Quick actions" />
|
tools:text="Quick actions" />
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/sub_text_tv"
|
android:id="@+id/sub_text_tv"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
android:textColor="?android:textColorSecondary"
|
android:textColor="?android:textColorSecondary"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
tools:text="8 of 4" />
|
tools:text="8 of 4" />
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="@dimen/content_padding"
|
android:layout_marginTop="@dimen/content_padding"
|
||||||
android:layout_marginBottom="@dimen/content_padding"
|
android:layout_marginBottom="@dimen/content_padding"
|
||||||
android:background="?attr/divider_color" />
|
android:background="?attr/divider_color_basic" />
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatCheckBox
|
<android.support.v7.widget.AppCompatCheckBox
|
||||||
android:id="@+id/check_box"
|
android:id="@+id/check_box"
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
android:id="@+id/divider"
|
android:id="@+id/divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:background="?attr/divider_color"
|
android:background="?attr/divider_color_basic"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.ApplicationMode.ApplicationModeBuilder;
|
import net.osmand.plus.ApplicationMode.ApplicationModeBuilder;
|
||||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||||
import net.osmand.plus.poi.PoiUIFilter;
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
|
import net.osmand.plus.profiles.ExportImportProfileBottomSheet;
|
||||||
import net.osmand.plus.quickaction.QuickAction;
|
import net.osmand.plus.quickaction.QuickAction;
|
||||||
import net.osmand.plus.quickaction.QuickActionFactory;
|
import net.osmand.plus.quickaction.QuickActionFactory;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -721,27 +722,52 @@ public class SettingsHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public QuickActionSettingsItem(@NonNull OsmandSettings settings,
|
public QuickActionSettingsItem(@NonNull OsmandSettings settings,
|
||||||
@NonNull JSONObject jsonObject) throws JSONException {
|
@NonNull JSONObject jsonObject, File file) throws JSONException {
|
||||||
super(SettingsItemType.QUICK_ACTION_LIST, settings, jsonObject);
|
super(SettingsItemType.QUICK_ACTION_LIST, settings, jsonObject);
|
||||||
readFromJson(jsonObject);
|
try {
|
||||||
|
readFromJson(jsonObject, file);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<QuickAction> getQuickActions() {
|
public List<QuickAction> getQuickActions() {
|
||||||
return quickActions;
|
return quickActions;
|
||||||
}
|
}
|
||||||
|
|
||||||
// void readFromJson(JSONObject jsonObject) {
|
void readFromJson(JSONObject jsonObject, File file) throws IllegalArgumentException, IOException, JSONException {
|
||||||
// try {
|
ZipInputStream zis = new ZipInputStream(new FileInputStream(file));
|
||||||
// JSONArray jsonArray = jsonObject.getJSONArray("");
|
InputStream ois = new BufferedInputStream(zis);
|
||||||
//
|
ZipEntry entry;
|
||||||
// } catch (JSONException e) {
|
while ((entry = zis.getNextEntry()) != null){
|
||||||
//
|
if (entry.getName().equals(getFileName())) {
|
||||||
// }
|
String itemsJson = null;
|
||||||
// }
|
try {
|
||||||
|
itemsJson = Algorithms.readFromInputStream(ois).toString();
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOG.error("Error reading items.json: " + itemsJson, e);
|
||||||
|
throw new IllegalArgumentException("No items");
|
||||||
|
} finally {
|
||||||
|
zis.closeEntry();
|
||||||
|
}
|
||||||
|
quickActions = new ArrayList<>();
|
||||||
|
JSONObject json = new JSONObject(itemsJson);
|
||||||
|
JSONArray items = json.getJSONArray("items");
|
||||||
|
for (int i = 0; i < items.length(); i++) {
|
||||||
|
JSONObject object = items.getJSONObject(i);
|
||||||
|
String name = object.getString("name");
|
||||||
|
int type = object.getInt("type");
|
||||||
|
QuickAction quickAction = new QuickAction(type);
|
||||||
|
quickAction.setName(name);
|
||||||
|
quickActions.add(quickAction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply() {
|
public void apply() {
|
||||||
if (quickActions.isEmpty()) {
|
if (!quickActions.isEmpty()) {
|
||||||
QuickActionFactory factory = new QuickActionFactory();
|
QuickActionFactory factory = new QuickActionFactory();
|
||||||
List<QuickAction> quickActionsList = factory.parseActiveActionsList(getSettings().QUICK_ACTION_LIST.get());
|
List<QuickAction> quickActionsList = factory.parseActiveActionsList(getSettings().QUICK_ACTION_LIST.get());
|
||||||
quickActionsList.addAll(quickActions);
|
quickActionsList.addAll(quickActions);
|
||||||
|
@ -914,13 +940,78 @@ public class SettingsHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class MapSourcesSettingsItem extends OsmandSettingsItem {
|
||||||
|
|
||||||
|
private List<ExportImportProfileBottomSheet.MapSourceWrapper> mapSources;
|
||||||
|
|
||||||
|
public MapSourcesSettingsItem(OsmandSettings settings, List<ExportImportProfileBottomSheet.MapSourceWrapper> mapSources) {
|
||||||
|
super(SettingsItemType.MAP_SOURCES_LIST, settings);
|
||||||
|
this.mapSources = mapSources;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapSourcesSettingsItem(OsmandSettings settings, JSONObject jsonObject) throws JSONException {
|
||||||
|
super(SettingsItemType.MAP_SOURCES_LIST, settings, jsonObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "map_sources";
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String getPublicName(@NonNull Context ctx) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String getFileName() {
|
||||||
|
return getName() + ".json";
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
SettingsItemReader getReader() {
|
||||||
|
return new OsmandSettingsItemReader(this, getSettings()) {
|
||||||
|
@Override
|
||||||
|
protected void readPreferenceFromJson(@NonNull OsmandPreference<?> preference, @NonNull JSONObject json) throws JSONException {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
SettingsItemWriter getWriter() {
|
||||||
|
return new OsmandSettingsItemWriter(this, getSettings()) {
|
||||||
|
@Override
|
||||||
|
protected void writePreferenceToJson(@NonNull OsmandPreference<?> preference, @NonNull JSONObject json) throws JSONException {
|
||||||
|
JSONArray items = new JSONArray();
|
||||||
|
if (!mapSources.isEmpty()) {
|
||||||
|
for (ExportImportProfileBottomSheet.MapSourceWrapper mapSourceWrapper : mapSources) {
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("name", mapSourceWrapper.getName());
|
||||||
|
jsonObject.put("url", mapSourceWrapper.getUrl());
|
||||||
|
items.put(jsonObject);
|
||||||
|
}
|
||||||
|
json.put("items", items);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class SettingsItemsFactory {
|
private static class SettingsItemsFactory {
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private List<SettingsItem> items = new ArrayList<>();
|
private List<SettingsItem> items = new ArrayList<>();
|
||||||
|
private File file;
|
||||||
|
|
||||||
SettingsItemsFactory(OsmandApplication app, String jsonStr) throws IllegalArgumentException, JSONException {
|
SettingsItemsFactory(OsmandApplication app, String jsonStr, File file) throws IllegalArgumentException, JSONException {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
this.file = file;
|
||||||
JSONObject json = new JSONObject(jsonStr);
|
JSONObject json = new JSONObject(jsonStr);
|
||||||
JSONArray itemsJson = json.getJSONArray("items");
|
JSONArray itemsJson = json.getJSONArray("items");
|
||||||
for (int i = 0; i < itemsJson.length(); i++) {
|
for (int i = 0; i < itemsJson.length(); i++) {
|
||||||
|
@ -971,14 +1062,14 @@ public class SettingsHelper {
|
||||||
item = new FileSettingsItem(app, json);
|
item = new FileSettingsItem(app, json);
|
||||||
break;
|
break;
|
||||||
case QUICK_ACTION_LIST:
|
case QUICK_ACTION_LIST:
|
||||||
item = new QuickActionSettingsItem(settings, json);
|
item = new QuickActionSettingsItem(settings, json, file);
|
||||||
break;
|
break;
|
||||||
case POI_UI_FILTERS_LIST:
|
case POI_UI_FILTERS_LIST:
|
||||||
item = new PoiUiFilterSettingsItem(settings, json);
|
item = new PoiUiFilterSettingsItem(settings, json);
|
||||||
break;
|
break;
|
||||||
// case MAP_SOURCES_LIST:
|
case MAP_SOURCES_LIST:
|
||||||
// item = new
|
item = new MapSourcesSettingsItem(settings, json);
|
||||||
// break;
|
break;
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -1079,7 +1170,7 @@ public class SettingsHelper {
|
||||||
}
|
}
|
||||||
SettingsItemsFactory itemsFactory;
|
SettingsItemsFactory itemsFactory;
|
||||||
try {
|
try {
|
||||||
itemsFactory = new SettingsItemsFactory(app, itemsJson);
|
itemsFactory = new SettingsItemsFactory(app, itemsJson, file);
|
||||||
if (collecting) {
|
if (collecting) {
|
||||||
items.addAll(itemsFactory.getItems());
|
items.addAll(itemsFactory.getItems());
|
||||||
}
|
}
|
||||||
|
@ -1462,11 +1553,6 @@ public class SettingsHelper {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onSettingsImportFinished(success, empty, items);
|
listener.onSettingsImportFinished(success, empty, items);
|
||||||
}
|
}
|
||||||
if (success) {
|
|
||||||
app.showShortToastMessage(app.getString(R.string.file_imported_successfully, ""));
|
|
||||||
} else if (!empty) {
|
|
||||||
app.showShortToastMessage(app.getString(R.string.file_import_error, "", app.getString(R.string.shared_string_unexpected_error)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
|
@ -1531,4 +1617,8 @@ public class SettingsHelper {
|
||||||
public void importSettings(List<SettingsItem> items, File file, SettingsImportListener listener) {
|
public void importSettings(List<SettingsItem> items, File file, SettingsImportListener listener) {
|
||||||
new ImportSettingsTask(items, file, listener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
new ImportSettingsTask(items, file, listener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public void preImportSettings(List<SettingsItem> items, File file, SettingsImportListener listener) {
|
||||||
|
// new ImportSettingsTask(items, file, listener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
private ApplicationMode profile;
|
private ApplicationMode profile;
|
||||||
|
|
||||||
private boolean includeAdditionalData = false;
|
private boolean includeAdditionalData = false;
|
||||||
|
|
||||||
private boolean containsAdditionalData = false;
|
private boolean containsAdditionalData = false;
|
||||||
|
|
||||||
private State state;
|
private State state;
|
||||||
|
@ -86,6 +87,7 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
|
|
||||||
private File file;
|
private File file;
|
||||||
|
|
||||||
|
private SettingsHelper.ProfileSettingsItem profileSettingsItem;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -111,6 +113,7 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
private ApplicationMode getAppModeFromItems() {
|
private ApplicationMode getAppModeFromItems() {
|
||||||
for (SettingsHelper.SettingsItem item : settingsItems) {
|
for (SettingsHelper.SettingsItem item : settingsItems) {
|
||||||
if (item.getType().equals(SettingsHelper.SettingsItemType.PROFILE)) {
|
if (item.getType().equals(SettingsHelper.SettingsItemType.PROFILE)) {
|
||||||
|
profileSettingsItem = ((SettingsHelper.ProfileSettingsItem) item);
|
||||||
return ((SettingsHelper.ProfileSettingsItem) item).getAppMode();
|
return ((SettingsHelper.ProfileSettingsItem) item).getAppMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,41 +187,49 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDataFromSettingsItems() {
|
private void updateDataFromSettingsItems() {
|
||||||
app.getSettingsHelper().importSettings(settingsItems, file, new SettingsHelper.SettingsImportListener() {
|
|
||||||
@Override
|
List<AdditionalDataWrapper> dataList = new ArrayList<>();
|
||||||
public void onSettingsImportFinished(boolean succeed, boolean empty, @NonNull List<SettingsHelper.SettingsItem> items) {
|
List<QuickAction> quickActions = new ArrayList<>();
|
||||||
List<AdditionalDataWrapper> dataList = new ArrayList<>();
|
List<PoiUIFilter> poiUIFilters = new ArrayList<>();
|
||||||
List<QuickAction> quickActions = new ArrayList<>();
|
for (SettingsHelper.SettingsItem item : settingsItems) {
|
||||||
List<PoiUIFilter> poiUIFilters = new ArrayList<>();
|
if (item.getType().equals(SettingsHelper.SettingsItemType.QUICK_ACTION_LIST)) {
|
||||||
for (SettingsHelper.SettingsItem item : items) {
|
|
||||||
if (item.getType().equals(SettingsHelper.SettingsItemType.QUICK_ACTION_LIST)) {
|
|
||||||
quickActions.addAll(((SettingsHelper.QuickActionSettingsItem) item).getQuickActions());
|
quickActions.addAll(((SettingsHelper.QuickActionSettingsItem) item).getQuickActions());
|
||||||
} else if (item.getType().equals(SettingsHelper.SettingsItemType.POI_UI_FILTERS_LIST)) {
|
} else if (item.getType().equals(SettingsHelper.SettingsItemType.POI_UI_FILTERS_LIST)) {
|
||||||
// poiUIFilters.addAll()
|
// poiUIFilters.addAll()
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!quickActions.isEmpty()) {
|
|
||||||
dataList.add(new AdditionalDataWrapper(
|
|
||||||
AdditionalDataWrapper.Type.QUICK_ACTIONS,
|
|
||||||
quickActions));
|
|
||||||
}
|
|
||||||
if (!poiUIFilters.isEmpty()) {
|
|
||||||
dataList.add(new AdditionalDataWrapper(
|
|
||||||
AdditionalDataWrapper.Type.POI_TYPES,
|
|
||||||
poiUIFilters));
|
|
||||||
}
|
|
||||||
adapter.updateList(dataList);
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
if (!quickActions.isEmpty()) {
|
||||||
|
dataList.add(new AdditionalDataWrapper(
|
||||||
|
AdditionalDataWrapper.Type.QUICK_ACTIONS,
|
||||||
|
quickActions));
|
||||||
|
}
|
||||||
|
if (!poiUIFilters.isEmpty()) {
|
||||||
|
dataList.add(new AdditionalDataWrapper(
|
||||||
|
AdditionalDataWrapper.Type.POI_TYPES,
|
||||||
|
poiUIFilters));
|
||||||
|
}
|
||||||
|
for (AdditionalDataWrapper dataWrapper : dataList) {
|
||||||
|
dataToOperate.addAll(dataWrapper.getItems());
|
||||||
|
}
|
||||||
|
adapter.updateList(dataList);
|
||||||
|
|
||||||
|
// app.getSettingsHelper().importSettings(settingsItems, file, new SettingsHelper.SettingsImportListener() {
|
||||||
|
// @Override
|
||||||
|
// public void onSettingsImportFinished(boolean succeed, boolean empty, @NonNull List<SettingsHelper.SettingsItem> items) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean checkAdditionalDataContains() {
|
private Boolean checkAdditionalDataContains() {
|
||||||
boolean containsData = false;
|
boolean containsData = false;
|
||||||
for (SettingsHelper.SettingsItem item : settingsItems) {
|
for (SettingsHelper.SettingsItem item : settingsItems) {
|
||||||
containsData = item.getType().equals(SettingsHelper.SettingsItemType.QUICK_ACTION_LIST)
|
containsData = item.getType().equals(SettingsHelper.SettingsItemType.QUICK_ACTION_LIST)
|
||||||
|| item.getType().equals(SettingsHelper.SettingsItemType.POI_UI_FILTERS_LIST);
|
|| item.getType().equals(SettingsHelper.SettingsItemType.POI_UI_FILTERS_LIST)
|
||||||
|
|| item.getType().equals(SettingsHelper.SettingsItemType.MAP_SOURCES_LIST);
|
||||||
|
if (containsData) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return containsData;
|
return containsData;
|
||||||
}
|
}
|
||||||
|
@ -228,24 +239,30 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
|
|
||||||
QuickActionFactory factory = new QuickActionFactory();
|
QuickActionFactory factory = new QuickActionFactory();
|
||||||
List<QuickAction> quickActions = factory.parseActiveActionsList(settings.QUICK_ACTION_LIST.get());
|
List<QuickAction> quickActions = factory.parseActiveActionsList(settings.QUICK_ACTION_LIST.get());
|
||||||
dataList.add(new AdditionalDataWrapper(
|
if (!quickActions.isEmpty()) {
|
||||||
AdditionalDataWrapper.Type.QUICK_ACTIONS, quickActions));
|
dataList.add(new AdditionalDataWrapper(
|
||||||
|
AdditionalDataWrapper.Type.QUICK_ACTIONS, quickActions));
|
||||||
|
}
|
||||||
|
|
||||||
List<PoiUIFilter> poiList = app.getPoiFilters().getUserDefinedPoiFilters(false);
|
List<PoiUIFilter> poiList = app.getPoiFilters().getUserDefinedPoiFilters(false);
|
||||||
dataList.add(new AdditionalDataWrapper(
|
if (!poiList.isEmpty()) {
|
||||||
AdditionalDataWrapper.Type.POI_TYPES,
|
dataList.add(new AdditionalDataWrapper(
|
||||||
poiList
|
AdditionalDataWrapper.Type.POI_TYPES,
|
||||||
));
|
poiList
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
// final LinkedHashMap<String, String> entriesMap = new LinkedHashMap<>(settings.getTileSourceEntries());
|
final LinkedHashMap<String, String> entriesMap = new LinkedHashMap<>(settings.getTileSourceEntries());
|
||||||
// List<MapSourceWrapper> mapSourceWrapperList = new ArrayList<>();
|
List<MapSourceWrapper> mapSourceWrapperList = new ArrayList<>();
|
||||||
// for (Map.Entry<String, String> entry : entriesMap.entrySet()) {
|
for (Map.Entry<String, String> entry : entriesMap.entrySet()) {
|
||||||
// mapSourceWrapperList.add(new MapSourceWrapper(entry.getKey(), entry.getValue()));
|
mapSourceWrapperList.add(new MapSourceWrapper(entry.getKey(), entry.getValue()));
|
||||||
// }
|
}
|
||||||
// dataList.add(new AdditionalDataWrapper(
|
if (!mapSourceWrapperList.isEmpty()) {
|
||||||
// AdditionalDataWrapper.Type.MAP_SOURCES,
|
dataList.add(new AdditionalDataWrapper(
|
||||||
// mapSourceWrapperList
|
AdditionalDataWrapper.Type.MAP_SOURCES,
|
||||||
// ));
|
mapSourceWrapperList
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
return dataList;
|
return dataList;
|
||||||
}
|
}
|
||||||
|
@ -270,13 +287,23 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void importSettings() {
|
private void importSettings() {
|
||||||
app.getSettingsHelper().importSettings(settingsItems, file, new SettingsHelper.SettingsImportListener() {
|
if (includeAdditionalData) {
|
||||||
|
|
||||||
@Override
|
} else {
|
||||||
public void onSettingsImportFinished(boolean succeed, boolean empty, @NonNull List<SettingsHelper.SettingsItem> items) {
|
List<SettingsHelper.SettingsItem> list = new ArrayList<>();
|
||||||
|
list.add(profileSettingsItem);
|
||||||
|
app.getSettingsHelper().importSettings(list, file, new SettingsHelper.SettingsImportListener() {
|
||||||
|
|
||||||
}
|
@Override
|
||||||
});
|
public void onSettingsImportFinished(boolean succeed, boolean empty, @NonNull List<SettingsHelper.SettingsItem> items) {
|
||||||
|
if (succeed) {
|
||||||
|
app.showShortToastMessage(app.getString(R.string.file_imported_successfully, ""));
|
||||||
|
} else if (!empty) {
|
||||||
|
app.showShortToastMessage(app.getString(R.string.file_import_error, "", app.getString(R.string.shared_string_unexpected_error)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,9 +340,9 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
if (!poiUIFilters.isEmpty()) {
|
if (!poiUIFilters.isEmpty()) {
|
||||||
settingsItems.add(new SettingsHelper.PoiUiFilterSettingsItem(app.getSettings(), poiUIFilters));
|
settingsItems.add(new SettingsHelper.PoiUiFilterSettingsItem(app.getSettings(), poiUIFilters));
|
||||||
}
|
}
|
||||||
// if (!mapSourceWrappers.isEmpty()) {
|
if (!mapSourceWrappers.isEmpty()) {
|
||||||
// settingsItems.add();
|
settingsItems.add(new SettingsHelper.MapSourcesSettingsItem(app.getSettings(), mapSourceWrappers));
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
return settingsItems;
|
return settingsItems;
|
||||||
}
|
}
|
||||||
|
@ -599,7 +626,7 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MapSourceWrapper {
|
public class MapSourceWrapper {
|
||||||
private String name;
|
private String name;
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue