diff --git a/OsmAnd-java/src/net/osmand/binary/BinaryMapPoiReaderAdapter.java b/OsmAnd-java/src/net/osmand/binary/BinaryMapPoiReaderAdapter.java index 11c21d8c3d..a9b482b9ec 100644 --- a/OsmAnd-java/src/net/osmand/binary/BinaryMapPoiReaderAdapter.java +++ b/OsmAnd-java/src/net/osmand/binary/BinaryMapPoiReaderAdapter.java @@ -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()); break; case OsmandOdb.OsmAndCategoryTable.SUBCATEGORIES_FIELD_NUMBER : diff --git a/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java b/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java index e0ead0cce8..3b41453769 100644 --- a/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java +++ b/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java @@ -97,11 +97,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); @@ -137,9 +132,16 @@ 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)) { diff --git a/OsmAnd/res/layout/searchpoi.xml b/OsmAnd/res/layout/searchpoi.xml index 37bc804b3e..86decd4cec 100644 --- a/OsmAnd/res/layout/searchpoi.xml +++ b/OsmAnd/res/layout/searchpoi.xml @@ -1,46 +1,68 @@ + android:orientation="vertical" > + android:orientation="horizontal" > - + + + + + 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" > + + + + android:layout_weight="1" /> + android:id="@+id/bottomControls" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:background="?attr/bottomToolBarColor" + android:orientation="horizontal" /> \ No newline at end of file diff --git a/OsmAnd/res/layout/searchpoi_list.xml b/OsmAnd/res/layout/searchpoi_list.xml index cf5457fcca..f5f3b906bc 100644 --- a/OsmAnd/res/layout/searchpoi_list.xml +++ b/OsmAnd/res/layout/searchpoi_list.xml @@ -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" + > + android:paddingLeft="@dimen/list_content_padding"> - + tools:text="@string/lorem_ipsum" + android:layout_marginRight="@dimen/list_content_padding"/> + + android:src="?attr/ic_action_overflow" /> diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index ee791377d6..4b7668a0c7 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -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 --> A-GPS info + Search Show description Message A-GPS data last downloaded: %1$s diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java index f58773061d..5b43083f7e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java @@ -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() { diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java index d36cebaf5a..75b0595b59 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java @@ -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; @@ -121,7 +121,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa @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() { @@ -231,7 +230,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(); @@ -352,7 +351,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() { diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java index 369fddca0c..ed8bd04cd7 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java @@ -3,21 +3,8 @@ */ 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 net.osmand.access.AccessibleToast; import net.osmand.data.LatLon; @@ -32,9 +19,26 @@ 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 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,26 +48,47 @@ 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; + + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View v = inflater.inflate(R.layout.searchpoi, container, false); + setupSearchEditText((EditText) v.findViewById(R.id.edit)); + setupOptions(v.findViewById(R.id.options)); + v.findViewById(R.id.bottomControls).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) { + } + }); + } @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; - } - }); setHasOptionsMenu(true); refreshPoiListAdapter(); } @@ -113,7 +138,7 @@ public class SearchPoiFilterFragment extends ListFragment implements SearchActiv } @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); if (filter.getFilterId().equals(PoiLegacyFilter.CUSTOM_FILTER_ID)) { filter.clearFilter(); @@ -127,15 +152,34 @@ public class SearchPoiFilterFragment extends ListFragment implements SearchActiv return; } } + showFilterActivity(filter); + } + + private void showFilterActivity(final PoiLegacyFilter filter) { final Intent newIntent = new Intent(getActivity(), SearchPOIActivity.class); newIntent.putExtra(SearchPOIActivity.AMENITY_FILTER, filter.getFilterId()); updateIntentToLaunch(newIntent); startActivityForResult(newIntent, 0); } + class SearchPoiByNameTask extends AsyncTask> { + + @Override + protected List doInBackground(Void... params) { + return null; + } + + @Override + protected void onPostExecute(List result) { + super.onPostExecute(result); + } + + } class AmenityAdapter extends ArrayAdapter { + + AmenityAdapter(List list) { super(getActivity(), R.layout.searchpoifolder_list, list); } @@ -164,23 +208,29 @@ public class SearchPoiFilterFragment extends ListFragment implements SearchActiv 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); - } else { - editIcon.setVisibility(View.VISIBLE); - } - editIcon.setOnClickListener(new View.OnClickListener() { - - @Override - public void onClick(View v) { - showEditActivity(model); - } - }); - 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().getFilterById(PoiLegacyFilter.CUSTOM_FILTER_ID); + if(filter != null) { + filter.clearFilter(); + showEditActivity(filter); + } + return true; + } + }); + optionsMenu.show(); } diff --git a/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java b/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java index 2bb9e92503..0c45ca96b6 100644 --- a/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java +++ b/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java @@ -318,7 +318,7 @@ public class PoiFiltersHelper { map.put(filterId, new LinkedHashMap>()); } Map> 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);