[Quick search] added UI for custom search
This commit is contained in:
parent
9d73687fc8
commit
7fba84ecdd
7 changed files with 483 additions and 246 deletions
|
@ -1,220 +1,240 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/dashboard_map_toolbar"
|
||||
android:background="?attr/bg_color"
|
||||
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||
android:theme="?attr/toolbar_theme"
|
||||
app:contentInsetLeft="54dp"
|
||||
app:contentInsetStart="54dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:gravity="center_vertical"
|
||||
android:focusableInTouchMode="true"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/searchEditText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:gravity="center_vertical"
|
||||
android:hint="@string/search_poi_category_hint"
|
||||
android:textColor="?attr/searchbar_text"
|
||||
android:textColorHint="?attr/searchbar_text_hint"
|
||||
android:lines="1"
|
||||
android:singleLine="true"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/searchProgressBar"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/clearButton"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:contentDescription="@string/shared_string_close"
|
||||
android:src="@drawable/ic_action_remove_dark"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar_edit"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/dashboard_map_toolbar"
|
||||
android:background="@color/osmand_orange"
|
||||
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||
android:theme="?attr/toolbar_theme"
|
||||
app:contentInsetLeft="54dp"
|
||||
app:contentInsetStart="54dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/titleEdit"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="@color/color_white"
|
||||
android:lines="1"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:text="5 selected"
|
||||
android:textSize="@dimen/default_list_text_size_large"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/shareButton"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:contentDescription="@string/shared_string_share"
|
||||
android:src="@drawable/ic_action_gshare_dark"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/deleteButton"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:contentDescription="@string/shared_string_delete"
|
||||
android:src="@drawable/ic_action_delete_dark"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/tab_toolbar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/ctx_menu_info_divider"/>
|
||||
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/tab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/ctx_menu_info_view_bg"
|
||||
android:theme="?attr/search_tabbar_layout_theme"
|
||||
app:tabGravity="fill"
|
||||
app:tabMaxWidth="0dp"
|
||||
app:tabMode="fixed"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/button_toolbar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/ctx_menu_info_view_bg"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/ctx_menu_info_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/buttonToolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="48dp"
|
||||
android:clickable="true"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/buttonToolbarImage"
|
||||
android:layout_width="54dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_action_marker_dark"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/buttonToolbarTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:lines="1"
|
||||
android:singleLine="true"
|
||||
android:text="@string/shared_string_show_on_map"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/filterButton"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="@string/poi_filter_custom_filter"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/ic_action_filter"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/tabs_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<net.osmand.plus.LockableViewPager
|
||||
android:id="@+id/pager"
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/dashboard_map_toolbar"
|
||||
android:background="?attr/bg_color"
|
||||
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||
android:theme="?attr/toolbar_theme"
|
||||
app:contentInsetLeft="54dp"
|
||||
app:contentInsetStart="54dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:focusableInTouchMode="true"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/searchEditText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:gravity="center_vertical"
|
||||
android:hint="@string/search_poi_category_hint"
|
||||
android:lines="1"
|
||||
android:singleLine="true"
|
||||
android:textColor="?attr/searchbar_text"
|
||||
android:textColorHint="?attr/searchbar_text_hint"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/searchProgressBar"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/clearButton"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:contentDescription="@string/shared_string_close"
|
||||
android:src="@drawable/ic_action_remove_dark"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar_edit"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/dashboard_map_toolbar"
|
||||
android:background="@color/osmand_orange"
|
||||
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||
android:theme="?attr/toolbar_theme"
|
||||
android:visibility="gone"
|
||||
app:contentInsetLeft="54dp"
|
||||
app:contentInsetStart="54dp"
|
||||
tools:visibility="visible">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/titleEdit"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:lines="1"
|
||||
android:singleLine="true"
|
||||
android:text="5 selected"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/default_list_text_size_large"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/shareButton"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:contentDescription="@string/shared_string_share"
|
||||
android:src="@drawable/ic_action_gshare_dark"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/deleteButton"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:contentDescription="@string/shared_string_delete"
|
||||
android:src="@drawable/ic_action_delete_dark"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/tab_toolbar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/ctx_menu_info_divider"/>
|
||||
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/tab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/ctx_menu_info_view_bg"
|
||||
android:theme="?attr/search_tabbar_layout_theme"
|
||||
app:tabGravity="fill"
|
||||
app:tabMaxWidth="0dp"
|
||||
app:tabMode="fixed"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/button_toolbar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/ctx_menu_info_view_bg"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/ctx_menu_info_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/buttonToolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:minHeight="48dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/buttonToolbarImage"
|
||||
android:layout_width="54dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_action_marker_dark"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/buttonToolbarTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:lines="1"
|
||||
android:singleLine="true"
|
||||
android:text="@string/shared_string_show_on_map"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/filterButton"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="@string/poi_filter_custom_filter"
|
||||
android:src="@drawable/ic_action_filter"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/tabs_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<net.osmand.plus.LockableViewPager
|
||||
android:id="@+id/pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/search_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/search_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
<ImageView
|
||||
android:id="@+id/fab"
|
||||
android:contentDescription="@string/layer_route"
|
||||
android:layout_width="@dimen/fab_size_with_shadow"
|
||||
android:layout_height="@dimen/fab_size_with_shadow"
|
||||
android:layout_gravity="right|bottom"
|
||||
android:layout_marginRight="@dimen/fab_margin_right"
|
||||
android:layout_marginBottom="@dimen/fab_margin_right"
|
||||
android:background="@drawable/fab_background_style"
|
||||
android:scaleType="center"
|
||||
android:clickable="true"
|
||||
android:src="@drawable/ic_action_save"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
64
OsmAnd/res/layout/subcategories_dialog_title.xml
Normal file
64
OsmAnd/res/layout/subcategories_dialog_title.xml
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="26dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="18dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="@dimen/dialog_header_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="Food"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
android:text="@string/subcategories"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
android:text="@string/shared_string_select_all"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/check"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -9,6 +9,8 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
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="edit_filter">Edit filter</string>
|
||||
<string name="subcategories">Subcategories</string>
|
||||
<string name="selected_categories">Selected categories</string>
|
||||
<string name="create_custom_poi">Create custom POI</string>
|
||||
<string name="custom_search">Custom search</string>
|
||||
|
|
|
@ -456,6 +456,8 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
|
|||
public void clearFilter() {
|
||||
acceptedTypes = new LinkedHashMap<>();
|
||||
poiAdditionals.clear();
|
||||
filterByName = null;
|
||||
clearCurrentResults();
|
||||
}
|
||||
|
||||
public boolean areAllTypesAccepted() {
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.content.DialogInterface;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.AppCompatImageView;
|
||||
import android.support.v7.widget.AppCompatTextView;
|
||||
|
@ -15,7 +16,10 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.PoiType;
|
||||
|
@ -50,6 +54,8 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
private View bottomBar;
|
||||
private AppCompatTextView barTitle;
|
||||
private AppCompatTextView barButton;
|
||||
private boolean editMode;
|
||||
|
||||
|
||||
public QuickSearchCustomPoiFragment() {
|
||||
}
|
||||
|
@ -83,6 +89,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
filter = helper.getCustomPOIFilter();
|
||||
filter.clearFilter();
|
||||
}
|
||||
editMode = !filterId.equals(helper.getCustomPOIFilter().getFilterId());
|
||||
|
||||
view = inflater.inflate(R.layout.search_custom_poi, container, false);
|
||||
|
||||
|
@ -96,6 +103,11 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
}
|
||||
});
|
||||
|
||||
TextView title = (TextView) view.findViewById(R.id.title);
|
||||
if (editMode) {
|
||||
title.setText(filter.getName());
|
||||
}
|
||||
|
||||
listView = (ListView) view.findViewById(android.R.id.list);
|
||||
listView.setBackgroundColor(getResources().getColor(
|
||||
app.getSettings().isLightContent() ? R.color.ctx_menu_info_view_bg_light
|
||||
|
@ -111,7 +123,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
PoiCategory category = listAdapter.getItem(position - listView.getHeaderViewsCount());
|
||||
showDialog(category);
|
||||
showDialog(category, false);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -122,7 +134,10 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
((QuickSearchDialogFragment) getParentFragment()).showFilter(filterId);
|
||||
QuickSearchDialogFragment quickSearchDialogFragment = getQuickSearchDialogFragment();
|
||||
if (quickSearchDialogFragment != null) {
|
||||
quickSearchDialogFragment.showFilter(filterId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -135,6 +150,31 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
outState.putString(QUICK_SEARCH_CUSTOM_POI_FILTER_ID_KEY, filterId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if (editMode) {
|
||||
QuickSearchDialogFragment quickSearchDialogFragment = getQuickSearchDialogFragment();
|
||||
if (quickSearchDialogFragment != null) {
|
||||
getMyApplication().getSearchUICore().refreshCustomPoiFilters();
|
||||
quickSearchDialogFragment.replaceQueryWithUiFilter(filter, "");
|
||||
quickSearchDialogFragment.reloadCategories();
|
||||
}
|
||||
}
|
||||
super.onDismiss(dialog);
|
||||
}
|
||||
|
||||
private QuickSearchDialogFragment getQuickSearchDialogFragment() {
|
||||
Fragment parent = getParentFragment();
|
||||
if (parent instanceof QuickSearchDialogFragment) {
|
||||
return (QuickSearchDialogFragment) parent;
|
||||
} else if (parent instanceof QuickSearchPoiFilterFragment
|
||||
&& parent.getParentFragment() instanceof QuickSearchDialogFragment) {
|
||||
return (QuickSearchDialogFragment) parent.getParentFragment();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private int getIconId(PoiCategory category) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
String id = null;
|
||||
|
@ -197,6 +237,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
iconView.setImageDrawable(null);
|
||||
}
|
||||
secondaryIconView.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_additional_option));
|
||||
check.setOnCheckedChangeListener(null);
|
||||
check.setChecked(filter.isTypeAccepted(category));
|
||||
String textString = category.getTranslation();
|
||||
titleView.setText(textString);
|
||||
|
@ -225,17 +266,16 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
}
|
||||
|
||||
private void addRowListener(final PoiCategory category, final SwitchCompat check) {
|
||||
check.setOnClickListener(new View.OnClickListener() {
|
||||
check.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (check.isChecked()) {
|
||||
filter.setTypeToAccept(category, true);
|
||||
showDialog(category);
|
||||
showDialog(category, true);
|
||||
} else {
|
||||
filter.setTypeToAccept(category, false);
|
||||
saveFilter();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -243,19 +283,21 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
|
||||
private void saveFilter() {
|
||||
helper.editPoiFilter(filter);
|
||||
if (filter.isEmpty()) {
|
||||
bottomBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
barTitle.setText(getContext().getString(R.string.selected_categories) + ": " + filter.getAcceptedTypesCount());
|
||||
bottomBar.setVisibility(View.VISIBLE);
|
||||
if (!editMode) {
|
||||
if (filter.isEmpty()) {
|
||||
bottomBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
barTitle.setText(getContext().getString(R.string.selected_categories) + ": " + filter.getAcceptedTypesCount());
|
||||
bottomBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showDialog(final PoiCategory poiCategory) {
|
||||
private void showDialog(final PoiCategory poiCategory, boolean selectAll) {
|
||||
final int index = listView.getFirstVisiblePosition();
|
||||
View v = listView.getChildAt(0);
|
||||
final int top = (v == null) ? 0 : v.getTop();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
final LinkedHashMap<String, String> subCategories = new LinkedHashMap<String, String>();
|
||||
Set<String> acceptedCategories = filter.getAcceptedSubtypes(poiCategory);
|
||||
if (acceptedCategories != null) {
|
||||
|
@ -281,17 +323,27 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
});
|
||||
final String[] visibleNames = new String[array.length];
|
||||
final boolean[] selected = new boolean[array.length];
|
||||
|
||||
boolean allSelected = true;
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
final String subcategory = array[i];
|
||||
visibleNames[i] = subCategories.get(subcategory);
|
||||
if (acceptedCategories == null) {
|
||||
if (acceptedCategories == null || selectAll) {
|
||||
selected[i] = true;
|
||||
} else {
|
||||
if (allSelected) {
|
||||
allSelected = false;
|
||||
}
|
||||
selected[i] = acceptedCategories.contains(subcategory);
|
||||
}
|
||||
}
|
||||
builder.setTitle(poiCategory.getTranslation());
|
||||
|
||||
View titleView = LayoutInflater.from(getActivity())
|
||||
.inflate(R.layout.subcategories_dialog_title, null);
|
||||
TextView titleTextView = (TextView) titleView.findViewById(R.id.title);
|
||||
titleTextView.setText(poiCategory.getTranslation());
|
||||
SwitchCompat check = (SwitchCompat) titleView.findViewById(R.id.check);
|
||||
check.setChecked(allSelected);
|
||||
builder.setCustomTitle(titleView);
|
||||
|
||||
builder.setCancelable(true);
|
||||
builder.setNegativeButton(getContext().getText(R.string.shared_string_cancel), new DialogInterface.OnClickListener() {
|
||||
|
@ -323,16 +375,6 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
}
|
||||
});
|
||||
|
||||
/*
|
||||
builder.setPositiveButton(getContext().getText(R.string.shared_string_select_all), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
selectAllFromCategory(poiCategory);
|
||||
listView.setSelectionFromTop(index, top);
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
builder.setMultiChoiceItems(visibleNames, selected, new DialogInterface.OnMultiChoiceClickListener() {
|
||||
|
||||
@Override
|
||||
|
@ -340,13 +382,19 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
|||
selected[item] = isChecked;
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
|
||||
}
|
||||
|
||||
public void selectAllFromCategory(PoiCategory poiCategory) {
|
||||
filter.updateTypesToAccept(poiCategory);
|
||||
saveFilter();
|
||||
listAdapter.notifyDataSetChanged();
|
||||
final AlertDialog dialog = builder.show();
|
||||
check.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
Arrays.fill(selected, true);
|
||||
} else {
|
||||
Arrays.fill(selected, false);
|
||||
}
|
||||
for (int i = 0; i < selected.length; i++) {
|
||||
dialog.getListView().setItemChecked(i, selected[i]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,9 +31,11 @@ import android.widget.CheckBox;
|
|||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Location;
|
||||
|
@ -75,6 +77,7 @@ import net.osmand.util.MapUtils;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -91,6 +94,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
private static final String QUICK_SEARCH_HIDDEN_KEY = "quick_search_hidden_key";
|
||||
private static final String QUICK_SEARCH_TOOLBAR_TITLE_KEY = "quick_search_toolbar_title_key";
|
||||
private static final String QUICK_SEARCH_TOOLBAR_VISIBLE_KEY = "quick_search_toolbar_visible_key";
|
||||
private static final String QUICK_SEARCH_FAB_VISIBLE_KEY = "quick_search_fab_visible_key";
|
||||
|
||||
private Toolbar toolbar;
|
||||
private LockableViewPager viewPager;
|
||||
|
@ -110,6 +114,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
|
||||
private Toolbar toolbarEdit;
|
||||
private TextView titleEdit;
|
||||
private View fab;
|
||||
|
||||
private EditText searchEditText;
|
||||
private ProgressBar progressBar;
|
||||
|
@ -136,6 +141,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
private boolean interruptedSearch;
|
||||
private long hideTimeMs;
|
||||
private boolean poiFilterApplied;
|
||||
private boolean fabVisible;
|
||||
|
||||
private static final double DISTANCE_THRESHOLD = 70000; // 70km
|
||||
private static final int EXPIRATION_TIME_MIN = 10; // 10 minutes
|
||||
|
@ -189,6 +195,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
hidden = savedInstanceState.getBoolean(QUICK_SEARCH_HIDDEN_KEY, false);
|
||||
toolbarTitle = savedInstanceState.getString(QUICK_SEARCH_TOOLBAR_TITLE_KEY);
|
||||
toolbarVisible = savedInstanceState.getBoolean(QUICK_SEARCH_TOOLBAR_VISIBLE_KEY, false);
|
||||
fabVisible = savedInstanceState.getBoolean(QUICK_SEARCH_FAB_VISIBLE_KEY, false);
|
||||
}
|
||||
if (searchQuery == null && arguments != null) {
|
||||
searchQuery = arguments.getString(QUICK_SEARCH_QUERY_KEY);
|
||||
|
@ -429,6 +436,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
if (textEmpty && poiFilterApplied) {
|
||||
poiFilterApplied = false;
|
||||
reloadCategories();
|
||||
if (fabVisible) {
|
||||
fabVisible = false;
|
||||
updateFab();
|
||||
}
|
||||
}
|
||||
if (!searchQuery.equalsIgnoreCase(newQueryText)) {
|
||||
searchQuery = newQueryText;
|
||||
|
@ -470,6 +481,15 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
}
|
||||
);
|
||||
|
||||
fab = view.findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
saveCustomFilter();
|
||||
}
|
||||
});
|
||||
updateFab();
|
||||
|
||||
setupSearch(mapActivity);
|
||||
|
||||
return view;
|
||||
|
@ -490,6 +510,51 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
}
|
||||
}
|
||||
|
||||
public void saveCustomFilter() {
|
||||
final OsmandApplication app = getMyApplication();
|
||||
final PoiUIFilter filter = app.getPoiFilters().getCustomPOIFilter();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle(R.string.access_hint_enter_name);
|
||||
|
||||
final EditText editText = new EditText(getContext());
|
||||
editText.setHint(R.string.new_filter);
|
||||
|
||||
final TextView textView = new TextView(getContext());
|
||||
textView.setText(app.getString(R.string.new_filter_desc));
|
||||
textView.setTextAppearance(getContext(), R.style.TextAppearance_ContextMenuSubtitle);
|
||||
LinearLayout ll = new LinearLayout(getContext());
|
||||
ll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||
ll.setOrientation(LinearLayout.VERTICAL);
|
||||
ll.setPadding(AndroidUtils.dpToPx(getContext(), 20f), AndroidUtils.dpToPx(getContext(), 12f), AndroidUtils.dpToPx(getContext(), 20f), AndroidUtils.dpToPx(getContext(), 12f));
|
||||
ll.addView(editText, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||
textView.setPadding(AndroidUtils.dpToPx(getContext(), 4f), AndroidUtils.dpToPx(getContext(), 6f), AndroidUtils.dpToPx(getContext(), 4f), AndroidUtils.dpToPx(getContext(), 4f));
|
||||
ll.addView(textView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||
|
||||
builder.setView(ll);
|
||||
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
builder.setPositiveButton(R.string.shared_string_save, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
PoiUIFilter nFilter = new PoiUIFilter(editText.getText().toString(), null, filter.getAcceptedTypes(), app);
|
||||
if (!Algorithms.isEmpty(filter.getFilterByName())) {
|
||||
nFilter.setSavedFilterByName(filter.getFilterByName());
|
||||
}
|
||||
if (app.getPoiFilters().createPoiFilter(nFilter)) {
|
||||
Toast.makeText(getContext(), MessageFormat.format(getContext().getText(R.string.edit_filter_create_message).toString(),
|
||||
editText.getText().toString()), Toast.LENGTH_SHORT).show();
|
||||
app.getSearchUICore().refreshCustomPoiFilters();
|
||||
replaceQueryWithUiFilter(nFilter, "");
|
||||
reloadCategories();
|
||||
|
||||
fabVisible = false;
|
||||
updateFab();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
public void restoreToolbar() {
|
||||
if (toolbarVisible) {
|
||||
if (toolbarTitle != null) {
|
||||
|
@ -680,6 +745,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
outState.putDouble(QUICK_SEARCH_LAT_KEY, centerLatLon.getLatitude());
|
||||
outState.putDouble(QUICK_SEARCH_LON_KEY, centerLatLon.getLongitude());
|
||||
}
|
||||
outState.putBoolean(QUICK_SEARCH_FAB_VISIBLE_KEY, fabVisible);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1297,8 +1363,14 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
}
|
||||
}
|
||||
|
||||
public void showFilter(String filterId) {
|
||||
public void showFilter(@NonNull String filterId) {
|
||||
PoiUIFilter filter = app.getPoiFilters().getFilterById(filterId);
|
||||
boolean isCustomFilter = filterId.equals(app.getPoiFilters().getCustomPOIFilter().getFilterId());
|
||||
if (isCustomFilter) {
|
||||
fabVisible = true;
|
||||
poiFilterApplied = true;
|
||||
updateFab();
|
||||
}
|
||||
|
||||
SearchResult sr = new SearchResult(searchUICore.getPhrase());
|
||||
sr.localeName = filter.getName();
|
||||
|
@ -1319,6 +1391,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
runCoreSearch(txt, false, false);
|
||||
}
|
||||
|
||||
private void updateFab() {
|
||||
fab.setVisibility(fabVisible ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
public class SearchFragmentPagerAdapter extends FragmentPagerAdapter {
|
||||
private final String[] fragments = new String[]{QuickSearchHistoryListFragment.class.getName(),
|
||||
QuickSearchCategoriesListFragment.class.getName()};
|
||||
|
|
|
@ -152,8 +152,25 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
|||
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
|
||||
MenuItem item;
|
||||
|
||||
item = optionsMenu.getMenu().add(R.string.save_filter).setIcon(
|
||||
iconsCache.getThemedIcon(R.drawable.ic_action_save));
|
||||
if (!filter.isStandardFilter()) {
|
||||
item = optionsMenu.getMenu().add(R.string.edit_filter).setIcon(
|
||||
iconsCache.getThemedIcon(R.drawable.ic_action_edit_dark));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
editFilter();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!filter.isStandardFilter()) {
|
||||
item = optionsMenu.getMenu().add(R.string.edit_filter_save_as_menu_item).setIcon(
|
||||
iconsCache.getThemedIcon(R.drawable.ic_action_save));
|
||||
} else {
|
||||
item = optionsMenu.getMenu().add(R.string.save_filter).setIcon(
|
||||
iconsCache.getThemedIcon(R.drawable.ic_action_save));
|
||||
}
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
|
@ -304,13 +321,19 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
|||
builder.create().show();
|
||||
}
|
||||
|
||||
private void editFilter() {
|
||||
QuickSearchCustomPoiFragment.showDialog(this, filter.getFilterId());
|
||||
}
|
||||
|
||||
private void saveFilter() {
|
||||
final OsmandApplication app = getMyApplication();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle(R.string.access_hint_enter_name);
|
||||
|
||||
final EditText editText = new EditText(getContext());
|
||||
editText.setHint(R.string.new_filter);
|
||||
editText.setText(filter.getName());
|
||||
|
||||
final TextView textView = new TextView(getContext());
|
||||
textView.setText(app.getString(R.string.new_filter_desc));
|
||||
textView.setTextAppearance(getContext(), R.style.TextAppearance_ContextMenuSubtitle);
|
||||
|
@ -321,7 +344,9 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
|||
ll.addView(editText, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||
textView.setPadding(AndroidUtils.dpToPx(getContext(), 4f), AndroidUtils.dpToPx(getContext(), 6f), AndroidUtils.dpToPx(getContext(), 4f), AndroidUtils.dpToPx(getContext(), 4f));
|
||||
ll.addView(textView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||
|
||||
builder.setView(ll);
|
||||
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
builder.setPositiveButton(R.string.shared_string_save, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue