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 int TITLE_LIMIT = 60;
|
||||
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 MapContextMenu mapContextMenu;
|
||||
|
@ -119,9 +121,6 @@ public class MenuBuilder {
|
|||
private boolean showOnlinePhotos = true;
|
||||
protected List<Amenity> nearestWiki = 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<>();
|
||||
@Nullable
|
||||
private CardsRowBuilder onlinePhotoCardsRow;
|
||||
|
@ -358,13 +357,13 @@ public class MenuBuilder {
|
|||
|
||||
protected void buildNearestWikiRow(View view) {
|
||||
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) {
|
||||
if (amenity != null) {
|
||||
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);
|
||||
}
|
||||
|
||||
protected CollapsableView getCollapsableView(Context context, boolean collapsed, List<Amenity> nearestAmenities, final String amenityKey) {
|
||||
LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
|
||||
protected CollapsableView getCollapsableView(Context context, boolean collapsed, List<Amenity> nearestAmenities, String nearestPoiType) {
|
||||
LinearLayout view = buildCollapsableContentView(context, collapsed, true);
|
||||
|
||||
for (final Amenity poi : nearestAmenities) {
|
||||
TextViewEx button = buildButtonInCollapsableView(context, false, false);
|
||||
|
@ -1184,30 +1183,28 @@ public class MenuBuilder {
|
|||
});
|
||||
view.addView(button);
|
||||
}
|
||||
|
||||
final PoiUIFilter filter;
|
||||
if (amenityKey.equals(keyPoi)) {
|
||||
filter = poiFilter;
|
||||
} else if (amenityKey.equals(keyWiki)) {
|
||||
filter = app.getPoiFilters().getTopWikiPoiFilter();
|
||||
} else {
|
||||
filter = null;
|
||||
}
|
||||
PoiUIFilter filter = getPoiFilterForType(nearestPoiType);
|
||||
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);
|
||||
buttonShowAll.setText(app.getString(R.string.shared_string_show_on_map));
|
||||
buttonShowAll.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final PoiFiltersHelper ph = app.getPoiFilters();
|
||||
ph.clearSelectedPoiFilters();
|
||||
ph.addSelectedPoiFilter(filter);
|
||||
final PoiFiltersHelper poiFiltersHelper = app.getPoiFilters();
|
||||
poiFiltersHelper.clearSelectedPoiFilters();
|
||||
poiFiltersHelper.addSelectedPoiFilter(filter);
|
||||
final QuickSearchToolbarController controller = new QuickSearchToolbarController();
|
||||
controller.setTitle(filter.getName());
|
||||
controller.setOnBackButtonClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mapActivity.showQuickSearch(filter);
|
||||
mapContextMenu.show();
|
||||
}
|
||||
});
|
||||
controller.setOnTitleClickListener(new OnClickListener() {
|
||||
|
@ -1219,7 +1216,7 @@ public class MenuBuilder {
|
|||
controller.setOnCloseButtonClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ph.clearSelectedPoiFilters();
|
||||
poiFiltersHelper.clearSelectedPoiFilters();
|
||||
mapActivity.hideTopToolbar(controller);
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
|
@ -1229,11 +1226,7 @@ public class MenuBuilder {
|
|||
mapActivity.refreshMap();
|
||||
}
|
||||
});
|
||||
|
||||
view.addView(buttonShowAll);
|
||||
}
|
||||
|
||||
return new CollapsableView(view, this, collapsed);
|
||||
return buttonShowAll;
|
||||
}
|
||||
|
||||
protected LinearLayout buildCollapsableContentView(Context context, boolean collapsed, boolean needMargin) {
|
||||
|
@ -1299,17 +1292,33 @@ public class MenuBuilder {
|
|||
|
||||
protected boolean processNearestPoi() {
|
||||
if (showNearestPoi && latLon != null && amenity != null) {
|
||||
PoiCategory pc = amenity.getType();
|
||||
PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType());
|
||||
poiFilter = app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + pt.getKeyName());
|
||||
if (poiFilter != null) {
|
||||
nearestPoi = getSortedAmenities(poiFilter, latLon);
|
||||
PoiUIFilter filter = getPoiFilterForAmenity(amenity);
|
||||
if (filter != null) {
|
||||
nearestPoi = getSortedAmenities(filter, latLon);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
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) {
|
||||
QuadRect rect = MapUtils.calculateLatLonBbox(latLon.getLatitude(), latLon.getLongitude(), 250);
|
||||
|
||||
|
|
|
@ -684,18 +684,18 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
|
||||
if (processNearestWiki() && nearestWiki.size() > 0) {
|
||||
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() + ")",
|
||||
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);
|
||||
buildAmenityRow(view, wikiInfo);
|
||||
}
|
||||
|
||||
if (processNearestPoi() && nearestPoi.size() > 0) {
|
||||
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() + ")",
|
||||
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);
|
||||
buildAmenityRow(view, poiInfo);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue