diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 3ef61ec5d0..8ec5eb8317 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -1646,27 +1646,29 @@ public class OsmandAidlApi { return true; } - boolean registerForOsmandInitialization(final OsmandAppInitCallback callback) throws RemoteException { + boolean registerForOsmandInitialization(final OsmandAppInitCallback callback) + throws RemoteException { if (app.isApplicationInitializing()) { - app.getAppInitializer().addListener(new AppInitializeListener() { - @Override - public void onProgress(AppInitializer init, InitEvents event) {} + app.getAppInitializer().addListener(new AppInitializeListener() { + @Override + public void onProgress(AppInitializer init, InitEvents event) { + } - @Override - public void onFinish(AppInitializer init) { - try{ - LOG.debug("AIDL App registerForOsmandInitialization"); - callback.onAppInitialized(); - } catch(Exception e){ - e.printStackTrace(); - } - } - }); - } else { - callback.onAppInitialized(); - } - return true; - } + @Override + public void onFinish(AppInitializer init) { + try { + LOG.debug("AIDL App registerForOsmandInitialization"); + callback.onAppInitialized(); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } else { + callback.onAppInitialized(); + } + return true; + } boolean setNavDrawerItems(String appPackage, List items) { if (!TextUtils.isEmpty(appPackage) && items != null) { @@ -1889,7 +1891,7 @@ public class OsmandAidlApi { } boolean setNavDrawerLogoWithParams( - @NonNull String uri, @Nullable String packageName, @Nullable String intent) { + String uri, @Nullable String packageName, @Nullable String intent) { return app.getAppCustomization().setNavDrawerLogoWithParams(uri, packageName, intent); } diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java index f7d2643953..f8d2c0d30b 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -170,8 +170,7 @@ public class OsmandAidlService extends Service { public boolean updateFavoriteGroup(UpdateFavoriteGroupParams params) throws RemoteException { try { OsmandAidlApi api = getApi("updateFavoriteGroup"); - return params != null && api != null && api - .updateFavoriteGroup(params.getFavoriteGroupPrev(), params.getFavoriteGroupNew()); + return params != null && api != null && api.updateFavoriteGroup(params.getFavoriteGroupPrev(), params.getFavoriteGroupNew()); } catch (Exception e) { handleException(e); return false; @@ -204,8 +203,7 @@ public class OsmandAidlService extends Service { public boolean updateFavorite(UpdateFavoriteParams params) throws RemoteException { try { OsmandAidlApi api = getApi("updateFavorite"); - return params != null && api != null && api - .updateFavorite(params.getFavoritePrev(), params.getFavoriteNew()); + return params != null && api != null && api.updateFavorite(params.getFavoritePrev(), params.getFavoriteNew()); } catch (Exception e) { handleException(e); return false; @@ -237,8 +235,7 @@ public class OsmandAidlService extends Service { public boolean updateMapMarker(UpdateMapMarkerParams params) throws RemoteException { try { OsmandAidlApi api = getApi("updateMapMarker"); - return params != null && api != null && api - .updateMapMarker(params.getMarkerPrev(), params.getMarkerNew()); + return params != null && api != null && api.updateMapMarker(params.getMarkerPrev(), params.getMarkerNew()); } catch (Exception e) { handleException(e); return false; @@ -281,8 +278,7 @@ public class OsmandAidlService extends Service { public boolean showMapPoint(ShowMapPointParams params) throws RemoteException { try { OsmandAidlApi api = getApi("showMapPoint"); - return params != null && api != null && api - .showMapPoint(params.getLayerId(), params.getPoint()); + return params != null && api != null && api.showMapPoint(params.getLayerId(), params.getPoint()); } catch (Exception e) { handleException(e); return false; @@ -293,8 +289,7 @@ public class OsmandAidlService extends Service { public boolean addMapPoint(AddMapPointParams params) throws RemoteException { try { OsmandAidlApi api = getApi("addMapPoint"); - return params != null && api != null && api - .putMapPoint(params.getLayerId(), params.getPoint()); + return params != null && api != null && api.putMapPoint(params.getLayerId(), params.getPoint()); } catch (Exception e) { handleException(e); return false; @@ -305,8 +300,7 @@ public class OsmandAidlService extends Service { public boolean removeMapPoint(RemoveMapPointParams params) throws RemoteException { try { OsmandAidlApi api = getApi("removeMapPoint"); - return params != null && api != null && api - .removeMapPoint(params.getLayerId(), params.getPointId()); + return params != null && api != null && api.removeMapPoint(params.getLayerId(), params.getPointId()); } catch (Exception e) { handleException(e); return false; @@ -317,8 +311,7 @@ public class OsmandAidlService extends Service { public boolean updateMapPoint(UpdateMapPointParams params) throws RemoteException { try { OsmandAidlApi api = getApi("updateMapPoint"); - return params != null && api != null && api - .putMapPoint(params.getLayerId(), params.getPoint()); + return params != null && api != null && api.putMapPoint(params.getLayerId(), params.getPoint()); } catch (Exception e) { handleException(e); return false; @@ -504,8 +497,7 @@ public class OsmandAidlService extends Service { public boolean takePhotoNote(TakePhotoNoteParams params) throws RemoteException { try { OsmandAidlApi api = getApi("takePhotoNote"); - return params != null && api != null && api - .takePhotoNote(params.getLatitude(), params.getLongitude()); + return params != null && api != null && api.takePhotoNote(params.getLatitude(), params.getLongitude()); } catch (Exception e) { handleException(e); return false; @@ -516,8 +508,7 @@ public class OsmandAidlService extends Service { public boolean startVideoRecording(StartVideoRecordingParams params) throws RemoteException { try { OsmandAidlApi api = getApi("startVideoRecording"); - return params != null && api != null && api - .startVideoRecording(params.getLatitude(), params.getLongitude()); + return params != null && api != null && api.startVideoRecording(params.getLatitude(), params.getLongitude()); } catch (Exception e) { handleException(e); return false; @@ -528,8 +519,7 @@ public class OsmandAidlService extends Service { public boolean startAudioRecording(StartAudioRecordingParams params) throws RemoteException { try { OsmandAidlApi api = getApi("startAudioRecording"); - return params != null && api != null && api - .startAudioRecording(params.getLatitude(), params.getLongitude()); + return params != null && api != null && api.startAudioRecording(params.getLatitude(), params.getLongitude()); } catch (Exception e) { handleException(e); return false; @@ -565,8 +555,7 @@ public class OsmandAidlService extends Service { public boolean navigateGpx(NavigateGpxParams params) throws RemoteException { try { OsmandAidlApi api = getApi("navigateGpx"); - return params != null && api != null && api - .navigateGpx(params.getData(), params.getUri(), params.isForce()); + return params != null && api != null && api.navigateGpx(params.getData(), params.getUri(), params.isForce()); } catch (Exception e) { handleException(e); return false; @@ -632,8 +621,7 @@ public class OsmandAidlService extends Service { public boolean setNavDrawerItems(SetNavDrawerItemsParams params) throws RemoteException { try { OsmandAidlApi api = getApi("setNavDrawerItems"); - return params != null && api != null && api - .setNavDrawerItems(params.getAppPackage(), params.getItems()); + return params != null && api != null && api.setNavDrawerItems(params.getAppPackage(), params.getItems()); } catch (Exception e) { handleException(e); return false; @@ -641,27 +629,24 @@ public class OsmandAidlService extends Service { } @Override - public boolean search(SearchParams params, final IOsmAndAidlCallback callback) - throws RemoteException { + public boolean search(SearchParams params, final IOsmAndAidlCallback callback) throws RemoteException { try { OsmandAidlApi api = getApi("search"); - return params != null && api != null && api - .search(params.getSearchQuery(), params.getSearchType(), - params.getLatitude(), params.getLongitude(), params.getRadiusLevel(), - params.getTotalLimit(), new SearchCompleteCallback() { - @Override - public void onSearchComplete(List resultSet) { - Bundle data = new Bundle(); - if (resultSet.size() > 0) { - data.putParcelableArrayList(DATA_KEY_RESULT_SET, new ArrayList<>(resultSet)); - } - try { - callback.onSearchComplete(resultSet); - } catch (RemoteException e) { - handleException(e); - } - } - }); + return params != null && api != null && api.search(params.getSearchQuery(), params.getSearchType(), + params.getLatitude(), params.getLongitude(), params.getRadiusLevel(), params.getTotalLimit(), new SearchCompleteCallback() { + @Override + public void onSearchComplete(List resultSet) { + Bundle data = new Bundle(); + if (resultSet.size() > 0) { + data.putParcelableArrayList(DATA_KEY_RESULT_SET, new ArrayList<>(resultSet)); + } + try { + callback.onSearchComplete(resultSet); + } catch (RemoteException e) { + handleException(e); + } + } + }); } catch (Exception e) { handleException(e); return false; @@ -683,8 +668,7 @@ public class OsmandAidlService extends Service { } @Override - public long registerForUpdates(long updateTimeMS, IOsmAndAidlCallback callback) - throws RemoteException { + public long registerForUpdates(long updateTimeMS, IOsmAndAidlCallback callback) throws RemoteException { if (updateTimeMS >= MIN_UPDATE_TIME_MS) { updateCallbackId++; callbacks.put(updateCallbackId, callback); @@ -731,8 +715,7 @@ public class OsmandAidlService extends Service { return api != null && api.setDisabledPatterns(patterns); } - void startRemoteUpdates(final long updateTimeMS, final long callbackId, - final IOsmAndAidlCallback callback) { + void startRemoteUpdates(final long updateTimeMS, final long callbackId, final IOsmAndAidlCallback callback) { mHandler.postDelayed(new Runnable() { @Override public void run() { @@ -751,26 +734,22 @@ public class OsmandAidlService extends Service { }, updateTimeMS); } - @Override public boolean regWidgetVisibility(SetWidgetsParams params) throws RemoteException { OsmandAidlApi api = getApi("regWidgetVisibility"); - return api != null && api - .regWidgetVisibility(params.getWidgetKey(), params.getAppModesKeys()); + return api != null && api.regWidgetVisibility(params.getWidgetKey(), params.getAppModesKeys()); } @Override public boolean regWidgetAvailability(SetWidgetsParams params) throws RemoteException { OsmandAidlApi api = getApi("regWidgetVisibility"); - return api != null && api - .regWidgetAvailability(params.getWidgetKey(), params.getAppModesKeys()); + return api != null && api.regWidgetAvailability(params.getWidgetKey(), params.getAppModesKeys()); } @Override public boolean customizeOsmandSettings(OsmandSettingsParams params) throws RemoteException { OsmandAidlApi api = getApi("customizeOsmandSettings"); - return api != null && api - .customizeOsmandSettings(params.getSharedPreferencesName(), params.getBundle()); + return api != null && api.customizeOsmandSettings(params.getSharedPreferencesName(), params.getBundle()); } @Override diff --git a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java index edefcd95b5..37f903958a 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java @@ -69,14 +69,12 @@ public class OsmAndAppCustomization { } public static class CustomOsmandSettings { - private String sharedPreferencesName; private OsmandSettings settings; CustomOsmandSettings(OsmandApplication app, String sharedPreferencesName, Bundle bundle) { this.sharedPreferencesName = sharedPreferencesName; - this.settings = new OsmandSettings(app, new net.osmand.plus.api.SettingsAPIImpl(app), - sharedPreferencesName); + this.settings = new OsmandSettings(app, new net.osmand.plus.api.SettingsAPIImpl(app), sharedPreferencesName); if (bundle != null) { for (String key : bundle.keySet()) { Object object = bundle.get(key); @@ -99,8 +97,7 @@ public class OsmAndAppCustomization { return customOsmandSettings != null ? customOsmandSettings.getSettings() : osmandSettings; } - public void customizeOsmandSettings(@NonNull String sharedPreferencesName, - @Nullable Bundle bundle) { + public void customizeOsmandSettings(@NonNull String sharedPreferencesName, @Nullable Bundle bundle) { customOsmandSettings = new CustomOsmandSettings(app, sharedPreferencesName, bundle); OsmandSettings newSettings = customOsmandSettings.getSettings(); if (Build.VERSION.SDK_INT < 19) { @@ -174,8 +171,7 @@ public class OsmAndAppCustomization { } public String getIndexesUrl() { - return "http://" + IndexConstants.INDEX_DOWNLOAD_DOMAIN + "/get_indexes?gzip&" + Version - .getVersionAsURLParam(app); + return "https://" + IndexConstants.INDEX_DOWNLOAD_DOMAIN + "/get_indexes?gzip&" + Version.getVersionAsURLParam(app); } public boolean showDownloadExtraActions() { @@ -213,12 +209,9 @@ public class OsmAndAppCustomization { } @Nullable - public ArrayList getNavDrawerLogoParams() { - return navDrawerParams; - } + public ArrayList getNavDrawerLogoParams() {return navDrawerParams; } - public boolean setNavDrawerLogo(@NonNull String uri, @Nullable String packageName, - @Nullable String intent) { + public boolean setNavDrawerLogo(String uri, @Nullable String packageName, @Nullable String intent) { if (TextUtils.isEmpty(uri)) { navDrawerLogo = null; } else { @@ -276,16 +269,14 @@ public class OsmAndAppCustomization { setFeaturesCustomized(); } - public Set regWidgetVisibility(@NonNull String widgetId, - @Nullable List appModeKeys) { + public Set regWidgetVisibility(@NonNull String widgetId, @Nullable List appModeKeys) { HashSet set = getAppModesSet(appModeKeys); widgetsVisibilityMap.put(widgetId, set); setWidgetsCustomized(); return set; } - public Set regWidgetAvailability(@NonNull String widgetId, - @Nullable List appModeKeys) { + public Set regWidgetAvailability(@NonNull String widgetId, @Nullable List appModeKeys) { HashSet set = getAppModesSet(appModeKeys); widgetsAvailabilityMap.put(widgetId, set); setWidgetsCustomized(); @@ -308,7 +299,7 @@ public class OsmAndAppCustomization { return set.contains(appMode); } - public boolean setNavDrawerLogoWithParams(@NonNull String imageUri, @Nullable String packageName, + public boolean setNavDrawerLogoWithParams(String imageUri, @Nullable String packageName, @Nullable String intent) { return setNavDrawerLogo(imageUri, packageName, intent); }