From dc618b3f7a80787777005e8b27135a330571d18e Mon Sep 17 00:00:00 2001 From: drizea Date: Mon, 13 Aug 2012 09:46:24 +0300 Subject: [PATCH] bug fix on searching for records using the Enter key (also change the enter key apperance to a search key on the virtual keyboard) --- .../searchCatalog/SearchCatalogListView.java | 30 ++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java index da1205e2c1..58e54e415a 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java @@ -18,13 +18,11 @@ import org.evergreen.android.views.ApplicationPreferences; import android.app.Activity; import android.app.AlertDialog; -import android.app.Dialog; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; import android.os.Bundle; -import android.preference.PreferenceActivity; import android.util.Log; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; @@ -37,7 +35,7 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnKeyListener; import android.view.ViewGroup; -import android.view.ViewGroup.LayoutParams; +import android.view.inputmethod.EditorInfo; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemSelectedListener; @@ -46,7 +44,6 @@ import android.widget.Button; import android.widget.EditText; import android.widget.ImageButton; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.ListView; import android.widget.Spinner; import android.widget.TextView; @@ -378,20 +375,27 @@ public class SearchCatalogListView extends Activity { searchText = (EditText) findViewById(R.id.searchText); + //enter key now is labeled "Search" on virtual keyboard + searchText.setImeActionLabel("Search", EditorInfo.IME_ACTION_SEARCH); + searchText.setImeOptions(EditorInfo.IME_ACTION_SEARCH); + + + //enter key on virtual keyboard starts the search searchText.setOnKeyListener(new OnKeyListener() { - - @Override - public boolean onKey(View v, int keyCode, KeyEvent event) { - - if (keyCode == KeyEvent.KEYCODE_ENTER) { + public boolean onKey(View v, int keyCode, KeyEvent event) { + // If the event is a key-down event on the "enter" button + if ((event.getAction() == KeyEvent.ACTION_DOWN) && + ((keyCode == KeyEvent.KEYCODE_ENTER) || keyCode == EditorInfo.IME_ACTION_SEARCH)) { + // Perform action on key press Thread searchThread = new Thread(searchForResultsRunnable); - searchThread.start(); - } - return false; - } + return true; + } + return false; + } }); + choseOrganisation = (Spinner) findViewById(R.id.chose_organisation); searchButton = (ImageButton) findViewById(R.id.searchButton); -- 2.11.0