diff options
-rw-r--r-- | android/source/res/layout/toolbar_bottom.xml | 3 | ||||
-rw-r--r-- | android/source/src/java/org/libreoffice/SearchController.java | 19 |
2 files changed, 21 insertions, 1 deletions
diff --git a/android/source/res/layout/toolbar_bottom.xml b/android/source/res/layout/toolbar_bottom.xml index 7688dd4f01fc..f4b3f3c5f8cc 100644 --- a/android/source/res/layout/toolbar_bottom.xml +++ b/android/source/res/layout/toolbar_bottom.xml @@ -435,7 +435,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="0.2" - android:inputType="" /> + android:imeOptions="actionSearch" + android:inputType="text" /> <ImageButton android:id="@+id/button_search_down" diff --git a/android/source/src/java/org/libreoffice/SearchController.java b/android/source/src/java/org/libreoffice/SearchController.java index 61f5373c82f0..a9414f7f7a71 100644 --- a/android/source/src/java/org/libreoffice/SearchController.java +++ b/android/source/src/java/org/libreoffice/SearchController.java @@ -1,8 +1,11 @@ package org.libreoffice; +import android.view.KeyEvent; import android.view.View; +import android.view.inputmethod.EditorInfo; import android.widget.EditText; import android.widget.ImageButton; +import android.widget.TextView; import org.json.JSONException; import org.json.JSONObject; @@ -19,6 +22,22 @@ public class SearchController implements View.OnClickListener { activity.findViewById(R.id.button_search_up).setOnClickListener(this); activity.findViewById(R.id.button_search_down).setOnClickListener(this); + + ((EditText) mActivity.findViewById(R.id.search_string)).setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_SEARCH) { + // search downward when the "search button" on keyboard is pressed, + SearchDirection direction = SearchDirection.DOWN; + String searchText = ((EditText) mActivity.findViewById(R.id.search_string)).getText().toString(); + float x = mActivity.getCurrentCursorPosition().centerX(); + float y = mActivity.getCurrentCursorPosition().centerY(); + search(searchText, direction, x, y); + return true; + } + return false; + } + }); } private void search(String searchString, SearchDirection direction, float x, float y) { |