Bug 1320449 - Enable keyboard text prediction on the awesome bar during normal browsing. r=sebastian
MozReview-Commit-ID: 17xMoyDhYmn
--- 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"