commit
a200608707
9 changed files with 242 additions and 11 deletions
8
OsmAnd/res/drawable/btn_border_bg_dark.xml
Normal file
8
OsmAnd/res/drawable/btn_border_bg_dark.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<corners android:radius="3dp" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/ctx_menu_info_divider_dark" />
|
||||||
|
</shape>
|
8
OsmAnd/res/drawable/btn_border_bg_light.xml
Normal file
8
OsmAnd/res/drawable/btn_border_bg_light.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<corners android:radius="3dp" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/ctx_menu_info_divider_light" />
|
||||||
|
</shape>
|
|
@ -2,6 +2,7 @@
|
||||||
<FrameLayout 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"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
@ -201,4 +202,77 @@
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_action_save"/>
|
android:src="@drawable/ic_action_save"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/no_search_results_bottom_bar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:background="?attr/ctx_menu_info_view_bg"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/keyboard_divider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="?attr/ctx_menu_info_divider" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/no_search_results_description"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
|
android:paddingBottom="@dimen/context_menu_padding_margin_tiny"
|
||||||
|
android:paddingLeft="@dimen/bottom_sheet_content_margin"
|
||||||
|
android:paddingRight="@dimen/bottom_sheet_content_margin"
|
||||||
|
android:paddingTop="@dimen/context_menu_padding_margin_tiny"
|
||||||
|
android:text="@string/search_no_results_description"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/send_empty_search_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/content_padding_small"
|
||||||
|
android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
|
||||||
|
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
||||||
|
android:layout_marginTop="@dimen/content_padding_small"
|
||||||
|
android:background="?attr/btn_border_bg">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/send_empty_search_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:gravity="center"
|
||||||
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:paddingBottom="@dimen/context_menu_padding_margin_small"
|
||||||
|
android:paddingLeft="@dimen/context_menu_padding_margin_small"
|
||||||
|
android:paddingRight="@dimen/context_menu_padding_margin_small"
|
||||||
|
android:paddingTop="@dimen/context_menu_padding_margin_small"
|
||||||
|
android:text="Отправить"
|
||||||
|
android:textColor="?attr/wikivoyage_active_color"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
12
OsmAnd/res/layout/send_missing_search_query_tv.xml
Normal file
12
OsmAnd/res/layout/send_missing_search_query_tv.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<net.osmand.plus.widgets.TextViewEx xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:minHeight="@dimen/bottom_sheet_title_height"
|
||||||
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingRight="@dimen/content_padding"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
|
tools:text="Some Title" />
|
|
@ -14,6 +14,7 @@
|
||||||
<attr name="searchbar_text_hint" format="color"/>
|
<attr name="searchbar_text_hint" format="color"/>
|
||||||
<attr name="list_divider" format="color"/>
|
<attr name="list_divider" format="color"/>
|
||||||
<attr name="btn_flat_bg" format="reference" />
|
<attr name="btn_flat_bg" format="reference" />
|
||||||
|
<attr name="btn_border_bg" format="reference" />
|
||||||
<attr name="expandable_list_item_background" format="color"/>
|
<attr name="expandable_list_item_background" format="color"/>
|
||||||
<attr name="expandable_list_background" format="color"/>
|
<attr name="expandable_list_background" format="color"/>
|
||||||
<attr name="bg_color" format="reference" />
|
<attr name="bg_color" format="reference" />
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
- For wording and consistency, please note http://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
|
- For wording and consistency, please note http://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="send_search_query_description"><![CDATA[We will send your search query: <b>\"%1$s\"</b>, as well as your location.<br/><br/>
|
||||||
|
We do not collect personal information, we only need search data to improve the search algorithm.<br/>]]></string>
|
||||||
|
<string name="search_no_results_description">No results?\nTell us about this.</string>
|
||||||
|
<string name="send_search_query">Send search query?</string>
|
||||||
<string name="shared_string_world">World</string>
|
<string name="shared_string_world">World</string>
|
||||||
<string name="point_deleted">Point %1$s deleted</string>
|
<string name="point_deleted">Point %1$s deleted</string>
|
||||||
<string name="coord_input_edit_point">Edit point</string>
|
<string name="coord_input_edit_point">Edit point</string>
|
||||||
|
|
|
@ -124,6 +124,7 @@
|
||||||
<item name="pstsTextColor">@color/color_white</item>
|
<item name="pstsTextColor">@color/color_white</item>
|
||||||
<item name="pstsInactiveTextColor">@color/icon_color</item>
|
<item name="pstsInactiveTextColor">@color/icon_color</item>
|
||||||
<item name="btn_flat_bg">@drawable/btn_flat</item>
|
<item name="btn_flat_bg">@drawable/btn_flat</item>
|
||||||
|
<item name="btn_border_bg">@drawable/btn_border_bg_light</item>
|
||||||
<item name="android:windowContentOverlay">@null</item>
|
<item name="android:windowContentOverlay">@null</item>
|
||||||
<item name="actionModeBackground">@color/actionbar_light_color</item>
|
<item name="actionModeBackground">@color/actionbar_light_color</item>
|
||||||
<item name="actionBarStyle">@style/Widget.Styled.ActionBarLight</item>
|
<item name="actionBarStyle">@style/Widget.Styled.ActionBarLight</item>
|
||||||
|
@ -352,6 +353,7 @@
|
||||||
<item name="pstsTextColor">@color/color_white</item>
|
<item name="pstsTextColor">@color/color_white</item>
|
||||||
<item name="pstsInactiveTextColor">@color/dash_search_icon_dark</item>
|
<item name="pstsInactiveTextColor">@color/dash_search_icon_dark</item>
|
||||||
<item name="btn_flat_bg">@drawable/btn_flat_night</item>
|
<item name="btn_flat_bg">@drawable/btn_flat_night</item>
|
||||||
|
<item name="btn_border_bg">@drawable/btn_border_bg_dark</item>
|
||||||
<item name="actionModeBackground">@color/actionbar_dark_color</item>
|
<item name="actionModeBackground">@color/actionbar_dark_color</item>
|
||||||
<item name="actionBarStyle">@style/Widget.Styled.ActionBarDark</item>
|
<item name="actionBarStyle">@style/Widget.Styled.ActionBarDark</item>
|
||||||
<item name="bg_color">@color/bg_color_dark</item>
|
<item name="bg_color">@color/bg_color_dark</item>
|
||||||
|
|
|
@ -33,6 +33,7 @@ import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
@ -102,6 +103,8 @@ import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static net.osmand.plus.search.SendSearchQueryBottomSheet.MISSING_SEARCH_LOCATION_KEY;
|
||||||
|
import static net.osmand.plus.search.SendSearchQueryBottomSheet.MISSING_SEARCH_QUERY_KEY;
|
||||||
import static net.osmand.search.core.ObjectType.POI_TYPE;
|
import static net.osmand.search.core.ObjectType.POI_TYPE;
|
||||||
import static net.osmand.search.core.ObjectType.SEARCH_STARTED;
|
import static net.osmand.search.core.ObjectType.SEARCH_STARTED;
|
||||||
import static net.osmand.search.core.SearchCoreFactory.SEARCH_AMENITY_TYPE_PRIORITY;
|
import static net.osmand.search.core.SearchCoreFactory.SEARCH_AMENITY_TYPE_PRIORITY;
|
||||||
|
@ -134,9 +137,12 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
private View tabsView;
|
private View tabsView;
|
||||||
private View searchView;
|
private View searchView;
|
||||||
private View buttonToolbarView;
|
private View buttonToolbarView;
|
||||||
|
private View sendEmptySearchView;
|
||||||
private ImageView buttonToolbarImage;
|
private ImageView buttonToolbarImage;
|
||||||
private ImageButton buttonToolbarFilter;
|
private ImageButton buttonToolbarFilter;
|
||||||
private TextView buttonToolbarText;
|
private TextView buttonToolbarText;
|
||||||
|
private TextView sendEmptySearchText;
|
||||||
|
private FrameLayout sendEmptySearchButton;
|
||||||
private QuickSearchMainListFragment mainSearchFragment;
|
private QuickSearchMainListFragment mainSearchFragment;
|
||||||
private QuickSearchHistoryListFragment historySearchFragment;
|
private QuickSearchHistoryListFragment historySearchFragment;
|
||||||
private QuickSearchCategoriesListFragment categoriesSearchFragment;
|
private QuickSearchCategoriesListFragment categoriesSearchFragment;
|
||||||
|
@ -178,6 +184,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
private boolean expired;
|
private boolean expired;
|
||||||
private boolean poiFilterApplied;
|
private boolean poiFilterApplied;
|
||||||
private boolean fabVisible;
|
private boolean fabVisible;
|
||||||
|
private boolean sendEmptySearchBottomBarVisible;
|
||||||
private boolean runSearchFirstTime;
|
private boolean runSearchFirstTime;
|
||||||
private boolean phraseDefined;
|
private boolean phraseDefined;
|
||||||
private boolean addressSearch;
|
private boolean addressSearch;
|
||||||
|
@ -555,6 +562,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
updateClearButtonVisibility(true);
|
updateClearButtonVisibility(true);
|
||||||
boolean textEmpty = newQueryText.length() == 0;
|
boolean textEmpty = newQueryText.length() == 0;
|
||||||
updateTabbarVisibility(textEmpty && !isOnlineSearch());
|
updateTabbarVisibility(textEmpty && !isOnlineSearch());
|
||||||
|
updateSendEmptySearchBottomBar(false);
|
||||||
if (textEmpty) {
|
if (textEmpty) {
|
||||||
if (addressSearch) {
|
if (addressSearch) {
|
||||||
startAddressSearch();
|
startAddressSearch();
|
||||||
|
@ -609,6 +617,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
updateClearButtonVisibility(true);
|
updateClearButtonVisibility(true);
|
||||||
startLocationUpdate();
|
startLocationUpdate();
|
||||||
}
|
}
|
||||||
|
updateSendEmptySearchBottomBar(false);
|
||||||
updateToolbarButton();
|
updateToolbarButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -625,6 +634,31 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
|
|
||||||
setupSearch(mapActivity);
|
setupSearch(mapActivity);
|
||||||
|
|
||||||
|
sendEmptySearchView = view.findViewById(R.id.no_search_results_bottom_bar);
|
||||||
|
sendEmptySearchText = view.findViewById(R.id.no_search_results_description);
|
||||||
|
sendEmptySearchButton = view.findViewById(R.id.send_empty_search_button);
|
||||||
|
sendEmptySearchButton.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
OsmandApplication app = getMyApplication();
|
||||||
|
if (app != null) {
|
||||||
|
if (!app.getSettings().isInternetConnectionAvailable()) {
|
||||||
|
Toast.makeText(app, R.string.internet_not_available, Toast.LENGTH_LONG).show();
|
||||||
|
} else {
|
||||||
|
if (location != null && searchQuery != null) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
SendSearchQueryBottomSheet fragment = new SendSearchQueryBottomSheet();
|
||||||
|
args.putString(MISSING_SEARCH_LOCATION_KEY, location.toString());
|
||||||
|
args.putString(MISSING_SEARCH_QUERY_KEY, searchQuery);
|
||||||
|
fragment.setArguments(args);
|
||||||
|
fragment.show(mapActivity.getSupportFragmentManager(), SendSearchQueryBottomSheet.TAG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
updateFab();
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1135,18 +1169,21 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
for (SearchResult sr : res.getCurrentSearchResults()) {
|
for (SearchResult sr : res.getCurrentSearchResults()) {
|
||||||
rows.add(new QuickSearchListItem(app, sr));
|
rows.add(new QuickSearchListItem(app, sr));
|
||||||
}
|
}
|
||||||
if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) {
|
rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_world_globe_dark,
|
||||||
rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_world_globe_dark,
|
app.getString(R.string.search_online_address), new OnClickListener() {
|
||||||
app.getString(R.string.search_online_address), new OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onClick(View view) {
|
||||||
public void onClick(View view) {
|
final OsmandSettings settings = app.getSettings();
|
||||||
startOnlineSearch();
|
if (!settings.isInternetConnectionAvailable()) {
|
||||||
mainSearchFragment.getAdapter().clear();
|
Toast.makeText(app, R.string.internet_not_available, Toast.LENGTH_LONG).show();
|
||||||
updateTabbarVisibility(false);
|
return;
|
||||||
openKeyboard();
|
|
||||||
}
|
}
|
||||||
}));
|
startOnlineSearch();
|
||||||
}
|
mainSearchFragment.getAdapter().clear();
|
||||||
|
updateTabbarVisibility(false);
|
||||||
|
openKeyboard();
|
||||||
|
}
|
||||||
|
}));
|
||||||
rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_action_search_dark,
|
rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_action_search_dark,
|
||||||
app.getString(R.string.custom_search), new OnClickListener() {
|
app.getString(R.string.custom_search), new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1845,6 +1882,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
moreListItem.setOnlineSearch(isOnlineSearch());
|
moreListItem.setOnlineSearch(isOnlineSearch());
|
||||||
moreListItem.setSearchMoreAvailable(searchMoreAvailable);
|
moreListItem.setSearchMoreAvailable(searchMoreAvailable);
|
||||||
mainSearchFragment.addListItem(moreListItem);
|
mainSearchFragment.addListItem(moreListItem);
|
||||||
|
updateSendEmptySearchBottomBar(isResultEmpty() && !interruptedSearch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1856,6 +1894,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
for (final SearchResult sr : res.getCurrentSearchResults()) {
|
for (final SearchResult sr : res.getCurrentSearchResults()) {
|
||||||
rows.add(new QuickSearchListItem(app, sr));
|
rows.add(new QuickSearchListItem(app, sr));
|
||||||
}
|
}
|
||||||
|
updateSendEmptySearchBottomBar(false);
|
||||||
}
|
}
|
||||||
mainSearchFragment.updateListAdapter(rows, append);
|
mainSearchFragment.updateListAdapter(rows, append);
|
||||||
}
|
}
|
||||||
|
@ -2111,6 +2150,12 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
fab.setVisibility(fabVisible ? View.VISIBLE : View.GONE);
|
fab.setVisibility(fabVisible ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateSendEmptySearchBottomBar(boolean sendSearchQueryVisible) {
|
||||||
|
sendEmptySearchView.setVisibility(sendSearchQueryVisible ? View.VISIBLE : View.GONE);
|
||||||
|
sendEmptySearchText.setVisibility(sendSearchQueryVisible ? View.VISIBLE : View.GONE);
|
||||||
|
sendEmptySearchButton.setVisibility(sendSearchQueryVisible ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
public interface SearchResultListener {
|
public interface SearchResultListener {
|
||||||
void searchStarted(SearchPhrase phrase);
|
void searchStarted(SearchPhrase phrase);
|
||||||
void publish(SearchResultCollection res, boolean append);
|
void publish(SearchResultCollection res, boolean append);
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
package net.osmand.plus.search;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.Html;
|
||||||
|
import android.view.ContextThemeWrapper;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import net.osmand.AndroidNetworkUtils;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
public class SendSearchQueryBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
|
public static final String TAG = "SendSearchQueryBottomSheet";
|
||||||
|
public static final String MISSING_SEARCH_QUERY_KEY = "missing_search_query_key";
|
||||||
|
public static final String MISSING_SEARCH_LOCATION_KEY = "missing_search_location_key";
|
||||||
|
|
||||||
|
private Map<String, String> params = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
|
Bundle args = getArguments();
|
||||||
|
if (args == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String searchQuery = args.getString(MISSING_SEARCH_QUERY_KEY);
|
||||||
|
String searchLocation = args.getString(MISSING_SEARCH_LOCATION_KEY);
|
||||||
|
if (Algorithms.isEmpty(searchQuery) || Algorithms.isEmpty(searchLocation)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
params.put(searchQuery, searchLocation);
|
||||||
|
items.add(new TitleItem(getString(R.string.send_search_query)));
|
||||||
|
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
|
final TextView textView = (TextView) View.inflate(new ContextThemeWrapper(getContext(), themeRes),
|
||||||
|
R.layout.send_missing_search_query_tv, null);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
textView.setText(Html.fromHtml(getString(R.string.send_search_query_description, searchQuery), android.text.Html.FROM_HTML_MODE_LEGACY));
|
||||||
|
} else {
|
||||||
|
textView.setText(Html.fromHtml(getString(R.string.send_search_query_description, searchQuery)));
|
||||||
|
}
|
||||||
|
BaseBottomSheetItem sendSearchQueryDescription = new SimpleBottomSheetItem.Builder().setCustomView(textView)
|
||||||
|
.create();
|
||||||
|
items.add(sendSearchQueryDescription);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getRightBottomButtonTextId() {
|
||||||
|
return R.string.shared_string_send;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRightBottomButtonClick() {
|
||||||
|
OsmandApplication app = getMyApplication();
|
||||||
|
if (app != null) {
|
||||||
|
if (!app.getSettings().isInternetConnectionAvailable()) {
|
||||||
|
Toast.makeText(app, R.string.internet_not_available, Toast.LENGTH_LONG).show();
|
||||||
|
} else {
|
||||||
|
AndroidNetworkUtils.sendRequestAsync(app, "http://osmand.net/api/missing_search", params,
|
||||||
|
null, true, true, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue