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 AbstractPoiType baseLangType;
|
||||||
private boolean notEditableOsm;
|
private boolean notEditableOsm;
|
||||||
private String poiAdditionalCategory;
|
private String poiAdditionalCategory;
|
||||||
|
private List<String> excludedPoiAdditionalCategoies;
|
||||||
|
|
||||||
public AbstractPoiType(String keyName, MapPoiTypes registry) {
|
public AbstractPoiType(String keyName, MapPoiTypes registry) {
|
||||||
this.keyName = keyName;
|
this.keyName = keyName;
|
||||||
|
@ -45,7 +46,7 @@ public abstract class AbstractPoiType {
|
||||||
|
|
||||||
public String getIconKeyName() {
|
public String getIconKeyName() {
|
||||||
String kn = getKeyName();
|
String kn = getKeyName();
|
||||||
if(kn.startsWith("osmand_")) {
|
if (kn.startsWith("osmand_")) {
|
||||||
kn = kn.substring("osmand_".length());
|
kn = kn.substring("osmand_".length());
|
||||||
}
|
}
|
||||||
return kn.replace(':', '_');
|
return kn.replace(':', '_');
|
||||||
|
@ -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() {
|
public List<PoiType> getPoiAdditionals() {
|
||||||
if (poiAdditionals == null) {
|
if (poiAdditionals == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
@ -119,6 +131,17 @@ public abstract class AbstractPoiType {
|
||||||
this.poiAdditionalCategory = poiAdditionalCategory;
|
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);
|
public abstract Map<PoiCategory, LinkedHashSet<String>> putTypes(Map<PoiCategory, LinkedHashSet<String>> acceptedTypes);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -23,7 +23,9 @@ import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
|
||||||
public class MapPoiTypes {
|
public class MapPoiTypes {
|
||||||
|
@ -265,6 +267,8 @@ public class MapPoiTypes {
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
List<PoiType> referenceTypes = new ArrayList<PoiType>();
|
List<PoiType> referenceTypes = new ArrayList<PoiType>();
|
||||||
final Map<String, PoiType> allTypes = new LinkedHashMap<String, 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) {
|
if (resourceName != null) {
|
||||||
this.resourceName = resourceName;
|
this.resourceName = resourceName;
|
||||||
}
|
}
|
||||||
|
@ -280,8 +284,11 @@ public class MapPoiTypes {
|
||||||
int tok;
|
int tok;
|
||||||
parser.setInput(is, "UTF-8");
|
parser.setInput(is, "UTF-8");
|
||||||
PoiCategory lastCategory = null;
|
PoiCategory lastCategory = null;
|
||||||
|
Set<String> lastCategoryPoiAdditionalsCategories = new TreeSet<>();
|
||||||
PoiFilter lastFilter = null;
|
PoiFilter lastFilter = null;
|
||||||
|
Set<String> lastFilterPoiAdditionalsCategories = new TreeSet<>();
|
||||||
PoiType lastType = null;
|
PoiType lastType = null;
|
||||||
|
Set<String> lastTypePoiAdditionalsCategories = new TreeSet<>();
|
||||||
String lastPoiAdditionalCategory = null;
|
String lastPoiAdditionalCategory = null;
|
||||||
while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
|
while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
|
||||||
if (tok == XmlPullParser.START_TAG) {
|
if (tok == XmlPullParser.START_TAG) {
|
||||||
|
@ -291,11 +298,26 @@ public class MapPoiTypes {
|
||||||
lastCategory.setTopVisible(Boolean.parseBoolean(parser.getAttributeValue("", "top")));
|
lastCategory.setTopVisible(Boolean.parseBoolean(parser.getAttributeValue("", "top")));
|
||||||
lastCategory.setNotEditableOsm("true".equals(parser.getAttributeValue("", "no_edit")));
|
lastCategory.setNotEditableOsm("true".equals(parser.getAttributeValue("", "no_edit")));
|
||||||
lastCategory.setDefaultTag(parser.getAttributeValue("", "default_tag"));
|
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);
|
categories.add(lastCategory);
|
||||||
} else if (name.equals("poi_filter")) {
|
} else if (name.equals("poi_filter")) {
|
||||||
PoiFilter tp = new PoiFilter(this, lastCategory, parser.getAttributeValue("", "name"));
|
PoiFilter tp = new PoiFilter(this, lastCategory, parser.getAttributeValue("", "name"));
|
||||||
tp.setTopVisible(Boolean.parseBoolean(parser.getAttributeValue("", "top")));
|
tp.setTopVisible(Boolean.parseBoolean(parser.getAttributeValue("", "top")));
|
||||||
lastFilter = tp;
|
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);
|
lastCategory.addPoiType(tp);
|
||||||
} else if (name.equals("poi_reference")) {
|
} else if (name.equals("poi_reference")) {
|
||||||
PoiType tp = new PoiType(this, lastCategory, parser.getAttributeValue("", "name"));
|
PoiType tp = new PoiType(this, lastCategory, parser.getAttributeValue("", "name"));
|
||||||
|
@ -316,6 +338,14 @@ public class MapPoiTypes {
|
||||||
}
|
}
|
||||||
parsePoiAdditional(parser, lastCategory, lastFilter, lastType, "en", baseType, lastPoiAdditionalCategory);
|
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")) {
|
} else if (name.equals("poi_additional_category")) {
|
||||||
if (lastPoiAdditionalCategory == null) {
|
if (lastPoiAdditionalCategory == null) {
|
||||||
|
@ -341,16 +371,36 @@ public class MapPoiTypes {
|
||||||
parsePoiType(allTypes, parser, lastCategory, lastFilter, lng, lastType);
|
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) {
|
} else if (tok == XmlPullParser.END_TAG) {
|
||||||
String name = parser.getName();
|
String name = parser.getName();
|
||||||
if (name.equals("poi_filter")) {
|
if (name.equals("poi_filter")) {
|
||||||
|
if (lastFilterPoiAdditionalsCategories.size() > 0) {
|
||||||
|
abstractTypeAdditionalCategories.put(lastFilter, lastFilterPoiAdditionalsCategories);
|
||||||
|
lastFilterPoiAdditionalsCategories = new TreeSet<>();
|
||||||
|
}
|
||||||
lastFilter = null;
|
lastFilter = null;
|
||||||
} else if (name.equals("poi_type")) {
|
} else if (name.equals("poi_type")) {
|
||||||
|
if (lastTypePoiAdditionalsCategories.size() > 0) {
|
||||||
|
abstractTypeAdditionalCategories.put(lastType, lastTypePoiAdditionalsCategories);
|
||||||
|
lastTypePoiAdditionalsCategories = new TreeSet<>();
|
||||||
|
}
|
||||||
lastType = null;
|
lastType = null;
|
||||||
} else if (name.equals("poi_category")) {
|
} else if (name.equals("poi_category")) {
|
||||||
|
if (lastCategoryPoiAdditionalsCategories.size() > 0) {
|
||||||
|
abstractTypeAdditionalCategories.put(lastCategory, lastCategoryPoiAdditionalsCategories);
|
||||||
|
lastCategoryPoiAdditionalsCategories = new TreeSet<>();
|
||||||
|
}
|
||||||
lastCategory = null;
|
lastCategory = null;
|
||||||
} else if (name.equals("poi_additional_category")) {
|
} else if (name.equals("poi_additional_category")) {
|
||||||
lastPoiAdditionalCategory = null;
|
lastPoiAdditionalCategory = null;
|
||||||
|
@ -379,6 +429,14 @@ public class MapPoiTypes {
|
||||||
gt.setReferenceType(pt);
|
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();
|
findDefaultOtherCategory();
|
||||||
init = true;
|
init = true;
|
||||||
log.info("Time to init poi types " + (System.currentTimeMillis() - time)); //$NON-NLS-1$
|
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
|
<ImageView
|
||||||
android:id="@+id/icon"
|
android:id="@+id/icon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="24dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="24dp"
|
||||||
android:src="@drawable/ic_action_search_dark"/>
|
android:src="@drawable/ic_action_search_dark"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -98,10 +98,11 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/divider"
|
android:id="@+id/item_divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:layout_marginLeft="54dp"
|
android:layout_marginLeft="54dp"
|
||||||
|
android:layout_marginStart="54dp"
|
||||||
android:background="?attr/dashboard_divider"/>
|
android:background="?attr/dashboard_divider"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -393,8 +393,14 @@ public abstract class OsmandPlugin {
|
||||||
}
|
}
|
||||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||||
if (!(plugin instanceof ParkingPositionPlugin) && !(plugin instanceof OsmandMonitoringPlugin)) {
|
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);
|
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() {
|
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
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()
|
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||||
.getSearchActivity());
|
.getSearchActivity());
|
||||||
LatLon loc = mapActivity.getMapLocation();
|
LatLon loc = mapActivity.getMapLocation();
|
||||||
|
@ -638,6 +640,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}
|
}
|
||||||
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
mapActivity.startActivity(newIntent);
|
mapActivity.startActivity(newIntent);
|
||||||
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}).createItem());
|
}).createItem());
|
||||||
|
|
|
@ -19,8 +19,10 @@ import android.widget.ArrayAdapter;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.osm.PoiCategory;
|
import net.osmand.osm.PoiCategory;
|
||||||
import net.osmand.osm.PoiType;
|
import net.osmand.osm.PoiType;
|
||||||
import net.osmand.plus.IconsCache;
|
import net.osmand.plus.IconsCache;
|
||||||
|
@ -204,7 +206,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
|
|
||||||
CategoryListAdapter(OsmandApplication app, List<PoiCategory> items) {
|
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;
|
this.app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +216,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
View row = convertView;
|
View row = convertView;
|
||||||
if (row == null) {
|
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);
|
PoiCategory category = getItem(position);
|
||||||
if (category != null) {
|
if (category != null) {
|
||||||
|
@ -350,6 +352,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setPositiveButton(getContext().getText(R.string.shared_string_apply), new DialogInterface.OnClickListener() {
|
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.AndroidUtils;
|
||||||
import net.osmand.osm.MapPoiTypes;
|
import net.osmand.osm.MapPoiTypes;
|
||||||
|
import net.osmand.osm.PoiCategory;
|
||||||
import net.osmand.osm.PoiType;
|
import net.osmand.osm.PoiType;
|
||||||
import net.osmand.plus.IconsCache;
|
import net.osmand.plus.IconsCache;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
@ -37,6 +38,7 @@ import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||||
import net.osmand.plus.poi.PoiUIFilter;
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
|
import net.osmand.plus.render.RenderingIcons;
|
||||||
import net.osmand.plus.widgets.TextViewEx;
|
import net.osmand.plus.widgets.TextViewEx;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
@ -44,6 +46,7 @@ import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
@ -426,12 +429,14 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
||||||
filterByName = filterByName.replaceAll(keyNameOpen24, "");
|
filterByName = filterByName.replaceAll(keyNameOpen24, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MapPoiTypes poiTypes = app.getPoiTypes();
|
||||||
Map<String, PoiType> poiAdditionals = filter.getPoiAdditionals();
|
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) {
|
if (poiAdditionals != null) {
|
||||||
Map<String, Set<String>> additionalsMap = new TreeMap<>();
|
Map<String, Set<String>> additionalsMap = new TreeMap<>();
|
||||||
extractPoiAdditionals(poiAdditionals.values(), additionalsMap, true);
|
extractPoiAdditionals(poiAdditionals.values(), additionalsMap, excludedPoiAdditionalCategories, true);
|
||||||
extractPoiAdditionals(otherAdditionalCategories, additionalsMap, true);
|
extractPoiAdditionals(otherAdditionalCategories, additionalsMap, excludedPoiAdditionalCategories, true);
|
||||||
|
|
||||||
if (additionalsMap.size() > 0) {
|
if (additionalsMap.size() > 0) {
|
||||||
for (Entry<String, Set<String>> entry : additionalsMap.entrySet()) {
|
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() {
|
private List<PoiFilterListItem> getListItems() {
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
MapPoiTypes poiTypes = app.getPoiTypes();
|
MapPoiTypes poiTypes = app.getPoiTypes();
|
||||||
|
@ -468,11 +491,12 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
||||||
selectedPoiAdditionals.contains(keyNameOpen24), null, keyNameOpen24));
|
selectedPoiAdditionals.contains(keyNameOpen24), null, keyNameOpen24));
|
||||||
|
|
||||||
Map<String, PoiType> poiAdditionals = filter.getPoiAdditionals();
|
Map<String, PoiType> poiAdditionals = filter.getPoiAdditionals();
|
||||||
|
Set<String> excludedPoiAdditionalCategories = getExcludedPoiAdditionalCategories();
|
||||||
List<PoiType> otherAdditionalCategories = poiTypes.getOtherMapCategory().getPoiAdditionalsCategorized();
|
List<PoiType> otherAdditionalCategories = poiTypes.getOtherMapCategory().getPoiAdditionalsCategorized();
|
||||||
if (poiAdditionals != null) {
|
if (poiAdditionals != null) {
|
||||||
Map<String, Set<String>> additionalsMap = new TreeMap<>();
|
Map<String, Set<String>> additionalsMap = new TreeMap<>();
|
||||||
extractPoiAdditionals(poiAdditionals.values(), additionalsMap, false);
|
extractPoiAdditionals(poiAdditionals.values(), additionalsMap, excludedPoiAdditionalCategories, false);
|
||||||
extractPoiAdditionals(otherAdditionalCategories, additionalsMap, false);
|
extractPoiAdditionals(otherAdditionalCategories, additionalsMap, excludedPoiAdditionalCategories, false);
|
||||||
|
|
||||||
if (additionalsMap.size() > 0) {
|
if (additionalsMap.size() > 0) {
|
||||||
for (Entry<String, Set<String>> entry : additionalsMap.entrySet()) {
|
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));
|
items.add(new PoiFilterListItem(PoiFilterListItemType.DIVIDER, 0, null, -1, false, false, false, null, null));
|
||||||
|
|
||||||
String categoryIconStr = poiTypes.getPoiAdditionalCategoryIcon(category);
|
String categoryIconStr = poiTypes.getPoiAdditionalCategoryIcon(category);
|
||||||
int categoryIconId = 0;
|
int categoryIconId;
|
||||||
if (!Algorithms.isEmpty(categoryIconStr)) {
|
if (!Algorithms.isEmpty(categoryIconStr)) {
|
||||||
categoryIconId = getResources().getIdentifier(categoryIconStr, "drawable", app.getPackageName());
|
categoryIconId = getResources().getIdentifier(categoryIconStr, "drawable", app.getPackageName());
|
||||||
|
} else {
|
||||||
|
categoryIconId = RenderingIcons.getBigIconResourceId(category);
|
||||||
}
|
}
|
||||||
if (categoryIconId == 0) {
|
if (categoryIconId == 0) {
|
||||||
categoryIconId = R.drawable.ic_action_folder_stroke;
|
categoryIconId = R.drawable.ic_action_folder_stroke;
|
||||||
|
@ -510,21 +536,38 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
||||||
return items;
|
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) {
|
for (PoiType poiType : poiAdditionals) {
|
||||||
String category = poiType.getPoiAdditionalCategory();
|
String category = poiType.getPoiAdditionalCategory();
|
||||||
if (category == null) {
|
if (category == null) {
|
||||||
category = "";
|
category = "";
|
||||||
}
|
}
|
||||||
|
if (excludedPoiAdditionalCategories != null && excludedPoiAdditionalCategories.contains(category)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (collapsedCategories.contains(category) && !extractAll) {
|
if (collapsedCategories.contains(category) && !extractAll) {
|
||||||
if (!additionalsMap.containsKey(category)) {
|
if (!additionalsMap.containsKey(category)) {
|
||||||
additionalsMap.put(category, new TreeSet<String>());
|
additionalsMap.put(category, new TreeSet<String>());
|
||||||
}
|
}
|
||||||
|
topTrueOnlyCategories.remove(category);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean showAll = showAllCategories.contains(category) || extractAll;
|
boolean showAll = showAllCategories.contains(category) || extractAll;
|
||||||
String name = poiType.getTranslation();
|
String name = poiType.getTranslation();
|
||||||
String keyName = name.replace(' ', ':').toLowerCase();
|
String keyName = name.replace(' ', ':').toLowerCase();
|
||||||
|
if (!poiType.isTopVisible()) {
|
||||||
|
topTrueOnlyCategories.remove(category);
|
||||||
|
}
|
||||||
if (showAll || poiType.isTopVisible() || selectedPoiAdditionals.contains(keyName)) {
|
if (showAll || poiType.isTopVisible() || selectedPoiAdditionals.contains(keyName)) {
|
||||||
Set<String> adds = additionalsMap.get(category);
|
Set<String> adds = additionalsMap.get(category);
|
||||||
if (adds == null) {
|
if (adds == null) {
|
||||||
|
@ -534,6 +577,11 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
||||||
adds.add(name);
|
adds.add(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (String category : topTrueOnlyCategories) {
|
||||||
|
if (!showAllCategories.contains(category)) {
|
||||||
|
showAllCategories.add(category);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showDialog(DialogFragment parentFragment, String filterByName, String filterId) {
|
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 SwitchCompat switchItem = (SwitchCompat) view.findViewById(R.id.switchItem);
|
||||||
final CheckBox checkBoxItem = (CheckBox) view.findViewById(R.id.checkboxItem);
|
final CheckBox checkBoxItem = (CheckBox) view.findViewById(R.id.checkboxItem);
|
||||||
final ImageView expandItem = (ImageView) view.findViewById(R.id.expandItem);
|
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 (item != null) {
|
||||||
if (nextItem != null && nextItem.groupIndex == item.groupIndex) {
|
if (nextItem != null && nextItem.groupIndex == item.groupIndex) {
|
||||||
|
@ -641,8 +689,10 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
||||||
} else {
|
} else {
|
||||||
divider.setVisibility(View.GONE);
|
divider.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.iconId != 0) {
|
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);
|
icon.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
icon.setVisibility(View.GONE);
|
icon.setVisibility(View.GONE);
|
||||||
|
|
|
@ -31,7 +31,6 @@ import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.QuadRect;
|
import net.osmand.data.QuadRect;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.data.TransportStop;
|
import net.osmand.data.TransportStop;
|
||||||
import net.osmand.osm.MapPoiTypes;
|
|
||||||
import net.osmand.osm.PoiCategory;
|
import net.osmand.osm.PoiCategory;
|
||||||
import net.osmand.osm.PoiFilter;
|
import net.osmand.osm.PoiFilter;
|
||||||
import net.osmand.osm.PoiType;
|
import net.osmand.osm.PoiType;
|
||||||
|
@ -601,7 +600,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
names.add(entry.getValue());
|
names.add(entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Amenity amenity = findAmenity(renderedObject.getId() >> 6, names,
|
Amenity amenity = findAmenity(renderedObject.getId() >> 7, names,
|
||||||
latLon.getLatitude(), latLon.getLongitude());
|
latLon.getLatitude(), latLon.getLongitude());
|
||||||
if (amenity != null) {
|
if (amenity != null) {
|
||||||
selectedObjects.put(amenity, poiMenuProvider);
|
selectedObjects.put(amenity, poiMenuProvider);
|
||||||
|
@ -610,7 +609,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
TransportStop nearestTransportStop = findNearestTransportStop(latLon.getLatitude(), latLon.getLongitude());
|
TransportStop nearestTransportStop = findNearestTransportStop(latLon.getLatitude(), latLon.getLongitude());
|
||||||
if (nearestTransportStop != null) {
|
if (nearestTransportStop != null) {
|
||||||
selectedObjects.put(nearestTransportStop, transportStopMenuProvider);
|
selectedObjects.put(nearestTransportStop, transportStopMenuProvider);
|
||||||
continue;
|
//continue;
|
||||||
}
|
}
|
||||||
if (renderedObject.getX() != null && renderedObject.getX().size() > 1
|
if (renderedObject.getX() != null && renderedObject.getX().size() > 1
|
||||||
&& renderedObject.getY() != null && renderedObject.getY().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) {
|
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(
|
List<Amenity> amenities = activity.getMyApplication().getResourceManager().searchAmenities(
|
||||||
new BinaryMapIndexReader.SearchPoiTypeFilter() {
|
new BinaryMapIndexReader.SearchPoiTypeFilter() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -656,22 +655,12 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
Amenity res = null;
|
Amenity res = null;
|
||||||
for (Amenity amenity : amenities) {
|
for (Amenity amenity : amenities) {
|
||||||
Long amenityId = amenity.getId();
|
Long amenityId = amenity.getId() >> 1;
|
||||||
if (amenityId != null && amenityId == id) {
|
if (amenityId == id) {
|
||||||
res = amenity;
|
res = amenity;
|
||||||
break;
|
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) {
|
if (res == null && names != null && names.size() > 0) {
|
||||||
for (Amenity amenity : amenities) {
|
for (Amenity amenity : amenities) {
|
||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
|
@ -695,7 +684,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private TransportStop findTransportStop(long id, double lat, double lon) {
|
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()
|
List<TransportStop> res = activity.getMyApplication().getResourceManager()
|
||||||
.searchTransportSync(rect.top, rect.left, rect.bottom, rect.right,
|
.searchTransportSync(rect.top, rect.left, rect.bottom, rect.right,
|
||||||
new ResultMatcher<TransportStop>() {
|
new ResultMatcher<TransportStop>() {
|
||||||
|
|
Loading…
Reference in a new issue