diff --git a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java index a0707906bf..9a367037ec 100644 --- a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java +++ b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java @@ -12,7 +12,6 @@ import java.text.Collator; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; -import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; @@ -146,6 +145,8 @@ public class BinaryMapIndexReader { mapIndex.length = readInt(); mapIndex.filePointer = codedIS.getTotalBytesRead(); int oldLimit = codedIS.pushLimit(mapIndex.length); + // FIXME +// codedIS.skipRawBytes(codedIS.getBytesUntilLimit()); readMapIndex(mapIndex); basemap = basemap || mapIndex.isBaseMap(); codedIS.popLimit(oldLimit); @@ -159,6 +160,8 @@ public class BinaryMapIndexReader { region.filePointer = codedIS.getTotalBytesRead(); if(addressAdapter != null){ oldLimit = codedIS.pushLimit(region.length); + // FIXME +// codedIS.skipRawBytes(codedIS.getBytesUntilLimit()); addressAdapter.readAddressIndex(region); if(region.name != null){ addressIndexes.add(region); @@ -174,6 +177,8 @@ public class BinaryMapIndexReader { ind.filePointer = codedIS.getTotalBytesRead(); if (transportAdapter != null) { oldLimit = codedIS.pushLimit(ind.length); + // FIXME +// codedIS.skipRawBytes(codedIS.getBytesUntilLimit()); transportAdapter.readTransportIndex(ind); codedIS.popLimit(oldLimit); transportIndexes.add(ind); @@ -187,6 +192,8 @@ public class BinaryMapIndexReader { routeReg.filePointer = codedIS.getTotalBytesRead(); if (routeAdapter != null) { oldLimit = codedIS.pushLimit(routeReg.length); + // FIXME +// codedIS.skipRawBytes(codedIS.getBytesUntilLimit()); routeAdapter.readRouteIndex(routeReg); codedIS.popLimit(oldLimit); routingIndexes.add(routeReg); @@ -200,6 +207,8 @@ public class BinaryMapIndexReader { poiInd.filePointer = codedIS.getTotalBytesRead(); if (poiAdapter != null) { oldLimit = codedIS.pushLimit(poiInd.length); + // FIXME +// codedIS.skipRawBytes(codedIS.getBytesUntilLimit()); poiAdapter.readPoiIndex(poiInd); codedIS.popLimit(oldLimit); poiIndexes.add(poiInd); diff --git a/OsmAnd/res/menu/map_menu.xml b/OsmAnd/res/menu/map_menu.xml deleted file mode 100644 index 82c0fb82bd..0000000000 --- a/OsmAnd/res/menu/map_menu.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 1114b1fec5..c4f75cc055 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -181,11 +181,9 @@ You can enable (online or cached) tile map sources, tracking settings, and many Show settings needed for OSM feedback like collecting / modifying OSM POI objects, opening / commenting OSM bugs, and contributing recorded GPX files (requires OSM credentials). Vector maps likely display faster. May not work well on some devices. - Simulate route progression manually Play commands of currently selected voice OsmAnd development Native rendering - Animate navigation Test voice prompts No offline vector map present for this location. You can download one in Settings (Offline data), or switch to online maps. Changes in 0.7.2 : diff --git a/OsmAnd/res/xml/settings_pref.xml b/OsmAnd/res/xml/settings_pref.xml index 06fd5571b6..f5bbf952dd 100644 --- a/OsmAnd/res/xml/settings_pref.xml +++ b/OsmAnd/res/xml/settings_pref.xml @@ -23,17 +23,17 @@ android:summary="@string/choose_auto_follow_route_descr"> - - + - --> + diff --git a/OsmAnd/src/net/osmand/plus/OptionsMenuHelper.java b/OsmAnd/src/net/osmand/plus/OptionsMenuHelper.java index e6276657e8..44b91c94c3 100644 --- a/OsmAnd/src/net/osmand/plus/OptionsMenuHelper.java +++ b/OsmAnd/src/net/osmand/plus/OptionsMenuHelper.java @@ -1,32 +1,82 @@ package net.osmand.plus; +import gnu.trove.list.array.TIntArrayList; + +import java.util.ArrayList; + import android.view.Menu; +import android.view.MenuItem; public class OptionsMenuHelper { - private final Menu menu; - - public OptionsMenuHelper(Menu menu) { - this.menu = menu; + public interface OnOptionsMenuClick { + + public void prepareOptionsMenu(Menu menu, MenuItem item); + + public boolean onClick(MenuItem item); } - public void registerOptionsMenuItem(int resItemId, int resName, int resIcon, boolean visibility) { - if (resIcon != -1) { - menu.add(Menu.CATEGORY_CONTAINER, resItemId, Menu.NONE, resName).setVisible(visibility).setIcon(resIcon); - } else { - menu.add(Menu.CATEGORY_CONTAINER, resItemId, Menu.NONE, resName).setVisible(visibility); + final TIntArrayList items = new TIntArrayList(); + final TIntArrayList itemNames = new TIntArrayList(); + final TIntArrayList visible = new TIntArrayList(); + final ArrayList listeners = new ArrayList(); + final TIntArrayList iconList = new TIntArrayList(); + + public OptionsMenuHelper() { + } + + public void registerOptionsMenu(Menu menu) { + for (int i = 0; i < items.size(); i++) { + int resItemId = items.get(i); + int resName = itemNames.get(i); + int resIcon = iconList.get(i); + boolean visibility = visible.get(i) > 0; + if (resIcon != -1) { + menu.add(Menu.CATEGORY_CONTAINER, resItemId, Menu.NONE, resName).setVisible(visibility).setIcon(resIcon); + } else { + menu.add(Menu.CATEGORY_CONTAINER, resItemId, Menu.NONE, resName).setVisible(visibility); + } } } - public void registerOptionsMenuItem(int resItemId, int resName, int resIcon) { - registerOptionsMenuItem(resItemId, resName, resIcon, true); + public boolean onClick(MenuItem mi) { + int id = mi.getItemId(); + int ind = items.indexOf(id); + if(ind >= 0 && ind < listeners.size() && listeners.get(ind) != null) { + return listeners.get(ind).onClick(mi); + } + return false; + } + + public void prepareOptionsMenu(Menu menu) { + for (int i = 0; i < items.size(); i++) { + int resItemId = items.get(i); + OnOptionsMenuClick l = listeners.get(i); + if (l != null) { + l.prepareOptionsMenu(menu, menu.findItem(resItemId)); + } + } } - public void registerOptionsMenuItem(int resItemId, int resName, boolean visibility) { - registerOptionsMenuItem(resItemId, resName, -1, visibility); + public void registerOptionsMenuItem(int resItemId, int resName, int resIcon, boolean visibility, OnOptionsMenuClick onClick) { + items.add(resItemId); + itemNames.add(resName); + visible.add(visibility ? 1 : 0); + listeners.add(onClick); + iconList.add(resIcon); } - public void registerOptionsMenuItem(int resItemId, int resName) { - registerOptionsMenuItem(resItemId, resName, -1, true); + public void registerOptionsMenuItem(int resItemId, int resName, int resIcon, OnOptionsMenuClick onClick) { + registerOptionsMenuItem(resItemId, resName, resIcon, true, onClick); } + + public void registerOptionsMenuItem(int resItemId, int resName, boolean visibility, OnOptionsMenuClick onClick) { + registerOptionsMenuItem(resItemId, resName, -1, visibility, onClick); + } + + public void registerOptionsMenuItem(int resItemId, int resName, OnOptionsMenuClick onClick) { + registerOptionsMenuItem(resItemId, resName, -1, true, onClick); + } + + } diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java index 0417ce417c..50afd543cf 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java @@ -25,7 +25,6 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.preference.PreferenceScreen; -import android.view.Menu; public abstract class OsmandPlugin { @@ -120,10 +119,6 @@ public abstract class OsmandPlugin { public void registerOptionsMenuItems(MapActivity mapActivity, OptionsMenuHelper helper) {} - public void prepareOptionsMenuItems(MapActivity mapActivity, Menu menu) {} - - public boolean onOptionsItemSelected(MapActivity mapActivity, int itemId) { return false; } - public static void refreshLayers(OsmandMapTileView mapView, MapActivity activity) { for (OsmandPlugin plugin : activePlugins) { plugin.updateLayers(mapView, activity); @@ -216,21 +211,6 @@ public abstract class OsmandPlugin { } } - public static void registerOnPrepareOptionsMenu(MapActivity mapActivity, Menu menu) { - for (OsmandPlugin plugin : activePlugins) { - plugin.prepareOptionsMenuItems(mapActivity, menu); - } - } - - public static boolean registerOnOptionsMenuItemSelected(MapActivity mapActivity, int itemId) { - for (OsmandPlugin plugin : activePlugins) { - if (plugin.onOptionsItemSelected(mapActivity, itemId)) { - return true; - } - } - return false; - } - private static void installParkingPlugin(OsmandApplication app) { Intent parkingIntent = new Intent(); parkingIntent.setComponent(new ComponentName(PARKING_PLUGIN_COMPONENT, PARKING_PLUGIN_ACTIVITY)); diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 13288a85a9..6ac3d84162 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -31,7 +31,6 @@ import android.content.SharedPreferences.Editor; import android.content.pm.ActivityInfo; import android.hardware.Sensor; import android.hardware.SensorManager; -import android.location.LocationManager; import android.media.AudioManager; import android.net.ConnectivityManager; import android.net.NetworkInfo; @@ -1226,10 +1225,6 @@ public class OsmandSettings { // for background service public final OsmandPreference MAP_ACTIVITY_ENABLED = new BooleanPreference("map_activity_enabled", false).makeGlobal(); - // test animate routing - // this value string is synchronized with settings_pref.xml preference name - public final OsmandPreference TEST_ANIMATE_ROUTING = new BooleanPreference("animate_routing", false).makeGlobal(); - // this value string is synchronized with settings_pref.xml preference name public final OsmandPreference NATIVE_RENDERING = new BooleanPreference("native_rendering", true).makeGlobal(); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 726db7ea41..10d41ebba1 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -26,13 +26,13 @@ import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.OptionsMenuHelper; +import net.osmand.plus.OptionsMenuHelper.OnOptionsMenuClick; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.ResourceManager; import net.osmand.plus.activities.search.SearchActivity; -import net.osmand.plus.routing.RouteAnimation; import net.osmand.plus.routing.RouteProvider.GPXRouteParams; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.views.BaseMapLayer; @@ -57,7 +57,6 @@ import android.location.Location; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; -import android.provider.Settings.Secure; import android.text.ClipboardManager; import android.text.Html; import android.util.FloatMath; @@ -100,7 +99,8 @@ public class MapActivityActions implements DialogProvider { private final MapActivity mapActivity; private OsmandSettings settings; private RoutingHelper routingHelper; - private RouteAnimation routeAnimation = new RouteAnimation(); + private OptionsMenuHelper optionsMenuHelper; + public MapActivityActions(MapActivity mapActivity){ this.mapActivity = mapActivity; @@ -844,138 +844,166 @@ public class MapActivityActions implements DialogProvider { } public boolean onCreateOptionsMenu(Menu menu) { -// NOTE: delete not a "menu.xml" because all id-resources are generated to R-class from there - OptionsMenuHelper helper = new OptionsMenuHelper(menu); - helper.registerOptionsMenuItem(R.id.map_where_am_i, R.string.where_am_i, android.R.drawable.ic_menu_mylocation); - helper.registerOptionsMenuItem(R.id.map_layers, R.string.menu_layers, android.R.drawable.ic_menu_mapmode); - helper.registerOptionsMenuItem(R.id.map_show_settings, R.string.settings_Button, android.R.drawable.ic_menu_preferences); - helper.registerOptionsMenuItem(R.id.map_navigate_to_point, R.string.stop_navigation, android.R.drawable.ic_menu_close_clear_cancel, false); - helper.registerOptionsMenuItem(R.id.map_mute, R.string.menu_mute_off, false); - helper.registerOptionsMenuItem(R.id.map_get_directions, R.string.get_directions, android.R.drawable.ic_menu_directions); - helper.registerOptionsMenuItem(R.id.map_animate_route, R.string.animate_route, false); - helper.registerOptionsMenuItem(R.id.map_specify_point, R.string.search_button, android.R.drawable.ic_menu_search); - helper.registerOptionsMenuItem(R.id.map_show_gps_status, R.string.show_gps_status, android.R.drawable.ic_menu_compass); - helper.registerOptionsMenuItem(R.id.map_show_point_options, R.string.show_point_options); - OsmandPlugin.registerOptionsMenu(mapActivity, helper); + final OsmandMapTileView mapView = mapActivity.getMapView(); + optionsMenuHelper = new OptionsMenuHelper(); + optionsMenuHelper.registerOptionsMenuItem(R.string.where_am_i, R.string.where_am_i, android.R.drawable.ic_menu_mylocation, + new OnOptionsMenuClick() { + @Override + public void prepareOptionsMenu(Menu menu, MenuItem item) { + } + @Override + public boolean onClick(MenuItem item) { + if (getMyApplication().accessibilityEnabled()) { + whereAmIDialog(); + } else { + mapActivity.backToLocationImpl(); + } + return true; + } + }); + optionsMenuHelper.registerOptionsMenuItem(R.string.menu_layers, R.string.menu_layers, android.R.drawable.ic_menu_mapmode, + new OnOptionsMenuClick() { + @Override + public void prepareOptionsMenu(Menu menu, MenuItem item) { + } + @Override + public boolean onClick(MenuItem item) { + mapActivity.getMapLayers().openLayerSelectionDialog(mapView); + return true; + } + }); + optionsMenuHelper.registerOptionsMenuItem(R.string.settings_Button, R.string.settings_Button, android.R.drawable.ic_menu_preferences, + new OnOptionsMenuClick() { + @Override + public void prepareOptionsMenu(Menu menu, MenuItem item) { + } + @Override + public boolean onClick(MenuItem item) { + final Intent intentSettings = new Intent(mapActivity, OsmandIntents.getSettingsActivity()); + mapActivity.startActivity(intentSettings); + return true; + } + }); + optionsMenuHelper.registerOptionsMenuItem(R.string.stop_navigation, R.string.stop_navigation, android.R.drawable.ic_menu_close_clear_cancel, false, + new OnOptionsMenuClick() { + @Override + public void prepareOptionsMenu(Menu menu, MenuItem navigateToPointMenu) { + if (settings.getPointToNavigate() != null) { + navigateToPointMenu.setTitle((routingHelper.isRouteCalculated() || routingHelper.isFollowingMode() || + routingHelper.isRouteBeingCalculated()) ? R.string.stop_routing : R.string.stop_navigation); + navigateToPointMenu.setVisible(true); + } else { + navigateToPointMenu.setVisible(false); + } + } + @Override + public boolean onClick(MenuItem item) { + if (mapActivity.getMapLayers().getNavigationLayer().getPointToNavigate() != null) { + if (routingHelper.isRouteCalculated() || routingHelper.isFollowingMode() || routingHelper.isRouteBeingCalculated()) { + routingHelper.setFinalAndCurrentLocation(null, routingHelper.getCurrentLocation(), routingHelper.getCurrentGPXRoute()); + // restore default mode + boolean changed = settings.APPLICATION_MODE.set(settings.PREV_APPLICATION_MODE.get()); + mapActivity.updateApplicationModeSettings(); + mapView.refreshMap(changed); + } else { + mapActivity.navigateToPoint(null); + } + } else { + mapActivity.navigateToPoint(new LatLon(mapView.getLatitude(), mapView.getLongitude())); + } + mapView.refreshMap(); + return true; + } + }); + optionsMenuHelper.registerOptionsMenuItem(R.string.menu_mute_off, R.string.menu_mute_off, false, new OnOptionsMenuClick() { + @Override + public void prepareOptionsMenu(Menu menu, MenuItem muteMenu) { + if (routingHelper.getFinalLocation() != null && routingHelper.isFollowingMode()) { + boolean mute = routingHelper.getVoiceRouter().isMute(); + muteMenu.setTitle(mute ? R.string.menu_mute_on : R.string.menu_mute_off); + muteMenu.setIcon(mute ? R.drawable.ic_menu_soundoff : R.drawable.ic_menu_soundon); + muteMenu.setVisible(true); + } else { + muteMenu.setVisible(false); + } + } + + @Override + public boolean onClick(MenuItem item) { + routingHelper.getVoiceRouter().setMute(!routingHelper.getVoiceRouter().isMute()); + return true; + } + }); + optionsMenuHelper.registerOptionsMenuItem(R.string.get_directions, R.string.get_directions, android.R.drawable.ic_menu_directions, + new OnOptionsMenuClick() { + @Override + public void prepareOptionsMenu(Menu menu, MenuItem directions) { + if(routingHelper.isRouteCalculated()){ + directions.setTitle(R.string.show_route); + } else { + directions.setTitle(R.string.get_directions); + } + + } + @Override + public boolean onClick(MenuItem item) { + if (routingHelper.isRouteCalculated()) { + aboutRoute(); + } else { + Location loc = mapActivity.getLastKnownLocation(); + getDirections(loc, true); + } + return true; + } + }); + optionsMenuHelper.registerOptionsMenuItem(R.string.search_button, R.string.search_button, android.R.drawable.ic_menu_search, new OnOptionsMenuClick() { + @Override + public void prepareOptionsMenu(Menu menu, MenuItem item) { + } + @Override + public boolean onClick(MenuItem item) { + Intent newIntent = new Intent(mapActivity, OsmandIntents.getSearchActivity()); + // causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + LatLon loc = mapActivity.getMapLocation(); + newIntent.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude()); + newIntent.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude()); + newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + mapActivity.startActivity(newIntent); + return true; + } + }); + optionsMenuHelper.registerOptionsMenuItem(R.string.show_gps_status, R.string.show_gps_status, android.R.drawable.ic_menu_compass, new OnOptionsMenuClick() { + @Override + public void prepareOptionsMenu(Menu menu, MenuItem item) { + } + @Override + public boolean onClick(MenuItem item) { + startGpsStatusIntent(); + return false; + } + }); + optionsMenuHelper.registerOptionsMenuItem(R.string.show_point_options, R.string.show_point_options, new OnOptionsMenuClick() { + @Override + public void prepareOptionsMenu(Menu menu, MenuItem item) { + } + @Override + public boolean onClick(MenuItem item) { + contextMenuPoint(mapView.getLatitude(), mapView.getLongitude()); + return true; + } + }); + OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper); + + optionsMenuHelper.registerOptionsMenu(menu); return true; } public void onPrepareOptionsMenu(Menu menu) { - MenuItem navigateToPointMenu = menu.findItem(R.id.map_navigate_to_point); - if (navigateToPointMenu != null) { - if (settings.getPointToNavigate() != null) { - navigateToPointMenu.setTitle((routingHelper.isRouteCalculated() || routingHelper.isFollowingMode() || - routingHelper.isRouteBeingCalculated()) ? R.string.stop_routing : R.string.stop_navigation); - navigateToPointMenu.setVisible(true); - } else { - navigateToPointMenu.setVisible(false); - } - } - MenuItem muteMenu = menu.findItem(R.id.map_mute); - if(muteMenu != null){ - if (routingHelper.getFinalLocation() != null && routingHelper.isFollowingMode()) { - boolean mute = routingHelper.getVoiceRouter().isMute(); - muteMenu.setTitle(mute ? R.string.menu_mute_on : R.string.menu_mute_off); - muteMenu.setIcon(mute ? R.drawable.ic_menu_soundoff : R.drawable.ic_menu_soundon); - muteMenu.setVisible(true); - } else { - muteMenu.setVisible(false); - } - } - MenuItem directions = menu.findItem(R.id.map_get_directions); - if(routingHelper.isRouteCalculated()){ - directions.setTitle(R.string.show_route); - } else { - directions.setTitle(R.string.get_directions); - } - - MenuItem animateMenu = menu.findItem(R.id.map_animate_route); - - if (animateMenu != null) { - if(settings.TEST_ANIMATE_ROUTING.get()){ - animateMenu.setTitle(routeAnimation.isRouteAnimating() ? R.string.animate_route_off - : R.string.animate_route); - animateMenu.setVisible("1".equals(Secure.getString( - mapActivity.getContentResolver(), Secure.ALLOW_MOCK_LOCATION)) - && settings.getPointToNavigate() != null - && routingHelper.isRouteCalculated()); - animateMenu.setVisible(true); - } else { - animateMenu.setVisible(false); - } - } - - OsmandPlugin.registerOnPrepareOptionsMenu(mapActivity, menu); + optionsMenuHelper.prepareOptionsMenu(menu); } public boolean onOptionsItemSelected(MenuItem item) { - final int itemId = item.getItemId(); - OsmandMapTileView mapView = mapActivity.getMapView(); - if (itemId == R.id.map_show_settings) { - final Intent intentSettings = new Intent(mapActivity, OsmandIntents.getSettingsActivity()); - mapActivity.startActivity(intentSettings); - return true; - } else if (itemId == R.id.map_where_am_i) { - if (getMyApplication().accessibilityEnabled()) { - whereAmIDialog(); - } else { - mapActivity.backToLocationImpl(); - } - return true; - } else if (itemId == R.id.map_show_gps_status) { - startGpsStatusIntent(); - return true; - } else if (itemId == R.id.map_specify_point) { - Intent newIntent = new Intent(mapActivity, OsmandIntents.getSearchActivity()); - // causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - LatLon loc = mapActivity.getMapLocation(); - newIntent.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude()); - newIntent.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude()); - newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - mapActivity.startActivity(newIntent); - return true; - } else { - if (itemId == R.id.map_get_directions) { - if (routingHelper.isRouteCalculated()) { - aboutRoute(); - } else { - Location loc = mapActivity.getLastKnownLocation(); - getDirections(loc, true); - } - return true; - } else if (itemId == R.id.map_layers) { - mapActivity.getMapLayers().openLayerSelectionDialog(mapView); - return true; - } else if (itemId == R.id.map_mute) { - routingHelper.getVoiceRouter().setMute(!routingHelper.getVoiceRouter().isMute()); - return true; - } else if (itemId == R.id.map_navigate_to_point) { - if (mapActivity.getMapLayers().getNavigationLayer().getPointToNavigate() != null) { - if (routingHelper.isRouteCalculated() || routingHelper.isFollowingMode() || routingHelper.isRouteBeingCalculated()) { - routingHelper.setFinalAndCurrentLocation(null, routingHelper.getCurrentLocation(), routingHelper.getCurrentGPXRoute()); - // restore default mode - boolean changed = settings.APPLICATION_MODE.set(settings.PREV_APPLICATION_MODE.get()); - mapActivity.updateApplicationModeSettings(); - mapView.refreshMap(changed); - } else { - mapActivity.navigateToPoint(null); - } - } else { - mapActivity.navigateToPoint(new LatLon(mapView.getLatitude(), mapView.getLongitude())); - } - mapView.refreshMap(); - return true; - } else if (itemId == R.id.map_show_point_options) { - contextMenuPoint(mapView.getLatitude(), mapView.getLongitude()); - return true; - } else if (itemId == R.id.map_animate_route) { - // animate moving on route - routeAnimation.startStopRouteAnimation(routingHelper, mapActivity); - return true; - } else { - return OsmandPlugin.registerOnOptionsMenuItemSelected(mapActivity, itemId); - } - } + return optionsMenuHelper.onClick(item); } private void startGpsStatusIntent() { diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java index 0f1d501521..6da26bfac2 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java @@ -273,9 +273,9 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference registerBooleanPreference(osmandSettings.USE_COMPASS_IN_NAVIGATION, screen); registerBooleanPreference(osmandSettings.LEFT_SIDE_NAVIGATION, screen); - registerBooleanPreference(osmandSettings.SHOW_CAMERAS, screen); - registerBooleanPreference(osmandSettings.SHOW_SPEED_LIMITS, screen); - registerBooleanPreference(osmandSettings.AVOID_TOLL_ROADS, screen); +// registerBooleanPreference(osmandSettings.SHOW_CAMERAS, screen); +// registerBooleanPreference(osmandSettings.SHOW_SPEED_LIMITS, screen); +// registerBooleanPreference(osmandSettings.AVOID_TOLL_ROADS, screen); CheckBoxPreference nativeCheckbox = registerBooleanPreference(osmandSettings.NATIVE_RENDERING,screen); diff --git a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java index 8831e6cb5f..edd67649bd 100644 --- a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java +++ b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java @@ -1,11 +1,15 @@ package net.osmand.plus.development; +import net.osmand.plus.OptionsMenuHelper; +import net.osmand.plus.OptionsMenuHelper.OnOptionsMenuClick; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.SettingsActivity; +import net.osmand.plus.routing.RouteAnimation; +import net.osmand.plus.routing.RoutingHelper; import android.content.Intent; import android.os.Debug; import android.os.Debug.MemoryInfo; @@ -14,11 +18,14 @@ import android.preference.Preference; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; +import android.view.Menu; +import android.view.MenuItem; public class OsmandDevelopmentPlugin extends OsmandPlugin { private static final String ID = "osmand.development"; private OsmandSettings settings; private OsmandApplication app; + private RouteAnimation routeAnimation = new RouteAnimation(); public OsmandDevelopmentPlugin(OsmandApplication app) { this.app = app; @@ -44,8 +51,29 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin { } @Override public void registerLayers(MapActivity activity) { + } + @Override + public void registerOptionsMenuItems(final MapActivity mapActivity, OptionsMenuHelper helper) { + helper.registerOptionsMenuItem(R.string.animate_route, R.string.animate_route, false, new OnOptionsMenuClick() { + @Override + public void prepareOptionsMenu(Menu menu, MenuItem animateMenu) { + animateMenu.setTitle(routeAnimation.isRouteAnimating() ? R.string.animate_route_off : R.string.animate_route); + animateMenu.setVisible(settings.getPointToNavigate() != null); + } + + @Override + public boolean onClick(MenuItem item) { + RoutingHelper routingHelper = mapActivity.getRoutingHelper(); + // animate moving on route + routeAnimation.startStopRouteAnimation(routingHelper, mapActivity); + return true; + } + }); + } + + @Override public void settingsActivityCreate(final SettingsActivity activity, PreferenceScreen screen) { @@ -58,9 +86,6 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin { CheckBoxPreference dbg = activity.createCheckBoxPreference(settings.DEBUG_RENDERING_INFO, R.string.trace_rendering, R.string.trace_rendering_descr); cat.addPreference(dbg); - CheckBoxPreference animate = activity.createCheckBoxPreference(settings.TEST_ANIMATE_ROUTING, - R.string.animate_routing, R.string.simulate_route_progression_manually); - cat.addPreference(animate); Preference pref = new Preference(app); pref.setTitle(R.string.test_voice_prompts); diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java index d00bbeb67f..fecabc4e6e 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java @@ -8,6 +8,7 @@ import net.osmand.osm.LatLon; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; import net.osmand.plus.OptionsMenuHelper; +import net.osmand.plus.OptionsMenuHelper.OnOptionsMenuClick; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; @@ -333,31 +334,26 @@ public class ParkingPositionPlugin extends OsmandPlugin { } @Override - public void registerOptionsMenuItems(MapActivity mapActivity, OptionsMenuHelper helper) { + public void registerOptionsMenuItems(final MapActivity mapActivity, OptionsMenuHelper helper) { if (parkingLayer != null) { //NOTE: R.id.parking_lim_text - is used just as a stub - helper.registerOptionsMenuItem(R.id.parking_lim_text, R.string.osmand_parking_delete, android.R.drawable.ic_menu_mylocation); - } - } - - @Override - public boolean onOptionsItemSelected(MapActivity mapActivity, int itemId) { - if (itemId == R.id.parking_lim_text) { - showDeleteDialog(mapActivity); - return true; - } - return false; - } - - @Override - public void prepareOptionsMenuItems(MapActivity mapActivity, Menu menu) { - MenuItem deleteParkingItem = menu.findItem(R.id.parking_lim_text); - if (deleteParkingItem != null) { - if (settings.getParkingPosition() != null) { - deleteParkingItem.setVisible(true); - } else { - deleteParkingItem.setVisible(false); - } + helper.registerOptionsMenuItem(R.string.osmand_parking_delete, R.string.osmand_parking_delete, android.R.drawable.ic_menu_mylocation, + new OnOptionsMenuClick() { + @Override + public void prepareOptionsMenu(Menu menu, MenuItem deleteParkingItem) { + if (settings.getParkingPosition() != null) { + deleteParkingItem.setVisible(true); + } else { + deleteParkingItem.setVisible(false); + } + } + + @Override + public boolean onClick(MenuItem item) { + showDeleteDialog(mapActivity); + return true; + } + }); } }