diff --git a/android/res/layout/search_box.xml b/android/res/layout/search_box.xml index 2f971d10a3..340f28d24a 100644 --- a/android/res/layout/search_box.xml +++ b/android/res/layout/search_box.xml @@ -48,7 +48,7 @@ android:layout_weight="1" android:background="@null" android:fontFamily="@string/robotoLight" - android:imeOptions="actionDone|flagNoExtractUi" + android:imeOptions="actionSearch|flagNoExtractUi" android:inputType="text" android:padding="@dimen/margin_tiny" android:singleLine="true" diff --git a/android/src/com/mapswithme/maps/SearchActivity.java b/android/src/com/mapswithme/maps/SearchActivity.java index c20f197726..0547b146c2 100644 --- a/android/src/com/mapswithme/maps/SearchActivity.java +++ b/android/src/com/mapswithme/maps/SearchActivity.java @@ -561,26 +561,21 @@ public class SearchActivity extends MapsWithMeBaseListActivity implements Locati runSearch(); } - // Listen for keyboard buttons mSearchEt.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - if (doShowCategories()) - return false; + final boolean isSearchDown = (event != null) && + (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_SEARCH); + final boolean isActionSearch = (actionId == EditorInfo.IME_ACTION_SEARCH); - final boolean isEnterDown = (event != null) && - (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER); - final boolean isActionDone = (actionId == EditorInfo.IME_ACTION_DONE); - - if (isEnterDown || isActionDone) + if ((isSearchDown || isActionSearch) && getSearchAdapter().getCount() > 0) { - if (getSearchAdapter().getCount() > 1) - { - getListView().performItemClick(getSearchAdapter().getView(0, null, null), 0, 0); - return true; - } + Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.SEARCH_KEY_PRESSED); + if (!doShowCategories()) + presentResult(0); + return true; } return false; } @@ -696,7 +691,7 @@ public class SearchActivity extends MapsWithMeBaseListActivity implements Locati final String suggestion = getSearchAdapter().onItemClick(position); if (suggestion == null) { - presentResult(v, position); + presentResult(position); } else { @@ -705,7 +700,7 @@ public class SearchActivity extends MapsWithMeBaseListActivity implements Locati } } - private void presentResult(View v, int position) + private void presentResult(int position) { // If user searched for something, then clear API layer SearchController.getInstance().cancelApiCall(); diff --git a/android/src/com/mapswithme/util/statistics/Statistics.java b/android/src/com/mapswithme/util/statistics/Statistics.java index 7bf06e77da..51ee2e7f01 100644 --- a/android/src/com/mapswithme/util/statistics/Statistics.java +++ b/android/src/com/mapswithme/util/statistics/Statistics.java @@ -61,6 +61,7 @@ public enum Statistics public static final String SETTINGS_HELP = "Settings. Help."; public static final String SETTINGS_ABOUT = "Settings. About."; public static final String SETTINGS_COPYRIGHT = "Settings. Copyright."; + public static final String SEARCH_KEY_PRESSED = "Search key pressed."; }