Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f93913368a
3 changed files with 88 additions and 20 deletions
|
@ -73,8 +73,10 @@ import java.util.Map;
|
||||||
|
|
||||||
import gnu.trove.list.array.TIntArrayList;
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
|
|
||||||
|
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_ATTR;
|
||||||
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_SCHEME_ATTR;
|
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_SCHEME_ATTR;
|
||||||
|
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_WIDTH_ATTR;
|
||||||
|
|
||||||
public class ConfigureMapMenu {
|
public class ConfigureMapMenu {
|
||||||
private static final Log LOG = PlatformUtil.getLog(ConfigureMapMenu.class);
|
private static final Log LOG = PlatformUtil.getLog(ConfigureMapMenu.class);
|
||||||
|
@ -1158,38 +1160,34 @@ public class ConfigureMapMenu {
|
||||||
return scale + " %";
|
return scale + " %";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isPropertyAccepted(RenderingRuleProperty p) {
|
||||||
|
return !(p.getAttrName().equals(RenderingRuleStorageProperties.A_APP_MODE) ||
|
||||||
|
p.getAttrName().equals(RenderingRuleStorageProperties.A_ENGINE_V1) ||
|
||||||
|
p.getAttrName().equals(HIKING_ROUTES_OSMC_ATTR) ||
|
||||||
|
p.getAttrName().equals(ROAD_STYLE_ATTR) ||
|
||||||
|
p.getAttrName().equals(CONTOUR_WIDTH_ATTR) ||
|
||||||
|
p.getAttrName().equals(CONTOUR_DENSITY_ATTR) ||
|
||||||
|
p.getAttrName().equals(CONTOUR_LINES_ATTR) ||
|
||||||
|
p.getAttrName().equals(CONTOUR_LINES_SCHEME_ATTR) ||
|
||||||
|
p.getAttrName().equals(CURRENT_TRACK_COLOR_ATTR) ||
|
||||||
|
p.getAttrName().equals(CURRENT_TRACK_WIDTH_ATTR));
|
||||||
|
}
|
||||||
|
|
||||||
private void createCustomRenderingProperties(final ContextMenuAdapter adapter, final MapActivity activity,
|
private void createCustomRenderingProperties(final ContextMenuAdapter adapter, final MapActivity activity,
|
||||||
List<RenderingRuleProperty> customRules) {
|
List<RenderingRuleProperty> customRules) {
|
||||||
for (final RenderingRuleProperty p : customRules) {
|
for (final RenderingRuleProperty p : customRules) {
|
||||||
if (p.getAttrName().equals(RenderingRuleStorageProperties.A_APP_MODE) ||
|
if (isPropertyAccepted(p)) {
|
||||||
p.getAttrName().equals(RenderingRuleStorageProperties.A_ENGINE_V1) ||
|
adapter.addItem(createRenderingProperty(adapter, activity, 0, p));
|
||||||
p.getAttrName().equals(HIKING_ROUTES_OSMC_ATTR) ||
|
|
||||||
p.getAttrName().equals(ROAD_STYLE_ATTR) ||
|
|
||||||
p.getAttrName().equals(CONTOUR_LINES_ATTR) ||
|
|
||||||
p.getAttrName().equals(CONTOUR_LINES_SCHEME_ATTR) ||
|
|
||||||
p.getAttrName().equals(CURRENT_TRACK_COLOR_ATTR) ||
|
|
||||||
p.getAttrName().equals(CURRENT_TRACK_WIDTH_ATTR)) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
adapter.addItem(createRenderingProperty(adapter, activity, 0, p));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getCustomRenderingPropertiesSize(List<RenderingRuleProperty> customRules) {
|
private int getCustomRenderingPropertiesSize(List<RenderingRuleProperty> customRules) {
|
||||||
int size = 0;
|
int size = 0;
|
||||||
for (final RenderingRuleProperty p : customRules) {
|
for (final RenderingRuleProperty p : customRules) {
|
||||||
if (p.getAttrName().equals(RenderingRuleStorageProperties.A_APP_MODE) ||
|
if (isPropertyAccepted(p)) {
|
||||||
p.getAttrName().equals(RenderingRuleStorageProperties.A_ENGINE_V1) ||
|
size++;
|
||||||
p.getAttrName().equals(HIKING_ROUTES_OSMC_ATTR) ||
|
|
||||||
p.getAttrName().equals(ROAD_STYLE_ATTR) ||
|
|
||||||
p.getAttrName().equals(CONTOUR_LINES_ATTR) ||
|
|
||||||
p.getAttrName().equals(CONTOUR_LINES_SCHEME_ATTR) ||
|
|
||||||
p.getAttrName().equals(CURRENT_TRACK_COLOR_ATTR) ||
|
|
||||||
p.getAttrName().equals(CURRENT_TRACK_WIDTH_ATTR)) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
size++;
|
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.PluginActivity;
|
import net.osmand.plus.activities.PluginActivity;
|
||||||
|
import net.osmand.plus.activities.SettingsActivity;
|
||||||
import net.osmand.plus.download.DownloadActivityType;
|
import net.osmand.plus.download.DownloadActivityType;
|
||||||
import net.osmand.plus.download.DownloadIndexesThread;
|
import net.osmand.plus.download.DownloadIndexesThread;
|
||||||
import net.osmand.plus.download.DownloadValidationManager;
|
import net.osmand.plus.download.DownloadValidationManager;
|
||||||
|
@ -31,9 +32,11 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
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_ATTR;
|
||||||
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_DISABLED_VALUE;
|
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_DISABLED_VALUE;
|
||||||
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_SCHEME_ATTR;
|
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_SCHEME_ATTR;
|
||||||
|
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_WIDTH_ATTR;
|
||||||
|
|
||||||
public class ContourLinesMenu {
|
public class ContourLinesMenu {
|
||||||
private static final String TAG = "ContourLinesMenu";
|
private static final String TAG = "ContourLinesMenu";
|
||||||
|
@ -61,6 +64,30 @@ public class ContourLinesMenu {
|
||||||
if (plugin == null || contourLinesProp == null || colorSchemeProp == null) {
|
if (plugin == null || contourLinesProp == null || colorSchemeProp == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String contourWidthName;
|
||||||
|
final String contourDensityName;
|
||||||
|
final OsmandSettings.CommonPreference<String> widthPref;
|
||||||
|
final OsmandSettings.CommonPreference<String> densityPref;
|
||||||
|
final RenderingRuleProperty contourWidthProp = app.getRendererRegistry().getCustomRenderingRuleProperty(CONTOUR_WIDTH_ATTR);
|
||||||
|
if (contourWidthProp != null) {
|
||||||
|
contourWidthName = SettingsActivity.getStringPropertyName(app, contourWidthProp.getAttrName(),
|
||||||
|
contourWidthProp.getName());
|
||||||
|
widthPref = settings.getCustomRenderProperty(contourWidthProp.getAttrName());
|
||||||
|
} else {
|
||||||
|
contourWidthName = null;
|
||||||
|
widthPref = null;
|
||||||
|
}
|
||||||
|
final RenderingRuleProperty contourDensityProp = app.getRendererRegistry().getCustomRenderingRuleProperty(CONTOUR_DENSITY_ATTR);
|
||||||
|
if (contourDensityProp != null) {
|
||||||
|
contourDensityName = SettingsActivity.getStringPropertyName(app, contourDensityProp.getAttrName(),
|
||||||
|
contourDensityProp.getName());
|
||||||
|
densityPref = settings.getCustomRenderProperty(contourDensityProp.getAttrName());
|
||||||
|
} else {
|
||||||
|
contourDensityName = null;
|
||||||
|
densityPref = null;
|
||||||
|
}
|
||||||
|
|
||||||
final OsmandSettings.CommonPreference<String> pref = settings.getCustomRenderProperty(contourLinesProp.getAttrName());
|
final OsmandSettings.CommonPreference<String> pref = settings.getCustomRenderProperty(contourLinesProp.getAttrName());
|
||||||
final OsmandSettings.CommonPreference<String> colorPref = settings.getCustomRenderProperty(colorSchemeProp.getAttrName());
|
final OsmandSettings.CommonPreference<String> colorPref = settings.getCustomRenderProperty(colorSchemeProp.getAttrName());
|
||||||
|
|
||||||
|
@ -68,6 +95,7 @@ public class ContourLinesMenu {
|
||||||
final int toggleActionStringId = selected ? R.string.shared_string_enabled : R.string.shared_string_disabled;
|
final int toggleActionStringId = selected ? R.string.shared_string_enabled : R.string.shared_string_disabled;
|
||||||
final int showZoomLevelStringId = R.string.show_from_zoom_level;
|
final int showZoomLevelStringId = R.string.show_from_zoom_level;
|
||||||
final int colorSchemeStringId = R.string.srtm_color_scheme;
|
final int colorSchemeStringId = R.string.srtm_color_scheme;
|
||||||
|
|
||||||
ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() {
|
ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onRowItemClick(ArrayAdapter<ContextMenuItem> adapter,
|
public boolean onRowItemClick(ArrayAdapter<ContextMenuItem> adapter,
|
||||||
|
@ -127,6 +155,30 @@ public class ContourLinesMenu {
|
||||||
intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, plugin.getId());
|
intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, plugin.getId());
|
||||||
mapActivity.startActivity(intent);
|
mapActivity.startActivity(intent);
|
||||||
closeDashboard(mapActivity);
|
closeDashboard(mapActivity);
|
||||||
|
} else if (contourWidthProp != null && itemId == contourWidthName.hashCode()) {
|
||||||
|
plugin.selectPropertyValue(mapActivity, contourWidthProp, widthPref, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
ContextMenuItem item = adapter.getItem(pos);
|
||||||
|
if (item != null) {
|
||||||
|
item.setDescription(plugin.getPrefDescription(app, contourWidthProp, widthPref));
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
refreshMapComplete(mapActivity);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (contourDensityProp != null && itemId == contourDensityName.hashCode()) {
|
||||||
|
plugin.selectPropertyValue(mapActivity, contourDensityProp, densityPref, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
ContextMenuItem item = adapter.getItem(pos);
|
||||||
|
if (item != null) {
|
||||||
|
item.setDescription(plugin.getPrefDescription(app, contourDensityProp, densityPref));
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
refreshMapComplete(mapActivity);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -162,6 +214,22 @@ public class ContourLinesMenu {
|
||||||
.setIcon(R.drawable.ic_action_appearance)
|
.setIcon(R.drawable.ic_action_appearance)
|
||||||
.setDescription(plugin.getPrefDescription(app, colorSchemeProp, colorPref))
|
.setDescription(plugin.getPrefDescription(app, colorSchemeProp, colorPref))
|
||||||
.setListener(l).createItem());
|
.setListener(l).createItem());
|
||||||
|
if (contourWidthProp != null) {
|
||||||
|
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||||
|
.setTitle(contourWidthName)
|
||||||
|
.setLayout(R.layout.list_item_single_line_descrition_narrow)
|
||||||
|
.setIcon(R.drawable.ic_action_gpx_width_thin)
|
||||||
|
.setDescription(plugin.getPrefDescription(app, contourWidthProp, widthPref))
|
||||||
|
.setListener(l).createItem());
|
||||||
|
}
|
||||||
|
if (contourDensityProp != null) {
|
||||||
|
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||||
|
.setTitle(contourDensityName)
|
||||||
|
.setLayout(R.layout.list_item_single_line_descrition_narrow)
|
||||||
|
.setIcon(R.drawable.ic_plugin_srtm)
|
||||||
|
.setDescription(plugin.getPrefDescription(app, contourDensityProp, densityPref))
|
||||||
|
.setListener(l).createItem());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!srtmEnabled) {
|
if (!srtmEnabled) {
|
||||||
|
|
|
@ -34,6 +34,8 @@ public class SRTMPlugin extends OsmandPlugin {
|
||||||
public static final String CONTOUR_LINES_ATTR = "contourLines";
|
public static final String CONTOUR_LINES_ATTR = "contourLines";
|
||||||
public static final String CONTOUR_LINES_SCHEME_ATTR = "contourColorScheme";
|
public static final String CONTOUR_LINES_SCHEME_ATTR = "contourColorScheme";
|
||||||
public static final String CONTOUR_LINES_DISABLED_VALUE = "disabled";
|
public static final String CONTOUR_LINES_DISABLED_VALUE = "disabled";
|
||||||
|
public static final String CONTOUR_WIDTH_ATTR = "contourWidth";
|
||||||
|
public static final String CONTOUR_DENSITY_ATTR = "contourDensity";
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private boolean paid;
|
private boolean paid;
|
||||||
|
|
Loading…
Reference in a new issue