summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2020-03-06 09:36:04 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2020-03-06 16:46:36 +0100
commit8432df8bd8368b7b3d502e025fdae7d2cad06767 (patch)
tree6086421603d95f00d7dcc6bbf10bf9bda955f689 /android
parent01f58847bb1addb59e963fe820e01b8a191bacba (diff)
android: Make keyboard in search bar show "search button"
... instead of "Enter" key that inserted a newline when clicked. Instead, start a search in downward direction when the search button is clicked, which makes using the search feature more intuitive. I quickly tested with both, Writer and Calc. Change-Id: Iffc9f6115e558721b34d8fb4ae2ed4a36c4a7aa5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90092 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'android')
-rw-r--r--android/source/res/layout/toolbar_bottom.xml3
-rw-r--r--android/source/src/java/org/libreoffice/SearchController.java19
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) {