bug 710843 - switch keyboard action button from go to search when action would be a search in the awesome bar r=minkle
authorBrad Lassey <blassey@mozilla.com>
Thu, 15 Dec 2011 02:34:54 -0500
changeset 84309 e9014ab86f5dc0634566fb4023ebb16045bc51ae
parent 84308 c5ebfdbe12d9edeaa083f4cde5bedbd4b8926acd
child 84310 dacb8e36e8bd371f126fb67e64ee6e9e33f53bef
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersminkle
bugs710843
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 710843 - switch keyboard action button from go to search when action would be a search in the awesome bar r=minkle
mobile/android/base/AwesomeBar.java
mobile/android/base/resources/layout/awesomebar_search.xml
--- a/mobile/android/base/AwesomeBar.java
+++ b/mobile/android/base/AwesomeBar.java
@@ -47,16 +47,17 @@ import android.content.res.Configuration
 import android.os.Bundle;
 import android.text.Editable;
 import android.text.TextWatcher;
 import android.util.AttributeSet;
 import android.util.Log;
 import android.view.KeyEvent;
 import android.view.View;
 import android.view.inputmethod.InputMethodManager;
+import android.view.inputmethod.EditorInfo;
 import android.widget.Button;
 import android.widget.EditText;
 import android.widget.ImageButton;
 
 import org.json.JSONArray;
 import org.json.JSONObject;
 
 public class AwesomeBar extends Activity implements GeckoEventListener {
@@ -241,20 +242,28 @@ public class AwesomeBar extends Activity
         if (text.length() == 0) {
             mGoButton.setVisibility(View.GONE);
             return;
         }
 
         mGoButton.setVisibility(View.VISIBLE);
 
         int imageResource = R.drawable.ic_awesomebar_go;
-        if (isSearchUrl(text))
+        int imeAction = EditorInfo.IME_ACTION_GO;
+        if (isSearchUrl(text)) {
             imageResource = R.drawable.ic_awesomebar_search;
+            imeAction = EditorInfo.IME_ACTION_SEARCH;
+        }
+        mGoButton.setImageResource(imageResource);
 
-        mGoButton.setImageResource(imageResource);
+        if ((mText.getImeOptions() & EditorInfo.IME_MASK_ACTION) != imeAction) {
+            InputMethodManager imm = (InputMethodManager) mText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+            mText.setImeOptions(imeAction);
+            imm.restartInput(mText);
+        }
     }
 
     private void submitAndFinish(String url) {
         if (isSearchUrl(url))
             openSearchAndFinish(url, "__default__");
         else
             openUrlAndFinish(url);
     }
--- a/mobile/android/base/resources/layout/awesomebar_search.xml
+++ b/mobile/android/base/resources/layout/awesomebar_search.xml
@@ -11,17 +11,17 @@
               style="@style/AddressBar.Button"
               android:layout_width="fill_parent"
               android:layout_alignParentBottom="true"
               android:layout_centerVertical="true"
               android:paddingLeft="15dip"
               android:paddingRight="40dip"
               android:hint="@string/awesomebar_default_text"
               android:inputType="textUri"
-              android:imeOptions="actionGo"
+              android:imeOptions="actionSearch"
               android:singleLine="true"
               android:gravity="center_vertical|left">
              <requestFocus/>
         </view>
 
         <ImageButton android:id="@+id/awesomebar_button"
                      style="@style/AddressBar.ImageButton"
                      android:layout_width="wrap_content"