From bc0bdcf99c995689d86c080677ad32f1bbcc2e99 Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 20 Jul 2018 17:05:25 +0300 Subject: [PATCH 1/8] Fix #4735 --- .../search/QuickSearchDialogFragment.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index 3f3b89c669..121cee5022 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -1135,18 +1135,21 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC for (SearchResult sr : res.getCurrentSearchResults()) { rows.add(new QuickSearchListItem(app, sr)); } - if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) { - rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_world_globe_dark, - app.getString(R.string.search_online_address), new OnClickListener() { - @Override - public void onClick(View view) { - startOnlineSearch(); - mainSearchFragment.getAdapter().clear(); - updateTabbarVisibility(false); - openKeyboard(); + rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_world_globe_dark, + app.getString(R.string.search_online_address), new OnClickListener() { + @Override + public void onClick(View view) { + final OsmandSettings settings = app.getSettings(); + if (!settings.isInternetConnectionAvailable()) { + Toast.makeText(app, R.string.internet_not_available, Toast.LENGTH_LONG).show(); + return; } - })); - } + startOnlineSearch(); + mainSearchFragment.getAdapter().clear(); + updateTabbarVisibility(false); + openKeyboard(); + } + })); rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_action_search_dark, app.getString(R.string.custom_search), new OnClickListener() { @Override From 743a9c6a01df9b51271405280845c8e97834b8fd Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 23 Jul 2018 16:12:52 +0300 Subject: [PATCH 2/8] add ability to send missing search queries --- OsmAnd/res/drawable/btn_border_bg_dark.xml | 18 +++++ OsmAnd/res/drawable/btn_border_bg_light.xml | 18 +++++ OsmAnd/res/layout/search_dialog_fragment.xml | 74 +++++++++++++++++++ .../layout/send_missing_search_query_tv.xml | 12 +++ OsmAnd/res/values/attrs.xml | 1 + OsmAnd/res/values/strings.xml | 4 + OsmAnd/res/values/styles.xml | 2 + .../search/QuickSearchDialogFragment.java | 35 +++++++++ .../search/SendSearchQueryBottomSheet.java | 68 +++++++++++++++++ 9 files changed, 232 insertions(+) create mode 100644 OsmAnd/res/drawable/btn_border_bg_dark.xml create mode 100644 OsmAnd/res/drawable/btn_border_bg_light.xml create mode 100644 OsmAnd/res/layout/send_missing_search_query_tv.xml create mode 100644 OsmAnd/src/net/osmand/plus/search/SendSearchQueryBottomSheet.java diff --git a/OsmAnd/res/drawable/btn_border_bg_dark.xml b/OsmAnd/res/drawable/btn_border_bg_dark.xml new file mode 100644 index 0000000000..ba97ce635a --- /dev/null +++ b/OsmAnd/res/drawable/btn_border_bg_dark.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/btn_border_bg_light.xml b/OsmAnd/res/drawable/btn_border_bg_light.xml new file mode 100644 index 0000000000..13de12e8c1 --- /dev/null +++ b/OsmAnd/res/drawable/btn_border_bg_light.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/search_dialog_fragment.xml b/OsmAnd/res/layout/search_dialog_fragment.xml index ec13482327..eaeb68b1d6 100644 --- a/OsmAnd/res/layout/search_dialog_fragment.xml +++ b/OsmAnd/res/layout/search_dialog_fragment.xml @@ -2,6 +2,7 @@ @@ -201,4 +202,77 @@ android:clickable="true" android:src="@drawable/ic_action_save"/> + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/send_missing_search_query_tv.xml b/OsmAnd/res/layout/send_missing_search_query_tv.xml new file mode 100644 index 0000000000..27a9578e32 --- /dev/null +++ b/OsmAnd/res/layout/send_missing_search_query_tv.xml @@ -0,0 +1,12 @@ + + diff --git a/OsmAnd/res/values/attrs.xml b/OsmAnd/res/values/attrs.xml index 3672e39346..b84259168e 100644 --- a/OsmAnd/res/values/attrs.xml +++ b/OsmAnd/res/values/attrs.xml @@ -14,6 +14,7 @@ + diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 103dd2a92d..7cf11092e6 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -10,6 +10,10 @@ - For wording and consistency, please note http://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience Thx - Hardy --> + "%1$s", as well as your location.

+ We do not collect personal information, we only need search data to improve the search algorithm.
]]>
+ No results?\nTell us about this. + Send search query? World Point %1$s deleted Edit point diff --git a/OsmAnd/res/values/styles.xml b/OsmAnd/res/values/styles.xml index a2d42b0b5a..6f3d9dcd0d 100644 --- a/OsmAnd/res/values/styles.xml +++ b/OsmAnd/res/values/styles.xml @@ -124,6 +124,7 @@ @color/color_white @color/icon_color @drawable/btn_flat + @drawable/btn_border_bg_light @null @color/actionbar_light_color @style/Widget.Styled.ActionBarLight @@ -352,6 +353,7 @@ @color/color_white @color/dash_search_icon_dark @drawable/btn_flat_night + @drawable/btn_border_bg_dark @color/actionbar_dark_color @style/Widget.Styled.ActionBarDark @color/bg_color_dark diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index 121cee5022..b69449bc88 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -33,6 +33,7 @@ import android.view.inputmethod.EditorInfo; import android.widget.AdapterView; import android.widget.CheckBox; import android.widget.EditText; +import android.widget.FrameLayout; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; @@ -102,6 +103,8 @@ import java.text.MessageFormat; import java.util.ArrayList; 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.SEARCH_STARTED; 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 searchView; private View buttonToolbarView; + private View sendEmptySearchView; private ImageView buttonToolbarImage; private ImageButton buttonToolbarFilter; private TextView buttonToolbarText; + private TextView sendEmptySearchText; + private FrameLayout sendEmptySearchButton; private QuickSearchMainListFragment mainSearchFragment; private QuickSearchHistoryListFragment historySearchFragment; private QuickSearchCategoriesListFragment categoriesSearchFragment; @@ -178,6 +184,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC private boolean expired; private boolean poiFilterApplied; private boolean fabVisible; + private boolean sendEmptySearchBottomBarVisible; private boolean runSearchFirstTime; private boolean phraseDefined; private boolean addressSearch; @@ -555,6 +562,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC updateClearButtonVisibility(true); boolean textEmpty = newQueryText.length() == 0; updateTabbarVisibility(textEmpty && !isOnlineSearch()); + updateSendEmptySearchBottomBar(false); if (textEmpty) { if (addressSearch) { startAddressSearch(); @@ -609,6 +617,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC updateClearButtonVisibility(true); startLocationUpdate(); } + updateSendEmptySearchBottomBar(false); updateToolbarButton(); } } @@ -625,6 +634,24 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC 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) { + Bundle args = new Bundle(); + SendSearchQueryBottomSheet fragment = new SendSearchQueryBottomSheet(); + args.putString(MISSING_SEARCH_QUERY_KEY, searchQuery); + if (location != null) { + args.putString(MISSING_SEARCH_LOCATION_KEY, location.toString()); + } + fragment.setArguments(args); + fragment.show(mapActivity.getSupportFragmentManager(), SendSearchQueryBottomSheet.TAG); + } + }); + updateFab(); + return view; } @@ -1848,6 +1875,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC moreListItem.setOnlineSearch(isOnlineSearch()); moreListItem.setSearchMoreAvailable(searchMoreAvailable); mainSearchFragment.addListItem(moreListItem); + updateSendEmptySearchBottomBar(isResultEmpty() && !interruptedSearch); } } @@ -1859,6 +1887,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC for (final SearchResult sr : res.getCurrentSearchResults()) { rows.add(new QuickSearchListItem(app, sr)); } + updateSendEmptySearchBottomBar(false); } mainSearchFragment.updateListAdapter(rows, append); } @@ -2114,6 +2143,12 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC 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 { void searchStarted(SearchPhrase phrase); void publish(SearchResultCollection res, boolean append); diff --git a/OsmAnd/src/net/osmand/plus/search/SendSearchQueryBottomSheet.java b/OsmAnd/src/net/osmand/plus/search/SendSearchQueryBottomSheet.java new file mode 100644 index 0000000000..0337eb6cb3 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/search/SendSearchQueryBottomSheet.java @@ -0,0 +1,68 @@ +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 net.osmand.AndroidNetworkUtils; +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 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() { + AndroidNetworkUtils.sendRequestAsync(getMyApplication(), "http://osmand.net/api/missing_search", params, + null, true, true, null); + dismiss(); + } +} From 2e0e53bee04e4ef23e979117284f7bb5d6252a45 Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 23 Jul 2018 16:18:55 +0300 Subject: [PATCH 3/8] add check for internet --- .../plus/search/SendSearchQueryBottomSheet.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/search/SendSearchQueryBottomSheet.java b/OsmAnd/src/net/osmand/plus/search/SendSearchQueryBottomSheet.java index 0337eb6cb3..936f73e0d7 100644 --- a/OsmAnd/src/net/osmand/plus/search/SendSearchQueryBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/search/SendSearchQueryBottomSheet.java @@ -6,8 +6,10 @@ 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; @@ -61,8 +63,15 @@ public class SendSearchQueryBottomSheet extends MenuBottomSheetDialogFragment { @Override protected void onRightBottomButtonClick() { - AndroidNetworkUtils.sendRequestAsync(getMyApplication(), "http://osmand.net/api/missing_search", params, - null, true, true, null); + 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(); } } From c198c78b51cb60dfb56eee368fb793216d4972d9 Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 23 Jul 2018 17:00:31 +0300 Subject: [PATCH 4/8] add check for internet before opening dialog --- .../search/QuickSearchDialogFragment.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index b69449bc88..a7260d032c 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -640,14 +640,21 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC sendEmptySearchButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - Bundle args = new Bundle(); - SendSearchQueryBottomSheet fragment = new SendSearchQueryBottomSheet(); - args.putString(MISSING_SEARCH_QUERY_KEY, searchQuery); - if (location != null) { - args.putString(MISSING_SEARCH_LOCATION_KEY, location.toString()); + 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); + } + } } - fragment.setArguments(args); - fragment.show(mapActivity.getSupportFragmentManager(), SendSearchQueryBottomSheet.TAG); } }); updateFab(); From 8d095cfb0e23eacd3e7fbb646cd2cbb147216387 Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 23 Jul 2018 17:19:17 +0300 Subject: [PATCH 5/8] fix string backslash --- OsmAnd/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 7cf11092e6..2f08137a7c 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -10,7 +10,7 @@ - For wording and consistency, please note http://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience Thx - Hardy --> - "%1$s", as well as your location.

+ \"%1$s\", as well as your location.

We do not collect personal information, we only need search data to improve the search algorithm.
]]>
No results?\nTell us about this. Send search query? From 09735f998a508b4bf0090ed0073f5f0bbd7c2583 Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 23 Jul 2018 17:29:34 +0300 Subject: [PATCH 6/8] remove selectors --- OsmAnd/res/drawable/btn_border_bg_dark.xml | 26 +++++++-------------- OsmAnd/res/drawable/btn_border_bg_light.xml | 26 +++++++-------------- 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/OsmAnd/res/drawable/btn_border_bg_dark.xml b/OsmAnd/res/drawable/btn_border_bg_dark.xml index ba97ce635a..c77fc8d62d 100644 --- a/OsmAnd/res/drawable/btn_border_bg_dark.xml +++ b/OsmAnd/res/drawable/btn_border_bg_dark.xml @@ -1,18 +1,10 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + diff --git a/OsmAnd/res/drawable/btn_border_bg_light.xml b/OsmAnd/res/drawable/btn_border_bg_light.xml index 13de12e8c1..792f94e56f 100644 --- a/OsmAnd/res/drawable/btn_border_bg_light.xml +++ b/OsmAnd/res/drawable/btn_border_bg_light.xml @@ -1,18 +1,10 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + \ No newline at end of file From 6af1ab24b799c831f721d4b3843f7c1bc44afabb Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 23 Jul 2018 17:30:57 +0300 Subject: [PATCH 7/8] remove unnecessary shape tag --- OsmAnd/res/drawable/btn_border_bg_dark.xml | 15 +++++++-------- OsmAnd/res/drawable/btn_border_bg_light.xml | 15 +++++++-------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/OsmAnd/res/drawable/btn_border_bg_dark.xml b/OsmAnd/res/drawable/btn_border_bg_dark.xml index c77fc8d62d..d533d20084 100644 --- a/OsmAnd/res/drawable/btn_border_bg_dark.xml +++ b/OsmAnd/res/drawable/btn_border_bg_dark.xml @@ -1,10 +1,9 @@ - - - - - - + + + + diff --git a/OsmAnd/res/drawable/btn_border_bg_light.xml b/OsmAnd/res/drawable/btn_border_bg_light.xml index 792f94e56f..78e70cb7a3 100644 --- a/OsmAnd/res/drawable/btn_border_bg_light.xml +++ b/OsmAnd/res/drawable/btn_border_bg_light.xml @@ -1,10 +1,9 @@ - - - - - - + + + + \ No newline at end of file From 4af42a3a5bd98b4e7bf11ac986a9f2444d7b94ae Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 23 Jul 2018 17:32:41 +0300 Subject: [PATCH 8/8] remove unnecessary shape tag --- OsmAnd/res/drawable/btn_border_bg_dark.xml | 1 - OsmAnd/res/drawable/btn_border_bg_light.xml | 1 - 2 files changed, 2 deletions(-) diff --git a/OsmAnd/res/drawable/btn_border_bg_dark.xml b/OsmAnd/res/drawable/btn_border_bg_dark.xml index d533d20084..0ba2ea7fb1 100644 --- a/OsmAnd/res/drawable/btn_border_bg_dark.xml +++ b/OsmAnd/res/drawable/btn_border_bg_dark.xml @@ -1,7 +1,6 @@ - -