Update poi search ui
This commit is contained in:
parent
019634049e
commit
ca31455f0e
10 changed files with 170 additions and 97 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 :
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -1,46 +1,68 @@
|
|||
<?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: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/bottomControls"
|
||||
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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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<Void, PoiLegacyFilter, List<PoiLegacyFilter>> {
|
||||
|
||||
@Override
|
||||
protected List<PoiLegacyFilter> doInBackground(Void... params) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(List<PoiLegacyFilter> result) {
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class AmenityAdapter extends ArrayAdapter<PoiLegacyFilter> {
|
||||
|
||||
|
||||
AmenityAdapter(List<PoiLegacyFilter> 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();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -318,7 +318,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);
|
||||
|
|
Loading…
Reference in a new issue