Minor fixes
This commit is contained in:
parent
dea4df61f8
commit
410f01d21e
2 changed files with 72 additions and 63 deletions
|
@ -102,6 +102,8 @@ public class MenuBuilder {
|
||||||
public static final float SHADOW_HEIGHT_TOP_DP = 17f;
|
public static final float SHADOW_HEIGHT_TOP_DP = 17f;
|
||||||
public static final int TITLE_LIMIT = 60;
|
public static final int TITLE_LIMIT = 60;
|
||||||
protected static final String[] arrowChars = new String[] {"=>", " - "};
|
protected static final String[] arrowChars = new String[] {"=>", " - "};
|
||||||
|
protected final String NEAREST_WIKI_KEY = "nearest_wiki_key";
|
||||||
|
protected final String NEAREST_POI_KEY = "nearest_poi_key";
|
||||||
|
|
||||||
protected MapActivity mapActivity;
|
protected MapActivity mapActivity;
|
||||||
protected MapContextMenu mapContextMenu;
|
protected MapContextMenu mapContextMenu;
|
||||||
|
@ -119,9 +121,6 @@ public class MenuBuilder {
|
||||||
private boolean showOnlinePhotos = true;
|
private boolean showOnlinePhotos = true;
|
||||||
protected List<Amenity> nearestWiki = new ArrayList<>();
|
protected List<Amenity> nearestWiki = new ArrayList<>();
|
||||||
protected List<Amenity> nearestPoi = new ArrayList<>();
|
protected List<Amenity> nearestPoi = new ArrayList<>();
|
||||||
protected final String keyWiki = "nearest_wiki";
|
|
||||||
protected final String keyPoi = "nearest_poi";
|
|
||||||
private PoiUIFilter poiFilter;
|
|
||||||
private List<OsmandPlugin> menuPlugins = new ArrayList<>();
|
private List<OsmandPlugin> menuPlugins = new ArrayList<>();
|
||||||
@Nullable
|
@Nullable
|
||||||
private CardsRowBuilder onlinePhotoCardsRow;
|
private CardsRowBuilder onlinePhotoCardsRow;
|
||||||
|
@ -358,13 +357,13 @@ public class MenuBuilder {
|
||||||
|
|
||||||
protected void buildNearestWikiRow(View view) {
|
protected void buildNearestWikiRow(View view) {
|
||||||
buildNearestRow(view, nearestWiki, processNearestWiki(),
|
buildNearestRow(view, nearestWiki, processNearestWiki(),
|
||||||
R.drawable.ic_action_wikipedia, app.getString(R.string.wiki_around), keyWiki);
|
R.drawable.ic_action_wikipedia, app.getString(R.string.wiki_around), NEAREST_WIKI_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void buildNearestPoiRow(View view) {
|
protected void buildNearestPoiRow(View view) {
|
||||||
if (amenity != null) {
|
if (amenity != null) {
|
||||||
buildNearestRow(view, nearestPoi, processNearestPoi(), AmenityMenuController.getRightIconId(amenity),
|
buildNearestRow(view, nearestPoi, processNearestPoi(), AmenityMenuController.getRightIconId(amenity),
|
||||||
app.getString(R.string.speak_poi) + " \"" + AmenityMenuController.getTypeStr(amenity) + "\" (" + nearestPoi.size() + ")", keyPoi);
|
app.getString(R.string.speak_poi) + " \"" + AmenityMenuController.getTypeStr(amenity) + "\" (" + nearestPoi.size() + ")", NEAREST_POI_KEY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1161,8 +1160,8 @@ public class MenuBuilder {
|
||||||
return new CollapsableView(textView, this, collapsed);
|
return new CollapsableView(textView, this, collapsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CollapsableView getCollapsableView(Context context, boolean collapsed, List<Amenity> nearestAmenities, final String amenityKey) {
|
protected CollapsableView getCollapsableView(Context context, boolean collapsed, List<Amenity> nearestAmenities, String nearestPoiType) {
|
||||||
LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
|
LinearLayout view = buildCollapsableContentView(context, collapsed, true);
|
||||||
|
|
||||||
for (final Amenity poi : nearestAmenities) {
|
for (final Amenity poi : nearestAmenities) {
|
||||||
TextViewEx button = buildButtonInCollapsableView(context, false, false);
|
TextViewEx button = buildButtonInCollapsableView(context, false, false);
|
||||||
|
@ -1184,30 +1183,28 @@ public class MenuBuilder {
|
||||||
});
|
});
|
||||||
view.addView(button);
|
view.addView(button);
|
||||||
}
|
}
|
||||||
|
PoiUIFilter filter = getPoiFilterForType(nearestPoiType);
|
||||||
final PoiUIFilter filter;
|
|
||||||
if (amenityKey.equals(keyPoi)) {
|
|
||||||
filter = poiFilter;
|
|
||||||
} else if (amenityKey.equals(keyWiki)) {
|
|
||||||
filter = app.getPoiFilters().getTopWikiPoiFilter();
|
|
||||||
} else {
|
|
||||||
filter = null;
|
|
||||||
}
|
|
||||||
if (filter != null) {
|
if (filter != null) {
|
||||||
|
view.addView(createShowAllButton(context, filter));
|
||||||
|
}
|
||||||
|
return new CollapsableView(view, this, collapsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
private View createShowAllButton(Context context, final PoiUIFilter filter) {
|
||||||
TextViewEx buttonShowAll = buildButtonInCollapsableView(context, false, false);
|
TextViewEx buttonShowAll = buildButtonInCollapsableView(context, false, false);
|
||||||
buttonShowAll.setText(app.getString(R.string.shared_string_show_on_map));
|
buttonShowAll.setText(app.getString(R.string.shared_string_show_on_map));
|
||||||
buttonShowAll.setOnClickListener(new View.OnClickListener() {
|
buttonShowAll.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
final PoiFiltersHelper ph = app.getPoiFilters();
|
final PoiFiltersHelper poiFiltersHelper = app.getPoiFilters();
|
||||||
ph.clearSelectedPoiFilters();
|
poiFiltersHelper.clearSelectedPoiFilters();
|
||||||
ph.addSelectedPoiFilter(filter);
|
poiFiltersHelper.addSelectedPoiFilter(filter);
|
||||||
final QuickSearchToolbarController controller = new QuickSearchToolbarController();
|
final QuickSearchToolbarController controller = new QuickSearchToolbarController();
|
||||||
controller.setTitle(filter.getName());
|
controller.setTitle(filter.getName());
|
||||||
controller.setOnBackButtonClickListener(new OnClickListener() {
|
controller.setOnBackButtonClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
mapActivity.showQuickSearch(filter);
|
mapContextMenu.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
controller.setOnTitleClickListener(new OnClickListener() {
|
controller.setOnTitleClickListener(new OnClickListener() {
|
||||||
|
@ -1219,7 +1216,7 @@ public class MenuBuilder {
|
||||||
controller.setOnCloseButtonClickListener(new OnClickListener() {
|
controller.setOnCloseButtonClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
ph.clearSelectedPoiFilters();
|
poiFiltersHelper.clearSelectedPoiFilters();
|
||||||
mapActivity.hideTopToolbar(controller);
|
mapActivity.hideTopToolbar(controller);
|
||||||
mapActivity.refreshMap();
|
mapActivity.refreshMap();
|
||||||
}
|
}
|
||||||
|
@ -1229,11 +1226,7 @@ public class MenuBuilder {
|
||||||
mapActivity.refreshMap();
|
mapActivity.refreshMap();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return buttonShowAll;
|
||||||
view.addView(buttonShowAll);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new CollapsableView(view, this, collapsed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LinearLayout buildCollapsableContentView(Context context, boolean collapsed, boolean needMargin) {
|
protected LinearLayout buildCollapsableContentView(Context context, boolean collapsed, boolean needMargin) {
|
||||||
|
@ -1299,17 +1292,33 @@ public class MenuBuilder {
|
||||||
|
|
||||||
protected boolean processNearestPoi() {
|
protected boolean processNearestPoi() {
|
||||||
if (showNearestPoi && latLon != null && amenity != null) {
|
if (showNearestPoi && latLon != null && amenity != null) {
|
||||||
PoiCategory pc = amenity.getType();
|
PoiUIFilter filter = getPoiFilterForAmenity(amenity);
|
||||||
PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType());
|
if (filter != null) {
|
||||||
poiFilter = app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + pt.getKeyName());
|
nearestPoi = getSortedAmenities(filter, latLon);
|
||||||
if (poiFilter != null) {
|
|
||||||
nearestPoi = getSortedAmenities(poiFilter, latLon);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PoiUIFilter getPoiFilterForType(String nearestPoiType) {
|
||||||
|
if (NEAREST_POI_KEY.equals(nearestPoiType)) {
|
||||||
|
return getPoiFilterForAmenity(amenity);
|
||||||
|
} else if (NEAREST_WIKI_KEY.equals(nearestPoiType)) {
|
||||||
|
return app.getPoiFilters().getTopWikiPoiFilter();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PoiUIFilter getPoiFilterForAmenity(Amenity amenity) {
|
||||||
|
if (amenity != null) {
|
||||||
|
PoiCategory category = amenity.getType();
|
||||||
|
PoiType poiType = category.getPoiTypeByKeyName(amenity.getSubType());
|
||||||
|
return app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + poiType.getKeyName());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private List<Amenity> getSortedAmenities(PoiUIFilter filter, final LatLon latLon) {
|
private List<Amenity> getSortedAmenities(PoiUIFilter filter, final LatLon latLon) {
|
||||||
QuadRect rect = MapUtils.calculateLatLonBbox(latLon.getLatitude(), latLon.getLongitude(), 250);
|
QuadRect rect = MapUtils.calculateLatLonBbox(latLon.getLatitude(), latLon.getLongitude(), 250);
|
||||||
|
|
||||||
|
|
|
@ -684,18 +684,18 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
||||||
|
|
||||||
if (processNearestWiki() && nearestWiki.size() > 0) {
|
if (processNearestWiki() && nearestWiki.size() > 0) {
|
||||||
AmenityInfoRow wikiInfo = new AmenityInfoRow(
|
AmenityInfoRow wikiInfo = new AmenityInfoRow(
|
||||||
keyWiki, R.drawable.ic_plugin_wikipedia, null,
|
NEAREST_WIKI_KEY, R.drawable.ic_plugin_wikipedia, null,
|
||||||
app.getString(R.string.wiki_around) + " (" + nearestWiki.size() + ")",
|
app.getString(R.string.wiki_around) + " (" + nearestWiki.size() + ")",
|
||||||
null, true, getCollapsableView(view.getContext(), true, nearestWiki, keyWiki),
|
null, true, getCollapsableView(view.getContext(), true, nearestWiki, NEAREST_WIKI_KEY),
|
||||||
0, false, false, false, 1000, null, false, false, false, 0);
|
0, false, false, false, 1000, null, false, false, false, 0);
|
||||||
buildAmenityRow(view, wikiInfo);
|
buildAmenityRow(view, wikiInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (processNearestPoi() && nearestPoi.size() > 0) {
|
if (processNearestPoi() && nearestPoi.size() > 0) {
|
||||||
AmenityInfoRow poiInfo = new AmenityInfoRow(
|
AmenityInfoRow poiInfo = new AmenityInfoRow(
|
||||||
keyPoi, AmenityMenuController.getRightIconId(amenity), null,
|
NEAREST_POI_KEY, AmenityMenuController.getRightIconId(amenity), null,
|
||||||
app.getString(R.string.speak_poi) + " \"" + AmenityMenuController.getTypeStr(amenity) + "\" (" + nearestPoi.size() + ")",
|
app.getString(R.string.speak_poi) + " \"" + AmenityMenuController.getTypeStr(amenity) + "\" (" + nearestPoi.size() + ")",
|
||||||
null, true, getCollapsableView(view.getContext(), true, nearestPoi, keyPoi),
|
null, true, getCollapsableView(view.getContext(), true, nearestPoi, NEAREST_POI_KEY),
|
||||||
0, false, false, false, 1000, null, false, false, false, 0);
|
0, false, false, false, 1000, null, false, false, false, 0);
|
||||||
buildAmenityRow(view, poiInfo);
|
buildAmenityRow(view, poiInfo);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue