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 :
|
||||
String cat = codedIS.readString().intern();
|
||||
region.categories.add(cat);
|
||||
region.categoriesType.add(poiTypes.getPoiCategoryByName(cat));
|
||||
region.categoriesType.add(poiTypes.getPoiCategoryByName(cat.toLowerCase()));
|
||||
region.subcategories.add(new ArrayList<String>());
|
||||
break;
|
||||
case OsmandOdb.OsmAndCategoryTable.SUBCATEGORIES_FIELD_NUMBER :
|
||||
|
|
|
@ -1,21 +1,18 @@
|
|||
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 MapPoiTypes registry;
|
||||
|
||||
|
||||
|
||||
public AbstractPoiType(String keyName, MapPoiTypes registry) {
|
||||
this.keyName = keyName;
|
||||
this.registry = registry;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return keyName;
|
||||
}
|
||||
|
||||
public String getKeyName() {
|
||||
return keyName;
|
||||
}
|
||||
|
@ -24,5 +21,7 @@ public class AbstractPoiType {
|
|||
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 net.osmand.PlatformUtil;
|
||||
import net.osmand.StringMatcher;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -97,11 +98,6 @@ public class MapPoiTypes {
|
|||
return otherCategory;
|
||||
}
|
||||
|
||||
public PoiCategory getPoiCategoryByName(String name) {
|
||||
name = name.toLowerCase();
|
||||
return getPoiCategoryByName(name, false);
|
||||
}
|
||||
|
||||
public PoiType getPoiTypeByKey(String name) {
|
||||
for(PoiCategory pc : categories) {
|
||||
PoiType pt = pc.getPoiTypeByKeyName(name);
|
||||
|
@ -125,6 +121,31 @@ public class MapPoiTypes {
|
|||
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) {
|
||||
Map<String, PoiType> translation = new TreeMap<String, PoiType>();
|
||||
for (PoiType pt : pc.getPoiTypes()) {
|
||||
|
@ -137,12 +158,19 @@ public class MapPoiTypes {
|
|||
return translation;
|
||||
}
|
||||
|
||||
public PoiCategory getPoiCategoryByName(String name) {
|
||||
return getPoiCategoryByName(name, false);
|
||||
}
|
||||
|
||||
public PoiCategory getPoiCategoryByName(String name, boolean create) {
|
||||
if(name.equals("entertainment") && !create) {
|
||||
name = "leisure";
|
||||
if(name.equals("leisure") && !create) {
|
||||
name = "entertainment";
|
||||
}
|
||||
if(name.equals("historic") && !create) {
|
||||
name = "tourism";
|
||||
}
|
||||
for(PoiCategory p : categories ) {
|
||||
if(p.getName().equals(name) || p.getKey().equalsIgnoreCase(name)) {
|
||||
if(p.getKeyName().equalsIgnoreCase(name)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
@ -265,9 +293,9 @@ public class MapPoiTypes {
|
|||
private static void print(MapPoiTypes df) {
|
||||
List<PoiCategory> pc = df.getCategories();
|
||||
for(PoiCategory p : pc) {
|
||||
System.out.println("Category " + p.getName());
|
||||
System.out.println("Category " + p.getKeyName());
|
||||
for(PoiFilter f : p.getPoiFilters()) {
|
||||
System.out.println(" Filter " + f.getName());
|
||||
System.out.println(" Filter " + f.getKeyName());
|
||||
print(" ", f);
|
||||
}
|
||||
print(" ", p);
|
||||
|
@ -277,8 +305,8 @@ public class MapPoiTypes {
|
|||
|
||||
private static void print(String indent, PoiFilter f) {
|
||||
for(PoiType pt : f.getPoiTypes()) {
|
||||
System.out.println(indent + " Type " + pt.getName() +
|
||||
(pt.isReference() ? (" -> " + pt.getReferenceType().getCategory().getKey() ): ""));
|
||||
System.out.println(indent + " Type " + pt.getKeyName() +
|
||||
(pt.isReference() ? (" -> " + pt.getReferenceType().getCategory().getKeyName() ): ""));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,7 +333,7 @@ public class MapPoiTypes {
|
|||
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);
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return keyName;
|
||||
}
|
||||
|
||||
public int ordinal() {
|
||||
return regId;
|
||||
|
|
|
@ -27,15 +27,15 @@ public class PoiFilter extends AbstractPoiType {
|
|||
}
|
||||
|
||||
public void addPoiType(PoiType type) {
|
||||
if(!map.containsKey(type.getName())) {
|
||||
if(!map.containsKey(type.getKeyName())) {
|
||||
poiTypes.add(type);
|
||||
map.put(type.getName(), type);
|
||||
map.put(type.getKeyName(), type);
|
||||
} else {
|
||||
PoiType prev = map.get(type.getName());
|
||||
PoiType prev = map.get(type.getKeyName());
|
||||
if(prev.isReference()) {
|
||||
poiTypes.remove(prev);
|
||||
poiTypes.add(type);
|
||||
map.put(type.getName(), type);
|
||||
map.put(type.getKeyName(), type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,10 +71,6 @@ public class PoiFilter extends AbstractPoiType {
|
|||
return poiTypes;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return keyName;
|
||||
}
|
||||
|
||||
public void setTopVisible(boolean topVisible) {
|
||||
this.topVisible = topVisible;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package net.osmand.osm;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
|
||||
public class PoiType extends AbstractPoiType {
|
||||
|
||||
private PoiCategory category;
|
||||
|
@ -74,5 +77,17 @@ public class PoiType extends AbstractPoiType {
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,46 +1,69 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/SearchFilterLayout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone">
|
||||
android:visibility="gone"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/TextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
tools:text="@string/lorem_ipsum"
|
||||
android:text="@string/search_poi_filter" />
|
||||
<ImageView
|
||||
android:id="@+id/search_icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="8dp"
|
||||
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
|
||||
android:id="@+id/SearchFilter"
|
||||
android:layout_width="fill_parent"
|
||||
android:id="@+id/edit"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:text="" />
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
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>
|
||||
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
android:layout_weight="1" />
|
||||
|
||||
<net.osmand.plus.activities.search.toolbar.SplitToolbar
|
||||
android:orientation="horizontal"
|
||||
android:background="?attr/bottomToolBarColor"
|
||||
android:id="@+id/bottomControls"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:id="@+id/poiSplitbar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bottomToolBarColor"
|
||||
android:orientation="horizontal" />
|
||||
|
||||
</LinearLayout>
|
|
@ -7,7 +7,9 @@
|
|||
android:minHeight="@dimen/list_item_height"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/list_content_padding"
|
||||
android:paddingRight="@dimen/list_content_padding" >
|
||||
android:paddingRight="@dimen/list_content_padding"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/poi_icon"
|
||||
|
|
|
@ -6,15 +6,13 @@
|
|||
android:minHeight="@dimen/list_item_height"
|
||||
android:orientation="horizontal"
|
||||
android:background="?attr/expandable_list_item_background"
|
||||
android:paddingLeft="@dimen/list_content_padding"
|
||||
android:paddingRight="@dimen/list_content_padding">
|
||||
android:paddingLeft="@dimen/list_content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/folder_icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"/>
|
||||
|
||||
<TextView
|
||||
|
@ -26,14 +24,16 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:maxLines="1"
|
||||
tools:text="@string/lorem_ipsum"/>
|
||||
tools:text="@string/lorem_ipsum"
|
||||
android:layout_marginRight="@dimen/list_content_padding"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/folder_edit_icon"
|
||||
android:id="@+id/options"
|
||||
android:layout_width="@dimen/list_item_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_height="@dimen/list_item_height"
|
||||
android:scaleType="center"
|
||||
android:visibility="gone"
|
||||
android:background="?attr/dashboard_button"
|
||||
android:src="@drawable/ic_action_filter_dark" />
|
||||
android:src="?attr/ic_action_overflow" />
|
||||
</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
|
||||
-->
|
||||
<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_message">Message</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);
|
||||
} else {
|
||||
final FavouritePoint point = (FavouritePoint) favouritesAdapter.getChild(groupPosition, childPosition);
|
||||
|
||||
ContextMenuAdapter qa = new ContextMenuAdapter(v.getContext());
|
||||
qa.setAnchor(v);
|
||||
final OsmandSettings settings = getMyApplication().getSettings();
|
||||
|
||||
LatLon location = new LatLon(point.getLatitude(), point.getLongitude());
|
||||
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
|
||||
DirectionsDialogs.createDirectionActionsPopUpMenu(optionsMenu, location, point,
|
||||
new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName()), settings.getLastKnownMapZoom(),
|
||||
getActivity(), true, false);
|
||||
|
||||
boolean light = getMyApplication().getSettings().isLightContent();
|
||||
MenuItem item = optionsMenu.getMenu().add(R.string.favourites_context_menu_edit)
|
||||
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_edit_dark));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
|
|
|
@ -255,26 +255,14 @@ public class MapActivityLayers {
|
|||
|
||||
|
||||
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 ContextMenuAdapter adapter = new ContextMenuAdapter(activity);
|
||||
final List<PoiLegacyFilter> list = new ArrayList<PoiLegacyFilter>();
|
||||
for (PoiLegacyFilter f : poiFilters.getTopDefinedPoiFilters()) {
|
||||
if(PoiLegacyFilter.BY_NAME_FILTER_ID.equals(f.getFilterId()) ||
|
||||
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, f);
|
||||
}
|
||||
addFilterToList(adapter, list, poiFilters.getCustomPOIFilter());
|
||||
Builder builder = new AlertDialog.Builder(activity);
|
||||
ListAdapter listAdapter = adapter.createListAdapter(activity, app.getSettings().isLightContent());
|
||||
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener(){
|
||||
|
@ -309,6 +297,17 @@ public class MapActivityLayers {
|
|||
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){
|
||||
if(OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) == null) {
|
||||
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.OsmAndLocationProvider.OsmAndCompassListener;
|
||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
||||
import net.osmand.plus.R.color;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.R.color;
|
||||
import net.osmand.plus.activities.EditPOIFilterActivity;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.OsmandListActivity;
|
||||
|
@ -52,7 +52,6 @@ import android.graphics.drawable.Drawable;
|
|||
import android.os.AsyncTask;
|
||||
import android.os.AsyncTask.Status;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
@ -61,21 +60,17 @@ import android.text.SpannableString;
|
|||
import android.text.TextWatcher;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MenuItem.OnMenuItemClickListener;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Filter;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
@ -104,7 +99,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
private net.osmand.Location location = null;
|
||||
private Float heading = null;
|
||||
|
||||
private Handler uiHandler;
|
||||
private OsmandSettings settings;
|
||||
|
||||
private float width = 24;
|
||||
|
@ -116,12 +110,10 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
private MenuItem showFilterItem;
|
||||
private MenuItem showOnMapItem;
|
||||
private MenuItem searchPOILevel;
|
||||
private Button searchFooterButton;
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
menu = getClearToolbar(true).getMenu();
|
||||
boolean light = getMyApplication().getSettings().isLightActionBar();
|
||||
searchPOILevel = menu.add(0, SEARCH_MORE, 0, R.string.search_POI_level_btn);
|
||||
MenuItemCompat.setShowAsAction(searchPOILevel, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
searchPOILevel.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
|
@ -189,7 +181,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
}
|
||||
|
||||
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.getMenu().clear();
|
||||
tb.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
|
@ -230,8 +222,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
|
||||
app = (OsmandApplication) getApplication();
|
||||
|
||||
uiHandler = new Handler();
|
||||
searchFilter = (EditText) findViewById(R.id.SearchFilter);
|
||||
searchFilter = (EditText) findViewById(R.id.edit);
|
||||
searchFilterLayout = findViewById(R.id.SearchFilterLayout);
|
||||
|
||||
settings = ((OsmandApplication) getApplication()).getSettings();
|
||||
|
@ -246,9 +237,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
searchPOILevel.setEnabled(true);
|
||||
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>());
|
||||
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
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
@ -352,7 +320,9 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
app.getLocationProvider().addCompassListener(this);
|
||||
app.getLocationProvider().registerOrUnregisterCompassListener(true);
|
||||
}
|
||||
searchFilter.requestFocus();
|
||||
if(searchFilterLayout.getVisibility() == View.VISIBLE) {
|
||||
searchFilter.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateShowFilterItem() {
|
||||
|
@ -435,14 +405,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
searchPOILevel.setEnabled(enabled);
|
||||
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() {
|
||||
|
@ -636,7 +598,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
if (searchPOILevel != null) {
|
||||
searchPOILevel.setEnabled(false);
|
||||
}
|
||||
searchFooterButton.setEnabled(false);
|
||||
existingObjects = new TLongHashSet();
|
||||
updateExisting = new TLongHashSet();
|
||||
if (request.type == SearchAmenityRequest.NEW_SEARCH_INIT) {
|
||||
|
|
|
@ -3,24 +3,16 @@
|
|||
*/
|
||||
package net.osmand.plus.activities.search;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.osmand.CollatorStringMatcher;
|
||||
import net.osmand.CollatorStringMatcher.StringMatcherMode;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.osm.AbstractPoiType;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
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.render.RenderingIcons;
|
||||
import net.osmand.plus.resources.ResourceManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.osmand.util.Algorithms;
|
||||
import android.content.Intent;
|
||||
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 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
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
// ListActivity has a ListView, which you can get with:
|
||||
ListView lv = getListView();
|
||||
|
||||
// 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;
|
||||
}
|
||||
});
|
||||
poiFitlersAdapter = new PoiFiltersAdapter(getFilters(""));
|
||||
setListAdapter(poiFitlersAdapter);
|
||||
setHasOptionsMenu(true);
|
||||
refreshPoiListAdapter();
|
||||
}
|
||||
|
||||
public void refreshPoiListAdapter() {
|
||||
PoiFiltersHelper poiFilters = getApp().getPoiFilters();
|
||||
List<PoiLegacyFilter> filters = new ArrayList<PoiLegacyFilter>() ;
|
||||
filters.addAll(poiFilters.getTopDefinedPoiFilters());
|
||||
setListAdapter(new AmenityAdapter(filters));
|
||||
public List<Object> getFilters(String s) {
|
||||
List<Object> filters = new ArrayList<Object>() ;
|
||||
if (Algorithms.isEmpty(s)) {
|
||||
PoiFiltersHelper poiFilters = getApp().getPoiFilters();
|
||||
filters.addAll(poiFilters.getTopDefinedPoiFilters());
|
||||
} 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(){
|
||||
|
@ -108,79 +162,121 @@ public class SearchPoiFilterFragment extends ListFragment implements SearchActiv
|
|||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if(requestCode == REQUEST_POI_EDIT) {
|
||||
refreshPoiListAdapter();
|
||||
poiFitlersAdapter.setResult(getFilters(searchEditText == null ? "" : searchEditText.getText().toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView parent, View v, int position, long id) {
|
||||
final PoiLegacyFilter filter = ((AmenityAdapter) getListAdapter()).getItem(position);
|
||||
if (filter.getFilterId().equals(PoiLegacyFilter.CUSTOM_FILTER_ID)) {
|
||||
filter.clearFilter();
|
||||
showEditActivity(filter);
|
||||
public void onListItemClick(ListView listView, View v, int position, long id) {
|
||||
final Object item = ((PoiFiltersAdapter) getListAdapter()).getItem(position);
|
||||
ResourceManager rm = getApp().getResourceManager();
|
||||
if (!rm.containsAmenityRepositoryToSearch(false)) {
|
||||
AccessibleToast.makeText(getActivity(), R.string.data_to_search_poi_not_available, Toast.LENGTH_LONG);
|
||||
return;
|
||||
}
|
||||
if(!(filter instanceof NameFinderPoiFilter)){
|
||||
ResourceManager rm = getApp().getResourceManager();
|
||||
if(!rm.containsAmenityRepositoryToSearch(filter instanceof SearchByNameFilter)){
|
||||
AccessibleToast.makeText(getActivity(), R.string.data_to_search_poi_not_available, Toast.LENGTH_LONG);
|
||||
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);
|
||||
newIntent.putExtra(SearchPOIActivity.AMENITY_FILTER, filter.getFilterId());
|
||||
newIntent.putExtra(SearchPOIActivity.AMENITY_FILTER, filterId);
|
||||
updateIntentToLaunch(newIntent);
|
||||
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> {
|
||||
AmenityAdapter(List<PoiLegacyFilter> list) {
|
||||
class PoiFiltersAdapter extends ArrayAdapter<Object> {
|
||||
|
||||
PoiFiltersAdapter(List<Object> 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
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View row = convertView;
|
||||
if(row == null) {
|
||||
if (row == null) {
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
row = inflater.inflate(R.layout.searchpoifolder_list, parent, false);
|
||||
}
|
||||
TextView label = (TextView) row.findViewById(R.id.folder_label);
|
||||
ImageView icon = (ImageView) row.findViewById(R.id.folder_icon);
|
||||
OsmandApplication app = getMyApplication();
|
||||
final PoiLegacyFilter model = getItem(position);
|
||||
label.setText(model.getName());
|
||||
IconsCache iconsCache = app.getIconsCache();
|
||||
if(model.getFilterId().equals(PoiLegacyFilter.CUSTOM_FILTER_ID)) {
|
||||
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())) {
|
||||
Object item = getItem(position);
|
||||
String name;
|
||||
if (item instanceof PoiLegacyFilter) {
|
||||
final PoiLegacyFilter model = (PoiLegacyFilter) item;
|
||||
if (RenderingIcons.containsBigIcon(model.getSimplifiedId())) {
|
||||
icon.setImageDrawable(RenderingIcons.getBigIcon(getActivity(), model.getSimplifiedId()));
|
||||
} else {
|
||||
icon.setImageResource(R.drawable.mx_user_defined);
|
||||
}
|
||||
}
|
||||
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);
|
||||
name = model.getName();
|
||||
} else {
|
||||
editIcon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
editIcon.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showEditActivity(model);
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
name = st.getTranslation();
|
||||
}
|
||||
label.setText(name);
|
||||
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.PoiCategory;
|
||||
import net.osmand.osm.PoiFilter;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||
|
@ -23,6 +24,9 @@ public class PoiFiltersHelper {
|
|||
private final OsmandApplication application;
|
||||
|
||||
private NameFinderPoiFilter nameFinderPOIFilter;
|
||||
private PoiLegacyFilter searchByNamePOIFilter;
|
||||
private PoiLegacyFilter customPOIFilter;
|
||||
private PoiLegacyFilter showAllPOIFilter;
|
||||
private List<PoiLegacyFilter> cacheTopStandardFilters;
|
||||
|
||||
private static final String UDF_CAR_AID = "car_aid";
|
||||
|
@ -44,6 +48,7 @@ public class PoiFiltersHelper {
|
|||
public PoiFiltersHelper(OsmandApplication application){
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public NameFinderPoiFilter getNameFinderPOIFilter() {
|
||||
if(nameFinderPOIFilter == null){
|
||||
nameFinderPOIFilter = new NameFinderPoiFilter(application);
|
||||
|
@ -51,7 +56,43 @@ public class PoiFiltersHelper {
|
|||
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){
|
||||
if(filterId == null){
|
||||
|
@ -62,6 +103,18 @@ public class PoiFiltersHelper {
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -117,19 +170,6 @@ public class PoiFiltersHelper {
|
|||
public List<PoiLegacyFilter> getTopDefinedPoiFilters() {
|
||||
if (cacheTopStandardFilters == null) {
|
||||
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
|
||||
cacheTopStandardFilters.addAll(getUserDefinedPoiFilters());
|
||||
// default
|
||||
|
@ -139,7 +179,10 @@ public class PoiFiltersHelper {
|
|||
}
|
||||
sortListOfFilters(cacheTopStandardFilters);
|
||||
}
|
||||
return Collections.unmodifiableList(cacheTopStandardFilters);
|
||||
List<PoiLegacyFilter> result = new ArrayList<PoiLegacyFilter>();
|
||||
result.add(getShowAllPOIFilter());
|
||||
result.addAll(cacheTopStandardFilters);
|
||||
return result;
|
||||
}
|
||||
|
||||
private PoiFilterDbHelper openDbHelper(){
|
||||
|
@ -287,13 +330,13 @@ public class PoiFiltersHelper {
|
|||
for(PoiCategory a : types.keySet()){
|
||||
if(types.get(a) == null){
|
||||
insertCategories.bindString(1, p.getFilterId());
|
||||
insertCategories.bindString(2, a.getKey());
|
||||
insertCategories.bindString(2, a.getKeyName());
|
||||
insertCategories.bindNull(3);
|
||||
insertCategories.execute();
|
||||
} else {
|
||||
for(String s : types.get(a)){
|
||||
insertCategories.bindString(1, p.getFilterId());
|
||||
insertCategories.bindString(2, a.getKey());
|
||||
insertCategories.bindString(2, a.getKeyName());
|
||||
insertCategories.bindString(3, s);
|
||||
insertCategories.execute();
|
||||
}
|
||||
|
@ -318,7 +361,7 @@ public class PoiFiltersHelper {
|
|||
map.put(filterId, new LinkedHashMap<PoiCategory, LinkedHashSet<String>>());
|
||||
}
|
||||
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);
|
||||
if(subCategory == null){
|
||||
m.put(a, null);
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Set;
|
|||
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.osm.AbstractPoiType;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.PoiFilter;
|
||||
|
@ -47,10 +48,10 @@ public class PoiLegacyFilter {
|
|||
|
||||
|
||||
// constructor for standard filters
|
||||
public PoiLegacyFilter(PoiFilter type, OsmandApplication application) {
|
||||
public PoiLegacyFilter(AbstractPoiType type, OsmandApplication application) {
|
||||
this.app = application;
|
||||
isStandardFilter = true;
|
||||
filterId = STD_PREFIX + (type == null ? null : type.getName());
|
||||
filterId = STD_PREFIX + (type == null ? null : type.getKeyName());
|
||||
poiTypes = application.getPoiTypes();
|
||||
name = type == null ? application.getString(R.string.poi_filter_closest_poi) : type.getTranslation(); //$NON-NLS-1$
|
||||
if (type == null) {
|
||||
|
|
Loading…
Reference in a new issue