Configure map.

This commit is contained in:
GaidamakUA 2016-04-04 17:48:03 +03:00
parent 615e869a03
commit 95d6ccd9fa
2 changed files with 51 additions and 26 deletions

View file

@ -4,6 +4,8 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnMultiChoiceClickListener; import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.content.Intent; import android.content.Intent;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.view.View; import android.view.View;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
@ -178,6 +180,7 @@ public class ConfigureMapMenu {
.setTitleId(R.string.layer_poi, activity) .setTitleId(R.string.layer_poi, activity)
.setSelected(settings.SELECTED_POI_FILTER_FOR_MAP.get() != null) .setSelected(settings.SELECTED_POI_FILTER_FOR_MAP.get() != null)
.setIcon(R.drawable.ic_action_info_dark) .setIcon(R.drawable.ic_action_info_dark)
.setSecondaryIcon(R.drawable.ic_action_additional_option)
.setListener(l).createItem()); .setListener(l).createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder() adapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.layer_amenity_label, activity) .setTitleId(R.string.layer_amenity_label, activity)
@ -193,6 +196,7 @@ public class ConfigureMapMenu {
.setTitleId(R.string.layer_gpx_layer, activity) .setTitleId(R.string.layer_gpx_layer, activity)
.setSelected(app.getSelectedGpxHelper().isShowingAnyGpxFiles()) .setSelected(app.getSelectedGpxHelper().isShowingAnyGpxFiles())
.setIcon(R.drawable.ic_action_polygom_dark) .setIcon(R.drawable.ic_action_polygom_dark)
.setSecondaryIcon(R.drawable.ic_action_additional_option)
.setListener(l).createItem()); .setListener(l).createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder() adapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.layer_map, activity) .setTitleId(R.string.layer_map, activity)
@ -232,6 +236,9 @@ public class ConfigureMapMenu {
String descr = getRenderDescr(activity); String descr = getRenderDescr(activity);
adapter.addItem(new ContextMenuItem.ItemBuilder() adapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.map_widget_renderer, activity) .setTitleId(R.string.map_widget_renderer, activity)
.setDescription(descr)
.setLayout(R.layout.list_item_single_line_descrition_narrow)
.setIcon(R.drawable.ic_map)
.setListener(new ContextMenuAdapter.ItemClickListener() { .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override @Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad,
@ -273,11 +280,13 @@ public class ConfigureMapMenu {
bld.show(); bld.show();
return false; return false;
} }
}).setDescription(descr).setLayout(R.layout.list_item_single_line_descrition_narrow).createItem()); }).createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder() adapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.map_widget_day_night, activity) .setTitleId(R.string.map_widget_day_night, activity)
.setDescription(getDayNightDescr(activity)) .setDescription(getDayNightDescr(activity))
.setLayout(R.layout.list_item_single_line_descrition_narrow)
.setIcon(R.drawable.ic_action_map_night)
.setListener(new ItemClickListener() { .setListener(new ItemClickListener() {
@Override @Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad,
@ -304,10 +313,14 @@ public class ConfigureMapMenu {
bld.show(); bld.show();
return false; return false;
} }
}).setLayout(R.layout.list_item_single_line_descrition_narrow).createItem()); }).createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder() adapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.map_magnifier, activity).setListener(new ContextMenuAdapter.ItemClickListener() { .setTitleId(R.string.map_magnifier, activity)
.setDescription(String.format("%.0f", 100f * activity.getMyApplication().getSettings().MAP_DENSITY.get()) + " %")
.setLayout(R.layout.list_item_single_line_descrition_narrow)
.setIcon(R.drawable.ic_action_map_magnifier)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override @Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad,
int itemId, final int pos, boolean isChecked) { int itemId, final int pos, boolean isChecked) {
@ -356,12 +369,14 @@ public class ConfigureMapMenu {
bld.show(); bld.show();
return false; return false;
} }
}).setDescription(String.format("%.0f", 100f * activity.getMyApplication().getSettings().MAP_DENSITY.get()) + " %") }).createItem());
.setLayout(R.layout.list_item_single_line_descrition_narrow)
.createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder() adapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.text_size, activity).setListener(new ContextMenuAdapter.ItemClickListener() { .setTitleId(R.string.text_size, activity)
.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 @Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad,
int itemId, final int pos, boolean isChecked) { int itemId, final int pos, boolean isChecked) {
@ -391,10 +406,14 @@ public class ConfigureMapMenu {
b.show(); b.show();
return false; return false;
} }
}).setDescription(getScale(activity)).setLayout(R.layout.list_item_single_line_descrition_narrow).createItem()); }).createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder() adapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.map_locale, activity).setListener(new ContextMenuAdapter.ItemClickListener() { .setTitleId(R.string.map_locale, activity)
.setDescription(activity.getMyApplication().getSettings().MAP_PREFERRED_LOCALE.get())
.setLayout(R.layout.list_item_single_line_descrition_narrow)
.setIcon(R.drawable.ic_action_map_language)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override @Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad,
int itemId, final int pos, boolean isChecked) { int itemId, final int pos, boolean isChecked) {
@ -424,9 +443,7 @@ public class ConfigureMapMenu {
b.show(); b.show();
return false; return false;
} }
}) }).createItem());
.setDescription(activity.getMyApplication().getSettings().MAP_PREFERRED_LOCALE.get())
.setLayout(R.layout.list_item_single_line_descrition_narrow).createItem());
RenderingRulesStorage renderer = activity.getMyApplication().getRendererRegistry().getCurrentSelectedRenderer(); RenderingRulesStorage renderer = activity.getMyApplication().getRendererRegistry().getCurrentSelectedRenderer();
if (renderer != null) { if (renderer != null) {
@ -437,14 +454,14 @@ public class ConfigureMapMenu {
} }
} }
createProperties(customRules, R.string.rendering_category_transport, "transport", createProperties(customRules, R.string.rendering_category_transport,
adapter, activity); R.drawable.ic_action_bus_dark, "transport", adapter, activity);
createProperties(customRules, R.string.rendering_category_details, "details", createProperties(customRules, R.string.rendering_category_details,
adapter, activity); R.drawable.widget_no_icon, "details", adapter, activity);
createProperties(customRules, R.string.rendering_category_hide, "hide", createProperties(customRules, R.string.rendering_category_hide,
adapter, activity); R.drawable.ic_action_hide,"hide", adapter, activity);
createProperties(customRules, R.string.rendering_category_routes, "routes", createProperties(customRules, R.string.rendering_category_routes,
adapter, activity); R.drawable.ic_action_map_routes, "routes", adapter, activity);
if (customRules.size() > 0) { if (customRules.size() > 0) {
adapter.addItem(new ContextMenuItem.ItemBuilder() adapter.addItem(new ContextMenuItem.ItemBuilder()
@ -494,7 +511,10 @@ public class ConfigureMapMenu {
return translates; return translates;
} }
private void createProperties(List<RenderingRuleProperty> customRules, final int strId, String cat, private void createProperties(List<RenderingRuleProperty> customRules,
@StringRes final int strId,
@DrawableRes final int icon,
String category,
final ContextMenuAdapter adapter, final MapActivity activity) { final ContextMenuAdapter adapter, final MapActivity activity) {
final List<RenderingRuleProperty> ps = new ArrayList<>(); final List<RenderingRuleProperty> ps = new ArrayList<>();
final List<OsmandSettings.CommonPreference<Boolean>> prefs = new ArrayList<>(); final List<OsmandSettings.CommonPreference<Boolean>> prefs = new ArrayList<>();
@ -502,7 +522,7 @@ public class ConfigureMapMenu {
while (it.hasNext()) { while (it.hasNext()) {
RenderingRuleProperty p = it.next(); RenderingRuleProperty p = it.next();
if (cat.equals(p.getCategory()) && p.isBoolean()) { if (category.equals(p.getCategory()) && p.isBoolean()) {
ps.add(p); ps.add(p);
final OsmandSettings.CommonPreference<Boolean> pref = activity.getMyApplication().getSettings() final OsmandSettings.CommonPreference<Boolean> pref = activity.getMyApplication().getSettings()
.getCustomRenderBooleanProperty(p.getAttrName()); .getCustomRenderBooleanProperty(p.getAttrName());
@ -516,6 +536,7 @@ public class ConfigureMapMenu {
.setTitleId(strId, activity) .setTitleId(strId, activity)
.setDescription(descr) .setDescription(descr)
.setLayout(R.layout.list_item_single_line_descrition_narrow) .setLayout(R.layout.list_item_single_line_descrition_narrow)
.setIcon(icon)
.setListener(new ContextMenuAdapter.ItemClickListener() { .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override @Override

View file

@ -254,20 +254,24 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
}; };
String overlayMapDescr = settings.MAP_OVERLAY.get(); String overlayMapDescr = settings.MAP_OVERLAY.get();
overlayMapDescr = overlayMapDescr != null ? overlayMapDescr : mapActivity.getString(R.string.shared_string_none); 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) adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_overlay, mapActivity)
.setLayout(R.layout.list_item_single_line_descrition_wide)
.setDescription(overlayMapDescr) .setDescription(overlayMapDescr)
.setSelected(hasOverlayDescription)
.setIcon(R.drawable.ic_layer_top_dark) .setIcon(R.drawable.ic_layer_top_dark)
.setSecondaryIcon(R.drawable.ic_action_additional_option)
.setListener(listener) .setListener(listener)
.setPosition(14) .setPosition(14)
.createItem()); .createItem());
String underlayMapDescr = settings.MAP_UNDERLAY.get(); String underlayMapDescr = settings.MAP_UNDERLAY.get();
underlayMapDescr = underlayMapDescr != null ? underlayMapDescr : mapActivity.getString(R.string.shared_string_none); 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) adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_underlay, mapActivity)
.setLayout(R.layout.list_item_single_line_descrition_wide)
.setDescription(underlayMapDescr) .setDescription(underlayMapDescr)
.setSelected(hasUnderlayDescription)
.setIcon(R.drawable.ic_layer_bottom_dark) .setIcon(R.drawable.ic_layer_bottom_dark)
.setSecondaryIcon(R.drawable.ic_action_additional_option)
.setListener(listener) .setListener(listener)
.setPosition(15) .setPosition(15)
.createItem()); .createItem());