[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"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_height="match_parent"
|
android:layout_width="match_parent"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
android:layout_height="match_parent">
|
||||||
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>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/tabs_view"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<net.osmand.plus.LockableViewPager
|
<android.support.design.widget.AppBarLayout
|
||||||
android:id="@+id/pager"
|
android:id="@+id/appbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="wrap_content">
|
||||||
android:layout_weight="1"/>
|
|
||||||
|
<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>
|
||||||
|
|
||||||
<LinearLayout
|
<ImageView
|
||||||
android:id="@+id/search_view"
|
android:id="@+id/fab"
|
||||||
android:layout_width="match_parent"
|
android:contentDescription="@string/layer_route"
|
||||||
android:layout_height="match_parent"
|
android:layout_width="@dimen/fab_size_with_shadow"
|
||||||
android:orientation="vertical"
|
android:layout_height="@dimen/fab_size_with_shadow"
|
||||||
android:visibility="gone">
|
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>
|
</FrameLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
|
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).
|
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
|
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="selected_categories">Selected categories</string>
|
||||||
<string name="create_custom_poi">Create custom POI</string>
|
<string name="create_custom_poi">Create custom POI</string>
|
||||||
<string name="custom_search">Custom search</string>
|
<string name="custom_search">Custom search</string>
|
||||||
|
|
|
@ -456,6 +456,8 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
|
||||||
public void clearFilter() {
|
public void clearFilter() {
|
||||||
acceptedTypes = new LinkedHashMap<>();
|
acceptedTypes = new LinkedHashMap<>();
|
||||||
poiAdditionals.clear();
|
poiAdditionals.clear();
|
||||||
|
filterByName = null;
|
||||||
|
clearCurrentResults();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean areAllTypesAccepted() {
|
public boolean areAllTypesAccepted() {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.AppCompatImageView;
|
import android.support.v7.widget.AppCompatImageView;
|
||||||
import android.support.v7.widget.AppCompatTextView;
|
import android.support.v7.widget.AppCompatTextView;
|
||||||
|
@ -15,7 +16,10 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.osm.PoiCategory;
|
import net.osmand.osm.PoiCategory;
|
||||||
import net.osmand.osm.PoiType;
|
import net.osmand.osm.PoiType;
|
||||||
|
@ -50,6 +54,8 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
private View bottomBar;
|
private View bottomBar;
|
||||||
private AppCompatTextView barTitle;
|
private AppCompatTextView barTitle;
|
||||||
private AppCompatTextView barButton;
|
private AppCompatTextView barButton;
|
||||||
|
private boolean editMode;
|
||||||
|
|
||||||
|
|
||||||
public QuickSearchCustomPoiFragment() {
|
public QuickSearchCustomPoiFragment() {
|
||||||
}
|
}
|
||||||
|
@ -83,6 +89,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
filter = helper.getCustomPOIFilter();
|
filter = helper.getCustomPOIFilter();
|
||||||
filter.clearFilter();
|
filter.clearFilter();
|
||||||
}
|
}
|
||||||
|
editMode = !filterId.equals(helper.getCustomPOIFilter().getFilterId());
|
||||||
|
|
||||||
view = inflater.inflate(R.layout.search_custom_poi, container, false);
|
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 = (ListView) view.findViewById(android.R.id.list);
|
||||||
listView.setBackgroundColor(getResources().getColor(
|
listView.setBackgroundColor(getResources().getColor(
|
||||||
app.getSettings().isLightContent() ? R.color.ctx_menu_info_view_bg_light
|
app.getSettings().isLightContent() ? R.color.ctx_menu_info_view_bg_light
|
||||||
|
@ -111,7 +123,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
PoiCategory category = listAdapter.getItem(position - listView.getHeaderViewsCount());
|
PoiCategory category = listAdapter.getItem(position - listView.getHeaderViewsCount());
|
||||||
showDialog(category);
|
showDialog(category, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -122,7 +134,10 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
dismiss();
|
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);
|
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) {
|
private int getIconId(PoiCategory category) {
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
String id = null;
|
String id = null;
|
||||||
|
@ -197,6 +237,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
iconView.setImageDrawable(null);
|
iconView.setImageDrawable(null);
|
||||||
}
|
}
|
||||||
secondaryIconView.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_additional_option));
|
secondaryIconView.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_additional_option));
|
||||||
|
check.setOnCheckedChangeListener(null);
|
||||||
check.setChecked(filter.isTypeAccepted(category));
|
check.setChecked(filter.isTypeAccepted(category));
|
||||||
String textString = category.getTranslation();
|
String textString = category.getTranslation();
|
||||||
titleView.setText(textString);
|
titleView.setText(textString);
|
||||||
|
@ -225,17 +266,16 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRowListener(final PoiCategory category, final SwitchCompat check) {
|
private void addRowListener(final PoiCategory category, final SwitchCompat check) {
|
||||||
check.setOnClickListener(new View.OnClickListener() {
|
check.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
if (check.isChecked()) {
|
if (check.isChecked()) {
|
||||||
filter.setTypeToAccept(category, true);
|
showDialog(category, true);
|
||||||
showDialog(category);
|
|
||||||
} else {
|
} else {
|
||||||
filter.setTypeToAccept(category, false);
|
filter.setTypeToAccept(category, false);
|
||||||
saveFilter();
|
saveFilter();
|
||||||
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -243,19 +283,21 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
|
|
||||||
private void saveFilter() {
|
private void saveFilter() {
|
||||||
helper.editPoiFilter(filter);
|
helper.editPoiFilter(filter);
|
||||||
if (filter.isEmpty()) {
|
if (!editMode) {
|
||||||
bottomBar.setVisibility(View.GONE);
|
if (filter.isEmpty()) {
|
||||||
} else {
|
bottomBar.setVisibility(View.GONE);
|
||||||
barTitle.setText(getContext().getString(R.string.selected_categories) + ": " + filter.getAcceptedTypesCount());
|
} else {
|
||||||
bottomBar.setVisibility(View.VISIBLE);
|
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();
|
final int index = listView.getFirstVisiblePosition();
|
||||||
View v = listView.getChildAt(0);
|
View v = listView.getChildAt(0);
|
||||||
final int top = (v == null) ? 0 : v.getTop();
|
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>();
|
final LinkedHashMap<String, String> subCategories = new LinkedHashMap<String, String>();
|
||||||
Set<String> acceptedCategories = filter.getAcceptedSubtypes(poiCategory);
|
Set<String> acceptedCategories = filter.getAcceptedSubtypes(poiCategory);
|
||||||
if (acceptedCategories != null) {
|
if (acceptedCategories != null) {
|
||||||
|
@ -281,17 +323,27 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
});
|
});
|
||||||
final String[] visibleNames = new String[array.length];
|
final String[] visibleNames = new String[array.length];
|
||||||
final boolean[] selected = new boolean[array.length];
|
final boolean[] selected = new boolean[array.length];
|
||||||
|
boolean allSelected = true;
|
||||||
for (int i = 0; i < array.length; i++) {
|
for (int i = 0; i < array.length; i++) {
|
||||||
final String subcategory = array[i];
|
final String subcategory = array[i];
|
||||||
visibleNames[i] = subCategories.get(subcategory);
|
visibleNames[i] = subCategories.get(subcategory);
|
||||||
if (acceptedCategories == null) {
|
if (acceptedCategories == null || selectAll) {
|
||||||
selected[i] = true;
|
selected[i] = true;
|
||||||
} else {
|
} else {
|
||||||
|
if (allSelected) {
|
||||||
|
allSelected = false;
|
||||||
|
}
|
||||||
selected[i] = acceptedCategories.contains(subcategory);
|
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.setCancelable(true);
|
||||||
builder.setNegativeButton(getContext().getText(R.string.shared_string_cancel), new DialogInterface.OnClickListener() {
|
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() {
|
builder.setMultiChoiceItems(visibleNames, selected, new DialogInterface.OnMultiChoiceClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -340,13 +382,19 @@ public class QuickSearchCustomPoiFragment extends DialogFragment {
|
||||||
selected[item] = isChecked;
|
selected[item] = isChecked;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.show();
|
final AlertDialog dialog = builder.show();
|
||||||
|
check.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
}
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
public void selectAllFromCategory(PoiCategory poiCategory) {
|
if (isChecked) {
|
||||||
filter.updateTypesToAccept(poiCategory);
|
Arrays.fill(selected, true);
|
||||||
saveFilter();
|
} else {
|
||||||
listAdapter.notifyDataSetChanged();
|
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.EditText;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
|
@ -75,6 +77,7 @@ import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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_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_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_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 Toolbar toolbar;
|
||||||
private LockableViewPager viewPager;
|
private LockableViewPager viewPager;
|
||||||
|
@ -110,6 +114,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
|
|
||||||
private Toolbar toolbarEdit;
|
private Toolbar toolbarEdit;
|
||||||
private TextView titleEdit;
|
private TextView titleEdit;
|
||||||
|
private View fab;
|
||||||
|
|
||||||
private EditText searchEditText;
|
private EditText searchEditText;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
|
@ -136,6 +141,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
private boolean interruptedSearch;
|
private boolean interruptedSearch;
|
||||||
private long hideTimeMs;
|
private long hideTimeMs;
|
||||||
private boolean poiFilterApplied;
|
private boolean poiFilterApplied;
|
||||||
|
private boolean fabVisible;
|
||||||
|
|
||||||
private static final double DISTANCE_THRESHOLD = 70000; // 70km
|
private static final double DISTANCE_THRESHOLD = 70000; // 70km
|
||||||
private static final int EXPIRATION_TIME_MIN = 10; // 10 minutes
|
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);
|
hidden = savedInstanceState.getBoolean(QUICK_SEARCH_HIDDEN_KEY, false);
|
||||||
toolbarTitle = savedInstanceState.getString(QUICK_SEARCH_TOOLBAR_TITLE_KEY);
|
toolbarTitle = savedInstanceState.getString(QUICK_SEARCH_TOOLBAR_TITLE_KEY);
|
||||||
toolbarVisible = savedInstanceState.getBoolean(QUICK_SEARCH_TOOLBAR_VISIBLE_KEY, false);
|
toolbarVisible = savedInstanceState.getBoolean(QUICK_SEARCH_TOOLBAR_VISIBLE_KEY, false);
|
||||||
|
fabVisible = savedInstanceState.getBoolean(QUICK_SEARCH_FAB_VISIBLE_KEY, false);
|
||||||
}
|
}
|
||||||
if (searchQuery == null && arguments != null) {
|
if (searchQuery == null && arguments != null) {
|
||||||
searchQuery = arguments.getString(QUICK_SEARCH_QUERY_KEY);
|
searchQuery = arguments.getString(QUICK_SEARCH_QUERY_KEY);
|
||||||
|
@ -429,6 +436,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
if (textEmpty && poiFilterApplied) {
|
if (textEmpty && poiFilterApplied) {
|
||||||
poiFilterApplied = false;
|
poiFilterApplied = false;
|
||||||
reloadCategories();
|
reloadCategories();
|
||||||
|
if (fabVisible) {
|
||||||
|
fabVisible = false;
|
||||||
|
updateFab();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!searchQuery.equalsIgnoreCase(newQueryText)) {
|
if (!searchQuery.equalsIgnoreCase(newQueryText)) {
|
||||||
searchQuery = 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);
|
setupSearch(mapActivity);
|
||||||
|
|
||||||
return view;
|
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() {
|
public void restoreToolbar() {
|
||||||
if (toolbarVisible) {
|
if (toolbarVisible) {
|
||||||
if (toolbarTitle != null) {
|
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_LAT_KEY, centerLatLon.getLatitude());
|
||||||
outState.putDouble(QUICK_SEARCH_LON_KEY, centerLatLon.getLongitude());
|
outState.putDouble(QUICK_SEARCH_LON_KEY, centerLatLon.getLongitude());
|
||||||
}
|
}
|
||||||
|
outState.putBoolean(QUICK_SEARCH_FAB_VISIBLE_KEY, fabVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
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());
|
SearchResult sr = new SearchResult(searchUICore.getPhrase());
|
||||||
sr.localeName = filter.getName();
|
sr.localeName = filter.getName();
|
||||||
|
@ -1319,6 +1391,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
runCoreSearch(txt, false, false);
|
runCoreSearch(txt, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateFab() {
|
||||||
|
fab.setVisibility(fabVisible ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
public class SearchFragmentPagerAdapter extends FragmentPagerAdapter {
|
public class SearchFragmentPagerAdapter extends FragmentPagerAdapter {
|
||||||
private final String[] fragments = new String[]{QuickSearchHistoryListFragment.class.getName(),
|
private final String[] fragments = new String[]{QuickSearchHistoryListFragment.class.getName(),
|
||||||
QuickSearchCategoriesListFragment.class.getName()};
|
QuickSearchCategoriesListFragment.class.getName()};
|
||||||
|
|
|
@ -152,8 +152,25 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
||||||
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
|
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
|
||||||
MenuItem item;
|
MenuItem item;
|
||||||
|
|
||||||
item = optionsMenu.getMenu().add(R.string.save_filter).setIcon(
|
if (!filter.isStandardFilter()) {
|
||||||
iconsCache.getThemedIcon(R.drawable.ic_action_save));
|
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() {
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
@ -304,13 +321,19 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void editFilter() {
|
||||||
|
QuickSearchCustomPoiFragment.showDialog(this, filter.getFilterId());
|
||||||
|
}
|
||||||
|
|
||||||
private void saveFilter() {
|
private void saveFilter() {
|
||||||
final OsmandApplication app = getMyApplication();
|
final OsmandApplication app = getMyApplication();
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
builder.setTitle(R.string.access_hint_enter_name);
|
builder.setTitle(R.string.access_hint_enter_name);
|
||||||
|
|
||||||
final EditText editText = new EditText(getContext());
|
final EditText editText = new EditText(getContext());
|
||||||
editText.setHint(R.string.new_filter);
|
editText.setHint(R.string.new_filter);
|
||||||
editText.setText(filter.getName());
|
editText.setText(filter.getName());
|
||||||
|
|
||||||
final TextView textView = new TextView(getContext());
|
final TextView textView = new TextView(getContext());
|
||||||
textView.setText(app.getString(R.string.new_filter_desc));
|
textView.setText(app.getString(R.string.new_filter_desc));
|
||||||
textView.setTextAppearance(getContext(), R.style.TextAppearance_ContextMenuSubtitle);
|
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));
|
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));
|
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));
|
ll.addView(textView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
builder.setView(ll);
|
builder.setView(ll);
|
||||||
|
|
||||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
builder.setPositiveButton(R.string.shared_string_save, new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(R.string.shared_string_save, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue