Bug 1320449 - Enable keyboard text prediction on the awesome bar during normal browsing. r=sebastian
authorJan Henning <jh+bugzilla@buttercookie.de>
Sat, 26 Nov 2016 15:14:22 +0100
changeset 324797 3118e664715ba656a1f9fde28cb61d22efd5c4f7
parent 324796 02c0dad1974eb9a35c324543cbfbf1e94ba486df
child 324798 3a44959def71d9e859bbaa40668f79995a6a6184
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerssebastian
bugs1320449
milestone53.0a1
Bug 1320449 - Enable keyboard text prediction on the awesome bar during normal browsing. r=sebastian MozReview-Commit-ID: 17xMoyDhYmn
mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarEditText.java
mobile/android/base/resources/layout/toolbar_edit_layout.xml
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarEditText.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarEditText.java
@@ -15,16 +15,17 @@ import org.mozilla.gecko.toolbar.Browser
 import org.mozilla.gecko.toolbar.BrowserToolbar.OnFilterListener;
 import org.mozilla.gecko.toolbar.ToolbarEditLayout.OnSearchStateChangeListener;
 import org.mozilla.gecko.util.GamepadUtils;
 import org.mozilla.gecko.util.StringUtils;
 
 import android.content.Context;
 import android.graphics.Rect;
 import android.text.Editable;
+import android.text.InputType;
 import android.text.NoCopySpan;
 import android.text.Selection;
 import android.text.Spanned;
 import android.text.TextUtils;
 import android.text.TextWatcher;
 import android.text.style.BackgroundColorSpan;
 import android.util.AttributeSet;
 import android.util.Log;
@@ -412,24 +413,30 @@ public class ToolbarEditText extends Cus
         return false;
     }
 
     /**
      * Code to handle deleting autocomplete first when backspacing.
      * If there is no autocomplete text, both removeAutocomplete() and commitAutocomplete()
      * are no-ops and return false. Therefore we can use them here without checking explicitly
      * if we have autocomplete text or not.
+     *
+     * Also turns off text prediction for private mode tabs.
      */
     @Override
     public InputConnection onCreateInputConnection(final EditorInfo outAttrs) {
         final InputConnection ic = super.onCreateInputConnection(outAttrs);
         if (ic == null) {
             return null;
         }
 
+        if (isPrivateMode()) {
+            outAttrs.inputType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
+        }
+
         return new InputConnectionWrapper(ic, false) {
             @Override
             public boolean deleteSurroundingText(final int beforeLength, final int afterLength) {
                 if (removeAutocomplete(getText())) {
                     // If we have autocomplete text, the cursor is at the boundary between
                     // regular and autocomplete text. So regardless of which direction we
                     // are deleting, we should delete the autocomplete text first.
                     // Make the IME aware that we interrupted the deleteSurroundingText call,
--- a/mobile/android/base/resources/layout/toolbar_edit_layout.xml
+++ b/mobile/android/base/resources/layout/toolbar_edit_layout.xml
@@ -25,17 +25,17 @@
         android:visibility="gone"/>
 
     <org.mozilla.gecko.toolbar.ToolbarEditText
           android:id="@+id/url_edit_text"
           style="@style/UrlBar.Title"
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:layout_weight="1.0"
-          android:inputType="textUri|textNoSuggestions"
+          android:inputType="textUri"
           android:imeOptions="actionGo|flagNoExtractUi|flagNoFullscreen"
           android:selectAllOnFocus="true"
           android:contentDescription="@string/url_bar_default_text"
           android:paddingRight="8dp"
           android:paddingEnd="8dp"
           gecko:autoUpdateTheme="false"/>
 
     <ImageButton android:id="@+id/qrcode"