Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a1967fd

Browse files
fix lint
1 parent e87f57f commit a1967fd

File tree

2 files changed

+16
-46
lines changed

2 files changed

+16
-46
lines changed

shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ private void hideTextInput(View view) {
298298
}
299299

300300
private void notifyViewEntered() {
301+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return;
302+
301303
if (afm != null && needsAutofill()) {
302304
final String triggerIdentifier = configuration.autofill.uniqueIdentifier;
303305
final int[] offset = new int[2];
@@ -309,13 +311,17 @@ private void notifyViewEntered() {
309311
}
310312

311313
private void notifyViewExited() {
314+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return;
315+
312316
if (afm != null && configuration != null && configuration.autofill != null) {
313317
final String triggerIdentifier = configuration.autofill.uniqueIdentifier;
314318
afm.notifyViewExited(mView, triggerIdentifier.hashCode());
315319
}
316320
}
317321

318322
private void notifyValueChanged(String newValue) {
323+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return;
324+
319325
if (afm != null && needsAutofill()) {
320326
final String triggerIdentifier = configuration.autofill.uniqueIdentifier;
321327
afm.notifyValueChanged(mView, triggerIdentifier.hashCode(), AutofillValue.forText(newValue));
@@ -453,7 +459,9 @@ private boolean needsAutofill() {
453459
}
454460

455461
public void onProvideAutofillVirtualStructure(ViewStructure structure, int flags) {
456-
if (mAutofillConfigurations == null) return;
462+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return;
463+
464+
if (!needsAutofill()) return;
457465

458466
final String triggerIdentifier = configuration.autofill.uniqueIdentifier;
459467
final AutofillId parentId = structure.getAutofillId();
@@ -474,10 +482,12 @@ public void onProvideAutofillVirtualStructure(ViewStructure structure, int flags
474482
}
475483

476484
public void autofill(SparseArray<AutofillValue> values) {
477-
final HashMap<String, TextInputChannel.TextEditState> editingValues = new HashMap<>();
485+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return;
486+
478487
final TextInputChannel.Configuration.Autofill currentAutofill = configuration.autofill;
479488
if (currentAutofill == null) return;
480489

490+
final HashMap<String, TextInputChannel.TextEditState> editingValues = new HashMap<>();
481491
for (int i = 0; i < values.size(); i++) {
482492
int virtualId = values.keyAt(i);
483493

shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -397,52 +397,10 @@ public void inputConnection_finishComposingTextUpdatesIMM() throws JSONException
397397
}
398398
}
399399

400-
@Test
401-
public void inputConnection_samsungFinishComposingTextSetsSelection() throws JSONException {
402-
ShadowBuild.setManufacturer("samsung");
403-
InputMethodSubtype inputMethodSubtype =
404-
new InputMethodSubtype(0, 0, /*locale=*/ "en", "", "", false, false);
405-
Settings.Secure.putString(
406-
RuntimeEnvironment.application.getContentResolver(),
407-
Settings.Secure.DEFAULT_INPUT_METHOD,
408-
"com.sec.android.inputmethod/.SamsungKeypad");
409-
TestImm testImm =
410-
Shadow.extract(
411-
RuntimeEnvironment.application.getSystemService(Context.INPUT_METHOD_SERVICE));
412-
testImm.setCurrentInputMethodSubtype(inputMethodSubtype);
413-
FlutterJNI mockFlutterJni = mock(FlutterJNI.class);
414-
View testView = new View(RuntimeEnvironment.application);
415-
DartExecutor dartExecutor = spy(new DartExecutor(mockFlutterJni, mock(AssetManager.class)));
416-
TextInputPlugin textInputPlugin =
417-
new TextInputPlugin(testView, dartExecutor, mock(PlatformViewsController.class));
418-
textInputPlugin.setTextInputClient(
419-
0,
420-
new TextInputChannel.Configuration(
421-
false,
422-
false,
423-
true,
424-
TextInputChannel.TextCapitalization.NONE,
425-
new TextInputChannel.InputType(TextInputChannel.TextInputType.TEXT, false, false),
426-
null,
427-
null,
428-
null,
429-
null));
430-
// There's a pending restart since we initialized the text input client. Flush that now.
431-
textInputPlugin.setTextInputEditingState(
432-
testView, new TextInputChannel.TextEditState("", 0, 0));
433-
InputConnection connection = textInputPlugin.createInputConnection(testView, new EditorInfo());
434-
435-
testImm.setTrackSelection(true);
436-
connection.finishComposingText();
437-
testImm.setTrackSelection(false);
438-
439-
List<Integer> expectedSelectionValues =
440-
Arrays.asList(0, 0, -1, -1, -1, -1, -1, -1, 0, 0, -1, -1);
441-
assertEquals(testImm.getSelectionUpdateValues(), expectedSelectionValues);
442-
}
443-
444400
@Test
445401
public void autofill_onProvideVirtualViewStructure() {
402+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return;
403+
446404
FlutterView testView = new FlutterView(RuntimeEnvironment.application);
447405
TextInputPlugin textInputPlugin =
448406
new TextInputPlugin(
@@ -509,6 +467,8 @@ public void autofill_onProvideVirtualViewStructure() {
509467

510468
@Test
511469
public void autofill_onProvideVirtualViewStructure_single() {
470+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return;
471+
512472
FlutterView testView = new FlutterView(RuntimeEnvironment.application);
513473
TextInputPlugin textInputPlugin =
514474
new TextInputPlugin(

0 commit comments

Comments
 (0)