Revert "Add Spellcheck to EditableText (Android) (#109334)" (#109631)

This reverts commit ff9fe35682.
This commit is contained in:
Jonah Williams
2022-08-16 14:30:03 -07:00
committed by GitHub
parent ff9fe35682
commit 0ba88d8b43
32 changed files with 3 additions and 1924 deletions

View File

@@ -1,12 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_devicelab/framework/devices.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/tasks/integration_tests.dart';
Future<void> main() async {
deviceOperatingSystem = DeviceOperatingSystem.android;
await task(createSpellCheckIntegrationTest());
}

View File

@@ -142,13 +142,6 @@ TaskFunction createEndToEndIntegrationTest() {
);
}
TaskFunction createSpellCheckIntegrationTest() {
return IntegrationTest(
'${flutterDirectory.path}/dev/integration_tests/spell_check',
'integration_test/integration_test.dart',
);
}
class DriverTest {
DriverTest(
this.testDirectory,

View File

@@ -1,3 +0,0 @@
# spell_check
A Flutter project for testing spell check for [EditableText].

View File

@@ -1,75 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.spell_check"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

View File

@@ -1,12 +0,0 @@
<!-- Copyright 2014 The Flutter Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.spell_check">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>

View File

@@ -1,38 +0,0 @@
<!-- Copyright 2014 The Flutter Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.spell_check">
<application
android:label="spell_check"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>

View File

@@ -1,6 +0,0 @@
package com.example.spell_check
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}

View File

@@ -1,16 +0,0 @@
<!-- Copyright 2014 The Flutter Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 544 B

View File

@@ -1,22 +0,0 @@
<!-- Copyright 2014 The Flutter Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>

View File

@@ -1,12 +0,0 @@
<!-- Copyright 2014 The Flutter Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.spell_check">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>

View File

@@ -1,35 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@@ -1,3 +0,0 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true

View File

@@ -1,6 +0,0 @@
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip

View File

@@ -1,15 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
include ':app'
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"

View File

@@ -1,188 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:spell_check/main.dart';
late DefaultSpellCheckService defaultSpellCheckService;
late Locale locale;
/// Copy from flutter/test/widgets/editable_text_utils.dart.
RenderEditable findRenderEditable(WidgetTester tester, Type type) {
final RenderObject root = tester.renderObject(find.byType(type));
expect(root, isNotNull);
late RenderEditable renderEditable;
void recursiveFinder(RenderObject child) {
if (child is RenderEditable) {
renderEditable = child;
return;
}
child.visitChildren(recursiveFinder);
}
root.visitChildren(recursiveFinder);
expect(renderEditable, isNotNull);
return renderEditable;
}
Future<void> main() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
setUp(() {
defaultSpellCheckService = DefaultSpellCheckService();
locale = const Locale('en', 'us');
});
test(
'fetchSpellCheckSuggestions returns null with no misspelled words',
() async {
const String text = 'Hello, world!';
final List<SuggestionSpan>? spellCheckSuggestionSpans =
await defaultSpellCheckService.fetchSpellCheckSuggestions(locale, text);
expect(spellCheckSuggestionSpans!.length, equals(0));
expect(
defaultSpellCheckService.lastSavedResults!.spellCheckedText,
equals(text)
);
expect(
defaultSpellCheckService.lastSavedResults!.suggestionSpans,
equals(spellCheckSuggestionSpans)
);
});
test(
'fetchSpellCheckSuggestions returns correct ranges with misspelled words',
() async {
const String text = 'Hlelo, world! Yuou are magnificente';
const List<TextRange> misspelledWordRanges = <TextRange>[
TextRange(start: 0, end: 5),
TextRange(start: 14, end: 18),
TextRange(start: 23, end: 35)
];
final List<SuggestionSpan>? spellCheckSuggestionSpans =
await defaultSpellCheckService.fetchSpellCheckSuggestions(locale, text);
expect(spellCheckSuggestionSpans, isNotNull);
expect(
spellCheckSuggestionSpans!.length,
equals(misspelledWordRanges.length)
);
for (int i = 0; i < misspelledWordRanges.length; i += 1) {
expect(
spellCheckSuggestionSpans[i].range,
equals(misspelledWordRanges[i])
);
}
expect(
defaultSpellCheckService.lastSavedResults!.spellCheckedText,
equals(text)
);
expect(
defaultSpellCheckService.lastSavedResults!.suggestionSpans,
equals(spellCheckSuggestionSpans)
);
});
test(
'fetchSpellCheckSuggestions does not correct results when Gboard not ignoring composing region',
() async {
const String text = 'Wwow, whaaett a beautiful day it is!';
final List<SuggestionSpan>? spellCheckSpansWithComposingRegion =
await defaultSpellCheckService.fetchSpellCheckSuggestions(locale, text);
expect(spellCheckSpansWithComposingRegion, isNotNull);
expect(spellCheckSpansWithComposingRegion!.length, equals(2));
final List<SuggestionSpan>? spellCheckSuggestionSpans =
await defaultSpellCheckService.fetchSpellCheckSuggestions(locale, text);
expect(
spellCheckSuggestionSpans,
equals(spellCheckSpansWithComposingRegion)
);
});
test(
'fetchSpellCheckSuggestions merges results when Gboard ignoring composing region',
() async {
const String text = 'Wooahha it is an amazzinng dayyebf!';
final List<SuggestionSpan>? modifiedSpellCheckSuggestionSpans =
await defaultSpellCheckService.fetchSpellCheckSuggestions(locale, text);
final List<SuggestionSpan> expectedSpellCheckSuggestionSpans =
List<SuggestionSpan>.from(modifiedSpellCheckSuggestionSpans!);
expect(modifiedSpellCheckSuggestionSpans, isNotNull);
expect(modifiedSpellCheckSuggestionSpans.length, equals(3));
// Remove one span to simulate Gboard attempting to un-ignore the composing region, after tapping away from "Yuou".
modifiedSpellCheckSuggestionSpans.removeAt(1);
defaultSpellCheckService.lastSavedResults =
SpellCheckResults(text, modifiedSpellCheckSuggestionSpans);
final List<SuggestionSpan>? spellCheckSuggestionSpans =
await defaultSpellCheckService.fetchSpellCheckSuggestions(locale, text);
expect(spellCheckSuggestionSpans, isNotNull);
expect(
spellCheckSuggestionSpans,
equals(expectedSpellCheckSuggestionSpans)
);
});
testWidgets('EditableText spell checks when text is entered and spell check enabled', (WidgetTester tester) async {
const TextStyle style = TextStyle();
const TextStyle misspelledTextStyle = TextField.materialMisspelledTextStyle;
await tester.pumpWidget(const MyApp());
await tester.enterText(find.byType(EditableText), 'Hey wrororld! Hey!');
await tester.pumpAndSettle();
final RenderEditable renderEditable = findRenderEditable(tester, EditableText);
final TextSpan textSpanTree = renderEditable.text! as TextSpan;
const TextSpan expectedTextSpanTree = TextSpan(
style: style,
children: <TextSpan>[
TextSpan(style: style, text: 'Hey '),
TextSpan(style: misspelledTextStyle, text: 'wrororld'),
TextSpan(style: style, text: '! Hey!'),
]);
expect(textSpanTree, equals(expectedTextSpanTree));
});
test(
'fetchSpellCheckSuggestions returns null when there is a pending request',
() async {
final String text =
'neaf niofenaifn iofn iefnaoeifn ifneoa finoiafn inf ionfieaon ienf ifn ieonfaiofneionf oieafn oifnaioe nioenfio nefaion oifan' *
10;
defaultSpellCheckService.fetchSpellCheckSuggestions(locale, text);
final String modifiedText = text.substring(5);
final List<SuggestionSpan>? spellCheckSuggestionSpans =
await defaultSpellCheckService.fetchSpellCheckSuggestions(
locale, modifiedText);
expect(spellCheckSuggestionSpans, isNull);
// We expect it to be rare for the first request to complete before the
// second, so no text should be saved as of now.
expect(defaultSpellCheckService.lastSavedResults, null);
});
}

View File

@@ -1,57 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Spellcheck Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Spellcheck Demo'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: EditableText(
controller: TextEditingController(),
backgroundCursorColor: Colors.grey,
focusNode: FocusNode(),
style: const TextStyle(),
cursorColor: Colors.red,
spellCheckConfiguration:
const SpellCheckConfiguration(
misspelledTextStyle: TextField.materialMisspelledTextStyle,
)
)
),
);
}
}

View File

@@ -1,108 +0,0 @@
name: spell_check
description: Integration test for spell check.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: '>=2.18.0-149.0.dev <3.0.0'
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: 1.0.5
characters: 1.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
collection: 1.16.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
material_color_utilities: 0.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
meta: 1.8.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
vector_math: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
dev_dependencies:
flutter_test:
sdk: flutter
# Used to run the integration tests in this app:
integration_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
async: 2.9.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
boolean_selector: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
clock: 1.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
fake_async: 1.3.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
matcher: 0.12.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
path: 1.8.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
source_span: 1.9.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
stack_trace: 1.10.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
stream_channel: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
string_scanner: 1.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
term_glyph: 1.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
test_api: 0.4.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
vm_service: 9.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
# PUBSPEC CHECKSUM: 53ec

View File

@@ -1,7 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:integration_test/integration_test_driver.dart';
Future<void> main() => integrationDriver();