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

Revert "Add Spell Check Support for Android Engine (#30858)" #33407

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,6 @@ FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/system
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformViewsChannel.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/RestorationChannel.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/SettingsChannel.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/SpellCheckChannel.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/SystemChannel.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/ActivityLifecycleListener.java
Expand All @@ -1425,7 +1424,6 @@ FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/FlutterT
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/ImeSyncDeferringInsetsCallback.java
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/ListenableEditingState.java
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/SpellCheckPlugin.java
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/TextEditingDelta.java
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/localization/LocalizationPlugin.java
Expand Down
14 changes: 0 additions & 14 deletions lib/ui/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -842,14 +842,6 @@ class PlatformDispatcher {
_onTextScaleFactorChangedZone = Zone.current;
}

/// Whether the spell check service is supported on the current platform.
///
/// This option is used by [EditableTextState] to define its
/// [SpellCheckConfiguration] when a default spell check service
/// is requested.
bool get nativeSpellCheckServiceDefined => _nativeSpellCheckServiceDefined;
bool _nativeSpellCheckServiceDefined = false;

/// Whether briefly displaying the characters as you type in obscured text
/// fields is enabled in system settings.
///
Expand Down Expand Up @@ -911,12 +903,6 @@ class PlatformDispatcher {

final double textScaleFactor = (data['textScaleFactor']! as num).toDouble();
final bool alwaysUse24HourFormat = data['alwaysUse24HourFormat']! as bool;
final bool? nativeSpellCheckServiceDefined = data['nativeSpellCheckServiceDefined'] as bool?;
if (nativeSpellCheckServiceDefined != null) {
_nativeSpellCheckServiceDefined = nativeSpellCheckServiceDefined;
} else {
_nativeSpellCheckServiceDefined = false;
}
// This field is optional.
final bool? brieflyShowPassword = data['brieflyShowPassword'] as bool?;
if (brieflyShowPassword != null) {
Expand Down
9 changes: 0 additions & 9 deletions lib/ui/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -425,15 +425,6 @@ class SingletonFlutterWindow extends FlutterWindow {
/// observe when this value changes.
double get textScaleFactor => platformDispatcher.textScaleFactor;

/// Whether the spell check service is supported on the current platform.
///
/// {@macro dart.ui.window.accessorForwardWarning}
///
/// This option is used by [EditableTextState] to define its
/// [SpellCheckConfiguration] when spell check is enabled, but no spell check
/// service is specified.
bool get nativeSpellCheckServiceDefined => platformDispatcher.nativeSpellCheckServiceDefined;

/// Whether briefly displaying the characters as you type in obscured text
/// fields is enabled in system settings.
///
Expand Down
2 changes: 0 additions & 2 deletions lib/web_ui/lib/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ abstract class PlatformDispatcher {

double get textScaleFactor => configuration.textScaleFactor;

bool get nativeSpellCheckServiceDefined => false;

bool get brieflyShowPassword => true;

VoidCallback? get onTextScaleFactorChanged;
Expand Down
2 changes: 0 additions & 2 deletions lib/web_ui/lib/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ abstract class SingletonFlutterWindow extends FlutterWindow {

double get textScaleFactor => platformDispatcher.textScaleFactor;

bool get nativeSpellCheckServiceDefined => platformDispatcher.nativeSpellCheckServiceDefined;

bool get brieflyShowPassword => platformDispatcher.brieflyShowPassword;

bool get alwaysUse24HourFormat => platformDispatcher.alwaysUse24HourFormat;
Expand Down
2 changes: 0 additions & 2 deletions shell/platform/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ android_java_sources = [
"io/flutter/embedding/engine/systemchannels/PlatformViewsChannel.java",
"io/flutter/embedding/engine/systemchannels/RestorationChannel.java",
"io/flutter/embedding/engine/systemchannels/SettingsChannel.java",
"io/flutter/embedding/engine/systemchannels/SpellCheckChannel.java",
"io/flutter/embedding/engine/systemchannels/SystemChannel.java",
"io/flutter/embedding/engine/systemchannels/TextInputChannel.java",
"io/flutter/plugin/common/ActivityLifecycleListener.java",
Expand All @@ -261,7 +260,6 @@ android_java_sources = [
"io/flutter/plugin/editing/ImeSyncDeferringInsetsCallback.java",
"io/flutter/plugin/editing/InputConnectionAdaptor.java",
"io/flutter/plugin/editing/ListenableEditingState.java",
"io/flutter/plugin/editing/SpellCheckPlugin.java",
"io/flutter/plugin/editing/TextEditingDelta.java",
"io/flutter/plugin/editing/TextInputPlugin.java",
"io/flutter/plugin/localization/LocalizationPlugin.java",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
import android.view.autofill.AutofillValue;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.textservice.SpellCheckerInfo;
import android.view.textservice.TextServicesManager;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand All @@ -60,7 +58,6 @@
import io.flutter.embedding.engine.renderer.RenderSurface;
import io.flutter.embedding.engine.systemchannels.SettingsChannel;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.editing.SpellCheckPlugin;
import io.flutter.plugin.editing.TextInputPlugin;
import io.flutter.plugin.localization.LocalizationPlugin;
import io.flutter.plugin.mouse.MouseCursorPlugin;
Expand Down Expand Up @@ -129,12 +126,10 @@ public class FlutterView extends FrameLayout
// existing, stateless system channels, e.g., MouseCursorChannel, TextInputChannel, etc.
@Nullable private MouseCursorPlugin mouseCursorPlugin;
@Nullable private TextInputPlugin textInputPlugin;
@Nullable private SpellCheckPlugin spellCheckPlugin;
@Nullable private LocalizationPlugin localizationPlugin;
@Nullable private KeyboardManager keyboardManager;
@Nullable private AndroidTouchProcessor androidTouchProcessor;
@Nullable private AccessibilityBridge accessibilityBridge;
@Nullable private TextServicesManager textServicesManager;

// Provides access to foldable/hinge information
@Nullable private WindowInfoRepositoryCallbackAdapterWrapper windowInfoRepo;
Expand Down Expand Up @@ -1146,17 +1141,6 @@ public void attachToFlutterEngine(@NonNull FlutterEngine flutterEngine) {
this,
this.flutterEngine.getTextInputChannel(),
this.flutterEngine.getPlatformViewsController());

try {
textServicesManager =
(TextServicesManager)
getContext().getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE);
spellCheckPlugin =
new SpellCheckPlugin(textServicesManager, this.flutterEngine.getSpellCheckChannel());
} catch (Exception e) {
Log.e(TAG, "TextServicesManager not supported by device, spell check disabled.");
}

localizationPlugin = this.flutterEngine.getLocalizationPlugin();

keyboardManager = new KeyboardManager(this);
Expand Down Expand Up @@ -1254,9 +1238,6 @@ public void detachFromFlutterEngine() {
textInputPlugin.getInputMethodManager().restartInput(this);
textInputPlugin.destroy();
keyboardManager.destroy();
if (spellCheckPlugin != null) {
spellCheckPlugin.destroy();
}

if (mouseCursorPlugin != null) {
mouseCursorPlugin.destroy();
Expand Down Expand Up @@ -1441,34 +1422,10 @@ public void removeFlutterEngineAttachmentListener(
? SettingsChannel.PlatformBrightness.dark
: SettingsChannel.PlatformBrightness.light;

boolean isNativeSpellCheckServiceDefined = false;

if (textServicesManager != null) {
if (Build.VERSION.SDK_INT >= 31) {
List<SpellCheckerInfo> enabledSpellCheckerInfos =
textServicesManager.getEnabledSpellCheckerInfos();
boolean gboardSpellCheckerEnabled =
enabledSpellCheckerInfos.stream()
.anyMatch(
spellCheckerInfo ->
spellCheckerInfo
.getPackageName()
.equals("com.google.android.inputmethod.latin"));

// Checks if enabled spell checker is the one that is suppported by Gboard, which is
// the one Flutter supports by default.
isNativeSpellCheckServiceDefined =
textServicesManager.isSpellCheckerEnabled() && gboardSpellCheckerEnabled;
} else {
isNativeSpellCheckServiceDefined = true;
}
}

flutterEngine
.getSettingsChannel()
.startMessage()
.setTextScaleFactor(getResources().getConfiguration().fontScale)
.setNativeSpellCheckServiceDefined(isNativeSpellCheckServiceDefined)
.setBrieflyShowPassword(
Settings.System.getInt(
getContext().getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD, 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import io.flutter.embedding.engine.systemchannels.PlatformChannel;
import io.flutter.embedding.engine.systemchannels.RestorationChannel;
import io.flutter.embedding.engine.systemchannels.SettingsChannel;
import io.flutter.embedding.engine.systemchannels.SpellCheckChannel;
import io.flutter.embedding.engine.systemchannels.SystemChannel;
import io.flutter.embedding.engine.systemchannels.TextInputChannel;
import io.flutter.plugin.localization.LocalizationPlugin;
Expand Down Expand Up @@ -94,7 +93,6 @@ public class FlutterEngine {
@NonNull private final RestorationChannel restorationChannel;
@NonNull private final PlatformChannel platformChannel;
@NonNull private final SettingsChannel settingsChannel;
@NonNull private final SpellCheckChannel spellCheckChannel;
@NonNull private final SystemChannel systemChannel;
@NonNull private final TextInputChannel textInputChannel;

Expand Down Expand Up @@ -308,7 +306,6 @@ public FlutterEngine(
platformChannel = new PlatformChannel(dartExecutor);
restorationChannel = new RestorationChannel(dartExecutor, waitForRestorationData);
settingsChannel = new SettingsChannel(dartExecutor);
spellCheckChannel = new SpellCheckChannel(dartExecutor);
systemChannel = new SystemChannel(dartExecutor);
textInputChannel = new TextInputChannel(dartExecutor);

Expand Down Expand Up @@ -553,12 +550,6 @@ public TextInputChannel getTextInputChannel() {
return textInputChannel;
}

/** System channel that sends and receives spell check requests and results. */
@NonNull
public SpellCheckChannel getSpellCheckChannel() {
return spellCheckChannel;
}

/**
* Plugin registry, which registers plugins that want to be applied to this {@code FlutterEngine}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class SettingsChannel {

public static final String CHANNEL_NAME = "flutter/settings";
private static final String TEXT_SCALE_FACTOR = "textScaleFactor";
private static final String NATIVE_SPELL_CHECK_SERVICE_DEFINED = "nativeSpellCheckServiceDefined";
private static final String BRIEFLY_SHOW_PASSWORD = "brieflyShowPassword";
private static final String ALWAYS_USE_24_HOUR_FORMAT = "alwaysUse24HourFormat";
private static final String PLATFORM_BRIGHTNESS = "platformBrightness";
Expand Down Expand Up @@ -43,13 +42,6 @@ public MessageBuilder setTextScaleFactor(float textScaleFactor) {
return this;
}

@NonNull
public MessageBuilder setNativeSpellCheckServiceDefined(
boolean nativeSpellCheckServiceDefined) {
message.put(NATIVE_SPELL_CHECK_SERVICE_DEFINED, nativeSpellCheckServiceDefined);
return this;
}

@NonNull
public MessageBuilder setBrieflyShowPassword(@NonNull boolean brieflyShowPassword) {
message.put(BRIEFLY_SHOW_PASSWORD, brieflyShowPassword);
Expand Down

This file was deleted.

Loading