Skip to content

Commit

Permalink
Add support for IME_FLAG_NO_PERSONALIZED_LEARNING on Android (flutter…
Browse files Browse the repository at this point in the history
  • Loading branch information
Renzo-Olivares authored Jul 30, 2021
1 parent 8bda579 commit 169bb4c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ public static Configuration fromJson(@NonNull JSONObject json)
json.optBoolean("obscureText"),
json.optBoolean("autocorrect", true),
json.optBoolean("enableSuggestions"),
json.optBoolean("enableIMEPersonalizedLearning"),
TextCapitalization.fromValue(json.getString("textCapitalization")),
InputType.fromJson(json.getJSONObject("inputType")),
inputAction,
Expand Down Expand Up @@ -573,6 +574,7 @@ public Autofill(
public final boolean obscureText;
public final boolean autocorrect;
public final boolean enableSuggestions;
public final boolean enableIMEPersonalizedLearning;
@NonNull public final TextCapitalization textCapitalization;
@NonNull public final InputType inputType;
@Nullable public final Integer inputAction;
Expand All @@ -584,6 +586,7 @@ public Configuration(
boolean obscureText,
boolean autocorrect,
boolean enableSuggestions,
boolean enableIMEPersonalizedLearning,
@NonNull TextCapitalization textCapitalization,
@NonNull InputType inputType,
@Nullable Integer inputAction,
Expand All @@ -593,6 +596,7 @@ public Configuration(
this.obscureText = obscureText;
this.autocorrect = autocorrect;
this.enableSuggestions = enableSuggestions;
this.enableIMEPersonalizedLearning = enableIMEPersonalizedLearning;
this.textCapitalization = textCapitalization;
this.inputType = inputType;
this.inputAction = inputAction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ private static int inputTypeFromTextInputType(
boolean obscureText,
boolean autocorrect,
boolean enableSuggestions,
boolean enableIMEPersonalizedLearning,
TextInputChannel.TextCapitalization textCapitalization) {
if (type.type == TextInputChannel.TextInputType.DATETIME) {
return InputType.TYPE_CLASS_DATETIME;
Expand Down Expand Up @@ -311,8 +312,15 @@ public InputConnection createInputConnection(
configuration.obscureText,
configuration.autocorrect,
configuration.enableSuggestions,
configuration.enableIMEPersonalizedLearning,
configuration.textCapitalization);
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
&& !configuration.enableIMEPersonalizedLearning) {
outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING;
}

int enterAction;
if (configuration.inputAction == null) {
// If an explicit input action isn't set, then default to none for multi-line fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public void setTextInputEditingState_doesNotInvokeUpdateEditingState() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
null,
null,
Expand Down Expand Up @@ -196,6 +197,7 @@ public void inputConnectionAdaptor_RepeatFilter() throws NullPointerException {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
new TextInputChannel.InputType(TextInputChannel.TextInputType.TEXT, false, false),
null,
Expand Down Expand Up @@ -284,6 +286,7 @@ public void setTextInputEditingState_doesNotRestartWhenTextIsIdentical() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
null,
null,
Expand Down Expand Up @@ -321,6 +324,7 @@ public void setTextInputEditingState_alwaysSetEditableWhenDifferent() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
null,
null,
Expand Down Expand Up @@ -367,6 +371,7 @@ public void setTextInputEditingState_restartsIMEOnlyWhenFrameworkChangesComposin
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
new TextInputChannel.InputType(TextInputChannel.TextInputType.TEXT, false, false),
null,
Expand Down Expand Up @@ -462,6 +467,7 @@ public void setTextInputEditingState_nullInputMethodSubtype() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
null,
null,
Expand Down Expand Up @@ -504,6 +510,7 @@ public void inputConnection_createsActionFromEnter() throws JSONException {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
new TextInputChannel.InputType(TextInputChannel.TextInputType.TEXT, false, false),
null,
Expand Down Expand Up @@ -582,6 +589,7 @@ public void inputConnection_finishComposingTextUpdatesIMM() throws JSONException
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
new TextInputChannel.InputType(TextInputChannel.TextInputType.TEXT, false, false),
null,
Expand Down Expand Up @@ -617,6 +625,7 @@ public void inputConnection_textInputTypeNone() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
new TextInputChannel.InputType(TextInputChannel.TextInputType.NONE, false, false),
null,
Expand Down Expand Up @@ -646,6 +655,7 @@ public void showTextInput_textInputTypeNone() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
new TextInputChannel.InputType(TextInputChannel.TextInputType.NONE, false, false),
null,
Expand Down Expand Up @@ -682,6 +692,7 @@ public void autofill_onProvideVirtualViewStructure() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
null,
null,
Expand All @@ -693,6 +704,7 @@ public void autofill_onProvideVirtualViewStructure() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
null,
null,
Expand All @@ -706,6 +718,7 @@ public void autofill_onProvideVirtualViewStructure() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
null,
null,
Expand Down Expand Up @@ -754,6 +767,7 @@ public void autofill_onProvideVirtualViewStructure_single() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
null,
null,
Expand Down Expand Up @@ -805,6 +819,7 @@ public void autofill_testLifeCycle() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
null,
null,
Expand All @@ -816,6 +831,7 @@ public void autofill_testLifeCycle() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
null,
null,
Expand All @@ -830,6 +846,7 @@ public void autofill_testLifeCycle() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
null,
null,
Expand Down Expand Up @@ -872,6 +889,7 @@ public void autofill_testLifeCycle() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
null,
null,
Expand Down Expand Up @@ -926,6 +944,7 @@ public void autofill_testAutofillUpdatesTheFramework() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
null,
null,
Expand All @@ -937,6 +956,7 @@ public void autofill_testAutofillUpdatesTheFramework() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
null,
null,
Expand All @@ -949,6 +969,7 @@ public void autofill_testAutofillUpdatesTheFramework() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
null,
null,
Expand Down Expand Up @@ -1011,6 +1032,7 @@ public void autofill_testSetTextIpnutClientUpdatesSideFields() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
null,
null,
Expand All @@ -1022,6 +1044,7 @@ public void autofill_testSetTextIpnutClientUpdatesSideFields() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
null,
null,
Expand All @@ -1034,6 +1057,7 @@ public void autofill_testSetTextIpnutClientUpdatesSideFields() {
false,
false,
true,
true,
TextInputChannel.TextCapitalization.NONE,
null,
null,
Expand Down

0 comments on commit 169bb4c

Please sign in to comment.