Fixed known poi selection bugs.
This commit is contained in:
parent
6a684e44ea
commit
174e4ecc4b
3 changed files with 48 additions and 28 deletions
|
@ -261,7 +261,7 @@ public class MapActivityLayers {
|
|||
}
|
||||
|
||||
|
||||
public void showMultichoicePoiFilterDialog(final OsmandMapTileView mapView, final ConfirmListener listener) {
|
||||
public void showMultichoicePoiFilterDialog(final OsmandMapTileView mapView, final DismissListener listener) {
|
||||
final OsmandApplication app = getApplication();
|
||||
final PoiFiltersHelper poiFilters = app.getPoiFilters();
|
||||
final ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||
|
@ -295,7 +295,6 @@ public class MapActivityLayers {
|
|||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mapView.refreshMap();
|
||||
listener.confirm();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.shared_string_cancel, null)
|
||||
|
@ -312,12 +311,19 @@ public class MapActivityLayers {
|
|||
public void onShow(DialogInterface dialog) {
|
||||
Button neutralButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
|
||||
Drawable drawable = app.getIconsCache().getThemedIcon(R.drawable.ic_action_singleselect);
|
||||
neutralButton.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); }
|
||||
neutralButton.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
|
||||
}
|
||||
});
|
||||
alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
listener.dismiss();
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
}
|
||||
|
||||
public void showSingleChoicePoiFilterDialog(final OsmandMapTileView mapView, final ConfirmListener listener) {
|
||||
public void showSingleChoicePoiFilterDialog(final OsmandMapTileView mapView, final DismissListener listener) {
|
||||
final OsmandApplication app = getApplication();
|
||||
final PoiFiltersHelper poiFilters = app.getPoiFilters();
|
||||
final ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||
|
@ -350,13 +356,12 @@ public class MapActivityLayers {
|
|||
getApplication().getPoiFilters().clearSelectedPoiFilters();
|
||||
getApplication().getPoiFilters().addSelectedPoiFilter(pf);
|
||||
mapView.refreshMap();
|
||||
listener.confirm();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
builder.setTitle(R.string.show_poi_over_map);
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
builder.setNegativeButton(R.string.shared_string_dismiss, null);
|
||||
builder.setNeutralButton(" ", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
@ -369,7 +374,14 @@ public class MapActivityLayers {
|
|||
public void onShow(DialogInterface dialog) {
|
||||
Button neutralButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
|
||||
Drawable drawable = app.getIconsCache().getThemedIcon(R.drawable.ic_action_multiselect);
|
||||
neutralButton.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); }
|
||||
neutralButton.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
|
||||
}
|
||||
});
|
||||
alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
listener.dismiss();
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
}
|
||||
|
@ -589,7 +601,7 @@ public class MapActivityLayers {
|
|||
return downloadedRegionsLayer;
|
||||
}
|
||||
|
||||
public interface ConfirmListener {
|
||||
void confirm();
|
||||
public interface DismissListener {
|
||||
void dismiss();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,18 +125,18 @@ public class ConfigureMapMenu {
|
|||
@Override
|
||||
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId, final int pos, boolean isChecked) {
|
||||
final OsmandSettings settings = ma.getMyApplication().getSettings();
|
||||
final PoiFiltersHelper pfh = ma.getMyApplication().getPoiFilters();
|
||||
final PoiFiltersHelper poiFiltersHelper = ma.getMyApplication().getPoiFilters();
|
||||
final ContextMenuItem item = cm.getItem(pos);
|
||||
if (item.getSelected() != null) {
|
||||
item.setColorRes(isChecked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
if (itemId == R.string.layer_poi) {
|
||||
pfh.clearSelectedPoiFilters();
|
||||
poiFiltersHelper.clearSelectedPoiFilters();
|
||||
if (isChecked) {
|
||||
showPoiFilterDialog(adapter, adapter.getItem(pos));
|
||||
} else {
|
||||
adapter.getItem(pos).setDescription(pfh.getSelectedPoiFiltersName());
|
||||
adapter.getItem(pos).setDescription(poiFiltersHelper.getSelectedPoiFiltersName());
|
||||
}
|
||||
} else if (itemId == R.string.layer_amenity_label) {
|
||||
settings.SHOW_POI_LABEL.set(isChecked);
|
||||
|
@ -185,18 +185,26 @@ public class ConfigureMapMenu {
|
|||
|
||||
protected void showPoiFilterDialog(final ArrayAdapter<ContextMenuItem> adapter,
|
||||
final ContextMenuItem item) {
|
||||
ma.getMapLayers().showSingleChoicePoiFilterDialog(ma.getMapView(),
|
||||
new MapActivityLayers.ConfirmListener() {
|
||||
@Override
|
||||
public void confirm() {
|
||||
PoiFiltersHelper pf = ma.getMyApplication().getPoiFilters();
|
||||
boolean selected = pf.isShowingAnyPoi();
|
||||
item.setSelected(selected);
|
||||
item.setDescription(pf.getSelectedPoiFiltersName());
|
||||
item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
final PoiFiltersHelper poiFiltersHelper = ma.getMyApplication().getPoiFilters();
|
||||
MapActivityLayers.DismissListener dismissListener =
|
||||
new MapActivityLayers.DismissListener() {
|
||||
@Override
|
||||
public void dismiss() {
|
||||
PoiFiltersHelper pf = ma.getMyApplication().getPoiFilters();
|
||||
boolean selected = pf.isShowingAnyPoi();
|
||||
item.setSelected(selected);
|
||||
item.setDescription(pf.getSelectedPoiFiltersName());
|
||||
item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
if (poiFiltersHelper.getSelectedPoiFilters().size() > 1) {
|
||||
ma.getMapLayers().showMultichoicePoiFilterDialog(ma.getMapView(),
|
||||
dismissListener);
|
||||
} else {
|
||||
ma.getMapLayers().showSingleChoicePoiFilterDialog(ma.getMapView(),
|
||||
dismissListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -618,9 +618,9 @@ public class WaypointDialogHelper {
|
|||
thisAdapter.notifyDataSetInvalidated();
|
||||
MapActivity map = (MapActivity) ctx;
|
||||
map.getMapLayers().showSingleChoicePoiFilterDialog(map.getMapView(),
|
||||
new MapActivityLayers.ConfirmListener() {
|
||||
new MapActivityLayers.DismissListener() {
|
||||
@Override
|
||||
public void confirm() {
|
||||
public void dismiss() {
|
||||
enableType(running, thisAdapter, type, true);
|
||||
}
|
||||
});
|
||||
|
@ -692,9 +692,9 @@ public class WaypointDialogHelper {
|
|||
!app.getPoiFilters().isPoiFilterSelected(PoiUIFilter.CUSTOM_FILTER_ID)) {
|
||||
MapActivity map = (MapActivity) ctx;
|
||||
map.getMapLayers().showSingleChoicePoiFilterDialog(map.getMapView(),
|
||||
new MapActivityLayers.ConfirmListener() {
|
||||
new MapActivityLayers.DismissListener() {
|
||||
@Override
|
||||
public void confirm() {
|
||||
public void dismiss() {
|
||||
if (app.getPoiFilters().isShowingAnyPoi()) {
|
||||
enableType(running, listAdapter, type, enable);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue