Bug 1320449 - Enable keyboard text prediction on the awesome bar during normal browsing. r=sebastian draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Sat, 26 Nov 2016 15:14:22 +0100
changeset 444182 64ee68c411c830dc5e89197e7d7fc62a50f14978
parent 444181 b5047d193426ebd16ee4f9375bfa06dc2e9773a5
child 444183 46e49d17ebb4b4184487ff22cb5365e02ef9bffe
push id37216
push usermozilla@buttercookie.de
push dateSat, 26 Nov 2016 18:50:16 +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"