Add categories, fix waypoints dialog
This commit is contained in:
parent
d543ccd9a8
commit
1db4e7dcfb
6 changed files with 89 additions and 38 deletions
|
@ -30,6 +30,7 @@ public class RenderingRuleProperty {
|
|||
protected String name;
|
||||
protected String description;
|
||||
protected String[] possibleValues;
|
||||
protected String category;
|
||||
|
||||
private RenderingRuleProperty(String attrName, int type, boolean input){
|
||||
this.attrName = attrName;
|
||||
|
@ -64,6 +65,10 @@ public class RenderingRuleProperty {
|
|||
return name;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
@ -76,6 +81,10 @@ public class RenderingRuleProperty {
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
protected void setPossibleValues(String[] possibleValues) {
|
||||
this.possibleValues = possibleValues;
|
||||
}
|
||||
|
|
|
@ -282,6 +282,7 @@ public class RenderingRulesStorage {
|
|||
prop = RenderingRuleProperty.createInputIntProperty(attr);
|
||||
}
|
||||
prop.setDescription(parser.getAttributeValue("", "description"));
|
||||
prop.setCategory(parser.getAttributeValue("", "category"));
|
||||
prop.setName(parser.getAttributeValue("", "name"));
|
||||
if(parser.getAttributeValue("", "possibleValues") != null){
|
||||
prop.setPossibleValues(parser.getAttributeValue("", "possibleValues").split(","));
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="rendering_category_details">Details</string>
|
||||
<string name="rendering_category_transport">Transport</string>
|
||||
<string name="rendering_category_hiking">Hiking</string>
|
||||
<string name="rendering_category_others">Others map attributes</string>
|
||||
<string name="map_widget_appearance_rem">Remaining elements</string>
|
||||
<string name="map_widget_vector_attributes">Rendering attributes</string>
|
||||
<string name="map_widget_top">Status bar</string>
|
||||
|
|
|
@ -752,6 +752,43 @@ public class MapActivityActions implements DialogProvider {
|
|||
return false;
|
||||
}
|
||||
}).reg();
|
||||
optionsMenuHelper.item(R.string.search_button)
|
||||
.icons(R.drawable.ic_action_search_dark, R.drawable.ic_action_search_light)
|
||||
.listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||
.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;
|
||||
}
|
||||
}).reg();
|
||||
|
||||
optionsMenuHelper.item(R.string.favorites_Button)
|
||||
.icons(R.drawable.ic_action_fav_dark, R.drawable.ic_action_fav_light).listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||
.getFavoritesActivity());
|
||||
// causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
mapActivity.startActivity(newIntent);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
optionsMenuHelper.item(R.string.show_point_options)
|
||||
.icons(R.drawable.ic_action_marker_dark, R.drawable.ic_action_marker_light)
|
||||
.listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
contextMenuPoint(mapView.getLatitude(), mapView.getLongitude());
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
|
||||
optionsMenuHelper.item(R.string.layer_map_appearance).icons(R.drawable.ic_action_settings_dark, R.drawable.ic_action_settings_light)
|
||||
.listen(new OnContextMenuClick() {
|
||||
|
@ -773,39 +810,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}).reg();
|
||||
|
||||
optionsMenuHelper.item(R.string.search_button).icons(R.drawable.ic_action_search_dark, R.drawable.ic_action_search_light)
|
||||
.listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().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;
|
||||
}
|
||||
}).reg();
|
||||
|
||||
optionsMenuHelper.item(R.string.favorites_Button).icons( R.drawable.ic_action_fav_dark, R.drawable.ic_action_fav_light)
|
||||
.listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getFavoritesActivity());
|
||||
// causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
mapActivity.startActivity(newIntent);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
optionsMenuHelper.item(R.string.show_point_options).icons(R.drawable.ic_action_marker_dark, R.drawable.ic_action_marker_light )
|
||||
.listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
contextMenuPoint(mapView.getLatitude(), mapView.getLongitude());
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
//////////// Others
|
||||
if (Version.isGpsStatusEnabled(app)) {
|
||||
optionsMenuHelper.item(R.string.show_gps_status).icons(R.drawable.ic_action_gabout_dark, R.drawable.ic_action_gabout_light )
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.dialogs;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.access.AccessibleToast;
|
||||
|
@ -243,7 +244,33 @@ public class ConfigureMapMenu {
|
|||
|
||||
RenderingRulesStorage renderer = activity.getMyApplication().getRendererRegistry().getCurrentSelectedRenderer();
|
||||
if (renderer != null) {
|
||||
createCustomRenderingProperties(renderer, adapter, activity);
|
||||
List<RenderingRuleProperty> customRules = new ArrayList<RenderingRuleProperty>(renderer.PROPS.getCustomRules());
|
||||
createProperties(customRules, R.string.rendering_category_details, "details",
|
||||
adapter, activity);
|
||||
createProperties(customRules, R.string.rendering_category_hiking, "hiking",
|
||||
adapter, activity);
|
||||
createProperties(customRules, R.string.rendering_category_transport, "transport",
|
||||
adapter, activity);
|
||||
if(customRules.size() > 0) {
|
||||
adapter.item(R.string.rendering_category_others).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
|
||||
createCustomRenderingProperties(adapter, activity, customRules);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createProperties(List<RenderingRuleProperty> customRules, int strId, String cat, ContextMenuAdapter adapter, MapActivity activity) {
|
||||
List<RenderingRuleProperty> ps = new ArrayList<RenderingRuleProperty>();
|
||||
Iterator<RenderingRuleProperty> it = customRules.iterator();
|
||||
while(it.hasNext()) {
|
||||
RenderingRuleProperty p = it.next();
|
||||
if(cat.equals(p.getCategory())) {
|
||||
ps.add(p);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
if(ps.size() > 0) {
|
||||
adapter.item(strId).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
|
||||
createCustomRenderingProperties(adapter, activity, ps);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,11 +288,10 @@ public class ConfigureMapMenu {
|
|||
}
|
||||
|
||||
|
||||
private void createCustomRenderingProperties(RenderingRulesStorage renderer, final ContextMenuAdapter adapter , final MapActivity activity){
|
||||
private void createCustomRenderingProperties(final ContextMenuAdapter adapter , final MapActivity activity,
|
||||
List<RenderingRuleProperty> customRules ){
|
||||
final OsmandMapTileView view = activity.getMapView();
|
||||
adapter.item(R.string.map_widget_vector_attributes).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
|
||||
final OsmandApplication app = view.getApplication();
|
||||
List<RenderingRuleProperty> customRules = renderer.PROPS.getCustomRules();
|
||||
for (final RenderingRuleProperty p : customRules) {
|
||||
String propertyName = SettingsActivity.getStringPropertyName(view.getContext(), p.getAttrName(),
|
||||
p.getName());
|
||||
|
|
|
@ -136,8 +136,14 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
});
|
||||
TextView textDist = (TextView) localView.findViewById(R.id.waypoint_dist);
|
||||
((ImageView) localView.findViewById(R.id.waypoint_icon)).setImageDrawable(ps.getDrawable(ctx));
|
||||
// Location lastKnownMapLocation = app.getLocationProvider().getLastKnownLocation();
|
||||
int dist = wh.getRouteDistance(ps);
|
||||
int dist;
|
||||
if(!wh.isRouteCalculated()) {
|
||||
Location lm = app.getLocationProvider().getLastKnownLocation();
|
||||
dist = (int) MapUtils.getDistance(lm.getLatitude(), lm.getLongitude(),
|
||||
point.getLatitude(), point.getLongitude());
|
||||
} else {
|
||||
dist = wh.getRouteDistance(ps);
|
||||
}
|
||||
String dd = OsmAndFormatter.getFormattedDistance(dist, app);
|
||||
if (ps.deviationDistance > 0) {
|
||||
dd += "\n+" + OsmAndFormatter.getFormattedDistance(ps.deviationDistance, app);
|
||||
|
|
Loading…
Reference in a new issue