diff --git a/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl b/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl index 3a8edb6d80..72a3035b60 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl +++ b/OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl @@ -106,8 +106,6 @@ import net.osmand.aidlapi.events.AKeyEventsParams; import net.osmand.aidlapi.info.AppInfoParams; import net.osmand.aidlapi.profile.ExportProfileParams; -import net.osmand.aidlapi.profile.ExportSettingsType; - // NOTE: Add new methods at the end of file!!! diff --git a/OsmAnd-api/src/net/osmand/aidlapi/customization/ProfileSettingsParams.java b/OsmAnd-api/src/net/osmand/aidlapi/customization/ProfileSettingsParams.java index 427ccc71fd..00c68851e7 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/customization/ProfileSettingsParams.java +++ b/OsmAnd-api/src/net/osmand/aidlapi/customization/ProfileSettingsParams.java @@ -5,7 +5,7 @@ import android.os.Bundle; import android.os.Parcel; import net.osmand.aidlapi.AidlParams; -import net.osmand.aidlapi.profile.ExportSettingsType; +import net.osmand.aidlapi.profile.AExportSettingsType; import java.util.ArrayList; @@ -20,13 +20,13 @@ public class ProfileSettingsParams extends AidlParams { private Uri profileSettingsUri; private String latestChanges; private int version; - ArrayList settingsTypeKeyList = new ArrayList<>(); + private ArrayList settingsTypeKeyList = new ArrayList<>(); boolean replace; - public ProfileSettingsParams(Uri profileSettingsUri, ArrayList settingsTypeList, boolean replace, + public ProfileSettingsParams(Uri profileSettingsUri, ArrayList settingsTypeList, boolean replace, String latestChanges, int version) { this.profileSettingsUri = profileSettingsUri; - for (ExportSettingsType settingsType : settingsTypeList) { + for (AExportSettingsType settingsType : settingsTypeList) { settingsTypeKeyList.add(settingsType.name()); } this.replace = replace; diff --git a/OsmAnd-api/src/net/osmand/aidlapi/profile/ExportSettingsType.java b/OsmAnd-api/src/net/osmand/aidlapi/profile/AExportSettingsType.java similarity index 80% rename from OsmAnd-api/src/net/osmand/aidlapi/profile/ExportSettingsType.java rename to OsmAnd-api/src/net/osmand/aidlapi/profile/AExportSettingsType.java index 19bdad37dc..23c0189615 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/profile/ExportSettingsType.java +++ b/OsmAnd-api/src/net/osmand/aidlapi/profile/AExportSettingsType.java @@ -1,6 +1,6 @@ package net.osmand.aidlapi.profile; -public enum ExportSettingsType { +public enum AExportSettingsType { PROFILE, QUICK_ACTIONS, POI_TYPES, diff --git a/OsmAnd-api/src/net/osmand/aidlapi/profile/ExportProfileParams.java b/OsmAnd-api/src/net/osmand/aidlapi/profile/ExportProfileParams.java index 6298ccba04..931f52eeb8 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/profile/ExportProfileParams.java +++ b/OsmAnd-api/src/net/osmand/aidlapi/profile/ExportProfileParams.java @@ -13,12 +13,12 @@ public class ExportProfileParams extends AidlParams { public static final String PROFILE_KEY = "profile"; public static final String SETTINGS_TYPE_KEY = "settings_type"; private String profile; - ArrayList settingsTypeKeyList = new ArrayList<>(); + private ArrayList settingsTypeKeyList = new ArrayList<>(); - public ExportProfileParams(String profile, ArrayList settingsTypeList) { + public ExportProfileParams(String profile, ArrayList settingsTypeList) { this.profile = profile; - for (ExportSettingsType settingsType : settingsTypeList) { + for (AExportSettingsType settingsType : settingsTypeList) { settingsTypeKeyList.add(settingsType.name()); } } diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 6cb1dee762..e1aecf5500 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -2253,8 +2253,20 @@ public class OsmandAidlApi { private Map copyFilesCache = new ConcurrentHashMap<>(); - public boolean importProfile(final Uri profileUri, ArrayList settingsTypeKeys, boolean replace, - String latestChanges, int version) { + public boolean importProfile(final Uri profileUri, String latestChanges, int version) { + if (profileUri != null) { + Bundle bundle = new Bundle(); + bundle.putString(SettingsHelper.SETTINGS_LATEST_CHANGES_KEY, latestChanges); + bundle.putInt(SettingsHelper.SETTINGS_VERSION_KEY, version); + + MapActivity.launchMapActivityMoveToTop(app, null, profileUri, bundle); + return true; + } + return false; + } + + public boolean importProfileV2(final Uri profileUri, ArrayList settingsTypeKeys, boolean replace, + String latestChanges, int version) { if (profileUri != null) { Bundle bundle = new Bundle(); bundle.putStringArrayList(SettingsHelper.SETTINGS_TYPE_LIST_KEY, settingsTypeKeys); @@ -2362,7 +2374,7 @@ public class OsmandAidlApi { } } - int copyFileOld(String fileName, byte[] filePartData, long startTime, boolean done) { + int copyFile(String fileName, byte[] filePartData, long startTime, boolean done) { if (Algorithms.isEmpty(fileName) || filePartData == null) { return COPY_FILE_PARAMS_ERROR; } @@ -2376,7 +2388,7 @@ public class OsmandAidlApi { } } - int copyFile(String destinationDir, String fileName, byte[] filePartData, long startTime, boolean done) { + int copyFileV2(String destinationDir, String fileName, byte[] filePartData, long startTime, boolean done) { if (Algorithms.isEmpty(fileName) || filePartData == null) { return COPY_FILE_PARAMS_ERROR; } @@ -2391,7 +2403,7 @@ public class OsmandAidlApi { } else if (fileName.endsWith(IndexConstants.GPX_FILE_EXT)) { if (destinationDir.startsWith(IndexConstants.GPX_INDEX_DIR) && !FILE_TO_SAVE.equals(fileName)) { - GPXUtilities.loadGPXFile(new File(destinationDir, fileName)); + showGpx(new File(destinationDir, fileName).getName()); } else if (destinationDir.isEmpty() && FILE_TO_SAVE.equals(fileName)) { GPXUtilities.loadGPXFile(new File(destinationDir, fileName)); app.getFavorites().loadFavorites(); @@ -2404,7 +2416,7 @@ public class OsmandAidlApi { private int copyFileImpl(String fileName, byte[] filePartData, long startTime, boolean done, String destinationDir) { File tempDir = FileUtils.getTempDir(app); File file = new File(tempDir, fileName); - File destFile = app.getAppPath(destinationDir + fileName); + File destFile = app.getAppPath(new File(destinationDir, fileName).getPath()); long currentTime = System.currentTimeMillis(); try { FileCopyInfo info = copyFilesCache.get(fileName); diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java index 0d9e5d6961..99e888973f 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -1138,7 +1138,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener { if (api == null) { return CANNOT_ACCESS_API_ERROR; } - return api.copyFileOld(params.getFileName(), params.getFilePartData(), params.getStartTime(), params.isDone()); + return api.copyFile(params.getFileName(), params.getFilePartData(), params.getStartTime(), params.isDone()); } catch (Exception e) { handleException(e); return UNKNOWN_API_ERROR; @@ -1299,8 +1299,8 @@ public class OsmandAidlService extends Service implements AidlCallbackListener { public boolean importProfile(ProfileSettingsParams params) { try { OsmandAidlApi api = getApi("importProfile"); - return api != null && api.importProfile(params.getProfileSettingsUri(), params.getSettingsTypeKeys(), - params.isReplace(), params.getLatestChanges(), params.getVersion()); + return api != null && api.importProfile(params.getProfileSettingsUri(), params.getLatestChanges(), + params.getVersion()); } catch (Exception e) { handleException(e); return false; diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java index 8f6564a957..7c69be1e94 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java @@ -1092,7 +1092,7 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener if (api == null) { return CANNOT_ACCESS_API_ERROR; } - return api.copyFile(params.getDestinationDir(), params.getFileName(), params.getFilePartData(), + return api.copyFileV2(params.getDestinationDir(), params.getFileName(), params.getFilePartData(), params.getStartTime(), params.isDone()); } catch (Exception e) { handleException(e); @@ -1260,7 +1260,7 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener public boolean importProfile(ProfileSettingsParams params) { try { OsmandAidlApi api = getApi("importProfile"); - return api != null && api.importProfile(params.getProfileSettingsUri(), params.getSettingsTypeKeys(), + return api != null && api.importProfileV2(params.getProfileSettingsUri(), params.getSettingsTypeKeys(), params.isReplace(), params.getLatestChanges(), params.getVersion()); } catch (Exception e) { handleException(e); diff --git a/OsmAnd/src/net/osmand/aidl/customization/ProfileSettingsParams.java b/OsmAnd/src/net/osmand/aidl/customization/ProfileSettingsParams.java index cd5cfecddf..6c2f82cd8f 100644 --- a/OsmAnd/src/net/osmand/aidl/customization/ProfileSettingsParams.java +++ b/OsmAnd/src/net/osmand/aidl/customization/ProfileSettingsParams.java @@ -4,20 +4,13 @@ import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; -import net.osmand.aidlapi.profile.ExportSettingsType; - -import java.util.ArrayList; - public class ProfileSettingsParams implements Parcelable { private Uri profileSettingsUri; private String latestChanges; private int version; - ArrayList settingsTypeKeyList = new ArrayList<>(); - boolean replace; - public ProfileSettingsParams(Uri profileSettingsUri, ArrayList settingsTypeList, - boolean replace, String latestChanges, int version) { + public ProfileSettingsParams(Uri profileSettingsUri, String latestChanges, int version) { this.profileSettingsUri = profileSettingsUri; this.latestChanges = latestChanges; this.version = version; @@ -51,29 +44,17 @@ public class ProfileSettingsParams implements Parcelable { return profileSettingsUri; } - public ArrayList getSettingsTypeKeys() { - return settingsTypeKeyList; - } - - public boolean isReplace() { - return replace; - } - @Override public void writeToParcel(Parcel out, int flags) { out.writeInt(version); out.writeString(latestChanges); out.writeParcelable(profileSettingsUri, flags); - out.writeStringList(settingsTypeKeyList); - out.writeInt(replace ? 1 : 0); } private void readFromParcel(Parcel in) { version = in.readInt(); latestChanges = in.readString(); profileSettingsUri = in.readParcelable(Uri.class.getClassLoader()); - in.readStringList(settingsTypeKeyList); - replace = in.readInt() == 1; } @Override diff --git a/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java index ec2cf92031..686a56233f 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java @@ -701,9 +701,7 @@ public class ImportHelper { private void handleOsmAndSettingsImport(Uri intentUri, String fileName, Bundle extras, CallbackWithObject> callback) { if (extras != null && extras.containsKey(SETTINGS_VERSION_KEY) - && extras.containsKey(REPLACE_KEY) - && extras.containsKey(SETTINGS_LATEST_CHANGES_KEY) - && extras.containsKey(SETTINGS_TYPE_LIST_KEY)) { + && extras.containsKey(SETTINGS_LATEST_CHANGES_KEY)) { int version = extras.getInt(SETTINGS_VERSION_KEY, -1); String latestChanges = extras.getString(SETTINGS_LATEST_CHANGES_KEY); boolean replace = extras.getBoolean(REPLACE_KEY); @@ -817,11 +815,7 @@ public class ImportHelper { if (mapActivity != null && succeed) { FragmentManager fm = mapActivity.getSupportFragmentManager(); app.getRendererRegistry().updateExternalRenderers(); - AppInitializer.loadRoutingFiles(app, new AppInitializer.LoadRoutingFilesCallback() { - @Override - public void onRoutingFilesLoaded() { - } - }); + AppInitializer.loadRoutingFiles(app, null); if (file != null) { ImportCompleteFragment.showInstance(fm, items, file.getName()); } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/settings/backend/SettingsHelper.java index 01ca1cb38c..0172531139 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/SettingsHelper.java @@ -2931,14 +2931,13 @@ public class SettingsHelper { IMPORT } - public List getFilteredSettingsItems(Map> additionalData, - List settingsTypes) { - List settingsItems = new ArrayList<>(); + public List getFilteredSettingsItems(Map> additionalData, + List settingsTypes) { + List settingsItems = new ArrayList<>(); for (ExportSettingsType settingsType : settingsTypes) { List settingsDataObjects = additionalData.get(settingsType); if (settingsDataObjects != null) { - settingsItems.addAll(app.getSettingsHelper().prepareAdditionalSettingsItems( - new ArrayList<>(settingsDataObjects))); + settingsItems.addAll(prepareAdditionalSettingsItems(new ArrayList<>(settingsDataObjects))); } } return settingsItems; diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java index 051bf422f8..7e8f6bb934 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java @@ -267,11 +267,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment FragmentManager fm = getFragmentManager(); if (succeed) { app.getRendererRegistry().updateExternalRenderers(); - AppInitializer.loadRoutingFiles(app, new AppInitializer.LoadRoutingFilesCallback() { - @Override - public void onRoutingFilesLoaded() { - } - }); + AppInitializer.loadRoutingFiles(app, null); if (fm != null && file != null) { ImportCompleteFragment.showInstance(fm, items, file.getName()); }