From 739934234ba7e9e800f8a91d2668ea8ba6575b42 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 30 Oct 2018 19:10:04 +0200 Subject: [PATCH 1/9] Cleanup the OsmAndAppCustomization --- .../osmand/plus/OsmAndAppCustomization.java | 76 +++++-------------- .../osmand/plus/activities/MapActivity.java | 3 - .../plus/activities/MapActivityActions.java | 1 - .../osmand/plus/dialogs/ConfigureMapMenu.java | 1 - .../plus/download/DownloadActivity.java | 2 - 5 files changed, 17 insertions(+), 66 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java index 9fcf0777e9..69037b66c6 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java @@ -9,9 +9,7 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.PluginsActivity; import net.osmand.plus.activities.SettingsActivity; import net.osmand.plus.activities.TrackActivity; -import net.osmand.plus.activities.search.SearchActivity; import net.osmand.plus.download.DownloadActivity; -import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.routing.RouteCalculationResult; @@ -23,7 +21,7 @@ import java.util.List; import java.util.Map; public class OsmAndAppCustomization { - + protected OsmandApplication app; protected OsmandSettings osmandSettings; @@ -32,113 +30,73 @@ public class OsmAndAppCustomization { this.osmandSettings = new OsmandSettings(app, new net.osmand.plus.api.SettingsAPIImpl(app)); } - public OsmandSettings getOsmandSettings(){ return osmandSettings;} - // Main menu - public boolean checkExceptionsOnStart() { - return true; + public OsmandSettings getOsmandSettings() { + return osmandSettings; } - public boolean showFirstTimeRunAndTips(boolean firstTime, boolean appVersionChanged) { - return true; - } - - public boolean checkBasemapDownloadedOnStart() { - return true; - } - - // Activities - public Class getSettingsActivity(){ + public Class getSettingsActivity() { return SettingsActivity.class; } - - public Class getMapActivity(){ + + public Class getMapActivity() { return MapActivity.class; } - - public Class getTrackActivity(){ + + public Class getTrackActivity() { return TrackActivity.class; } - - public Class getFavoritesActivity(){ + + public Class getFavoritesActivity() { return FavoritesActivity.class; } public Class getDownloadIndexActivity() { return DownloadActivity.class; } - + public Class getPluginsActivity() { return PluginsActivity.class; } - + public Class getDownloadActivity() { return DownloadActivity.class; } - // Download screen - public void getDownloadTypes(List items) { - - } - - public List onIndexingFiles(IProgress progress, Map indexFileNames) { return Collections.emptyList(); } - public void prepareLayerContextMenu(MapActivity activity, ContextMenuAdapter adapter) { - } - - public void prepareOptionsMenu(MapActivity mapActivity, ContextMenuAdapter optionsMenuHelper) { - } - - public String getIndexesUrl() { - return "http://"+IndexConstants.INDEX_DOWNLOAD_DOMAIN+"/get_indexes?gzip&" + Version.getVersionAsURLParam(app); //$NON-NLS-1$; + return "http://" + IndexConstants.INDEX_DOWNLOAD_DOMAIN + "/get_indexes?gzip&" + Version.getVersionAsURLParam(app); } public boolean showDownloadExtraActions() { return true; } - public File getTracksDir() { return app.getAppPath(IndexConstants.GPX_RECORDED_INDEX_DIR); } public void createLayers(OsmandMapTileView mapView, MapActivity activity) { - + } - + public List getWaypoints() { return Collections.emptyList(); } public boolean isWaypointGroupVisible(int waypointType, RouteCalculationResult route) { - if(waypointType == WaypointHelper.ALARMS) { + if (waypointType == WaypointHelper.ALARMS) { return route != null && !route.getAlarmInfo().isEmpty(); - } else if(waypointType == WaypointHelper.WAYPOINTS) { + } else if (waypointType == WaypointHelper.WAYPOINTS) { return route != null && !route.getLocationPoints().isEmpty(); } return true; } - public void showLocationPoint(MapActivity ctx, LocationPoint locationPoint) { - } - public boolean onDestinationReached() { return true; } - - - public boolean onlyTourDownload() { - return false; - } - - public void resumeActivity(Class class1, T d) { - } - - public void pauseActivity(Class class1) { - } - } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 7f15f47692..d4be6c6b9d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -90,7 +90,6 @@ import net.osmand.plus.firstusage.FirstUsageWelcomeFragment; import net.osmand.plus.firstusage.FirstUsageWizardFragment; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.DiscountHelper; -import net.osmand.plus.helpers.DiscountHelper.DiscountBarController; import net.osmand.plus.helpers.ExternalApiHelper; import net.osmand.plus.helpers.ImportHelper; import net.osmand.plus.helpers.ImportHelper.ImportGpxBottomSheetDialogFragment; @@ -770,7 +769,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven } } - getMyApplication().getAppCustomization().resumeActivity(MapActivity.class, this); if (System.currentTimeMillis() - tm > 50) { System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms"); } @@ -1306,7 +1304,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven settings.setLastKnownMapZoom(mapView.getZoom()); settings.MAP_ACTIVITY_ENABLED.set(false); - getMyApplication().getAppCustomization().pauseActivity(MapActivity.class); app.getResourceManager().interruptRendering(); OsmandPlugin.onMapActivityPause(this); } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 62d697f3b3..db6cb0e773 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -885,7 +885,6 @@ public class MapActivityActions implements DialogProvider { divider.setPosition(dividerItemIndex >= 0 ? dividerItemIndex : 8); optionsMenuHelper.addItem(divider.createItem()); - getMyApplication().getAppCustomization().prepareOptionsMenu(mapActivity, optionsMenuHelper); return optionsMenuHelper; } diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java index 19a42bfd83..f71f1dbbed 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java @@ -482,7 +482,6 @@ public class ConfigureMapMenu { .setListener(l).createItem()); OsmandPlugin.registerLayerContextMenu(activity.getMapView(), adapter, activity); - app.getAppCustomization().prepareLayerContextMenu(activity, adapter); boolean srtmDisabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) == null && !InAppPurchaseHelper.isSubscribedToLiveUpdates(app); if (srtmDisabled) { diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index 0ebb98195c..1c0dc9d4f8 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -254,7 +254,6 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo protected void onResume() { super.onResume(); initAppStatusVariables(); - getMyApplication().getAppCustomization().resumeActivity(DownloadActivity.class, this); downloadThread.setUiActivity(this); downloadInProgress(); } @@ -283,7 +282,6 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo @Override public void onPause() { super.onPause(); - getMyApplication().getAppCustomization().pauseActivity(DownloadActivity.class); downloadThread.resetUiActivity(this); } From 5c37af174dba3398fc172eb004020efd6064a0be Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Wed, 31 Oct 2018 15:45:30 +0200 Subject: [PATCH 2/9] Add the ability to add logo to the nav drawer --- .../net/osmand/aidl/IOsmAndAidlInterface.aidl | 2 ++ OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 4 +++ .../net/osmand/aidl/OsmandAidlService.java | 6 ++++ .../osmand/plus/OsmAndAppCustomization.java | 34 +++++++++++++++++++ .../plus/activities/MapActivityActions.java | 15 +++++++- 5 files changed, 60 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl index d7ebb4492d..83774492c0 100644 --- a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl +++ b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl @@ -133,4 +133,6 @@ interface IOsmAndAidlInterface { long registerForUpdates(in long updateTimeMS, IOsmAndAidlCallback callback); boolean unregisterFromUpdates(in long callbackId); + + boolean setNavDrawerLogo(in String imageUri); } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index bece844fcb..58d17e998d 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -1655,6 +1655,10 @@ public class OsmandAidlApi { } } + boolean setNavDrawerLogo(@Nullable String uri) { + return app.getAppCustomization().setNavDrawerLogo(uri); + } + public static class ConnectedApp implements Comparable { static final String PACK_KEY = "pack"; diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java index ce61fe4386..bd2ab3e493 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -671,6 +671,12 @@ public class OsmandAidlService extends Service { return true; } + @Override + public boolean setNavDrawerLogo(String imageUri) throws RemoteException { + OsmandAidlApi api = getApi("setNavDrawerLogo"); + return api != null && api.setNavDrawerLogo(imageUri); + } + void startRemoteUpdates(final long updateTimeMS, final long callbackId, final IOsmAndAidlCallback callback) { mHandler.postDelayed(new Runnable() { @Override diff --git a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java index 69037b66c6..098c7a85fc 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java @@ -1,6 +1,11 @@ package net.osmand.plus; import android.app.Activity; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.net.Uri; +import android.support.annotation.Nullable; +import android.text.TextUtils; import net.osmand.IProgress; import net.osmand.IndexConstants; @@ -16,6 +21,9 @@ import net.osmand.plus.routing.RouteCalculationResult; import net.osmand.plus.views.OsmandMapTileView; import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; import java.util.Collections; import java.util.List; import java.util.Map; @@ -25,6 +33,8 @@ public class OsmAndAppCustomization { protected OsmandApplication app; protected OsmandSettings osmandSettings; + private Bitmap navDrawerLogo; + public void setup(OsmandApplication app) { this.app = app; this.osmandSettings = new OsmandSettings(app, new net.osmand.plus.api.SettingsAPIImpl(app)); @@ -99,4 +109,28 @@ public class OsmAndAppCustomization { public boolean onDestinationReached() { return true; } + + @Nullable + public Bitmap getNavDrawerLogo() { + return navDrawerLogo; + } + + public boolean setNavDrawerLogo(@Nullable String uri) { + if (TextUtils.isEmpty(uri)) { + navDrawerLogo = null; + } else { + try { + InputStream is = app.getContentResolver().openInputStream(Uri.parse(uri)); + if (is != null) { + navDrawerLogo = BitmapFactory.decodeStream(is); + is.close(); + } + } catch (FileNotFoundException e) { + return false; + } catch (IOException e) { + // ignore + } + } + return true; + } } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index db6cb0e773..08df53f5bb 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -5,8 +5,10 @@ import android.app.Activity; import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent; +import android.graphics.Bitmap; import android.os.AsyncTask; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; @@ -17,9 +19,11 @@ import android.view.WindowManager; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.EditText; +import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; + import net.osmand.AndroidUtils; import net.osmand.IndexConstants; import net.osmand.Location; @@ -47,7 +51,6 @@ import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.Version; import net.osmand.plus.activities.actions.OsmAndDialogs; -import net.osmand.plus.activities.search.SearchActivity; import net.osmand.plus.dashboard.DashboardOnMap.DashboardType; import net.osmand.plus.dialogs.FavoriteDialogs; import net.osmand.plus.download.IndexItem; @@ -109,10 +112,14 @@ public class MapActivityActions implements DialogProvider { private OsmandSettings settings; private RoutingHelper routingHelper; + @NonNull + private ImageView navDrawerLogoHeader; + public MapActivityActions(MapActivity mapActivity) { this.mapActivity = mapActivity; settings = mapActivity.getMyApplication().getSettings(); routingHelper = mapActivity.getMyApplication().getRoutingHelper(); + navDrawerLogoHeader = new ImageView(mapActivity); } public void addAsTarget(double latitude, double longitude, PointDescription pd) { @@ -957,6 +964,12 @@ public class MapActivityActions implements DialogProvider { } else { menuItemsListView.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.bg_color_light)); } + menuItemsListView.removeHeaderView(navDrawerLogoHeader); + Bitmap navDrawerLogo = getMyApplication().getAppCustomization().getNavDrawerLogo(); + if (navDrawerLogo != null) { + navDrawerLogoHeader.setImageBitmap(navDrawerLogo); + menuItemsListView.addHeaderView(navDrawerLogoHeader); + } menuItemsListView.setDivider(null); final ContextMenuAdapter contextMenuAdapter = createMainOptionsMenu(); contextMenuAdapter.setDefaultLayoutId(R.layout.simple_list_menu_item); From 36d32983251e856752a8e6d9834fdbad6f5525df Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Wed, 31 Oct 2018 19:43:37 +0200 Subject: [PATCH 3/9] Add ids to the nav drawer, configure map and map controls --- .../src/net/osmand/plus/ContextMenuItem.java | 17 ++++- .../plus/activities/MapActivityActions.java | 31 +++++++++ .../osmand/plus/dialogs/ConfigureMapMenu.java | 64 ++++++++++++++++--- .../osmand/plus/views/MapControlsLayer.java | 30 ++++++--- 4 files changed, 121 insertions(+), 21 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuItem.java b/OsmAnd/src/net/osmand/plus/ContextMenuItem.java index 3143a28f39..f29a5ee808 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuItem.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuItem.java @@ -38,6 +38,7 @@ public class ContextMenuItem { private final boolean hideDivider; private final int minHeight; private final int tag; + private final String id; private ContextMenuItem(@StringRes int titleId, String title, @@ -59,7 +60,8 @@ public class ContextMenuItem { ContextMenuAdapter.ProgressListener progressListener, boolean hideDivider, int minHeight, - int tag) { + int tag, + String id) { this.titleId = titleId; this.title = title; this.mIcon = icon; @@ -81,6 +83,7 @@ public class ContextMenuItem { this.hideDivider = hideDivider; this.minHeight = minHeight; this.tag = tag; + this.id = id; } @StringRes @@ -218,6 +221,10 @@ public class ContextMenuItem { return tag; } + public String getId() { + return id; + } + public static ItemBuilder createBuilder(String title) { return new ItemBuilder().setTitle(title); } @@ -249,6 +256,7 @@ public class ContextMenuItem { private boolean mHideDivider; private int mMinHeight; private int mTag; + private String mId; public ItemBuilder setTitleId(@StringRes int titleId, @Nullable Context context) { this.mTitleId = titleId; @@ -363,11 +371,16 @@ public class ContextMenuItem { return this; } + public ItemBuilder setId(String id) { + this.mId = id; + return this; + } + public ContextMenuItem createItem() { return new ContextMenuItem(mTitleId, mTitle, mIcon, mColorRes, mSecondaryIcon, mSelected, mProgress, mLayout, mLoading, mIsCategory, mIsClickable, mSkipPaintingWithoutColor, mPosition, mOrder, mDescription, mItemClickListener, mIntegerListener, mProgressListener, - mHideDivider, mMinHeight, mTag); + mHideDivider, mMinHeight, mTag, mId); } } } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 08df53f5bb..798172b8c2 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -105,6 +105,23 @@ public class MapActivityActions implements DialogProvider { private static final int DIALOG_RELOAD_TITLE = 103; private static final int DIALOG_SAVE_DIRECTIONS = 106; + + private static final String DRAWER_ITEM_ID_SCHEME = "drawer.action."; + private static final String DRAWER_DASHBOARD_ID = DRAWER_ITEM_ID_SCHEME + "dashboard"; + private static final String DRAWER_MAP_MARKERS_ID = DRAWER_ITEM_ID_SCHEME + "map_markers"; + private static final String DRAWER_MY_PLACES_ID = DRAWER_ITEM_ID_SCHEME + "my_places"; + private static final String DRAWER_SEARCH_ID = DRAWER_ITEM_ID_SCHEME + "search"; + private static final String DRAWER_DIRECTIONS_ID = DRAWER_ITEM_ID_SCHEME + "directions"; + private static final String DRAWER_CONFIGURE_MAP_ID = DRAWER_ITEM_ID_SCHEME + "configure_map"; + private static final String DRAWER_DOWNLOAD_MAPS_ID = DRAWER_ITEM_ID_SCHEME + "download_maps"; + private static final String DRAWER_OSMAND_LIVE_ID = DRAWER_ITEM_ID_SCHEME + "osmand_live"; + private static final String DRAWER_TRAVEL_GUIDES_ID = DRAWER_ITEM_ID_SCHEME + "travel_guides"; + private static final String DRAWER_MEASURE_DISTANCE_ID = DRAWER_ITEM_ID_SCHEME + "measure_distance"; + private static final String DRAWER_CONFIGURE_SCREEN_ID = DRAWER_ITEM_ID_SCHEME + "configure_screen"; + private static final String DRAWER_PLUGINS_ID = DRAWER_ITEM_ID_SCHEME + "plugins"; + private static final String DRAWER_SETTINGS_ID = DRAWER_ITEM_ID_SCHEME + "settings"; + private static final String DRAWER_HELP_ID = DRAWER_ITEM_ID_SCHEME + "help"; + // make static private static Bundle dialogBundle = new Bundle(); @@ -654,6 +671,7 @@ public class MapActivityActions implements DialogProvider { ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(); optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.home, mapActivity) + .setId(DRAWER_DASHBOARD_ID) .setIcon(R.drawable.map_dashboard) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override @@ -667,6 +685,7 @@ public class MapActivityActions implements DialogProvider { }).createItem()); optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.map_markers, mapActivity) + .setId(DRAWER_MAP_MARKERS_ID) .setIcon(R.drawable.ic_action_flag_dark) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override @@ -679,6 +698,7 @@ public class MapActivityActions implements DialogProvider { }).createItem()); optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_my_places, mapActivity) + .setId(DRAWER_MY_PLACES_ID) .setIcon(R.drawable.ic_action_fav_dark) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override @@ -693,6 +713,7 @@ public class MapActivityActions implements DialogProvider { }).createItem()); optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.search_button, mapActivity) + .setId(DRAWER_SEARCH_ID) .setIcon(R.drawable.ic_action_search_dark) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override @@ -705,6 +726,7 @@ public class MapActivityActions implements DialogProvider { optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.get_directions, mapActivity) + .setId(DRAWER_DIRECTIONS_ID) .setIcon(R.drawable.ic_action_gdirections_dark) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override @@ -732,6 +754,7 @@ public class MapActivityActions implements DialogProvider { */ optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.configure_map, mapActivity) + .setId(DRAWER_CONFIGURE_MAP_ID) .setIcon(R.drawable.ic_action_layers_dark) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override @@ -751,6 +774,7 @@ public class MapActivityActions implements DialogProvider { } } optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.welmode_download_maps, null) + .setId(DRAWER_DOWNLOAD_MAPS_ID) .setTitle(d).setIcon(R.drawable.ic_type_archive) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override @@ -766,6 +790,7 @@ public class MapActivityActions implements DialogProvider { if (Version.isGooglePlayEnabled(app) || Version.isDeveloperVersion(app)) { optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.osm_live, mapActivity) + .setId(DRAWER_OSMAND_LIVE_ID) .setIcon(R.drawable.ic_action_osm_live) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override @@ -780,6 +805,7 @@ public class MapActivityActions implements DialogProvider { } optionsMenuHelper.addItem(new ItemBuilder().setTitle(getString(R.string.shared_string_travel_guides) + " (Beta)") + .setId(DRAWER_TRAVEL_GUIDES_ID) .setIcon(R.drawable.ic_action_travel) .setListener(new ItemClickListener() { @Override @@ -799,6 +825,7 @@ public class MapActivityActions implements DialogProvider { }).createItem()); optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity) + .setId(DRAWER_MEASURE_DISTANCE_ID) .setIcon(R.drawable.ic_action_ruler) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override @@ -811,6 +838,7 @@ public class MapActivityActions implements DialogProvider { app.getAidlApi().registerNavDrawerItems(mapActivity, optionsMenuHelper); optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.layer_map_appearance, mapActivity) + .setId(DRAWER_CONFIGURE_SCREEN_ID) .setIcon(R.drawable.ic_configure_screen_dark) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override @@ -823,6 +851,7 @@ public class MapActivityActions implements DialogProvider { }).createItem()); optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.prefs_plugins, mapActivity) + .setId(DRAWER_PLUGINS_ID) .setIcon(R.drawable.ic_extension_dark) .setListener(new ItemClickListener() { @Override @@ -837,6 +866,7 @@ public class MapActivityActions implements DialogProvider { }).createItem()); optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_settings, mapActivity) + .setId(DRAWER_SETTINGS_ID) .setIcon(R.drawable.ic_action_settings) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override @@ -864,6 +894,7 @@ public class MapActivityActions implements DialogProvider { */ optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_help, mapActivity) + .setId(DRAWER_HELP_ID) .setIcon(R.drawable.ic_action_help) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java index f71f1dbbed..8a6aaf7d09 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java @@ -80,6 +80,33 @@ public class ConfigureMapMenu { public static final String CURRENT_TRACK_WIDTH_ATTR = "currentTrackWidth"; public static final String COLOR_ATTR = "color"; public static final String ROAD_STYLE_ATTR = "roadStyle"; + + private static final String ITEM_ID_SCHEME = "map.configure."; + private static final String SHOW_ITEMS_ID_SCHEME = ITEM_ID_SCHEME + "show."; + private static final String RENDERING_ITEMS_ID_SCHEME = ITEM_ID_SCHEME + "rendering."; + private static final String CUSTOM_RENDERING_ITEMS_ID_SCHEME = RENDERING_ITEMS_ID_SCHEME + "custom."; + + private static final String APP_PROFILES_ID = ITEM_ID_SCHEME + "app_profiles"; + + private static final String FAVORITES_ID = SHOW_ITEMS_ID_SCHEME + "favorites"; + private static final String POI_OVERLAY_ID = SHOW_ITEMS_ID_SCHEME + "poi_overlay"; + private static final String POI_OVERLAY_LABELS_ID = SHOW_ITEMS_ID_SCHEME + "poi_overlay_labels"; + private static final String TRANSPORT_ID = SHOW_ITEMS_ID_SCHEME + "transport"; + private static final String GPX_FILES_ID = SHOW_ITEMS_ID_SCHEME + "gpx_files"; + private static final String MAP_MARKERS_ID = SHOW_ITEMS_ID_SCHEME + "map_markers"; + private static final String MAP_SOURCE_ID = SHOW_ITEMS_ID_SCHEME + "map_source"; + + private static final String MAP_STYLE_ID = RENDERING_ITEMS_ID_SCHEME + "map_style"; + private static final String MAP_MODE_ID = RENDERING_ITEMS_ID_SCHEME + "map_mode"; + private static final String MAP_MAGNIFIER_ID = RENDERING_ITEMS_ID_SCHEME + "map_marnifier"; + private static final String ROAD_STYLE_ID = RENDERING_ITEMS_ID_SCHEME + "road_style"; + private static final String TEXT_SIZE_ID = RENDERING_ITEMS_ID_SCHEME + "text_size"; + private static final String MAP_LANGUAGE_ID = RENDERING_ITEMS_ID_SCHEME + "map_language"; + private static final String TRANSPORT_RENDERING_ID = RENDERING_ITEMS_ID_SCHEME + "transport"; + private static final String DETAILS_ID = RENDERING_ITEMS_ID_SCHEME + "details"; + private static final String HIDE_ID = RENDERING_ITEMS_ID_SCHEME + "hide"; + private static final String ROUTES_ID = RENDERING_ITEMS_ID_SCHEME + "routes"; + private int hikingRouteOSMCValue; private int selectedLanguageIndex; private boolean transliterateNames; @@ -93,6 +120,7 @@ public class ConfigureMapMenu { ContextMenuAdapter adapter = new ContextMenuAdapter(); adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu); adapter.addItem(new ContextMenuItem.ItemBuilder() + .setId(APP_PROFILES_ID) .setTitleId(R.string.app_modes_choose, ma) .setLayout(R.layout.mode_toggles).createItem()); adapter.setChangeAppModeListener(new OnClickListener() { @@ -256,6 +284,7 @@ public class ConfigureMapMenu { // String appMode = " [" + settings.getApplicationMode().toHumanString(view.getApplication()) +"] "; boolean selected = settings.SHOW_FAVORITES.get(); adapter.addItem(new ContextMenuItem.ItemBuilder() + .setId(FAVORITES_ID) .setTitleId(R.string.shared_string_favorites, activity) .setSelected(settings.SHOW_FAVORITES.get()) .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) @@ -263,6 +292,7 @@ public class ConfigureMapMenu { .setListener(l).createItem()); selected = app.getPoiFilters().isShowingAnyPoi(); adapter.addItem(new ContextMenuItem.ItemBuilder() + .setId(POI_OVERLAY_ID) .setTitleId(R.string.layer_poi, activity) .setSelected(selected) .setDescription(app.getPoiFilters().getSelectedPoiFiltersName()) @@ -272,6 +302,7 @@ public class ConfigureMapMenu { .setListener(l).createItem()); selected = settings.SHOW_POI_LABEL.get(); adapter.addItem(new ContextMenuItem.ItemBuilder() + .setId(POI_OVERLAY_LABELS_ID) .setTitleId(R.string.layer_amenity_label, activity) .setSelected(settings.SHOW_POI_LABEL.get()) .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) @@ -308,6 +339,7 @@ public class ConfigureMapMenu { } final boolean transportSelected = selected; adapter.addItem(new ContextMenuItem.ItemBuilder() + .setId(TRANSPORT_ID) .setTitleId(R.string.rendering_category_transport, activity) .setIcon(R.drawable.ic_action_bus_dark) .setSecondaryIcon(R.drawable.ic_action_additional_option) @@ -459,6 +491,7 @@ public class ConfigureMapMenu { }).createItem()); selected = app.getSelectedGpxHelper().isShowingAnyGpxFiles(); adapter.addItem(new ContextMenuItem.ItemBuilder() + .setId(GPX_FILES_ID) .setTitleId(R.string.layer_gpx_layer, activity) .setSelected(app.getSelectedGpxHelper().isShowingAnyGpxFiles()) .setDescription(app.getSelectedGpxHelper().getGpxDescription()) @@ -469,6 +502,7 @@ public class ConfigureMapMenu { selected = settings.SHOW_MAP_MARKERS.get(); adapter.addItem(new ContextMenuItem.ItemBuilder() + .setId(MAP_MARKERS_ID) .setTitleId(R.string.map_markers, activity) .setSelected(selected) .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) @@ -476,6 +510,7 @@ public class ConfigureMapMenu { .setListener(l).createItem()); adapter.addItem(new ContextMenuItem.ItemBuilder() + .setId(MAP_SOURCE_ID) .setTitleId(R.string.layer_map, activity) .setIcon(R.drawable.ic_world_globe_dark) .setDescription(settings.MAP_ONLINE_DATA.get() ? settings.MAP_TILE_SOURCES.get() : null) @@ -503,6 +538,7 @@ public class ConfigureMapMenu { adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_map_rendering, activity) .setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem()); adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_renderer, activity) + .setId(MAP_STYLE_ID) .setDescription(getRenderDescr(activity)).setLayout(R.layout.list_item_single_line_descrition_narrow) .setIcon(R.drawable.ic_map).setListener(new ContextMenuAdapter.ItemClickListener() { @Override @@ -515,6 +551,7 @@ public class ConfigureMapMenu { }).createItem()); adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_mode, activity) + .setId(MAP_MODE_ID) .setDescription(getDayNightDescr(activity)).setLayout(R.layout.list_item_single_line_descrition_narrow) .setIcon(getDayNightIcon(activity)).setListener(new ItemClickListener() { @Override @@ -547,6 +584,7 @@ public class ConfigureMapMenu { }).createItem()); adapter.addItem(new ContextMenuItem.ItemBuilder() + .setId(MAP_MAGNIFIER_ID) .setTitleId(R.string.map_magnifier, activity) .setDescription( String.format(Locale.UK, "%.0f", @@ -608,12 +646,13 @@ public class ConfigureMapMenu { }).createItem()); ContextMenuItem props; - props = createRenderingProperty(customRules, adapter, activity, R.drawable.ic_action_intersection, ROAD_STYLE_ATTR); + props = createRenderingProperty(customRules, adapter, activity, R.drawable.ic_action_intersection, ROAD_STYLE_ATTR, ROAD_STYLE_ID); if (props != null) { adapter.addItem(props); } adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.text_size, activity) + .setId(TEXT_SIZE_ID) .setDescription(getScale(activity)).setLayout(R.layout.list_item_single_line_descrition_narrow) .setIcon(R.drawable.ic_action_map_text_size).setListener(new ContextMenuAdapter.ItemClickListener() { @Override @@ -652,6 +691,7 @@ public class ConfigureMapMenu { localeDescr = localeDescr == null || localeDescr.equals("") ? activity.getString(R.string.local_map_names) : localeDescr; adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_locale, activity) + .setId(MAP_LANGUAGE_ID) .setDescription(localeDescr).setLayout(R.layout.list_item_single_line_descrition_narrow) .setIcon(R.drawable.ic_action_map_language) .setListener(new ContextMenuAdapter.ItemClickListener() { @@ -742,17 +782,17 @@ public class ConfigureMapMenu { }).createItem()); props = createProperties(customRules, null, R.string.rendering_category_transport, R.drawable.ic_action_bus_dark, - "transport", null, adapter, activity, true); + "transport", null, adapter, activity, true, TRANSPORT_RENDERING_ID); if (props != null) { adapter.addItem(props); } props = createProperties(customRules, null, R.string.rendering_category_details, R.drawable.ic_action_layers_dark, - "details", null, adapter, activity, true); + "details", null, adapter, activity, true, DETAILS_ID); if (props != null) { adapter.addItem(props); } props = createProperties(customRules, null, R.string.rendering_category_hide, R.drawable.ic_action_hide, - "hide", null, adapter, activity, true); + "hide", null, adapter, activity, true, HIDE_ID); if (props != null) { adapter.addItem(props); } @@ -764,7 +804,7 @@ public class ConfigureMapMenu { } } props = createProperties(customRules, customRulesIncluded, R.string.rendering_category_routes, R.drawable.ic_action_map_routes, - "routes", null, adapter, activity, true); + "routes", null, adapter, activity, true, ROUTES_ID); if (props != null) { adapter.addItem(props); } @@ -826,7 +866,8 @@ public class ConfigureMapMenu { final ListStringPreference defaultSettings, final ContextMenuAdapter adapter, final MapActivity activity, - final boolean useDescription) { + final boolean useDescription, + final String id) { final List ps = new ArrayList<>(); final List> prefs = new ArrayList<>(); @@ -882,6 +923,7 @@ public class ConfigureMapMenu { }; ContextMenuItem.ItemBuilder builder = new ContextMenuItem.ItemBuilder().setTitleId(strId, activity) + .setId(id) .setIcon(icon).setListener(clickListener); boolean selected = false; for (OsmandSettings.CommonPreference p : prefs) { @@ -1137,7 +1179,7 @@ public class ConfigureMapMenu { List customRules) { for (final RenderingRuleProperty p : customRules) { if (isPropertyAccepted(p)) { - adapter.addItem(createRenderingProperty(adapter, activity, 0, p)); + adapter.addItem(createRenderingProperty(adapter, activity, 0, p, CUSTOM_RENDERING_ITEMS_ID_SCHEME + p.getName())); } } } @@ -1154,17 +1196,17 @@ public class ConfigureMapMenu { private ContextMenuItem createRenderingProperty(final List customRules, final ContextMenuAdapter adapter, final MapActivity activity, - @DrawableRes final int icon, final String attrName) { + @DrawableRes final int icon, final String attrName, String id) { for (final RenderingRuleProperty p : customRules) { if (p.getAttrName().equals(attrName)) { - return createRenderingProperty(adapter, activity, icon, p); + return createRenderingProperty(adapter, activity, icon, p, id); } } return null; } private ContextMenuItem createRenderingProperty(final ContextMenuAdapter adapter, final MapActivity activity, - @DrawableRes final int icon, final RenderingRuleProperty p) { + @DrawableRes final int icon, final RenderingRuleProperty p, final String id) { final OsmandMapTileView view = activity.getMapView(); String propertyName = SettingsActivity.getStringPropertyName(view.getContext(), p.getAttrName(), p.getName()); @@ -1175,6 +1217,7 @@ public class ConfigureMapMenu { final OsmandSettings.CommonPreference pref = view.getApplication().getSettings() .getCustomRenderBooleanProperty(p.getAttrName()); return ContextMenuItem.createBuilder(propertyName) + .setId(id) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override @@ -1197,6 +1240,7 @@ public class ConfigureMapMenu { p.getDefaultValueDescription()); } ContextMenuItem.ItemBuilder builder = ContextMenuItem.createBuilder(propertyName) + .setId(id) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index 167ab41942..ef7cf22e4f 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -68,10 +68,21 @@ public class MapControlsLayer extends OsmandMapLayer { private static final int REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION = 201; private static final int REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION = 202; - public MapHudButton createHudButton(View iv, int resId) { + private static final String HUD_BTN_ID_SCHEME = "map.view."; + private static final String LAYERS_HUD_ID = HUD_BTN_ID_SCHEME + "layers"; + private static final String COMPASS_HUD_ID = HUD_BTN_ID_SCHEME + "compass"; + private static final String QUICK_SEARCH_HUD_ID = HUD_BTN_ID_SCHEME + "quick_search"; + private static final String BACK_TO_LOC_HUD_ID = HUD_BTN_ID_SCHEME + "back_to_loc"; + private static final String MENU_HUD_ID = HUD_BTN_ID_SCHEME + "menu"; + private static final String ROUTE_PLANNING_HUD_ID = HUD_BTN_ID_SCHEME + "route_planning"; + private static final String ZOOM_IN_HUD_ID = HUD_BTN_ID_SCHEME + "zoom_id"; + private static final String ZOOM_OUT_HUD_ID = HUD_BTN_ID_SCHEME + "zoom_out"; + + public MapHudButton createHudButton(View iv, int resId, String id) { MapHudButton mc = new MapHudButton(); mc.iv = iv; mc.resId = resId; + mc.id = id; return mc; } @@ -246,7 +257,7 @@ public class MapControlsLayer extends OsmandMapLayer { private void initTopControls() { View configureMap = mapActivity.findViewById(R.id.map_layers_button); - layersHud = createHudButton(configureMap, R.drawable.map_world_globe_dark) + layersHud = createHudButton(configureMap, R.drawable.map_world_globe_dark, LAYERS_HUD_ID) .setIconColorId(R.color.on_map_icon_color, 0) .setBg(R.drawable.btn_inset_circle_trans, R.drawable.btn_inset_circle_night); controls.add(layersHud); @@ -259,7 +270,7 @@ public class MapControlsLayer extends OsmandMapLayer { }); View compass = mapActivity.findViewById(R.id.map_compass_button); - compassHud = createHudButton(compass, R.drawable.map_compass).setIconColorId(0). + compassHud = createHudButton(compass, R.drawable.map_compass, COMPASS_HUD_ID).setIconColorId(0). setBg(R.drawable.btn_inset_circle_trans, R.drawable.btn_inset_circle_night); compassHud.compass = true; controls.add(compassHud); @@ -271,7 +282,7 @@ public class MapControlsLayer extends OsmandMapLayer { }); View search = mapActivity.findViewById(R.id.map_search_button); - quickSearchHud = createHudButton(search, R.drawable.map_search_dark) + quickSearchHud = createHudButton(search, R.drawable.map_search_dark, QUICK_SEARCH_HUD_ID) .setIconsId(R.drawable.map_search_dark, R.drawable.map_search_night) .setIconColorId(0) .setBg(R.drawable.btn_inset_circle_trans, R.drawable.btn_inset_circle_night); @@ -389,7 +400,7 @@ public class MapControlsLayer extends OsmandMapLayer { private void initControls() { View backToLocation = mapActivity.findViewById(R.id.map_my_location_button); - backToLocationControl = createHudButton(backToLocation, R.drawable.map_my_location) + backToLocationControl = createHudButton(backToLocation, R.drawable.map_my_location, BACK_TO_LOC_HUD_ID) .setBg(R.drawable.btn_circle_blue); controls.add(backToLocationControl); @@ -409,7 +420,7 @@ public class MapControlsLayer extends OsmandMapLayer { final boolean dash = settings.SHOW_DASHBOARD_ON_MAP_SCREEN.get(); menuControl = createHudButton(backToMenuButton, - !dash ? R.drawable.map_drawer : R.drawable.map_dashboard).setBg( + !dash ? R.drawable.map_drawer : R.drawable.map_dashboard, MENU_HUD_ID).setBg( R.drawable.btn_round, R.drawable.btn_round_night); controls.add(menuControl); backToMenuButton.setOnClickListener(new View.OnClickListener() { @@ -426,7 +437,7 @@ public class MapControlsLayer extends OsmandMapLayer { zoomText = (TextView) mapActivity.findViewById(R.id.map_app_mode_text); View routePlanButton = mapActivity.findViewById(R.id.map_route_info_button); - routePlanningBtn = createHudButton(routePlanButton, R.drawable.map_directions).setBg( + routePlanningBtn = createHudButton(routePlanButton, R.drawable.map_directions, ROUTE_PLANNING_HUD_ID).setBg( R.drawable.btn_round, R.drawable.btn_round_night); controls.add(routePlanningBtn); routePlanButton.setOnClickListener(new View.OnClickListener() { @@ -634,7 +645,7 @@ public class MapControlsLayer extends OsmandMapLayer { private void initZooms() { final OsmandMapTileView view = mapActivity.getMapView(); View zoomInButton = mapActivity.findViewById(R.id.map_zoom_in_button); - mapZoomIn = createHudButton(zoomInButton, R.drawable.map_zoom_in). + mapZoomIn = createHudButton(zoomInButton, R.drawable.map_zoom_in, ZOOM_IN_HUD_ID). setIconsId(R.drawable.map_zoom_in, R.drawable.map_zoom_in_night).setRoundTransparent(); controls.add(mapZoomIn); zoomInButton.setOnClickListener(new View.OnClickListener() { @@ -653,7 +664,7 @@ public class MapControlsLayer extends OsmandMapLayer { final View.OnLongClickListener listener = MapControlsLayer.getOnClickMagnifierListener(view); zoomInButton.setOnLongClickListener(listener); View zoomOutButton = mapActivity.findViewById(R.id.map_zoom_out_button); - mapZoomOut = createHudButton(zoomOutButton, R.drawable.map_zoom_out). + mapZoomOut = createHudButton(zoomOutButton, R.drawable.map_zoom_out, ZOOM_OUT_HUD_ID). setIconsId(R.drawable.map_zoom_out, R.drawable.map_zoom_out_night).setRoundTransparent(); controls.add(mapZoomOut); zoomOutButton.setOnClickListener(new View.OnClickListener() { @@ -1035,6 +1046,7 @@ public class MapControlsLayer extends OsmandMapLayer { int resDarkId; int resClrLight = R.color.icon_color; int resClrDark = 0; + String id; boolean nightMode = false; boolean f = true; From f24d6aadac419f25ee445d63f3fdf4f00dc5d76d Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Thu, 1 Nov 2018 12:19:42 +0200 Subject: [PATCH 4/9] Extract constants to the OsmAndCustomizationConstants --- .../plus/OsmAndCustomizationConstants.java | 62 +++++++++++++++++++ .../plus/activities/MapActivityActions.java | 30 +++++---- .../osmand/plus/dialogs/ConfigureMapMenu.java | 45 ++++++-------- .../osmand/plus/views/MapControlsLayer.java | 19 +++--- 4 files changed, 104 insertions(+), 52 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/OsmAndCustomizationConstants.java diff --git a/OsmAnd/src/net/osmand/plus/OsmAndCustomizationConstants.java b/OsmAnd/src/net/osmand/plus/OsmAndCustomizationConstants.java new file mode 100644 index 0000000000..720e4e4c16 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/OsmAndCustomizationConstants.java @@ -0,0 +1,62 @@ +package net.osmand.plus; + +public interface OsmAndCustomizationConstants { + + // Navigation Drawer: + + String DRAWER_ITEM_ID_SCHEME = "drawer.action."; + String DRAWER_DASHBOARD_ID = DRAWER_ITEM_ID_SCHEME + "dashboard"; + String DRAWER_MAP_MARKERS_ID = DRAWER_ITEM_ID_SCHEME + "map_markers"; + String DRAWER_MY_PLACES_ID = DRAWER_ITEM_ID_SCHEME + "my_places"; + String DRAWER_SEARCH_ID = DRAWER_ITEM_ID_SCHEME + "search"; + String DRAWER_DIRECTIONS_ID = DRAWER_ITEM_ID_SCHEME + "directions"; + String DRAWER_CONFIGURE_MAP_ID = DRAWER_ITEM_ID_SCHEME + "configure_map"; + String DRAWER_DOWNLOAD_MAPS_ID = DRAWER_ITEM_ID_SCHEME + "download_maps"; + String DRAWER_OSMAND_LIVE_ID = DRAWER_ITEM_ID_SCHEME + "osmand_live"; + String DRAWER_TRAVEL_GUIDES_ID = DRAWER_ITEM_ID_SCHEME + "travel_guides"; + String DRAWER_MEASURE_DISTANCE_ID = DRAWER_ITEM_ID_SCHEME + "measure_distance"; + String DRAWER_CONFIGURE_SCREEN_ID = DRAWER_ITEM_ID_SCHEME + "configure_screen"; + String DRAWER_PLUGINS_ID = DRAWER_ITEM_ID_SCHEME + "plugins"; + String DRAWER_SETTINGS_ID = DRAWER_ITEM_ID_SCHEME + "settings"; + String DRAWER_HELP_ID = DRAWER_ITEM_ID_SCHEME + "help"; + + // Configure Map: + + String ITEM_ID_SCHEME = "map.configure."; + String SHOW_ITEMS_ID_SCHEME = ITEM_ID_SCHEME + "show."; + String RENDERING_ITEMS_ID_SCHEME = ITEM_ID_SCHEME + "rendering."; + String CUSTOM_RENDERING_ITEMS_ID_SCHEME = RENDERING_ITEMS_ID_SCHEME + "custom."; + + String APP_PROFILES_ID = ITEM_ID_SCHEME + "app_profiles"; + + String FAVORITES_ID = SHOW_ITEMS_ID_SCHEME + "favorites"; + String POI_OVERLAY_ID = SHOW_ITEMS_ID_SCHEME + "poi_overlay"; + String POI_OVERLAY_LABELS_ID = SHOW_ITEMS_ID_SCHEME + "poi_overlay_labels"; + String TRANSPORT_ID = SHOW_ITEMS_ID_SCHEME + "transport"; + String GPX_FILES_ID = SHOW_ITEMS_ID_SCHEME + "gpx_files"; + String MAP_MARKERS_ID = SHOW_ITEMS_ID_SCHEME + "map_markers"; + String MAP_SOURCE_ID = SHOW_ITEMS_ID_SCHEME + "map_source"; + + String MAP_STYLE_ID = RENDERING_ITEMS_ID_SCHEME + "map_style"; + String MAP_MODE_ID = RENDERING_ITEMS_ID_SCHEME + "map_mode"; + String MAP_MAGNIFIER_ID = RENDERING_ITEMS_ID_SCHEME + "map_marnifier"; + String ROAD_STYLE_ID = RENDERING_ITEMS_ID_SCHEME + "road_style"; + String TEXT_SIZE_ID = RENDERING_ITEMS_ID_SCHEME + "text_size"; + String MAP_LANGUAGE_ID = RENDERING_ITEMS_ID_SCHEME + "map_language"; + String TRANSPORT_RENDERING_ID = RENDERING_ITEMS_ID_SCHEME + "transport"; + String DETAILS_ID = RENDERING_ITEMS_ID_SCHEME + "details"; + String HIDE_ID = RENDERING_ITEMS_ID_SCHEME + "hide"; + String ROUTES_ID = RENDERING_ITEMS_ID_SCHEME + "routes"; + + // Map Controls: + + String HUD_BTN_ID_SCHEME = "map.view."; + String LAYERS_HUD_ID = HUD_BTN_ID_SCHEME + "layers"; + String COMPASS_HUD_ID = HUD_BTN_ID_SCHEME + "compass"; + String QUICK_SEARCH_HUD_ID = HUD_BTN_ID_SCHEME + "quick_search"; + String BACK_TO_LOC_HUD_ID = HUD_BTN_ID_SCHEME + "back_to_loc"; + String MENU_HUD_ID = HUD_BTN_ID_SCHEME + "menu"; + String ROUTE_PLANNING_HUD_ID = HUD_BTN_ID_SCHEME + "route_planning"; + String ZOOM_IN_HUD_ID = HUD_BTN_ID_SCHEME + "zoom_id"; + String ZOOM_OUT_HUD_ID = HUD_BTN_ID_SCHEME + "zoom_out"; +} diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 798172b8c2..fb253f6d11 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -79,6 +79,20 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_CONFIGURE_MAP_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_CONFIGURE_SCREEN_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_DASHBOARD_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_DIRECTIONS_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_DOWNLOAD_MAPS_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_HELP_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_MAP_MARKERS_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_MEASURE_DISTANCE_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_MY_PLACES_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_OSMAND_LIVE_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_PLUGINS_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_SEARCH_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_TRAVEL_GUIDES_ID; import static net.osmand.plus.helpers.ImportHelper.GPX_SUFFIX; public class MapActivityActions implements DialogProvider { @@ -106,22 +120,6 @@ public class MapActivityActions implements DialogProvider { private static final int DIALOG_SAVE_DIRECTIONS = 106; - private static final String DRAWER_ITEM_ID_SCHEME = "drawer.action."; - private static final String DRAWER_DASHBOARD_ID = DRAWER_ITEM_ID_SCHEME + "dashboard"; - private static final String DRAWER_MAP_MARKERS_ID = DRAWER_ITEM_ID_SCHEME + "map_markers"; - private static final String DRAWER_MY_PLACES_ID = DRAWER_ITEM_ID_SCHEME + "my_places"; - private static final String DRAWER_SEARCH_ID = DRAWER_ITEM_ID_SCHEME + "search"; - private static final String DRAWER_DIRECTIONS_ID = DRAWER_ITEM_ID_SCHEME + "directions"; - private static final String DRAWER_CONFIGURE_MAP_ID = DRAWER_ITEM_ID_SCHEME + "configure_map"; - private static final String DRAWER_DOWNLOAD_MAPS_ID = DRAWER_ITEM_ID_SCHEME + "download_maps"; - private static final String DRAWER_OSMAND_LIVE_ID = DRAWER_ITEM_ID_SCHEME + "osmand_live"; - private static final String DRAWER_TRAVEL_GUIDES_ID = DRAWER_ITEM_ID_SCHEME + "travel_guides"; - private static final String DRAWER_MEASURE_DISTANCE_ID = DRAWER_ITEM_ID_SCHEME + "measure_distance"; - private static final String DRAWER_CONFIGURE_SCREEN_ID = DRAWER_ITEM_ID_SCHEME + "configure_screen"; - private static final String DRAWER_PLUGINS_ID = DRAWER_ITEM_ID_SCHEME + "plugins"; - private static final String DRAWER_SETTINGS_ID = DRAWER_ITEM_ID_SCHEME + "settings"; - private static final String DRAWER_HELP_ID = DRAWER_ITEM_ID_SCHEME + "help"; - // make static private static Bundle dialogBundle = new Bundle(); diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java index 8a6aaf7d09..d5dd460e68 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java @@ -68,6 +68,25 @@ import java.util.Map; import gnu.trove.list.array.TIntArrayList; +import static net.osmand.plus.OsmAndCustomizationConstants.APP_PROFILES_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.CUSTOM_RENDERING_ITEMS_ID_SCHEME; +import static net.osmand.plus.OsmAndCustomizationConstants.DETAILS_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.FAVORITES_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.GPX_FILES_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.HIDE_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.MAP_LANGUAGE_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.MAP_MAGNIFIER_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.MAP_MARKERS_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.MAP_MODE_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.MAP_SOURCE_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.MAP_STYLE_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.POI_OVERLAY_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.POI_OVERLAY_LABELS_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.ROAD_STYLE_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.ROUTES_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.TEXT_SIZE_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.TRANSPORT_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.TRANSPORT_RENDERING_ID; import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_DENSITY_ATTR; import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_ATTR; import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_SCHEME_ATTR; @@ -81,32 +100,6 @@ public class ConfigureMapMenu { public static final String COLOR_ATTR = "color"; public static final String ROAD_STYLE_ATTR = "roadStyle"; - private static final String ITEM_ID_SCHEME = "map.configure."; - private static final String SHOW_ITEMS_ID_SCHEME = ITEM_ID_SCHEME + "show."; - private static final String RENDERING_ITEMS_ID_SCHEME = ITEM_ID_SCHEME + "rendering."; - private static final String CUSTOM_RENDERING_ITEMS_ID_SCHEME = RENDERING_ITEMS_ID_SCHEME + "custom."; - - private static final String APP_PROFILES_ID = ITEM_ID_SCHEME + "app_profiles"; - - private static final String FAVORITES_ID = SHOW_ITEMS_ID_SCHEME + "favorites"; - private static final String POI_OVERLAY_ID = SHOW_ITEMS_ID_SCHEME + "poi_overlay"; - private static final String POI_OVERLAY_LABELS_ID = SHOW_ITEMS_ID_SCHEME + "poi_overlay_labels"; - private static final String TRANSPORT_ID = SHOW_ITEMS_ID_SCHEME + "transport"; - private static final String GPX_FILES_ID = SHOW_ITEMS_ID_SCHEME + "gpx_files"; - private static final String MAP_MARKERS_ID = SHOW_ITEMS_ID_SCHEME + "map_markers"; - private static final String MAP_SOURCE_ID = SHOW_ITEMS_ID_SCHEME + "map_source"; - - private static final String MAP_STYLE_ID = RENDERING_ITEMS_ID_SCHEME + "map_style"; - private static final String MAP_MODE_ID = RENDERING_ITEMS_ID_SCHEME + "map_mode"; - private static final String MAP_MAGNIFIER_ID = RENDERING_ITEMS_ID_SCHEME + "map_marnifier"; - private static final String ROAD_STYLE_ID = RENDERING_ITEMS_ID_SCHEME + "road_style"; - private static final String TEXT_SIZE_ID = RENDERING_ITEMS_ID_SCHEME + "text_size"; - private static final String MAP_LANGUAGE_ID = RENDERING_ITEMS_ID_SCHEME + "map_language"; - private static final String TRANSPORT_RENDERING_ID = RENDERING_ITEMS_ID_SCHEME + "transport"; - private static final String DETAILS_ID = RENDERING_ITEMS_ID_SCHEME + "details"; - private static final String HIDE_ID = RENDERING_ITEMS_ID_SCHEME + "hide"; - private static final String ROUTES_ID = RENDERING_ITEMS_ID_SCHEME + "routes"; - private int hikingRouteOSMCValue; private int selectedLanguageIndex; private boolean transliterateNames; diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index ef7cf22e4f..dd12390aeb 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -61,6 +61,15 @@ import java.util.List; import gnu.trove.list.array.TIntArrayList; +import static net.osmand.plus.OsmAndCustomizationConstants.BACK_TO_LOC_HUD_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.COMPASS_HUD_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.LAYERS_HUD_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.MENU_HUD_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.QUICK_SEARCH_HUD_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.ROUTE_PLANNING_HUD_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.ZOOM_IN_HUD_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.ZOOM_OUT_HUD_ID; + public class MapControlsLayer extends OsmandMapLayer { private static final int TIMEOUT_TO_SHOW_BUTTONS = 7000; @@ -68,16 +77,6 @@ public class MapControlsLayer extends OsmandMapLayer { private static final int REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION = 201; private static final int REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION = 202; - private static final String HUD_BTN_ID_SCHEME = "map.view."; - private static final String LAYERS_HUD_ID = HUD_BTN_ID_SCHEME + "layers"; - private static final String COMPASS_HUD_ID = HUD_BTN_ID_SCHEME + "compass"; - private static final String QUICK_SEARCH_HUD_ID = HUD_BTN_ID_SCHEME + "quick_search"; - private static final String BACK_TO_LOC_HUD_ID = HUD_BTN_ID_SCHEME + "back_to_loc"; - private static final String MENU_HUD_ID = HUD_BTN_ID_SCHEME + "menu"; - private static final String ROUTE_PLANNING_HUD_ID = HUD_BTN_ID_SCHEME + "route_planning"; - private static final String ZOOM_IN_HUD_ID = HUD_BTN_ID_SCHEME + "zoom_id"; - private static final String ZOOM_OUT_HUD_ID = HUD_BTN_ID_SCHEME + "zoom_out"; - public MapHudButton createHudButton(View iv, int resId, String id) { MapHudButton mc = new MapHudButton(); mc.iv = iv; From 29c6f95cba20ed10e6fbf2697e0c4916246469f1 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Fri, 2 Nov 2018 16:20:42 +0200 Subject: [PATCH 5/9] Add the ability to disable and enable features --- .../net/osmand/plus/ContextMenuAdapter.java | 9 ++++ .../osmand/plus/OsmAndAppCustomization.java | 51 +++++++++++++++++++ .../plus/OsmAndCustomizationConstants.java | 2 + .../osmand/plus/views/MapControlsLayer.java | 6 +++ 4 files changed, 68 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java index 7a37d2860b..786c6ed646 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java @@ -10,6 +10,7 @@ import android.support.annotation.IdRes; import android.support.annotation.LayoutRes; import android.support.v4.app.FragmentActivity; import android.support.v7.widget.AppCompatImageView; +import android.text.TextUtils; import android.view.ContextThemeWrapper; import android.view.View; import android.view.ViewGroup; @@ -32,6 +33,7 @@ import org.apache.commons.logging.Log; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -100,6 +102,13 @@ public class ContextMenuAdapter { public ArrayAdapter createListAdapter(final Activity activity, final boolean lightTheme) { final int layoutId = DEFAULT_LAYOUT_ID; final OsmandApplication app = ((OsmandApplication) activity.getApplication()); + final OsmAndAppCustomization customization = app.getAppCustomization(); + for (Iterator iterator = items.iterator(); iterator.hasNext(); ) { + String id = iterator.next().getId(); + if (!TextUtils.isEmpty(id) && !customization.isFeatureEnabled(id)) { + iterator.remove(); + } + } return new ContextMenuArrayAdapter(activity, layoutId, R.id.title, items.toArray(new ContextMenuItem[items.size()]), app, lightTheme, changeAppModeListener); } diff --git a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java index 098c7a85fc..64529dcb77 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.Uri; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.text.TextUtils; @@ -24,9 +25,12 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; public class OsmAndAppCustomization { @@ -35,6 +39,11 @@ public class OsmAndAppCustomization { private Bitmap navDrawerLogo; + private Set enabledIds = new HashSet<>(); + private Set disabledIds = new HashSet<>(); + private Set enabledPatterns = new HashSet<>(); + private Set disabledPatterns = new HashSet<>(); + public void setup(OsmandApplication app) { this.app = app; this.osmandSettings = new OsmandSettings(app, new net.osmand.plus.api.SettingsAPIImpl(app)); @@ -133,4 +142,46 @@ public class OsmAndAppCustomization { } return true; } + + public void setEnabledIds(@NonNull Collection ids) { + enabledIds.clear(); + enabledIds.addAll(ids); + } + + public void setDisabledIds(@NonNull Collection ids) { + disabledIds.clear(); + disabledIds.addAll(ids); + } + + public void setEnabledPatterns(@NonNull Collection patterns) { + enabledPatterns.clear(); + enabledPatterns.addAll(patterns); + } + + public void setDisabledPatterns(@NonNull Collection patterns) { + disabledPatterns.clear(); + disabledPatterns.addAll(patterns); + } + + public boolean isFeatureEnabled(@NonNull String id) { + if (enabledIds.contains(id)) { + return true; + } + if (disabledIds.contains(id)) { + return false; + } + if (isMatchesPattern(id, enabledPatterns)) { + return true; + } + return !isMatchesPattern(id, disabledPatterns); + } + + private boolean isMatchesPattern(@NonNull String id, @NonNull Set patterns) { + for (String pattern : patterns) { + if (id.startsWith(pattern)) { + return true; + } + } + return false; + } } diff --git a/OsmAnd/src/net/osmand/plus/OsmAndCustomizationConstants.java b/OsmAnd/src/net/osmand/plus/OsmAndCustomizationConstants.java index 720e4e4c16..71cc7dde5c 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndCustomizationConstants.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndCustomizationConstants.java @@ -2,6 +2,8 @@ package net.osmand.plus; public interface OsmAndCustomizationConstants { + // TODO: add ids for category items + // Navigation Drawer: String DRAWER_ITEM_ID_SCHEME = "drawer.action."; diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index dd12390aeb..ca75709b39 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -36,6 +36,7 @@ import net.osmand.core.android.MapRendererContext; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.RotatedTileBox; +import net.osmand.plus.OsmAndAppCustomization; import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; @@ -107,6 +108,7 @@ public class MapControlsLayer extends OsmandMapLayer { private TextView zoomText; private OsmandMapTileView mapView; private OsmandApplication app; + private OsmAndAppCustomization appCustomization; private MapHudButton routePlanningBtn; private long touchEvent; private MapHudButton mapZoomOut; @@ -122,6 +124,7 @@ public class MapControlsLayer extends OsmandMapLayer { public MapControlsLayer(MapActivity activity) { this.mapActivity = activity; app = activity.getMyApplication(); + appCustomization = app.getAppCustomization(); settings = activity.getMyApplication().getSettings(); mapView = mapActivity.getMapView(); contextMenuLayer = mapActivity.getMapLayers().getContextMenuLayer(); @@ -1105,6 +1108,9 @@ public class MapControlsLayer extends OsmandMapLayer { } public boolean updateVisibility(boolean visible) { + if (visible) { + visible = appCustomization.isFeatureEnabled(id); + } if (!compassOutside && visible != (iv.getVisibility() == View.VISIBLE)) { if (visible) { if (hideAnimator != null) { From 4fc9ccff6404d537a88c4b946fd054c9acf3efc7 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Sat, 3 Nov 2018 14:33:23 +0200 Subject: [PATCH 6/9] Check if customization is enabled --- .../net/osmand/plus/OsmAndAppCustomization.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java index 64529dcb77..c7847e4106 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java @@ -44,6 +44,8 @@ public class OsmAndAppCustomization { private Set enabledPatterns = new HashSet<>(); private Set disabledPatterns = new HashSet<>(); + private boolean customizationEnabled; + public void setup(OsmandApplication app) { this.app = app; this.osmandSettings = new OsmandSettings(app, new net.osmand.plus.api.SettingsAPIImpl(app)); @@ -146,24 +148,31 @@ public class OsmAndAppCustomization { public void setEnabledIds(@NonNull Collection ids) { enabledIds.clear(); enabledIds.addAll(ids); + updateCustomizationEnabled(); } public void setDisabledIds(@NonNull Collection ids) { disabledIds.clear(); disabledIds.addAll(ids); + updateCustomizationEnabled(); } public void setEnabledPatterns(@NonNull Collection patterns) { enabledPatterns.clear(); enabledPatterns.addAll(patterns); + updateCustomizationEnabled(); } public void setDisabledPatterns(@NonNull Collection patterns) { disabledPatterns.clear(); disabledPatterns.addAll(patterns); + updateCustomizationEnabled(); } public boolean isFeatureEnabled(@NonNull String id) { + if (!customizationEnabled) { + return true; + } if (enabledIds.contains(id)) { return true; } @@ -176,6 +185,11 @@ public class OsmAndAppCustomization { return !isMatchesPattern(id, disabledPatterns); } + private void updateCustomizationEnabled() { + customizationEnabled = !enabledIds.isEmpty() || !disabledIds.isEmpty() + || !enabledPatterns.isEmpty() || !disabledPatterns.isEmpty(); + } + private boolean isMatchesPattern(@NonNull String id, @NonNull Set patterns) { for (String pattern : patterns) { if (id.startsWith(pattern)) { From a4688772450dacfa691a8e0b3d36aa75a39841c6 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Sat, 3 Nov 2018 15:41:15 +0200 Subject: [PATCH 7/9] Add ids --- OsmAnd/src/net/osmand/plus/OsmAndCustomizationConstants.java | 5 +++-- .../src/net/osmand/plus/activities/MapActivityActions.java | 2 ++ OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndCustomizationConstants.java b/OsmAnd/src/net/osmand/plus/OsmAndCustomizationConstants.java index 71cc7dde5c..1b52d90e08 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndCustomizationConstants.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndCustomizationConstants.java @@ -2,8 +2,6 @@ package net.osmand.plus; public interface OsmAndCustomizationConstants { - // TODO: add ids for category items - // Navigation Drawer: String DRAWER_ITEM_ID_SCHEME = "drawer.action."; @@ -21,6 +19,7 @@ public interface OsmAndCustomizationConstants { String DRAWER_PLUGINS_ID = DRAWER_ITEM_ID_SCHEME + "plugins"; String DRAWER_SETTINGS_ID = DRAWER_ITEM_ID_SCHEME + "settings"; String DRAWER_HELP_ID = DRAWER_ITEM_ID_SCHEME + "help"; + String DRAWER_DIVIDER_ID = DRAWER_ITEM_ID_SCHEME + "divider"; // Configure Map: @@ -31,6 +30,7 @@ public interface OsmAndCustomizationConstants { String APP_PROFILES_ID = ITEM_ID_SCHEME + "app_profiles"; + String SHOW_CATEGORY_ID = SHOW_ITEMS_ID_SCHEME + "category"; String FAVORITES_ID = SHOW_ITEMS_ID_SCHEME + "favorites"; String POI_OVERLAY_ID = SHOW_ITEMS_ID_SCHEME + "poi_overlay"; String POI_OVERLAY_LABELS_ID = SHOW_ITEMS_ID_SCHEME + "poi_overlay_labels"; @@ -39,6 +39,7 @@ public interface OsmAndCustomizationConstants { String MAP_MARKERS_ID = SHOW_ITEMS_ID_SCHEME + "map_markers"; String MAP_SOURCE_ID = SHOW_ITEMS_ID_SCHEME + "map_source"; + String MAP_RENDERING_CATEGORY_ID = RENDERING_ITEMS_ID_SCHEME + "category"; String MAP_STYLE_ID = RENDERING_ITEMS_ID_SCHEME + "map_style"; String MAP_MODE_ID = RENDERING_ITEMS_ID_SCHEME + "map_mode"; String MAP_MAGNIFIER_ID = RENDERING_ITEMS_ID_SCHEME + "map_marnifier"; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index fb253f6d11..5894047cfd 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -83,6 +83,7 @@ import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_CONFIGURE_MAP_ import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_CONFIGURE_SCREEN_ID; import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_DASHBOARD_ID; import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_DIRECTIONS_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_DIVIDER_ID; import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_DOWNLOAD_MAPS_ID; import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_HELP_ID; import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_MAP_MARKERS_ID; @@ -918,6 +919,7 @@ public class MapActivityActions implements DialogProvider { } ItemBuilder divider = new ItemBuilder().setLayout(R.layout.drawer_divider); + divider.setId(DRAWER_DIVIDER_ID); divider.setPosition(dividerItemIndex >= 0 ? dividerItemIndex : 8); optionsMenuHelper.addItem(divider.createItem()); diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java index d5dd460e68..596501d99e 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java @@ -78,12 +78,14 @@ import static net.osmand.plus.OsmAndCustomizationConstants.MAP_LANGUAGE_ID; import static net.osmand.plus.OsmAndCustomizationConstants.MAP_MAGNIFIER_ID; import static net.osmand.plus.OsmAndCustomizationConstants.MAP_MARKERS_ID; import static net.osmand.plus.OsmAndCustomizationConstants.MAP_MODE_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.MAP_RENDERING_CATEGORY_ID; import static net.osmand.plus.OsmAndCustomizationConstants.MAP_SOURCE_ID; import static net.osmand.plus.OsmAndCustomizationConstants.MAP_STYLE_ID; import static net.osmand.plus.OsmAndCustomizationConstants.POI_OVERLAY_ID; import static net.osmand.plus.OsmAndCustomizationConstants.POI_OVERLAY_LABELS_ID; import static net.osmand.plus.OsmAndCustomizationConstants.ROAD_STYLE_ID; import static net.osmand.plus.OsmAndCustomizationConstants.ROUTES_ID; +import static net.osmand.plus.OsmAndCustomizationConstants.SHOW_CATEGORY_ID; import static net.osmand.plus.OsmAndCustomizationConstants.TEXT_SIZE_ID; import static net.osmand.plus.OsmAndCustomizationConstants.TRANSPORT_ID; import static net.osmand.plus.OsmAndCustomizationConstants.TRANSPORT_RENDERING_ID; @@ -272,6 +274,7 @@ public class ConfigureMapMenu { final OsmandSettings settings = app.getSettings(); LayerMenuListener l = new LayerMenuListener(activity, adapter); adapter.addItem(new ContextMenuItem.ItemBuilder() + .setId(SHOW_CATEGORY_ID) .setTitleId(R.string.shared_string_show, activity) .setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem()); // String appMode = " [" + settings.getApplicationMode().toHumanString(view.getApplication()) +"] "; @@ -529,6 +532,7 @@ public class ConfigureMapMenu { private void createRenderingAttributeItems(List customRules, final ContextMenuAdapter adapter, final MapActivity activity) { adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_map_rendering, activity) + .setId(MAP_RENDERING_CATEGORY_ID) .setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem()); adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_renderer, activity) .setId(MAP_STYLE_ID) From aabf6bfdeca8ab39bcdbb5f8884474fc35840137 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Sat, 3 Nov 2018 16:27:37 +0200 Subject: [PATCH 8/9] Add ids for plugins --- .../src/net/osmand/plus/OsmAndCustomizationConstants.java | 8 ++++++++ .../net/osmand/plus/audionotes/AudioVideoNotesPlugin.java | 3 +++ .../osmand/plus/development/OsmandDevelopmentPlugin.java | 3 +++ OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java | 2 ++ OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java | 3 +++ .../osmand/plus/parkingpoint/ParkingPositionPlugin.java | 4 ---- .../osmand/plus/rastermaps/OsmandRasterMapsPlugin.java | 5 +++++ OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java | 5 +++++ 8 files changed, 29 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndCustomizationConstants.java b/OsmAnd/src/net/osmand/plus/OsmAndCustomizationConstants.java index 1b52d90e08..524d293792 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndCustomizationConstants.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndCustomizationConstants.java @@ -19,6 +19,7 @@ public interface OsmAndCustomizationConstants { String DRAWER_PLUGINS_ID = DRAWER_ITEM_ID_SCHEME + "plugins"; String DRAWER_SETTINGS_ID = DRAWER_ITEM_ID_SCHEME + "settings"; String DRAWER_HELP_ID = DRAWER_ITEM_ID_SCHEME + "help"; + String DRAWER_BUILDS_ID = DRAWER_ITEM_ID_SCHEME + "builds"; String DRAWER_DIVIDER_ID = DRAWER_ITEM_ID_SCHEME + "divider"; // Configure Map: @@ -38,6 +39,13 @@ public interface OsmAndCustomizationConstants { String GPX_FILES_ID = SHOW_ITEMS_ID_SCHEME + "gpx_files"; String MAP_MARKERS_ID = SHOW_ITEMS_ID_SCHEME + "map_markers"; String MAP_SOURCE_ID = SHOW_ITEMS_ID_SCHEME + "map_source"; + String RECORDING_LAYER = SHOW_ITEMS_ID_SCHEME + "recording_layer"; + String MAPILLARY = SHOW_ITEMS_ID_SCHEME + "mapillary"; + String OSM_NOTES = SHOW_ITEMS_ID_SCHEME + "osm_notes"; + String OVERLAY_MAP = SHOW_ITEMS_ID_SCHEME + "overlay_map"; + String UNDERLAY_MAP = SHOW_ITEMS_ID_SCHEME + "underlay_map"; + String CONTOUR_LINES = SHOW_ITEMS_ID_SCHEME + "contour_lines"; + String HILLSHADE_LAYER = SHOW_ITEMS_ID_SCHEME + "hillshade_layer"; String MAP_RENDERING_CATEGORY_ID = RENDERING_ITEMS_ID_SCHEME + "category"; String MAP_STYLE_ID = RENDERING_ITEMS_ID_SCHEME + "map_style"; diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index 8f3208daa7..bb0777836e 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -91,6 +91,8 @@ import java.util.Map; import java.util.Timer; import java.util.TimerTask; +import static net.osmand.plus.OsmAndCustomizationConstants.RECORDING_LAYER; + public class AudioVideoNotesPlugin extends OsmandPlugin { @@ -640,6 +642,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { } }; adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_recordings, app) + .setId(RECORDING_LAYER) .setSelected(SHOW_RECORDINGS.get()) .setIcon(R.drawable.ic_action_micro_dark) .setColor(SHOW_RECORDINGS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) diff --git a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java index 3113e2cf09..aaf2ed7ff6 100644 --- a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java +++ b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java @@ -18,6 +18,8 @@ import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.mapwidgets.TextInfoWidget; +import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_BUILDS_ID; + public class OsmandDevelopmentPlugin extends OsmandPlugin { private static final String ID = "osmand.development"; private OsmandApplication app; @@ -57,6 +59,7 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin { public void registerOptionsMenuItems(final MapActivity mapActivity, ContextMenuAdapter helper) { if (Version.isDeveloperVersion(mapActivity.getMyApplication())) { helper.addItem(new ContextMenuItem.ItemBuilder() + .setId(DRAWER_BUILDS_ID) .setTitleId(R.string.version_settings, mapActivity) .setIcon(R.drawable.ic_action_gabout_dark) .setListener(new ContextMenuAdapter.ItemClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java index c1547333b2..ddc87dd1d0 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java @@ -39,6 +39,7 @@ import java.text.MessageFormat; import java.util.List; import static android.content.Intent.ACTION_VIEW; +import static net.osmand.plus.OsmAndCustomizationConstants.MAPILLARY; public class MapillaryPlugin extends OsmandPlugin { public static final String ID = "osmand.mapillary"; @@ -179,6 +180,7 @@ public class MapillaryPlugin extends OsmandPlugin { settings.SHOW_MAPILLARY.set(false); } adapter.addItem(new ContextMenuItem.ItemBuilder() + .setId(MAPILLARY) .setTitleId(R.string.mapillary, mapActivity) .setSelected(settings.SHOW_MAPILLARY.get()) .setColor(settings.SHOW_MAPILLARY.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index cfc08ab1be..3f93a5f774 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -47,6 +47,8 @@ import org.apache.commons.logging.Log; import java.util.List; +import static net.osmand.plus.OsmAndCustomizationConstants.OSM_NOTES; + public class OsmEditingPlugin extends OsmandPlugin { private static final Log LOG = PlatformUtil.getLog(OsmEditingPlugin.class); @@ -292,6 +294,7 @@ public class OsmEditingPlugin extends OsmandPlugin { @Override public void registerLayerContextMenuActions(OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) { adapter.addItem(new ContextMenuItem.ItemBuilder() + .setId(OSM_NOTES) .setTitleId(R.string.layer_osm_bugs, mapActivity) .setSelected(settings.SHOW_OSM_BUGS.get()) .setIcon(R.drawable.ic_action_bug_dark) diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java index 7cc68c2652..afa1d1aea6 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java @@ -420,10 +420,6 @@ public class ParkingPositionPlugin extends OsmandPlugin { } clearParkingPosition(); } - - @Override - public void registerOptionsMenuItems(final MapActivity mapActivity, ContextMenuAdapter helper) { - } /** * @return the control to be added on a MapInfoLayer diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java index 53d04cef51..6bb17ed5b2 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java @@ -46,6 +46,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import static net.osmand.plus.OsmAndCustomizationConstants.OVERLAY_MAP; +import static net.osmand.plus.OsmAndCustomizationConstants.UNDERLAY_MAP; + public class OsmandRasterMapsPlugin extends OsmandPlugin { public static final String ID = "osmand.rastermaps"; @@ -323,6 +326,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { boolean hasOverlayDescription = overlayMapDescr != null; overlayMapDescr = hasOverlayDescription ? overlayMapDescr : mapActivity.getString(R.string.shared_string_none); adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_overlay, mapActivity) + .setId(OVERLAY_MAP) .setDescription(overlayMapDescr) .setSelected(hasOverlayDescription) .setColor(hasOverlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) @@ -335,6 +339,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { boolean hasUnderlayDescription = underlayMapDescr != null; underlayMapDescr = hasUnderlayDescription ? underlayMapDescr : mapActivity.getString(R.string.shared_string_none); adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_underlay, mapActivity) + .setId(UNDERLAY_MAP) .setDescription(underlayMapDescr) .setSelected(hasUnderlayDescription) .setColor(hasUnderlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java index 66ee81ffcd..4e23944e16 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java @@ -29,6 +29,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import static net.osmand.plus.OsmAndCustomizationConstants.CONTOUR_LINES; +import static net.osmand.plus.OsmAndCustomizationConstants.HILLSHADE_LAYER; + public class SRTMPlugin extends OsmandPlugin { public static final String ID = "osmand.srtm"; @@ -217,6 +220,7 @@ public class SRTMPlugin extends OsmandPlugin { } String descr = getPrefDescription(app, contourLinesProp, pref); adapter.addItem(new ContextMenuItem.ItemBuilder() + .setId(CONTOUR_LINES) .setTitleId(R.string.srtm_plugin_name, mapActivity) .setSelected(contourLinesSelected) .setIcon(R.drawable.ic_plugin_srtm) @@ -227,6 +231,7 @@ public class SRTMPlugin extends OsmandPlugin { .setListener(listener).createItem()); } adapter.addItem(new ContextMenuItem.ItemBuilder() + .setId(HILLSHADE_LAYER) .setTitleId(R.string.layer_hillshade, mapActivity) .setSelected(HILLSHADE.get()) .setColor(HILLSHADE.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) From b68392315e8fdc4d44308bbda37df269395254dd Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Sat, 3 Nov 2018 16:28:25 +0200 Subject: [PATCH 9/9] Add the ability to customize interface via AIDL API --- .../net/osmand/aidl/IOsmAndAidlInterface.aidl | 5 ++++ OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 21 ++++++++++++++++ .../net/osmand/aidl/OsmandAidlService.java | 24 +++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl index 83774492c0..a28a0af228 100644 --- a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl +++ b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl @@ -135,4 +135,9 @@ interface IOsmAndAidlInterface { boolean unregisterFromUpdates(in long callbackId); boolean setNavDrawerLogo(in String imageUri); + + boolean setEnabledIds(in List ids); + boolean setDisabledIds(in List ids); + boolean setEnabledPatterns(in List patterns); + boolean setDisabledPatterns(in List patterns); } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 58d17e998d..60ccad50fa 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -82,6 +82,7 @@ import java.io.IOException; import java.io.InputStream; import java.lang.ref.WeakReference; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; @@ -1659,6 +1660,26 @@ public class OsmandAidlApi { return app.getAppCustomization().setNavDrawerLogo(uri); } + boolean setEnabledIds(Collection ids) { + app.getAppCustomization().setEnabledIds(ids); + return true; + } + + boolean setDisabledIds(Collection ids) { + app.getAppCustomization().setDisabledIds(ids); + return true; + } + + boolean setEnabledPatterns(Collection patterns) { + app.getAppCustomization().setEnabledPatterns(patterns); + return true; + } + + boolean setDisabledPatterns(Collection patterns) { + app.getAppCustomization().setDisabledPatterns(patterns); + return true; + } + public static class ConnectedApp implements Comparable { static final String PACK_KEY = "pack"; diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java index bd2ab3e493..22caa53a79 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -677,6 +677,30 @@ public class OsmandAidlService extends Service { return api != null && api.setNavDrawerLogo(imageUri); } + @Override + public boolean setEnabledIds(List ids) throws RemoteException { + OsmandAidlApi api = getApi("setEnabledIds"); + return api != null && api.setEnabledIds(ids); + } + + @Override + public boolean setDisabledIds(List ids) throws RemoteException { + OsmandAidlApi api = getApi("setDisabledIds"); + return api != null && api.setDisabledIds(ids); + } + + @Override + public boolean setEnabledPatterns(List patterns) throws RemoteException { + OsmandAidlApi api = getApi("setEnabledPatterns"); + return api != null && api.setEnabledPatterns(patterns); + } + + @Override + public boolean setDisabledPatterns(List patterns) throws RemoteException { + OsmandAidlApi api = getApi("setDisabledPatterns"); + return api != null && api.setDisabledPatterns(patterns); + } + void startRemoteUpdates(final long updateTimeMS, final long callbackId, final IOsmAndAidlCallback callback) { mHandler.postDelayed(new Runnable() { @Override