Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
497fce4c2c
9 changed files with 276 additions and 47 deletions
|
@ -17,6 +17,7 @@ public abstract class AbstractPoiType {
|
|||
private AbstractPoiType baseLangType;
|
||||
private boolean notEditableOsm;
|
||||
private String poiAdditionalCategory;
|
||||
private List<String> excludedPoiAdditionalCategoies;
|
||||
|
||||
public AbstractPoiType(String keyName, MapPoiTypes registry) {
|
||||
this.keyName = keyName;
|
||||
|
@ -89,6 +90,17 @@ public abstract class AbstractPoiType {
|
|||
}
|
||||
}
|
||||
|
||||
public void addPoiAdditionalsCategorized(List<PoiType> tps) {
|
||||
if (poiAdditionals == null) {
|
||||
poiAdditionals = new ArrayList<>();
|
||||
}
|
||||
poiAdditionals.addAll(tps);
|
||||
if (poiAdditionalsCategorized == null) {
|
||||
poiAdditionalsCategorized = new ArrayList<>();
|
||||
}
|
||||
poiAdditionalsCategorized.addAll(tps);
|
||||
}
|
||||
|
||||
public List<PoiType> getPoiAdditionals() {
|
||||
if (poiAdditionals == null) {
|
||||
return Collections.emptyList();
|
||||
|
@ -119,6 +131,17 @@ public abstract class AbstractPoiType {
|
|||
this.poiAdditionalCategory = poiAdditionalCategory;
|
||||
}
|
||||
|
||||
public List<String> getExcludedPoiAdditionalCategories() {
|
||||
return excludedPoiAdditionalCategoies;
|
||||
}
|
||||
|
||||
public void addExcludedPoiAdditionalCategories(String[] excludedPoiAdditionalCategories) {
|
||||
if (excludedPoiAdditionalCategoies == null) {
|
||||
excludedPoiAdditionalCategoies = new ArrayList<>();
|
||||
}
|
||||
Collections.addAll(excludedPoiAdditionalCategoies, excludedPoiAdditionalCategories);
|
||||
}
|
||||
|
||||
public abstract Map<PoiCategory, LinkedHashSet<String>> putTypes(Map<PoiCategory, LinkedHashSet<String>> acceptedTypes);
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,7 +23,9 @@ import java.util.LinkedHashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
|
||||
public class MapPoiTypes {
|
||||
|
@ -265,6 +267,8 @@ public class MapPoiTypes {
|
|||
long time = System.currentTimeMillis();
|
||||
List<PoiType> referenceTypes = new ArrayList<PoiType>();
|
||||
final Map<String, PoiType> allTypes = new LinkedHashMap<String, PoiType>();
|
||||
final Map<String, List<PoiType>> categoryPoiAdditionalMap = new LinkedHashMap<String, List<PoiType>>();
|
||||
final Map<AbstractPoiType, Set<String>> abstractTypeAdditionalCategories = new LinkedHashMap<AbstractPoiType, Set<String>>();
|
||||
if (resourceName != null) {
|
||||
this.resourceName = resourceName;
|
||||
}
|
||||
|
@ -280,8 +284,11 @@ public class MapPoiTypes {
|
|||
int tok;
|
||||
parser.setInput(is, "UTF-8");
|
||||
PoiCategory lastCategory = null;
|
||||
Set<String> lastCategoryPoiAdditionalsCategories = new TreeSet<>();
|
||||
PoiFilter lastFilter = null;
|
||||
Set<String> lastFilterPoiAdditionalsCategories = new TreeSet<>();
|
||||
PoiType lastType = null;
|
||||
Set<String> lastTypePoiAdditionalsCategories = new TreeSet<>();
|
||||
String lastPoiAdditionalCategory = null;
|
||||
while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
|
||||
if (tok == XmlPullParser.START_TAG) {
|
||||
|
@ -291,11 +298,26 @@ public class MapPoiTypes {
|
|||
lastCategory.setTopVisible(Boolean.parseBoolean(parser.getAttributeValue("", "top")));
|
||||
lastCategory.setNotEditableOsm("true".equals(parser.getAttributeValue("", "no_edit")));
|
||||
lastCategory.setDefaultTag(parser.getAttributeValue("", "default_tag"));
|
||||
if(!Algorithms.isEmpty(parser.getAttributeValue("", "poi_additional_category"))) {
|
||||
Collections.addAll(lastCategoryPoiAdditionalsCategories, parser.getAttributeValue("", "poi_additional_category").split(","));
|
||||
}
|
||||
if(!Algorithms.isEmpty(parser.getAttributeValue("", "excluded_poi_additional_category"))) {
|
||||
lastCategory.addExcludedPoiAdditionalCategories(parser.getAttributeValue("", "excluded_poi_additional_category").split(","));
|
||||
lastCategoryPoiAdditionalsCategories.removeAll(lastCategory.getExcludedPoiAdditionalCategories());
|
||||
}
|
||||
categories.add(lastCategory);
|
||||
} else if (name.equals("poi_filter")) {
|
||||
PoiFilter tp = new PoiFilter(this, lastCategory, parser.getAttributeValue("", "name"));
|
||||
tp.setTopVisible(Boolean.parseBoolean(parser.getAttributeValue("", "top")));
|
||||
lastFilter = tp;
|
||||
lastFilterPoiAdditionalsCategories.addAll(lastCategoryPoiAdditionalsCategories);
|
||||
if(!Algorithms.isEmpty(parser.getAttributeValue("", "poi_additional_category"))) {
|
||||
Collections.addAll(lastFilterPoiAdditionalsCategories, parser.getAttributeValue("", "poi_additional_category").split(","));
|
||||
}
|
||||
if(!Algorithms.isEmpty(parser.getAttributeValue("", "excluded_poi_additional_category"))) {
|
||||
lastFilter.addExcludedPoiAdditionalCategories(parser.getAttributeValue("", "excluded_poi_additional_category").split(","));
|
||||
lastFilterPoiAdditionalsCategories.removeAll(lastFilter.getExcludedPoiAdditionalCategories());
|
||||
}
|
||||
lastCategory.addPoiType(tp);
|
||||
} else if (name.equals("poi_reference")) {
|
||||
PoiType tp = new PoiType(this, lastCategory, parser.getAttributeValue("", "name"));
|
||||
|
@ -316,6 +338,14 @@ public class MapPoiTypes {
|
|||
}
|
||||
parsePoiAdditional(parser, lastCategory, lastFilter, lastType, "en", baseType, lastPoiAdditionalCategory);
|
||||
}
|
||||
if (lastPoiAdditionalCategory != null) {
|
||||
List<PoiType> categoryAdditionals = categoryPoiAdditionalMap.get(lastPoiAdditionalCategory);
|
||||
if (categoryAdditionals == null) {
|
||||
categoryAdditionals = new ArrayList<>();
|
||||
categoryPoiAdditionalMap.put(lastPoiAdditionalCategory, categoryAdditionals);
|
||||
}
|
||||
categoryAdditionals.add(baseType);
|
||||
}
|
||||
|
||||
} else if (name.equals("poi_additional_category")) {
|
||||
if (lastPoiAdditionalCategory == null) {
|
||||
|
@ -341,16 +371,36 @@ public class MapPoiTypes {
|
|||
parsePoiType(allTypes, parser, lastCategory, lastFilter, lng, lastType);
|
||||
}
|
||||
}
|
||||
lastTypePoiAdditionalsCategories.addAll(lastCategoryPoiAdditionalsCategories);
|
||||
lastTypePoiAdditionalsCategories.addAll(lastFilterPoiAdditionalsCategories);
|
||||
if(!Algorithms.isEmpty(parser.getAttributeValue("", "poi_additional_category"))) {
|
||||
Collections.addAll(lastFilterPoiAdditionalsCategories, parser.getAttributeValue("", "poi_additional_category").split(","));
|
||||
}
|
||||
if(!Algorithms.isEmpty(parser.getAttributeValue("", "excluded_poi_additional_category"))) {
|
||||
lastType.addExcludedPoiAdditionalCategories(parser.getAttributeValue("", "excluded_poi_additional_category").split(","));
|
||||
lastTypePoiAdditionalsCategories.removeAll(lastType.getExcludedPoiAdditionalCategories());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else if (tok == XmlPullParser.END_TAG) {
|
||||
String name = parser.getName();
|
||||
if (name.equals("poi_filter")) {
|
||||
if (lastFilterPoiAdditionalsCategories.size() > 0) {
|
||||
abstractTypeAdditionalCategories.put(lastFilter, lastFilterPoiAdditionalsCategories);
|
||||
lastFilterPoiAdditionalsCategories = new TreeSet<>();
|
||||
}
|
||||
lastFilter = null;
|
||||
} else if (name.equals("poi_type")) {
|
||||
if (lastTypePoiAdditionalsCategories.size() > 0) {
|
||||
abstractTypeAdditionalCategories.put(lastType, lastTypePoiAdditionalsCategories);
|
||||
lastTypePoiAdditionalsCategories = new TreeSet<>();
|
||||
}
|
||||
lastType = null;
|
||||
} else if (name.equals("poi_category")) {
|
||||
if (lastCategoryPoiAdditionalsCategories.size() > 0) {
|
||||
abstractTypeAdditionalCategories.put(lastCategory, lastCategoryPoiAdditionalsCategories);
|
||||
lastCategoryPoiAdditionalsCategories = new TreeSet<>();
|
||||
}
|
||||
lastCategory = null;
|
||||
} else if (name.equals("poi_additional_category")) {
|
||||
lastPoiAdditionalCategory = null;
|
||||
|
@ -379,6 +429,14 @@ public class MapPoiTypes {
|
|||
gt.setReferenceType(pt);
|
||||
}
|
||||
}
|
||||
for (Entry<AbstractPoiType, Set<String>> entry : abstractTypeAdditionalCategories.entrySet()) {
|
||||
for (String category : entry.getValue()) {
|
||||
List<PoiType> poiAdditionals = categoryPoiAdditionalMap.get(category);
|
||||
if (poiAdditionals != null) {
|
||||
entry.getKey().addPoiAdditionalsCategorized(poiAdditionals);
|
||||
}
|
||||
}
|
||||
}
|
||||
findDefaultOtherCategory();
|
||||
init = true;
|
||||
log.info("Time to init poi types " + (System.currentTimeMillis() - time)); //$NON-NLS-1$
|
||||
|
|
96
OsmAnd/res/layout/list_item_icon24_and_menu.xml
Normal file
96
OsmAnd/res/layout/list_item_icon24_and_menu.xml
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
android:minHeight="60dp"
|
||||
tools:layout_height="60dp">
|
||||
|
||||
<android.support.v7.widget.AppCompatImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
tools:src="@drawable/ic_action_gabout_dark"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/text_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_toEndOf="@+id/icon"
|
||||
android:layout_toLeftOf="@+id/secondary_icon"
|
||||
android:layout_toRightOf="@+id/icon"
|
||||
android:layout_toStartOf="@+id/secondary_icon"
|
||||
android:minHeight="60dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatTextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
tools:text="Some title text"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatTextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:lines="1"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
tools:text="Some very long subtitle text, that won't fit into one line"/>
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.AppCompatImageView
|
||||
android:id="@+id/secondary_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_margin="16dp"
|
||||
android:layout_toLeftOf="@+id/toggle_item"
|
||||
android:layout_toStartOf="@+id/toggle_item"
|
||||
tools:src="@drawable/ic_action_gabout_dark"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/toggle_item"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:focusable="false"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignLeft="@+id/text_wrapper"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignStart="@+id/text_wrapper"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
</RelativeLayout>
|
|
@ -24,8 +24,8 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/ic_action_search_dark"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -98,10 +98,11 @@
|
|||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:id="@+id/item_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="54dp"
|
||||
android:layout_marginStart="54dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -393,8 +393,14 @@ public abstract class OsmandPlugin {
|
|||
}
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
if (!(plugin instanceof ParkingPositionPlugin) && !(plugin instanceof OsmandMonitoringPlugin)) {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setLayout(R.layout.context_menu_list_divider).createItem());
|
||||
int itemsCount = adapter.length();
|
||||
plugin.registerMapContextMenuActions(map, latitude, longitude, adapter, selectedObj);
|
||||
if (adapter.length() > itemsCount) {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setPosition(itemsCount)
|
||||
.setLayout(R.layout.context_menu_list_divider)
|
||||
.createItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -628,6 +628,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.NEW_IF_EXPIRED, false);
|
||||
/*
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||
.getSearchActivity());
|
||||
LatLon loc = mapActivity.getMapLocation();
|
||||
|
@ -638,6 +640,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
mapActivity.startActivity(newIntent);
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
|
|
|
@ -19,8 +19,10 @@ import android.widget.ArrayAdapter;
|
|||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.IconsCache;
|
||||
|
@ -204,7 +206,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
private OsmandApplication app;
|
||||
|
||||
CategoryListAdapter(OsmandApplication app, List<PoiCategory> items) {
|
||||
super(app, R.layout.list_item_icon_and_menu, items);
|
||||
super(app, R.layout.list_item_icon24_and_menu, items);
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
|
@ -214,7 +216,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View row = convertView;
|
||||
if (row == null) {
|
||||
row = inflater.inflate(R.layout.list_item_icon_and_menu, parent, false);
|
||||
row = inflater.inflate(R.layout.list_item_icon24_and_menu, parent, false);
|
||||
}
|
||||
PoiCategory category = getItem(position);
|
||||
if (category != null) {
|
||||
|
@ -350,6 +352,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(getContext().getText(R.string.shared_string_apply), new DialogInterface.OnClickListener() {
|
||||
|
|
|
@ -30,6 +30,7 @@ import android.widget.Toast;
|
|||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -37,6 +38,7 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
import net.osmand.plus.widgets.TextViewEx;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
@ -44,6 +46,7 @@ import java.text.MessageFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
@ -426,12 +429,14 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
|||
filterByName = filterByName.replaceAll(keyNameOpen24, "");
|
||||
}
|
||||
|
||||
MapPoiTypes poiTypes = app.getPoiTypes();
|
||||
Map<String, PoiType> poiAdditionals = filter.getPoiAdditionals();
|
||||
List<PoiType> otherAdditionalCategories = app.getPoiTypes().getOtherMapCategory().getPoiAdditionalsCategorized();
|
||||
Set<String> excludedPoiAdditionalCategories = getExcludedPoiAdditionalCategories();
|
||||
List<PoiType> otherAdditionalCategories = poiTypes.getOtherMapCategory().getPoiAdditionalsCategorized();
|
||||
if (poiAdditionals != null) {
|
||||
Map<String, Set<String>> additionalsMap = new TreeMap<>();
|
||||
extractPoiAdditionals(poiAdditionals.values(), additionalsMap, true);
|
||||
extractPoiAdditionals(otherAdditionalCategories, additionalsMap, true);
|
||||
extractPoiAdditionals(poiAdditionals.values(), additionalsMap, excludedPoiAdditionalCategories, true);
|
||||
extractPoiAdditionals(otherAdditionalCategories, additionalsMap, excludedPoiAdditionalCategories, true);
|
||||
|
||||
if (additionalsMap.size() > 0) {
|
||||
for (Entry<String, Set<String>> entry : additionalsMap.entrySet()) {
|
||||
|
@ -452,6 +457,24 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
|||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private Set<String> getExcludedPoiAdditionalCategories() {
|
||||
MapPoiTypes poiTypes = getMyApplication().getPoiTypes();
|
||||
Set<String> excludedPoiAdditionalCategories = new LinkedHashSet<>();
|
||||
for (Entry<PoiCategory, LinkedHashSet<String>> entry : filter.getAcceptedTypes().entrySet()) {
|
||||
if (entry.getKey().getExcludedPoiAdditionalCategories() != null) {
|
||||
excludedPoiAdditionalCategories.addAll(entry.getKey().getExcludedPoiAdditionalCategories());
|
||||
}
|
||||
for (String keyName : entry.getValue()) {
|
||||
List<String> categories = poiTypes.getPoiTypeByKey(keyName).getExcludedPoiAdditionalCategories();
|
||||
if (categories != null) {
|
||||
excludedPoiAdditionalCategories.addAll(categories);
|
||||
}
|
||||
}
|
||||
}
|
||||
return excludedPoiAdditionalCategories;
|
||||
}
|
||||
|
||||
private List<PoiFilterListItem> getListItems() {
|
||||
OsmandApplication app = getMyApplication();
|
||||
MapPoiTypes poiTypes = app.getPoiTypes();
|
||||
|
@ -468,11 +491,12 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
|||
selectedPoiAdditionals.contains(keyNameOpen24), null, keyNameOpen24));
|
||||
|
||||
Map<String, PoiType> poiAdditionals = filter.getPoiAdditionals();
|
||||
Set<String> excludedPoiAdditionalCategories = getExcludedPoiAdditionalCategories();
|
||||
List<PoiType> otherAdditionalCategories = poiTypes.getOtherMapCategory().getPoiAdditionalsCategorized();
|
||||
if (poiAdditionals != null) {
|
||||
Map<String, Set<String>> additionalsMap = new TreeMap<>();
|
||||
extractPoiAdditionals(poiAdditionals.values(), additionalsMap, false);
|
||||
extractPoiAdditionals(otherAdditionalCategories, additionalsMap, false);
|
||||
extractPoiAdditionals(poiAdditionals.values(), additionalsMap, excludedPoiAdditionalCategories, false);
|
||||
extractPoiAdditionals(otherAdditionalCategories, additionalsMap, excludedPoiAdditionalCategories, false);
|
||||
|
||||
if (additionalsMap.size() > 0) {
|
||||
for (Entry<String, Set<String>> entry : additionalsMap.entrySet()) {
|
||||
|
@ -483,9 +507,11 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
|||
items.add(new PoiFilterListItem(PoiFilterListItemType.DIVIDER, 0, null, -1, false, false, false, null, null));
|
||||
|
||||
String categoryIconStr = poiTypes.getPoiAdditionalCategoryIcon(category);
|
||||
int categoryIconId = 0;
|
||||
int categoryIconId;
|
||||
if (!Algorithms.isEmpty(categoryIconStr)) {
|
||||
categoryIconId = getResources().getIdentifier(categoryIconStr, "drawable", app.getPackageName());
|
||||
} else {
|
||||
categoryIconId = RenderingIcons.getBigIconResourceId(category);
|
||||
}
|
||||
if (categoryIconId == 0) {
|
||||
categoryIconId = R.drawable.ic_action_folder_stroke;
|
||||
|
@ -510,21 +536,38 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
|||
return items;
|
||||
}
|
||||
|
||||
private void extractPoiAdditionals(Collection<PoiType> poiAdditionals, Map<String, Set<String>> additionalsMap, boolean extractAll) {
|
||||
private void extractPoiAdditionals(Collection<PoiType> poiAdditionals,
|
||||
Map<String, Set<String>> additionalsMap,
|
||||
Set<String> excludedPoiAdditionalCategories,
|
||||
boolean extractAll) {
|
||||
Set<String> topTrueOnlyCategories = new LinkedHashSet<>();
|
||||
for (PoiType poiType : poiAdditionals) {
|
||||
String category = poiType.getPoiAdditionalCategory();
|
||||
if (category != null) {
|
||||
topTrueOnlyCategories.add(category);
|
||||
}
|
||||
}
|
||||
for (PoiType poiType : poiAdditionals) {
|
||||
String category = poiType.getPoiAdditionalCategory();
|
||||
if (category == null) {
|
||||
category = "";
|
||||
}
|
||||
if (excludedPoiAdditionalCategories != null && excludedPoiAdditionalCategories.contains(category)) {
|
||||
continue;
|
||||
}
|
||||
if (collapsedCategories.contains(category) && !extractAll) {
|
||||
if (!additionalsMap.containsKey(category)) {
|
||||
additionalsMap.put(category, new TreeSet<String>());
|
||||
}
|
||||
topTrueOnlyCategories.remove(category);
|
||||
continue;
|
||||
}
|
||||
boolean showAll = showAllCategories.contains(category) || extractAll;
|
||||
String name = poiType.getTranslation();
|
||||
String keyName = name.replace(' ', ':').toLowerCase();
|
||||
if (!poiType.isTopVisible()) {
|
||||
topTrueOnlyCategories.remove(category);
|
||||
}
|
||||
if (showAll || poiType.isTopVisible() || selectedPoiAdditionals.contains(keyName)) {
|
||||
Set<String> adds = additionalsMap.get(category);
|
||||
if (adds == null) {
|
||||
|
@ -534,6 +577,11 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
|||
adds.add(name);
|
||||
}
|
||||
}
|
||||
for (String category : topTrueOnlyCategories) {
|
||||
if (!showAllCategories.contains(category)) {
|
||||
showAllCategories.add(category);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void showDialog(DialogFragment parentFragment, String filterByName, String filterId) {
|
||||
|
@ -633,7 +681,7 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
|||
final SwitchCompat switchItem = (SwitchCompat) view.findViewById(R.id.switchItem);
|
||||
final CheckBox checkBoxItem = (CheckBox) view.findViewById(R.id.checkboxItem);
|
||||
final ImageView expandItem = (ImageView) view.findViewById(R.id.expandItem);
|
||||
final View divider = view.findViewById(R.id.divider);
|
||||
final View divider = view.findViewById(R.id.item_divider);
|
||||
|
||||
if (item != null) {
|
||||
if (nextItem != null && nextItem.groupIndex == item.groupIndex) {
|
||||
|
@ -641,8 +689,10 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
|||
} else {
|
||||
divider.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (item.iconId != 0) {
|
||||
icon.setImageDrawable(app.getIconsCache().getThemedIcon(item.iconId));
|
||||
icon.setImageDrawable(app.getIconsCache().getIcon(item.iconId,
|
||||
app.getSettings().isLightContent() ? R.color.icon_color : R.color.color_white));
|
||||
icon.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
icon.setVisibility(View.GONE);
|
||||
|
|
|
@ -31,7 +31,6 @@ import net.osmand.data.PointDescription;
|
|||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.PoiFilter;
|
||||
import net.osmand.osm.PoiType;
|
||||
|
@ -601,7 +600,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
names.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
Amenity amenity = findAmenity(renderedObject.getId() >> 6, names,
|
||||
Amenity amenity = findAmenity(renderedObject.getId() >> 7, names,
|
||||
latLon.getLatitude(), latLon.getLongitude());
|
||||
if (amenity != null) {
|
||||
selectedObjects.put(amenity, poiMenuProvider);
|
||||
|
@ -610,7 +609,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
TransportStop nearestTransportStop = findNearestTransportStop(latLon.getLatitude(), latLon.getLongitude());
|
||||
if (nearestTransportStop != null) {
|
||||
selectedObjects.put(nearestTransportStop, transportStopMenuProvider);
|
||||
continue;
|
||||
//continue;
|
||||
}
|
||||
if (renderedObject.getX() != null && renderedObject.getX().size() > 1
|
||||
&& renderedObject.getY() != null && renderedObject.getY().size() > 1) {
|
||||
|
@ -640,7 +639,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
private Amenity findAmenity(long id, List<String> names, double lat, double lon) {
|
||||
QuadRect rect = MapUtils.calculateLatLonBbox(lat, lon, 150);
|
||||
QuadRect rect = MapUtils.calculateLatLonBbox(lat, lon, 50);
|
||||
List<Amenity> amenities = activity.getMyApplication().getResourceManager().searchAmenities(
|
||||
new BinaryMapIndexReader.SearchPoiTypeFilter() {
|
||||
@Override
|
||||
|
@ -656,22 +655,12 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
|
||||
Amenity res = null;
|
||||
for (Amenity amenity : amenities) {
|
||||
Long amenityId = amenity.getId();
|
||||
if (amenityId != null && amenityId == id) {
|
||||
Long amenityId = amenity.getId() >> 1;
|
||||
if (amenityId == id) {
|
||||
res = amenity;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (res == null && (id & 1) == 0) {
|
||||
id++;
|
||||
for (Amenity amenity : amenities) {
|
||||
Long amenityId = amenity.getId();
|
||||
if (amenityId != null && amenityId == id) {
|
||||
res = amenity;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (res == null && names != null && names.size() > 0) {
|
||||
for (Amenity amenity : amenities) {
|
||||
for (String name : names) {
|
||||
|
@ -695,7 +684,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
|
||||
private TransportStop findTransportStop(long id, double lat, double lon) {
|
||||
|
||||
QuadRect rect = MapUtils.calculateLatLonBbox(lat, lon, 150);
|
||||
QuadRect rect = MapUtils.calculateLatLonBbox(lat, lon, 50);
|
||||
List<TransportStop> res = activity.getMyApplication().getResourceManager()
|
||||
.searchTransportSync(rect.top, rect.left, rect.bottom, rect.right,
|
||||
new ResultMatcher<TransportStop>() {
|
||||
|
|
Loading…
Reference in a new issue