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

Commit 23bd09d

Browse files
authored
Revert "Add Spell Check Support for Android Engine (#30858)"
This reverts commit 05ddf05.
1 parent 05ddf05 commit 23bd09d

File tree

16 files changed

+0
-596
lines changed

16 files changed

+0
-596
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,6 @@ FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/system
14001400
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformViewsChannel.java
14011401
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/RestorationChannel.java
14021402
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/SettingsChannel.java
1403-
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/SpellCheckChannel.java
14041403
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/SystemChannel.java
14051404
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java
14061405
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/ActivityLifecycleListener.java
@@ -1425,7 +1424,6 @@ FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/FlutterT
14251424
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/ImeSyncDeferringInsetsCallback.java
14261425
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java
14271426
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/ListenableEditingState.java
1428-
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/SpellCheckPlugin.java
14291427
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/TextEditingDelta.java
14301428
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java
14311429
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/localization/LocalizationPlugin.java

lib/ui/platform_dispatcher.dart

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -842,14 +842,6 @@ class PlatformDispatcher {
842842
_onTextScaleFactorChangedZone = Zone.current;
843843
}
844844

845-
/// Whether the spell check service is supported on the current platform.
846-
///
847-
/// This option is used by [EditableTextState] to define its
848-
/// [SpellCheckConfiguration] when a default spell check service
849-
/// is requested.
850-
bool get nativeSpellCheckServiceDefined => _nativeSpellCheckServiceDefined;
851-
bool _nativeSpellCheckServiceDefined = false;
852-
853845
/// Whether briefly displaying the characters as you type in obscured text
854846
/// fields is enabled in system settings.
855847
///
@@ -911,12 +903,6 @@ class PlatformDispatcher {
911903

912904
final double textScaleFactor = (data['textScaleFactor']! as num).toDouble();
913905
final bool alwaysUse24HourFormat = data['alwaysUse24HourFormat']! as bool;
914-
final bool? nativeSpellCheckServiceDefined = data['nativeSpellCheckServiceDefined'] as bool?;
915-
if (nativeSpellCheckServiceDefined != null) {
916-
_nativeSpellCheckServiceDefined = nativeSpellCheckServiceDefined;
917-
} else {
918-
_nativeSpellCheckServiceDefined = false;
919-
}
920906
// This field is optional.
921907
final bool? brieflyShowPassword = data['brieflyShowPassword'] as bool?;
922908
if (brieflyShowPassword != null) {

lib/ui/window.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -425,15 +425,6 @@ class SingletonFlutterWindow extends FlutterWindow {
425425
/// observe when this value changes.
426426
double get textScaleFactor => platformDispatcher.textScaleFactor;
427427

428-
/// Whether the spell check service is supported on the current platform.
429-
///
430-
/// {@macro dart.ui.window.accessorForwardWarning}
431-
///
432-
/// This option is used by [EditableTextState] to define its
433-
/// [SpellCheckConfiguration] when spell check is enabled, but no spell check
434-
/// service is specified.
435-
bool get nativeSpellCheckServiceDefined => platformDispatcher.nativeSpellCheckServiceDefined;
436-
437428
/// Whether briefly displaying the characters as you type in obscured text
438429
/// fields is enabled in system settings.
439430
///

lib/web_ui/lib/platform_dispatcher.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ abstract class PlatformDispatcher {
8282

8383
double get textScaleFactor => configuration.textScaleFactor;
8484

85-
bool get nativeSpellCheckServiceDefined => false;
86-
8785
bool get brieflyShowPassword => true;
8886

8987
VoidCallback? get onTextScaleFactorChanged;

lib/web_ui/lib/window.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ abstract class SingletonFlutterWindow extends FlutterWindow {
4848

4949
double get textScaleFactor => platformDispatcher.textScaleFactor;
5050

51-
bool get nativeSpellCheckServiceDefined => platformDispatcher.nativeSpellCheckServiceDefined;
52-
5351
bool get brieflyShowPassword => platformDispatcher.brieflyShowPassword;
5452

5553
bool get alwaysUse24HourFormat => platformDispatcher.alwaysUse24HourFormat;

shell/platform/android/BUILD.gn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ android_java_sources = [
236236
"io/flutter/embedding/engine/systemchannels/PlatformViewsChannel.java",
237237
"io/flutter/embedding/engine/systemchannels/RestorationChannel.java",
238238
"io/flutter/embedding/engine/systemchannels/SettingsChannel.java",
239-
"io/flutter/embedding/engine/systemchannels/SpellCheckChannel.java",
240239
"io/flutter/embedding/engine/systemchannels/SystemChannel.java",
241240
"io/flutter/embedding/engine/systemchannels/TextInputChannel.java",
242241
"io/flutter/plugin/common/ActivityLifecycleListener.java",
@@ -261,7 +260,6 @@ android_java_sources = [
261260
"io/flutter/plugin/editing/ImeSyncDeferringInsetsCallback.java",
262261
"io/flutter/plugin/editing/InputConnectionAdaptor.java",
263262
"io/flutter/plugin/editing/ListenableEditingState.java",
264-
"io/flutter/plugin/editing/SpellCheckPlugin.java",
265263
"io/flutter/plugin/editing/TextEditingDelta.java",
266264
"io/flutter/plugin/editing/TextInputPlugin.java",
267265
"io/flutter/plugin/localization/LocalizationPlugin.java",

shell/platform/android/io/flutter/embedding/android/FlutterView.java

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
import android.view.autofill.AutofillValue;
3636
import android.view.inputmethod.EditorInfo;
3737
import android.view.inputmethod.InputConnection;
38-
import android.view.textservice.SpellCheckerInfo;
39-
import android.view.textservice.TextServicesManager;
4038
import android.widget.FrameLayout;
4139
import androidx.annotation.NonNull;
4240
import androidx.annotation.Nullable;
@@ -60,7 +58,6 @@
6058
import io.flutter.embedding.engine.renderer.RenderSurface;
6159
import io.flutter.embedding.engine.systemchannels.SettingsChannel;
6260
import io.flutter.plugin.common.BinaryMessenger;
63-
import io.flutter.plugin.editing.SpellCheckPlugin;
6461
import io.flutter.plugin.editing.TextInputPlugin;
6562
import io.flutter.plugin.localization.LocalizationPlugin;
6663
import io.flutter.plugin.mouse.MouseCursorPlugin;
@@ -129,12 +126,10 @@ public class FlutterView extends FrameLayout
129126
// existing, stateless system channels, e.g., MouseCursorChannel, TextInputChannel, etc.
130127
@Nullable private MouseCursorPlugin mouseCursorPlugin;
131128
@Nullable private TextInputPlugin textInputPlugin;
132-
@Nullable private SpellCheckPlugin spellCheckPlugin;
133129
@Nullable private LocalizationPlugin localizationPlugin;
134130
@Nullable private KeyboardManager keyboardManager;
135131
@Nullable private AndroidTouchProcessor androidTouchProcessor;
136132
@Nullable private AccessibilityBridge accessibilityBridge;
137-
@Nullable private TextServicesManager textServicesManager;
138133

139134
// Provides access to foldable/hinge information
140135
@Nullable private WindowInfoRepositoryCallbackAdapterWrapper windowInfoRepo;
@@ -1146,17 +1141,6 @@ public void attachToFlutterEngine(@NonNull FlutterEngine flutterEngine) {
11461141
this,
11471142
this.flutterEngine.getTextInputChannel(),
11481143
this.flutterEngine.getPlatformViewsController());
1149-
1150-
try {
1151-
textServicesManager =
1152-
(TextServicesManager)
1153-
getContext().getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE);
1154-
spellCheckPlugin =
1155-
new SpellCheckPlugin(textServicesManager, this.flutterEngine.getSpellCheckChannel());
1156-
} catch (Exception e) {
1157-
Log.e(TAG, "TextServicesManager not supported by device, spell check disabled.");
1158-
}
1159-
11601144
localizationPlugin = this.flutterEngine.getLocalizationPlugin();
11611145

11621146
keyboardManager = new KeyboardManager(this);
@@ -1254,9 +1238,6 @@ public void detachFromFlutterEngine() {
12541238
textInputPlugin.getInputMethodManager().restartInput(this);
12551239
textInputPlugin.destroy();
12561240
keyboardManager.destroy();
1257-
if (spellCheckPlugin != null) {
1258-
spellCheckPlugin.destroy();
1259-
}
12601241

12611242
if (mouseCursorPlugin != null) {
12621243
mouseCursorPlugin.destroy();
@@ -1441,34 +1422,10 @@ public void removeFlutterEngineAttachmentListener(
14411422
? SettingsChannel.PlatformBrightness.dark
14421423
: SettingsChannel.PlatformBrightness.light;
14431424

1444-
boolean isNativeSpellCheckServiceDefined = false;
1445-
1446-
if (textServicesManager != null) {
1447-
if (Build.VERSION.SDK_INT >= 31) {
1448-
List<SpellCheckerInfo> enabledSpellCheckerInfos =
1449-
textServicesManager.getEnabledSpellCheckerInfos();
1450-
boolean gboardSpellCheckerEnabled =
1451-
enabledSpellCheckerInfos.stream()
1452-
.anyMatch(
1453-
spellCheckerInfo ->
1454-
spellCheckerInfo
1455-
.getPackageName()
1456-
.equals("com.google.android.inputmethod.latin"));
1457-
1458-
// Checks if enabled spell checker is the one that is suppported by Gboard, which is
1459-
// the one Flutter supports by default.
1460-
isNativeSpellCheckServiceDefined =
1461-
textServicesManager.isSpellCheckerEnabled() && gboardSpellCheckerEnabled;
1462-
} else {
1463-
isNativeSpellCheckServiceDefined = true;
1464-
}
1465-
}
1466-
14671425
flutterEngine
14681426
.getSettingsChannel()
14691427
.startMessage()
14701428
.setTextScaleFactor(getResources().getConfiguration().fontScale)
1471-
.setNativeSpellCheckServiceDefined(isNativeSpellCheckServiceDefined)
14721429
.setBrieflyShowPassword(
14731430
Settings.System.getInt(
14741431
getContext().getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD, 1)

shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import io.flutter.embedding.engine.systemchannels.PlatformChannel;
3333
import io.flutter.embedding.engine.systemchannels.RestorationChannel;
3434
import io.flutter.embedding.engine.systemchannels.SettingsChannel;
35-
import io.flutter.embedding.engine.systemchannels.SpellCheckChannel;
3635
import io.flutter.embedding.engine.systemchannels.SystemChannel;
3736
import io.flutter.embedding.engine.systemchannels.TextInputChannel;
3837
import io.flutter.plugin.localization.LocalizationPlugin;
@@ -94,7 +93,6 @@ public class FlutterEngine {
9493
@NonNull private final RestorationChannel restorationChannel;
9594
@NonNull private final PlatformChannel platformChannel;
9695
@NonNull private final SettingsChannel settingsChannel;
97-
@NonNull private final SpellCheckChannel spellCheckChannel;
9896
@NonNull private final SystemChannel systemChannel;
9997
@NonNull private final TextInputChannel textInputChannel;
10098

@@ -308,7 +306,6 @@ public FlutterEngine(
308306
platformChannel = new PlatformChannel(dartExecutor);
309307
restorationChannel = new RestorationChannel(dartExecutor, waitForRestorationData);
310308
settingsChannel = new SettingsChannel(dartExecutor);
311-
spellCheckChannel = new SpellCheckChannel(dartExecutor);
312309
systemChannel = new SystemChannel(dartExecutor);
313310
textInputChannel = new TextInputChannel(dartExecutor);
314311

@@ -553,12 +550,6 @@ public TextInputChannel getTextInputChannel() {
553550
return textInputChannel;
554551
}
555552

556-
/** System channel that sends and receives spell check requests and results. */
557-
@NonNull
558-
public SpellCheckChannel getSpellCheckChannel() {
559-
return spellCheckChannel;
560-
}
561-
562553
/**
563554
* Plugin registry, which registers plugins that want to be applied to this {@code FlutterEngine}.
564555
*/

shell/platform/android/io/flutter/embedding/engine/systemchannels/SettingsChannel.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public class SettingsChannel {
1313

1414
public static final String CHANNEL_NAME = "flutter/settings";
1515
private static final String TEXT_SCALE_FACTOR = "textScaleFactor";
16-
private static final String NATIVE_SPELL_CHECK_SERVICE_DEFINED = "nativeSpellCheckServiceDefined";
1716
private static final String BRIEFLY_SHOW_PASSWORD = "brieflyShowPassword";
1817
private static final String ALWAYS_USE_24_HOUR_FORMAT = "alwaysUse24HourFormat";
1918
private static final String PLATFORM_BRIGHTNESS = "platformBrightness";
@@ -43,13 +42,6 @@ public MessageBuilder setTextScaleFactor(float textScaleFactor) {
4342
return this;
4443
}
4544

46-
@NonNull
47-
public MessageBuilder setNativeSpellCheckServiceDefined(
48-
boolean nativeSpellCheckServiceDefined) {
49-
message.put(NATIVE_SPELL_CHECK_SERVICE_DEFINED, nativeSpellCheckServiceDefined);
50-
return this;
51-
}
52-
5345
@NonNull
5446
public MessageBuilder setBrieflyShowPassword(@NonNull boolean brieflyShowPassword) {
5547
message.put(BRIEFLY_SHOW_PASSWORD, brieflyShowPassword);

shell/platform/android/io/flutter/embedding/engine/systemchannels/SpellCheckChannel.java

Lines changed: 0 additions & 101 deletions
This file was deleted.

0 commit comments

Comments
 (0)