Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
800399b8f3
16 changed files with 382 additions and 226 deletions
|
@ -205,7 +205,7 @@ public class BinaryMapPoiReaderAdapter {
|
||||||
case OsmandOdb.OsmAndCategoryTable.CATEGORY_FIELD_NUMBER :
|
case OsmandOdb.OsmAndCategoryTable.CATEGORY_FIELD_NUMBER :
|
||||||
String cat = codedIS.readString().intern();
|
String cat = codedIS.readString().intern();
|
||||||
region.categories.add(cat);
|
region.categories.add(cat);
|
||||||
region.categoriesType.add(poiTypes.getPoiCategoryByName(cat));
|
region.categoriesType.add(poiTypes.getPoiCategoryByName(cat.toLowerCase()));
|
||||||
region.subcategories.add(new ArrayList<String>());
|
region.subcategories.add(new ArrayList<String>());
|
||||||
break;
|
break;
|
||||||
case OsmandOdb.OsmAndCategoryTable.SUBCATEGORIES_FIELD_NUMBER :
|
case OsmandOdb.OsmAndCategoryTable.SUBCATEGORIES_FIELD_NUMBER :
|
||||||
|
|
|
@ -1,21 +1,18 @@
|
||||||
package net.osmand.osm;
|
package net.osmand.osm;
|
||||||
|
|
||||||
public class AbstractPoiType {
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public abstract class AbstractPoiType {
|
||||||
|
|
||||||
protected final String keyName;
|
protected final String keyName;
|
||||||
protected final MapPoiTypes registry;
|
protected final MapPoiTypes registry;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public AbstractPoiType(String keyName, MapPoiTypes registry) {
|
public AbstractPoiType(String keyName, MapPoiTypes registry) {
|
||||||
this.keyName = keyName;
|
this.keyName = keyName;
|
||||||
this.registry = registry;
|
this.registry = registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return keyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKeyName() {
|
public String getKeyName() {
|
||||||
return keyName;
|
return keyName;
|
||||||
}
|
}
|
||||||
|
@ -24,5 +21,7 @@ public class AbstractPoiType {
|
||||||
return registry.getTranslation(this);
|
return registry.getTranslation(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract Map<PoiCategory, LinkedHashSet<String>> putTypes(Map<PoiCategory, LinkedHashSet<String>> acceptedTypes);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
|
import net.osmand.StringMatcher;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -97,11 +98,6 @@ public class MapPoiTypes {
|
||||||
return otherCategory;
|
return otherCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PoiCategory getPoiCategoryByName(String name) {
|
|
||||||
name = name.toLowerCase();
|
|
||||||
return getPoiCategoryByName(name, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PoiType getPoiTypeByKey(String name) {
|
public PoiType getPoiTypeByKey(String name) {
|
||||||
for(PoiCategory pc : categories) {
|
for(PoiCategory pc : categories) {
|
||||||
PoiType pt = pc.getPoiTypeByKeyName(name);
|
PoiType pt = pc.getPoiTypeByKeyName(name);
|
||||||
|
@ -125,6 +121,31 @@ public class MapPoiTypes {
|
||||||
return translation;
|
return translation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, AbstractPoiType> getAllTypesTranslatedNames(StringMatcher matcher) {
|
||||||
|
TreeMap<String, AbstractPoiType> tm = new TreeMap<String, AbstractPoiType>(Collator.getInstance());
|
||||||
|
Map<String, PoiType> translation = new TreeMap<String, PoiType>();
|
||||||
|
for(PoiCategory pc : categories) {
|
||||||
|
addIf(tm, pc, matcher);
|
||||||
|
for(PoiFilter pt : pc.getPoiFilters()) {
|
||||||
|
addIf(tm, pt, matcher);
|
||||||
|
}
|
||||||
|
for(PoiType pt : pc.getPoiTypes()) {
|
||||||
|
if(pt.isReference()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
addIf(tm, pt, matcher);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tm;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addIf(Map<String, AbstractPoiType> tm, AbstractPoiType pc, StringMatcher matcher) {
|
||||||
|
if(matcher.matches(pc.getTranslation()) || matcher.matches(pc.getKeyName().replace('_', ' '))) {
|
||||||
|
tm.put(pc.getTranslation(), pc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Map<String, PoiType> getAllTranslatedNames(PoiCategory pc, boolean onlyTranslation) {
|
public Map<String, PoiType> getAllTranslatedNames(PoiCategory pc, boolean onlyTranslation) {
|
||||||
Map<String, PoiType> translation = new TreeMap<String, PoiType>();
|
Map<String, PoiType> translation = new TreeMap<String, PoiType>();
|
||||||
for (PoiType pt : pc.getPoiTypes()) {
|
for (PoiType pt : pc.getPoiTypes()) {
|
||||||
|
@ -137,12 +158,19 @@ public class MapPoiTypes {
|
||||||
return translation;
|
return translation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PoiCategory getPoiCategoryByName(String name) {
|
||||||
|
return getPoiCategoryByName(name, false);
|
||||||
|
}
|
||||||
|
|
||||||
public PoiCategory getPoiCategoryByName(String name, boolean create) {
|
public PoiCategory getPoiCategoryByName(String name, boolean create) {
|
||||||
if(name.equals("entertainment") && !create) {
|
if(name.equals("leisure") && !create) {
|
||||||
name = "leisure";
|
name = "entertainment";
|
||||||
|
}
|
||||||
|
if(name.equals("historic") && !create) {
|
||||||
|
name = "tourism";
|
||||||
}
|
}
|
||||||
for(PoiCategory p : categories ) {
|
for(PoiCategory p : categories ) {
|
||||||
if(p.getName().equals(name) || p.getKey().equalsIgnoreCase(name)) {
|
if(p.getKeyName().equalsIgnoreCase(name)) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,9 +293,9 @@ public class MapPoiTypes {
|
||||||
private static void print(MapPoiTypes df) {
|
private static void print(MapPoiTypes df) {
|
||||||
List<PoiCategory> pc = df.getCategories();
|
List<PoiCategory> pc = df.getCategories();
|
||||||
for(PoiCategory p : pc) {
|
for(PoiCategory p : pc) {
|
||||||
System.out.println("Category " + p.getName());
|
System.out.println("Category " + p.getKeyName());
|
||||||
for(PoiFilter f : p.getPoiFilters()) {
|
for(PoiFilter f : p.getPoiFilters()) {
|
||||||
System.out.println(" Filter " + f.getName());
|
System.out.println(" Filter " + f.getKeyName());
|
||||||
print(" ", f);
|
print(" ", f);
|
||||||
}
|
}
|
||||||
print(" ", p);
|
print(" ", p);
|
||||||
|
@ -277,8 +305,8 @@ public class MapPoiTypes {
|
||||||
|
|
||||||
private static void print(String indent, PoiFilter f) {
|
private static void print(String indent, PoiFilter f) {
|
||||||
for(PoiType pt : f.getPoiTypes()) {
|
for(PoiType pt : f.getPoiTypes()) {
|
||||||
System.out.println(indent + " Type " + pt.getName() +
|
System.out.println(indent + " Type " + pt.getKeyName() +
|
||||||
(pt.isReference() ? (" -> " + pt.getReferenceType().getCategory().getKey() ): ""));
|
(pt.isReference() ? (" -> " + pt.getReferenceType().getCategory().getKeyName() ): ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +333,7 @@ public class MapPoiTypes {
|
||||||
return translation;
|
return translation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Algorithms.capitalizeFirstLetterAndLowercase(abstractPoiType.getName().replace('_', ' '));
|
return Algorithms.capitalizeFirstLetterAndLowercase(abstractPoiType.getKeyName().replace('_', ' '));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,9 +48,6 @@ public class PoiCategory extends PoiFilter {
|
||||||
return keyName.equals(MapPoiTypes.OSM_WIKI_CATEGORY);
|
return keyName.equals(MapPoiTypes.OSM_WIKI_CATEGORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKey() {
|
|
||||||
return keyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int ordinal() {
|
public int ordinal() {
|
||||||
return regId;
|
return regId;
|
||||||
|
|
|
@ -27,15 +27,15 @@ public class PoiFilter extends AbstractPoiType {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPoiType(PoiType type) {
|
public void addPoiType(PoiType type) {
|
||||||
if(!map.containsKey(type.getName())) {
|
if(!map.containsKey(type.getKeyName())) {
|
||||||
poiTypes.add(type);
|
poiTypes.add(type);
|
||||||
map.put(type.getName(), type);
|
map.put(type.getKeyName(), type);
|
||||||
} else {
|
} else {
|
||||||
PoiType prev = map.get(type.getName());
|
PoiType prev = map.get(type.getKeyName());
|
||||||
if(prev.isReference()) {
|
if(prev.isReference()) {
|
||||||
poiTypes.remove(prev);
|
poiTypes.remove(prev);
|
||||||
poiTypes.add(type);
|
poiTypes.add(type);
|
||||||
map.put(type.getName(), type);
|
map.put(type.getKeyName(), type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,10 +71,6 @@ public class PoiFilter extends AbstractPoiType {
|
||||||
return poiTypes;
|
return poiTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return keyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTopVisible(boolean topVisible) {
|
public void setTopVisible(boolean topVisible) {
|
||||||
this.topVisible = topVisible;
|
this.topVisible = topVisible;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package net.osmand.osm;
|
package net.osmand.osm;
|
||||||
|
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class PoiType extends AbstractPoiType {
|
public class PoiType extends AbstractPoiType {
|
||||||
|
|
||||||
private PoiCategory category;
|
private PoiCategory category;
|
||||||
|
@ -74,5 +77,17 @@ public class PoiType extends AbstractPoiType {
|
||||||
return category;
|
return category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<PoiCategory, LinkedHashSet<String>> putTypes(Map<PoiCategory, LinkedHashSet<String>> acceptedTypes) {
|
||||||
|
PoiType rt = getReferenceType();
|
||||||
|
PoiType poiType = rt != null ? rt : this;
|
||||||
|
if (!acceptedTypes.containsKey(poiType.category)) {
|
||||||
|
acceptedTypes.put(poiType.category, new LinkedHashSet<String>());
|
||||||
|
}
|
||||||
|
LinkedHashSet<String> set = acceptedTypes.get(poiType.category);
|
||||||
|
if(set != null) {
|
||||||
|
set.add(poiType.getKeyName());
|
||||||
|
}
|
||||||
|
return acceptedTypes;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,44 +3,67 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical" >
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/SearchFilterLayout"
|
android:id="@+id/SearchFilterLayout"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="5dp"
|
||||||
android:orientation="horizontal"
|
android:visibility="gone"
|
||||||
android:visibility="gone">
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
<TextView
|
<ImageView
|
||||||
android:id="@+id/TextView"
|
android:id="@+id/search_icon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="@dimen/standard_icon_size"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/standard_icon_size"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:layout_gravity="center_vertical"
|
||||||
tools:text="@string/lorem_ipsum"
|
android:layout_marginRight="8dp"
|
||||||
android:text="@string/search_poi_filter" />
|
android:src="@android:drawable/ic_search_category_default" />
|
||||||
|
|
||||||
|
<!-- to not gain focus everytime -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0px"
|
||||||
|
android:layout_height="0px"
|
||||||
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/SearchFilter"
|
android:id="@+id/edit"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_gravity="bottom"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="@dimen/list_content_padding"
|
||||||
android:text="" />
|
android:layout_weight="1"
|
||||||
|
android:hint="@string/shared_string_search"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:nextFocusLeft="@id/edit"
|
||||||
|
android:nextFocusUp="@id/edit"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
|
tools:text="@string/lorem_ipsum" >
|
||||||
|
</EditText>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/options"
|
||||||
|
android:layout_width="@dimen/list_item_height"
|
||||||
|
android:layout_height="@dimen/list_item_height"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:background="?attr/dashboard_button"
|
||||||
|
android:scaleType="center"
|
||||||
|
android:src="?attr/ic_action_overflow" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@android:id/list"
|
android:id="@android:id/list"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"/>
|
android:layout_weight="1" />
|
||||||
|
|
||||||
<net.osmand.plus.activities.search.toolbar.SplitToolbar
|
<net.osmand.plus.activities.search.toolbar.SplitToolbar
|
||||||
android:orientation="horizontal"
|
android:id="@+id/poiSplitbar"
|
||||||
android:background="?attr/bottomToolBarColor"
|
|
||||||
android:id="@+id/bottomControls"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/bottomToolBarColor"
|
||||||
|
android:orientation="horizontal" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -7,7 +7,9 @@
|
||||||
android:minHeight="@dimen/list_item_height"
|
android:minHeight="@dimen/list_item_height"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingLeft="@dimen/list_content_padding"
|
android:paddingLeft="@dimen/list_content_padding"
|
||||||
android:paddingRight="@dimen/list_content_padding" >
|
android:paddingRight="@dimen/list_content_padding"
|
||||||
|
android:descendantFocusability="blocksDescendants"
|
||||||
|
>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/poi_icon"
|
android:id="@+id/poi_icon"
|
||||||
|
|
|
@ -6,15 +6,13 @@
|
||||||
android:minHeight="@dimen/list_item_height"
|
android:minHeight="@dimen/list_item_height"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:background="?attr/expandable_list_item_background"
|
android:background="?attr/expandable_list_item_background"
|
||||||
android:paddingLeft="@dimen/list_content_padding"
|
android:paddingLeft="@dimen/list_content_padding">
|
||||||
android:paddingRight="@dimen/list_content_padding">
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/folder_icon"
|
android:id="@+id/folder_icon"
|
||||||
android:layout_width="@dimen/standard_icon_size"
|
android:layout_width="@dimen/standard_icon_size"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_height="@dimen/standard_icon_size"
|
android:layout_height="@dimen/standard_icon_size"
|
||||||
android:layout_marginLeft="8dp"
|
|
||||||
android:layout_marginRight="8dp"/>
|
android:layout_marginRight="8dp"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -26,14 +24,16 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
tools:text="@string/lorem_ipsum"/>
|
tools:text="@string/lorem_ipsum"
|
||||||
|
android:layout_marginRight="@dimen/list_content_padding"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/folder_edit_icon"
|
android:id="@+id/options"
|
||||||
android:layout_width="@dimen/list_item_height"
|
android:layout_width="@dimen/list_item_height"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_height="@dimen/list_item_height"
|
android:layout_height="@dimen/list_item_height"
|
||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
|
android:visibility="gone"
|
||||||
android:background="?attr/dashboard_button"
|
android:background="?attr/dashboard_button"
|
||||||
android:src="@drawable/ic_action_filter_dark" />
|
android:src="?attr/ic_action_overflow" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||||
-->
|
-->
|
||||||
<string name="agps_info">A-GPS info</string>
|
<string name="agps_info">A-GPS info</string>
|
||||||
|
<string name="shared_string_search">Search</string>
|
||||||
<string name="shared_string_show_description">Show description</string>
|
<string name="shared_string_show_description">Show description</string>
|
||||||
<string name="shared_string_message">Message</string>
|
<string name="shared_string_message">Message</string>
|
||||||
<string name="agps_data_last_downloaded">A-GPS data last downloaded: %1$s</string>
|
<string name="agps_data_last_downloaded">A-GPS data last downloaded: %1$s</string>
|
||||||
|
|
|
@ -183,18 +183,13 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
||||||
updateSelectionMode(actionMode);
|
updateSelectionMode(actionMode);
|
||||||
} else {
|
} else {
|
||||||
final FavouritePoint point = (FavouritePoint) favouritesAdapter.getChild(groupPosition, childPosition);
|
final FavouritePoint point = (FavouritePoint) favouritesAdapter.getChild(groupPosition, childPosition);
|
||||||
|
|
||||||
ContextMenuAdapter qa = new ContextMenuAdapter(v.getContext());
|
|
||||||
qa.setAnchor(v);
|
|
||||||
final OsmandSettings settings = getMyApplication().getSettings();
|
final OsmandSettings settings = getMyApplication().getSettings();
|
||||||
|
|
||||||
LatLon location = new LatLon(point.getLatitude(), point.getLongitude());
|
LatLon location = new LatLon(point.getLatitude(), point.getLongitude());
|
||||||
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
|
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
|
||||||
DirectionsDialogs.createDirectionActionsPopUpMenu(optionsMenu, location, point,
|
DirectionsDialogs.createDirectionActionsPopUpMenu(optionsMenu, location, point,
|
||||||
new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName()), settings.getLastKnownMapZoom(),
|
new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName()), settings.getLastKnownMapZoom(),
|
||||||
getActivity(), true, false);
|
getActivity(), true, false);
|
||||||
|
|
||||||
boolean light = getMyApplication().getSettings().isLightContent();
|
|
||||||
MenuItem item = optionsMenu.getMenu().add(R.string.favourites_context_menu_edit)
|
MenuItem item = optionsMenu.getMenu().add(R.string.favourites_context_menu_edit)
|
||||||
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_edit_dark));
|
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_edit_dark));
|
||||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
|
|
|
@ -255,26 +255,14 @@ public class MapActivityLayers {
|
||||||
|
|
||||||
|
|
||||||
public AlertDialog selectPOIFilterLayer(final OsmandMapTileView mapView, final PoiLegacyFilter[] selected){
|
public AlertDialog selectPOIFilterLayer(final OsmandMapTileView mapView, final PoiLegacyFilter[] selected){
|
||||||
final List<PoiLegacyFilter> userDefined = new ArrayList<PoiLegacyFilter>();
|
OsmandApplication app = (OsmandApplication) getApplication();
|
||||||
OsmandApplication app = (OsmandApplication)getApplication();
|
|
||||||
final PoiFiltersHelper poiFilters = app.getPoiFilters();
|
final PoiFiltersHelper poiFilters = app.getPoiFilters();
|
||||||
final ContextMenuAdapter adapter = new ContextMenuAdapter(activity);
|
final ContextMenuAdapter adapter = new ContextMenuAdapter(activity);
|
||||||
final List<PoiLegacyFilter> list = new ArrayList<PoiLegacyFilter>();
|
final List<PoiLegacyFilter> list = new ArrayList<PoiLegacyFilter>();
|
||||||
for (PoiLegacyFilter f : poiFilters.getTopDefinedPoiFilters()) {
|
for (PoiLegacyFilter f : poiFilters.getTopDefinedPoiFilters()) {
|
||||||
if(PoiLegacyFilter.BY_NAME_FILTER_ID.equals(f.getFilterId()) ||
|
addFilterToList(adapter, list, f);
|
||||||
PoiLegacyFilter.NAME_FINDER_FILTER_ID.equals(f.getFilterId())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
list.add(f);
|
|
||||||
Item it = adapter.item(f.getName());
|
|
||||||
if (RenderingIcons.containsBigIcon(f.getSimplifiedId())) {
|
|
||||||
it.icon(RenderingIcons.getBigIconResourceId(f.getSimplifiedId()));
|
|
||||||
} else {
|
|
||||||
it.icon(RenderingIcons.getBigIconResourceId("user_defined"));
|
|
||||||
}
|
|
||||||
it.reg();
|
|
||||||
userDefined.add(f);
|
|
||||||
}
|
}
|
||||||
|
addFilterToList(adapter, list, poiFilters.getCustomPOIFilter());
|
||||||
Builder builder = new AlertDialog.Builder(activity);
|
Builder builder = new AlertDialog.Builder(activity);
|
||||||
ListAdapter listAdapter = adapter.createListAdapter(activity, app.getSettings().isLightContent());
|
ListAdapter listAdapter = adapter.createListAdapter(activity, app.getSettings().isLightContent());
|
||||||
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener(){
|
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener(){
|
||||||
|
@ -309,6 +297,17 @@ public class MapActivityLayers {
|
||||||
return builder.show();
|
return builder.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addFilterToList(final ContextMenuAdapter adapter, final List<PoiLegacyFilter> list, PoiLegacyFilter f) {
|
||||||
|
list.add(f);
|
||||||
|
Item it = adapter.item(f.getName());
|
||||||
|
if (RenderingIcons.containsBigIcon(f.getSimplifiedId())) {
|
||||||
|
it.icon(RenderingIcons.getBigIconResourceId(f.getSimplifiedId()));
|
||||||
|
} else {
|
||||||
|
it.icon(RenderingIcons.getBigIconResourceId("user_defined"));
|
||||||
|
}
|
||||||
|
it.reg();
|
||||||
|
}
|
||||||
|
|
||||||
public void selectMapLayer(final OsmandMapTileView mapView){
|
public void selectMapLayer(final OsmandMapTileView mapView){
|
||||||
if(OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) == null) {
|
if(OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) == null) {
|
||||||
AccessibleToast.makeText(activity, R.string.map_online_plugin_is_not_installed, Toast.LENGTH_LONG).show();
|
AccessibleToast.makeText(activity, R.string.map_online_plugin_is_not_installed, Toast.LENGTH_LONG).show();
|
||||||
|
|
|
@ -25,10 +25,10 @@ import net.osmand.osm.PoiType;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
|
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
|
||||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
||||||
import net.osmand.plus.R.color;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.R.color;
|
||||||
import net.osmand.plus.activities.EditPOIFilterActivity;
|
import net.osmand.plus.activities.EditPOIFilterActivity;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.OsmandListActivity;
|
import net.osmand.plus.activities.OsmandListActivity;
|
||||||
|
@ -52,7 +52,6 @@ import android.graphics.drawable.Drawable;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.AsyncTask.Status;
|
import android.os.AsyncTask.Status;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.support.v4.view.MenuItemCompat;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
import android.support.v7.widget.PopupMenu;
|
import android.support.v7.widget.PopupMenu;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
|
@ -61,21 +60,17 @@ import android.text.SpannableString;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.text.util.Linkify;
|
import android.text.util.Linkify;
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MenuItem.OnMenuItemClickListener;
|
import android.view.MenuItem.OnMenuItemClickListener;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewGroup.LayoutParams;
|
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -104,7 +99,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
||||||
private net.osmand.Location location = null;
|
private net.osmand.Location location = null;
|
||||||
private Float heading = null;
|
private Float heading = null;
|
||||||
|
|
||||||
private Handler uiHandler;
|
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
|
|
||||||
private float width = 24;
|
private float width = 24;
|
||||||
|
@ -116,12 +110,10 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
||||||
private MenuItem showFilterItem;
|
private MenuItem showFilterItem;
|
||||||
private MenuItem showOnMapItem;
|
private MenuItem showOnMapItem;
|
||||||
private MenuItem searchPOILevel;
|
private MenuItem searchPOILevel;
|
||||||
private Button searchFooterButton;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
menu = getClearToolbar(true).getMenu();
|
menu = getClearToolbar(true).getMenu();
|
||||||
boolean light = getMyApplication().getSettings().isLightActionBar();
|
|
||||||
searchPOILevel = menu.add(0, SEARCH_MORE, 0, R.string.search_POI_level_btn);
|
searchPOILevel = menu.add(0, SEARCH_MORE, 0, R.string.search_POI_level_btn);
|
||||||
MenuItemCompat.setShowAsAction(searchPOILevel, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
MenuItemCompat.setShowAsAction(searchPOILevel, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||||
searchPOILevel.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
searchPOILevel.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||||
|
@ -189,7 +181,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
||||||
}
|
}
|
||||||
|
|
||||||
public Toolbar getClearToolbar(boolean visible) {
|
public Toolbar getClearToolbar(boolean visible) {
|
||||||
final Toolbar tb = (Toolbar) findViewById(R.id.bottomControls);
|
final Toolbar tb = (Toolbar) findViewById(R.id.poiSplitbar);
|
||||||
tb.setTitle(null);
|
tb.setTitle(null);
|
||||||
tb.getMenu().clear();
|
tb.getMenu().clear();
|
||||||
tb.setVisibility(visible ? View.VISIBLE : View.GONE);
|
tb.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||||
|
@ -230,8 +222,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
||||||
|
|
||||||
app = (OsmandApplication) getApplication();
|
app = (OsmandApplication) getApplication();
|
||||||
|
|
||||||
uiHandler = new Handler();
|
searchFilter = (EditText) findViewById(R.id.edit);
|
||||||
searchFilter = (EditText) findViewById(R.id.SearchFilter);
|
|
||||||
searchFilterLayout = findViewById(R.id.SearchFilterLayout);
|
searchFilterLayout = findViewById(R.id.SearchFilterLayout);
|
||||||
|
|
||||||
settings = ((OsmandApplication) getApplication()).getSettings();
|
settings = ((OsmandApplication) getApplication()).getSettings();
|
||||||
|
@ -246,9 +237,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
||||||
searchPOILevel.setEnabled(true);
|
searchPOILevel.setEnabled(true);
|
||||||
searchPOILevel.setTitle(R.string.search_button);
|
searchPOILevel.setTitle(R.string.search_button);
|
||||||
}
|
}
|
||||||
searchFooterButton.setEnabled(true);
|
|
||||||
searchFooterButton.setText(R.string.search_button);
|
|
||||||
// Cancel current search request here?
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +256,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addFooterView();
|
|
||||||
amenityAdapter = new AmenityAdapter(new ArrayList<Amenity>());
|
amenityAdapter = new AmenityAdapter(new ArrayList<Amenity>());
|
||||||
setListAdapter(amenityAdapter);
|
setListAdapter(amenityAdapter);
|
||||||
|
|
||||||
|
@ -281,25 +268,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFooterView() {
|
|
||||||
final FrameLayout ll = new FrameLayout(this);
|
|
||||||
android.widget.FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
|
|
||||||
LayoutParams.WRAP_CONTENT);
|
|
||||||
lp.gravity = Gravity.CENTER_HORIZONTAL;
|
|
||||||
searchFooterButton = new Button(this);
|
|
||||||
searchFooterButton.setText(R.string.search_POI_level_btn);
|
|
||||||
searchFooterButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
searchMore();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
searchFooterButton.setLayoutParams(lp);
|
|
||||||
ll.addView(searchFooterButton);
|
|
||||||
|
|
||||||
getListView().addFooterView(ll);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
@ -352,8 +320,10 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
||||||
app.getLocationProvider().addCompassListener(this);
|
app.getLocationProvider().addCompassListener(this);
|
||||||
app.getLocationProvider().registerOrUnregisterCompassListener(true);
|
app.getLocationProvider().registerOrUnregisterCompassListener(true);
|
||||||
}
|
}
|
||||||
|
if(searchFilterLayout.getVisibility() == View.VISIBLE) {
|
||||||
searchFilter.requestFocus();
|
searchFilter.requestFocus();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateShowFilterItem() {
|
private void updateShowFilterItem() {
|
||||||
if (showFilterItem != null) {
|
if (showFilterItem != null) {
|
||||||
|
@ -435,14 +405,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
||||||
searchPOILevel.setEnabled(enabled);
|
searchPOILevel.setEnabled(enabled);
|
||||||
searchPOILevel.setTitle(title);
|
searchPOILevel.setTitle(title);
|
||||||
}
|
}
|
||||||
// if(ResourcesCompat.getResources_getBoolean(this, R.bool.abs__split_action_bar_is_narrow)) {
|
|
||||||
if (true) {
|
|
||||||
searchFooterButton.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
searchFooterButton.setVisibility(View.VISIBLE);
|
|
||||||
searchFooterButton.setEnabled(enabled);
|
|
||||||
searchFooterButton.setText(title);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private net.osmand.Location getSearchedLocation() {
|
private net.osmand.Location getSearchedLocation() {
|
||||||
|
@ -636,7 +598,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
||||||
if (searchPOILevel != null) {
|
if (searchPOILevel != null) {
|
||||||
searchPOILevel.setEnabled(false);
|
searchPOILevel.setEnabled(false);
|
||||||
}
|
}
|
||||||
searchFooterButton.setEnabled(false);
|
|
||||||
existingObjects = new TLongHashSet();
|
existingObjects = new TLongHashSet();
|
||||||
updateExisting = new TLongHashSet();
|
updateExisting = new TLongHashSet();
|
||||||
if (request.type == SearchAmenityRequest.NEW_SEARCH_INIT) {
|
if (request.type == SearchAmenityRequest.NEW_SEARCH_INIT) {
|
||||||
|
|
|
@ -3,24 +3,16 @@
|
||||||
*/
|
*/
|
||||||
package net.osmand.plus.activities.search;
|
package net.osmand.plus.activities.search;
|
||||||
|
|
||||||
import android.content.Intent;
|
import java.util.ArrayList;
|
||||||
import android.os.Bundle;
|
import java.util.List;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import java.util.Map;
|
||||||
import android.support.v4.app.ListFragment;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
|
import net.osmand.CollatorStringMatcher;
|
||||||
|
import net.osmand.CollatorStringMatcher.StringMatcherMode;
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.osm.AbstractPoiType;
|
||||||
|
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;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -32,9 +24,27 @@ import net.osmand.plus.poi.PoiLegacyFilter;
|
||||||
import net.osmand.plus.poi.SearchByNameFilter;
|
import net.osmand.plus.poi.SearchByNameFilter;
|
||||||
import net.osmand.plus.render.RenderingIcons;
|
import net.osmand.plus.render.RenderingIcons;
|
||||||
import net.osmand.plus.resources.ResourceManager;
|
import net.osmand.plus.resources.ResourceManager;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
import java.util.ArrayList;
|
import android.content.Intent;
|
||||||
import java.util.List;
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
import android.support.v4.app.ListFragment;
|
||||||
|
import android.support.v7.widget.PopupMenu;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,35 +54,79 @@ public class SearchPoiFilterFragment extends ListFragment implements SearchActiv
|
||||||
public static final String SEARCH_LON = SearchActivity.SEARCH_LON;
|
public static final String SEARCH_LON = SearchActivity.SEARCH_LON;
|
||||||
public static final int REQUEST_POI_EDIT = 55;
|
public static final int REQUEST_POI_EDIT = 55;
|
||||||
|
|
||||||
|
private EditText searchEditText;
|
||||||
|
private SearchPoiByNameTask currentTask = null;
|
||||||
|
private PoiFiltersAdapter poiFitlersAdapter;
|
||||||
|
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View v = inflater.inflate(R.layout.searchpoi, container, false);
|
||||||
|
|
||||||
|
v.findViewById(R.id.SearchFilterLayout).setVisibility(View.VISIBLE);
|
||||||
|
setupSearchEditText((EditText) v.findViewById(R.id.edit));
|
||||||
|
setupOptions(v.findViewById(R.id.options));
|
||||||
|
v.findViewById(R.id.poiSplitbar).setVisibility(View.GONE);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupOptions(View options) {
|
||||||
|
options.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
showOptionsMenu(v);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupSearchEditText(EditText e) {
|
||||||
|
searchEditText = e;
|
||||||
|
searchEditText.addTextChangedListener(new TextWatcher() {
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
if(currentTask != null) {
|
||||||
|
currentTask.cancel(true);
|
||||||
|
}
|
||||||
|
currentTask = new SearchPoiByNameTask();
|
||||||
|
currentTask.execute(s.toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
// ListActivity has a ListView, which you can get with:
|
poiFitlersAdapter = new PoiFiltersAdapter(getFilters(""));
|
||||||
ListView lv = getListView();
|
setListAdapter(poiFitlersAdapter);
|
||||||
|
|
||||||
// Then you can create a listener like so:
|
|
||||||
lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
|
|
||||||
PoiLegacyFilter poi = ((AmenityAdapter) getListAdapter()).getItem(pos);
|
|
||||||
if(!poi.isStandardFilter() || poi.getFilterId().equals(PoiLegacyFilter.CUSTOM_FILTER_ID)) {
|
|
||||||
showEditActivity(poi);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
refreshPoiListAdapter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshPoiListAdapter() {
|
public List<Object> getFilters(String s) {
|
||||||
|
List<Object> filters = new ArrayList<Object>() ;
|
||||||
|
if (Algorithms.isEmpty(s)) {
|
||||||
PoiFiltersHelper poiFilters = getApp().getPoiFilters();
|
PoiFiltersHelper poiFilters = getApp().getPoiFilters();
|
||||||
List<PoiLegacyFilter> filters = new ArrayList<PoiLegacyFilter>() ;
|
|
||||||
filters.addAll(poiFilters.getTopDefinedPoiFilters());
|
filters.addAll(poiFilters.getTopDefinedPoiFilters());
|
||||||
setListAdapter(new AmenityAdapter(filters));
|
} else {
|
||||||
|
PoiFiltersHelper poiFilters = getApp().getPoiFilters();
|
||||||
|
for(PoiLegacyFilter pf : poiFilters.getTopDefinedPoiFilters()) {
|
||||||
|
if(!pf.isStandardFilter()) {
|
||||||
|
filters.add(pf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Map<String, AbstractPoiType> res =
|
||||||
|
getApp().getPoiTypes().getAllTypesTranslatedNames(new CollatorStringMatcher(s, StringMatcherMode.CHECK_STARTS_FROM_SPACE));
|
||||||
|
for(AbstractPoiType p : res.values()) {
|
||||||
|
filters.add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsmandApplication getApp(){
|
public OsmandApplication getApp(){
|
||||||
|
@ -108,79 +162,121 @@ public class SearchPoiFilterFragment extends ListFragment implements SearchActiv
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
if(requestCode == REQUEST_POI_EDIT) {
|
if(requestCode == REQUEST_POI_EDIT) {
|
||||||
refreshPoiListAdapter();
|
poiFitlersAdapter.setResult(getFilters(searchEditText == null ? "" : searchEditText.getText().toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onListItemClick(ListView parent, View v, int position, long id) {
|
public void onListItemClick(ListView listView, View v, int position, long id) {
|
||||||
final PoiLegacyFilter filter = ((AmenityAdapter) getListAdapter()).getItem(position);
|
final Object item = ((PoiFiltersAdapter) getListAdapter()).getItem(position);
|
||||||
if (filter.getFilterId().equals(PoiLegacyFilter.CUSTOM_FILTER_ID)) {
|
|
||||||
filter.clearFilter();
|
|
||||||
showEditActivity(filter);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(!(filter instanceof NameFinderPoiFilter)){
|
|
||||||
ResourceManager rm = getApp().getResourceManager();
|
ResourceManager rm = getApp().getResourceManager();
|
||||||
if(!rm.containsAmenityRepositoryToSearch(filter instanceof SearchByNameFilter)){
|
if (!rm.containsAmenityRepositoryToSearch(false)) {
|
||||||
AccessibleToast.makeText(getActivity(), R.string.data_to_search_poi_not_available, Toast.LENGTH_LONG);
|
AccessibleToast.makeText(getActivity(), R.string.data_to_search_poi_not_available, Toast.LENGTH_LONG);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (item instanceof PoiLegacyFilter) {
|
||||||
|
showFilterActivity(((PoiLegacyFilter) item).getFilterId());
|
||||||
|
} else {
|
||||||
|
showFilterActivity(PoiLegacyFilter.STD_PREFIX + ((AbstractPoiType) item).getKeyName());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showFilterActivity(String filterId) {
|
||||||
final Intent newIntent = new Intent(getActivity(), SearchPOIActivity.class);
|
final Intent newIntent = new Intent(getActivity(), SearchPOIActivity.class);
|
||||||
newIntent.putExtra(SearchPOIActivity.AMENITY_FILTER, filter.getFilterId());
|
newIntent.putExtra(SearchPOIActivity.AMENITY_FILTER, filterId);
|
||||||
updateIntentToLaunch(newIntent);
|
updateIntentToLaunch(newIntent);
|
||||||
startActivityForResult(newIntent, 0);
|
startActivityForResult(newIntent, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SearchPoiByNameTask extends AsyncTask<String, Object, List<Object>> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Object> doInBackground(String... params) {
|
||||||
|
String filter = params[0];
|
||||||
|
return getFilters(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(List<Object> result) {
|
||||||
|
if(!isCancelled() && isVisible()){
|
||||||
|
poiFitlersAdapter.setResult(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class AmenityAdapter extends ArrayAdapter<PoiLegacyFilter> {
|
class PoiFiltersAdapter extends ArrayAdapter<Object> {
|
||||||
AmenityAdapter(List<PoiLegacyFilter> list) {
|
|
||||||
|
PoiFiltersAdapter(List<Object> list) {
|
||||||
super(getActivity(), R.layout.searchpoifolder_list, list);
|
super(getActivity(), R.layout.searchpoifolder_list, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setResult(List<Object> filters) {
|
||||||
|
setNotifyOnChange(false);
|
||||||
|
clear();
|
||||||
|
for(Object o : filters) {
|
||||||
|
add(o);
|
||||||
|
}
|
||||||
|
setNotifyOnChange(true);
|
||||||
|
notifyDataSetInvalidated();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
View row = convertView;
|
View row = convertView;
|
||||||
if(row == null) {
|
if (row == null) {
|
||||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
row = inflater.inflate(R.layout.searchpoifolder_list, parent, false);
|
row = inflater.inflate(R.layout.searchpoifolder_list, parent, false);
|
||||||
}
|
}
|
||||||
TextView label = (TextView) row.findViewById(R.id.folder_label);
|
TextView label = (TextView) row.findViewById(R.id.folder_label);
|
||||||
ImageView icon = (ImageView) row.findViewById(R.id.folder_icon);
|
ImageView icon = (ImageView) row.findViewById(R.id.folder_icon);
|
||||||
OsmandApplication app = getMyApplication();
|
Object item = getItem(position);
|
||||||
final PoiLegacyFilter model = getItem(position);
|
String name;
|
||||||
label.setText(model.getName());
|
if (item instanceof PoiLegacyFilter) {
|
||||||
IconsCache iconsCache = app.getIconsCache();
|
final PoiLegacyFilter model = (PoiLegacyFilter) item;
|
||||||
if(model.getFilterId().equals(PoiLegacyFilter.CUSTOM_FILTER_ID)) {
|
if (RenderingIcons.containsBigIcon(model.getSimplifiedId())) {
|
||||||
icon.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_action_filter_dark));
|
|
||||||
} else if (model.getFilterId().equals(PoiLegacyFilter.BY_NAME_FILTER_ID)) {
|
|
||||||
icon.setImageResource(android.R.drawable.ic_search_category_default);
|
|
||||||
} else {
|
|
||||||
if(RenderingIcons.containsBigIcon(model.getSimplifiedId())) {
|
|
||||||
icon.setImageDrawable(RenderingIcons.getBigIcon(getActivity(), model.getSimplifiedId()));
|
icon.setImageDrawable(RenderingIcons.getBigIcon(getActivity(), model.getSimplifiedId()));
|
||||||
} else {
|
} else {
|
||||||
icon.setImageResource(R.drawable.mx_user_defined);
|
icon.setImageResource(R.drawable.mx_user_defined);
|
||||||
}
|
}
|
||||||
}
|
name = model.getName();
|
||||||
ImageView editIcon = (ImageView) row.findViewById(R.id.folder_edit_icon);
|
|
||||||
editIcon.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_action_edit_dark));
|
|
||||||
if (model.isStandardFilter()) {
|
|
||||||
editIcon.setVisibility(View.GONE);
|
|
||||||
} else {
|
} else {
|
||||||
editIcon.setVisibility(View.VISIBLE);
|
AbstractPoiType st = (AbstractPoiType) item;
|
||||||
|
if (RenderingIcons.containsBigIcon(st.getKeyName())) {
|
||||||
|
icon.setImageDrawable(RenderingIcons.getBigIcon(getActivity(), st.getKeyName()));
|
||||||
|
} else if (st instanceof PoiType
|
||||||
|
&& RenderingIcons.containsBigIcon(((PoiType) st).getOsmTag() + "_"
|
||||||
|
+ ((PoiType) st).getOsmValue())) {
|
||||||
|
icon.setImageResource(RenderingIcons.getBigIconResourceId(((PoiType) st).getOsmTag() + "_"
|
||||||
|
+ ((PoiType) st).getOsmValue()));
|
||||||
|
} else {
|
||||||
|
icon.setImageDrawable(null);
|
||||||
}
|
}
|
||||||
editIcon.setOnClickListener(new View.OnClickListener() {
|
name = st.getTranslation();
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
showEditActivity(model);
|
|
||||||
}
|
}
|
||||||
});
|
label.setText(name);
|
||||||
|
|
||||||
return (row);
|
return (row);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showOptionsMenu(View v) {
|
||||||
|
// Show menu with search all, name finder, name finder poi
|
||||||
|
IconsCache iconsCache = getMyApplication().getIconsCache();
|
||||||
|
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
|
||||||
|
|
||||||
|
MenuItem item = optionsMenu.getMenu().add(R.string.poi_filter_custom_filter)
|
||||||
|
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_filter_dark));
|
||||||
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
PoiLegacyFilter filter = getApp().getPoiFilters().getCustomPOIFilter();
|
||||||
|
filter.clearFilter();
|
||||||
|
showEditActivity(filter);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
optionsMenu.show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import java.util.Map;
|
||||||
import net.osmand.osm.MapPoiTypes;
|
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.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||||
|
@ -23,6 +24,9 @@ public class PoiFiltersHelper {
|
||||||
private final OsmandApplication application;
|
private final OsmandApplication application;
|
||||||
|
|
||||||
private NameFinderPoiFilter nameFinderPOIFilter;
|
private NameFinderPoiFilter nameFinderPOIFilter;
|
||||||
|
private PoiLegacyFilter searchByNamePOIFilter;
|
||||||
|
private PoiLegacyFilter customPOIFilter;
|
||||||
|
private PoiLegacyFilter showAllPOIFilter;
|
||||||
private List<PoiLegacyFilter> cacheTopStandardFilters;
|
private List<PoiLegacyFilter> cacheTopStandardFilters;
|
||||||
|
|
||||||
private static final String UDF_CAR_AID = "car_aid";
|
private static final String UDF_CAR_AID = "car_aid";
|
||||||
|
@ -44,6 +48,7 @@ public class PoiFiltersHelper {
|
||||||
public PoiFiltersHelper(OsmandApplication application){
|
public PoiFiltersHelper(OsmandApplication application){
|
||||||
this.application = application;
|
this.application = application;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NameFinderPoiFilter getNameFinderPOIFilter() {
|
public NameFinderPoiFilter getNameFinderPOIFilter() {
|
||||||
if(nameFinderPOIFilter == null){
|
if(nameFinderPOIFilter == null){
|
||||||
nameFinderPOIFilter = new NameFinderPoiFilter(application);
|
nameFinderPOIFilter = new NameFinderPoiFilter(application);
|
||||||
|
@ -51,7 +56,43 @@ public class PoiFiltersHelper {
|
||||||
return nameFinderPOIFilter;
|
return nameFinderPOIFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PoiLegacyFilter getSearchByNamePOIFilter() {
|
||||||
|
if(searchByNamePOIFilter == null){
|
||||||
|
PoiLegacyFilter filter = new SearchByNameFilter(application);
|
||||||
|
filter.setStandardFilter(true);
|
||||||
|
searchByNamePOIFilter = filter;
|
||||||
|
}
|
||||||
|
return searchByNamePOIFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PoiLegacyFilter getCustomPOIFilter() {
|
||||||
|
if(customPOIFilter == null){
|
||||||
|
PoiLegacyFilter filter = new PoiLegacyFilter(application.getString(R.string.poi_filter_custom_filter),
|
||||||
|
PoiLegacyFilter.CUSTOM_FILTER_ID, new LinkedHashMap<PoiCategory, LinkedHashSet<String>>(), application); //$NON-NLS-1$
|
||||||
|
filter.setStandardFilter(true);
|
||||||
|
customPOIFilter = filter;
|
||||||
|
}
|
||||||
|
return customPOIFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PoiLegacyFilter getShowAllPOIFilter() {
|
||||||
|
if(showAllPOIFilter == null){
|
||||||
|
PoiLegacyFilter filter = new PoiLegacyFilter(null, application); //$NON-NLS-1$
|
||||||
|
filter.setStandardFilter(true);
|
||||||
|
showAllPOIFilter = filter;
|
||||||
|
}
|
||||||
|
return showAllPOIFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private PoiLegacyFilter getFilterById(String filterId, PoiLegacyFilter... filters){
|
||||||
|
for(PoiLegacyFilter pf : filters) {
|
||||||
|
if(pf.getFilterId().equals(filterId)){
|
||||||
|
return pf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public PoiLegacyFilter getFilterById(String filterId){
|
public PoiLegacyFilter getFilterById(String filterId){
|
||||||
if(filterId == null){
|
if(filterId == null){
|
||||||
|
@ -62,6 +103,18 @@ public class PoiFiltersHelper {
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PoiLegacyFilter ff = getFilterById(filterId, getCustomPOIFilter(), getSearchByNamePOIFilter(),
|
||||||
|
getShowAllPOIFilter(), getNameFinderPOIFilter());
|
||||||
|
if (ff != null) {
|
||||||
|
return ff;
|
||||||
|
}
|
||||||
|
if(filterId.startsWith(PoiLegacyFilter.STD_PREFIX)) {
|
||||||
|
String typeId = filterId.substring(PoiLegacyFilter.STD_PREFIX.length());
|
||||||
|
PoiType tp = application.getPoiTypes().getPoiTypeByKey(typeId);
|
||||||
|
if(tp != null) {
|
||||||
|
return new PoiLegacyFilter(tp, application);
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,19 +170,6 @@ public class PoiFiltersHelper {
|
||||||
public List<PoiLegacyFilter> getTopDefinedPoiFilters() {
|
public List<PoiLegacyFilter> getTopDefinedPoiFilters() {
|
||||||
if (cacheTopStandardFilters == null) {
|
if (cacheTopStandardFilters == null) {
|
||||||
cacheTopStandardFilters = new ArrayList<PoiLegacyFilter>();
|
cacheTopStandardFilters = new ArrayList<PoiLegacyFilter>();
|
||||||
// by name
|
|
||||||
PoiLegacyFilter filter = new SearchByNameFilter(application);
|
|
||||||
filter.setStandardFilter(true);
|
|
||||||
cacheTopStandardFilters.add(filter);
|
|
||||||
// custom
|
|
||||||
filter = new PoiLegacyFilter(application.getString(R.string.poi_filter_custom_filter),
|
|
||||||
PoiLegacyFilter.CUSTOM_FILTER_ID, new LinkedHashMap<PoiCategory, LinkedHashSet<String>>(), application); //$NON-NLS-1$
|
|
||||||
filter.setStandardFilter(true);
|
|
||||||
cacheTopStandardFilters.add(filter);
|
|
||||||
// all
|
|
||||||
cacheTopStandardFilters.add(new PoiLegacyFilter(null, application));
|
|
||||||
// name finder
|
|
||||||
cacheTopStandardFilters.add(getNameFinderPOIFilter());
|
|
||||||
// user defined
|
// user defined
|
||||||
cacheTopStandardFilters.addAll(getUserDefinedPoiFilters());
|
cacheTopStandardFilters.addAll(getUserDefinedPoiFilters());
|
||||||
// default
|
// default
|
||||||
|
@ -139,7 +179,10 @@ public class PoiFiltersHelper {
|
||||||
}
|
}
|
||||||
sortListOfFilters(cacheTopStandardFilters);
|
sortListOfFilters(cacheTopStandardFilters);
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableList(cacheTopStandardFilters);
|
List<PoiLegacyFilter> result = new ArrayList<PoiLegacyFilter>();
|
||||||
|
result.add(getShowAllPOIFilter());
|
||||||
|
result.addAll(cacheTopStandardFilters);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PoiFilterDbHelper openDbHelper(){
|
private PoiFilterDbHelper openDbHelper(){
|
||||||
|
@ -287,13 +330,13 @@ public class PoiFiltersHelper {
|
||||||
for(PoiCategory a : types.keySet()){
|
for(PoiCategory a : types.keySet()){
|
||||||
if(types.get(a) == null){
|
if(types.get(a) == null){
|
||||||
insertCategories.bindString(1, p.getFilterId());
|
insertCategories.bindString(1, p.getFilterId());
|
||||||
insertCategories.bindString(2, a.getKey());
|
insertCategories.bindString(2, a.getKeyName());
|
||||||
insertCategories.bindNull(3);
|
insertCategories.bindNull(3);
|
||||||
insertCategories.execute();
|
insertCategories.execute();
|
||||||
} else {
|
} else {
|
||||||
for(String s : types.get(a)){
|
for(String s : types.get(a)){
|
||||||
insertCategories.bindString(1, p.getFilterId());
|
insertCategories.bindString(1, p.getFilterId());
|
||||||
insertCategories.bindString(2, a.getKey());
|
insertCategories.bindString(2, a.getKeyName());
|
||||||
insertCategories.bindString(3, s);
|
insertCategories.bindString(3, s);
|
||||||
insertCategories.execute();
|
insertCategories.execute();
|
||||||
}
|
}
|
||||||
|
@ -318,7 +361,7 @@ public class PoiFiltersHelper {
|
||||||
map.put(filterId, new LinkedHashMap<PoiCategory, LinkedHashSet<String>>());
|
map.put(filterId, new LinkedHashMap<PoiCategory, LinkedHashSet<String>>());
|
||||||
}
|
}
|
||||||
Map<PoiCategory, LinkedHashSet<String>> m = map.get(filterId);
|
Map<PoiCategory, LinkedHashSet<String>> m = map.get(filterId);
|
||||||
PoiCategory a = mapPoiTypes.getPoiCategoryByName(query.getString(1));
|
PoiCategory a = mapPoiTypes.getPoiCategoryByName(query.getString(1).toLowerCase(), false);
|
||||||
String subCategory = query.getString(2);
|
String subCategory = query.getString(2);
|
||||||
if(subCategory == null){
|
if(subCategory == null){
|
||||||
m.put(a, null);
|
m.put(a, null);
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import net.osmand.ResultMatcher;
|
import net.osmand.ResultMatcher;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
|
import net.osmand.osm.AbstractPoiType;
|
||||||
import net.osmand.osm.MapPoiTypes;
|
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;
|
||||||
|
@ -47,10 +48,10 @@ public class PoiLegacyFilter {
|
||||||
|
|
||||||
|
|
||||||
// constructor for standard filters
|
// constructor for standard filters
|
||||||
public PoiLegacyFilter(PoiFilter type, OsmandApplication application) {
|
public PoiLegacyFilter(AbstractPoiType type, OsmandApplication application) {
|
||||||
this.app = application;
|
this.app = application;
|
||||||
isStandardFilter = true;
|
isStandardFilter = true;
|
||||||
filterId = STD_PREFIX + (type == null ? null : type.getName());
|
filterId = STD_PREFIX + (type == null ? null : type.getKeyName());
|
||||||
poiTypes = application.getPoiTypes();
|
poiTypes = application.getPoiTypes();
|
||||||
name = type == null ? application.getString(R.string.poi_filter_closest_poi) : type.getTranslation(); //$NON-NLS-1$
|
name = type == null ? application.getString(R.string.poi_filter_closest_poi) : type.getTranslation(); //$NON-NLS-1$
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
|
|
Loading…
Reference in a new issue