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

Commit 08cc7f2

Browse files
authored
Revert "Hardware Keyboard: Android (#33113)"
This reverts commit 8bf69d1.
1 parent 6b20c39 commit 08cc7f2

File tree

16 files changed

+150
-2967
lines changed

16 files changed

+150
-2967
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,10 +1363,7 @@ FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/Flutt
13631363
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/FlutterTextureView.java
13641364
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/FlutterView.java
13651365
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/KeyChannelResponder.java
1366-
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/KeyData.java
1367-
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/KeyEmbedderResponder.java
13681366
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/KeyboardManager.java
1369-
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/KeyboardMap.java
13701367
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/MotionEventTracker.java
13711368
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/RenderMode.java
13721369
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/SplashScreen.java

lib/ui/key.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class KeyData {
146146

147147
String? _escapeCharacter() {
148148
if (character == null) {
149-
return '<none>';
149+
return character ?? '<none>';
150150
}
151151
switch (character!) {
152152
case '\n':

lib/ui/window/key_data.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ enum class KeyEventType : int64_t {
2828
// a different way in KeyDataPacket.
2929
//
3030
// This structure is unpacked by hooks.dart.
31-
//
32-
// Changes to this struct must also be made to
33-
// io/flutter/embedding/android/KeyData.java.
3431
struct alignas(8) KeyData {
3532
// Timestamp in microseconds from an arbitrary and consistent start point
3633
uint64_t timestamp;

lib/ui/window/key_data_packet.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
namespace flutter {
1515

1616
// A byte stream representing a key event, to be sent to the framework.
17-
//
18-
// Changes to the marshalling format here must also be made to
19-
// io/flutter/embedding/android/KeyData.java.
2017
class KeyDataPacket {
2118
public:
2219
// Build the key data packet by providing information.

shell/platform/android/BUILD.gn

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,7 @@ android_java_sources = [
185185
"io/flutter/embedding/android/FlutterTextureView.java",
186186
"io/flutter/embedding/android/FlutterView.java",
187187
"io/flutter/embedding/android/KeyChannelResponder.java",
188-
"io/flutter/embedding/android/KeyData.java",
189-
"io/flutter/embedding/android/KeyEmbedderResponder.java",
190188
"io/flutter/embedding/android/KeyboardManager.java",
191-
"io/flutter/embedding/android/KeyboardMap.java",
192189
"io/flutter/embedding/android/MotionEventTracker.java",
193190
"io/flutter/embedding/android/RenderMode.java",
194191
"io/flutter/embedding/android/SplashScreen.java",

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

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package io.flutter.embedding.android;
66

7+
import android.view.KeyCharacterMap;
78
import android.view.KeyEvent;
89
import androidx.annotation.NonNull;
910
import io.flutter.embedding.engine.systemchannels.KeyEventChannel;
@@ -18,15 +19,66 @@ public class KeyChannelResponder implements KeyboardManager.Responder {
1819
private static final String TAG = "KeyChannelResponder";
1920

2021
@NonNull private final KeyEventChannel keyEventChannel;
21-
22-
@NonNull
23-
private final KeyboardManager.CharacterCombiner characterCombiner =
24-
new KeyboardManager.CharacterCombiner();
22+
private int combiningCharacter;
2523

2624
public KeyChannelResponder(@NonNull KeyEventChannel keyEventChannel) {
2725
this.keyEventChannel = keyEventChannel;
2826
}
2927

28+
/**
29+
* Applies the given Unicode character in {@code newCharacterCodePoint} to a previously entered
30+
* Unicode combining character and returns the combination of these characters if a combination
31+
* exists.
32+
*
33+
* <p>This method mutates {@link #combiningCharacter} over time to combine characters.
34+
*
35+
* <p>One of the following things happens in this method:
36+
*
37+
* <ul>
38+
* <li>If no previous {@link #combiningCharacter} exists and the {@code newCharacterCodePoint}
39+
* is not a combining character, then {@code newCharacterCodePoint} is returned.
40+
* <li>If no previous {@link #combiningCharacter} exists and the {@code newCharacterCodePoint}
41+
* is a combining character, then {@code newCharacterCodePoint} is saved as the {@link
42+
* #combiningCharacter} and null is returned.
43+
* <li>If a previous {@link #combiningCharacter} exists and the {@code newCharacterCodePoint} is
44+
* also a combining character, then the {@code newCharacterCodePoint} is combined with the
45+
* existing {@link #combiningCharacter} and null is returned.
46+
* <li>If a previous {@link #combiningCharacter} exists and the {@code newCharacterCodePoint} is
47+
* not a combining character, then the {@link #combiningCharacter} is applied to the regular
48+
* {@code newCharacterCodePoint} and the resulting complex character is returned. The {@link
49+
* #combiningCharacter} is cleared.
50+
* </ul>
51+
*
52+
* <p>The following reference explains the concept of a "combining character":
53+
* https://en.wikipedia.org/wiki/Combining_character
54+
*/
55+
Character applyCombiningCharacterToBaseCharacter(int newCharacterCodePoint) {
56+
char complexCharacter = (char) newCharacterCodePoint;
57+
boolean isNewCodePointACombiningCharacter =
58+
(newCharacterCodePoint & KeyCharacterMap.COMBINING_ACCENT) != 0;
59+
if (isNewCodePointACombiningCharacter) {
60+
// If a combining character was entered before, combine this one with that one.
61+
int plainCodePoint = newCharacterCodePoint & KeyCharacterMap.COMBINING_ACCENT_MASK;
62+
if (combiningCharacter != 0) {
63+
combiningCharacter = KeyCharacterMap.getDeadChar(combiningCharacter, plainCodePoint);
64+
} else {
65+
combiningCharacter = plainCodePoint;
66+
}
67+
} else {
68+
// The new character is a regular character. Apply combiningCharacter to it, if
69+
// it exists.
70+
if (combiningCharacter != 0) {
71+
int combinedChar = KeyCharacterMap.getDeadChar(combiningCharacter, newCharacterCodePoint);
72+
if (combinedChar > 0) {
73+
complexCharacter = (char) combinedChar;
74+
}
75+
combiningCharacter = 0;
76+
}
77+
}
78+
79+
return complexCharacter;
80+
}
81+
3082
@Override
3183
public void handleEvent(
3284
@NonNull KeyEvent keyEvent, @NonNull OnKeyEventHandledCallback onKeyEventHandledCallback) {
@@ -40,7 +92,7 @@ public void handleEvent(
4092
}
4193

4294
final Character complexCharacter =
43-
characterCombiner.applyCombiningCharacterToBaseCharacter(keyEvent.getUnicodeChar());
95+
applyCombiningCharacterToBaseCharacter(keyEvent.getUnicodeChar());
4496
KeyEventChannel.FlutterKeyEvent flutterEvent =
4597
new KeyEventChannel.FlutterKeyEvent(keyEvent, complexCharacter);
4698

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

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

0 commit comments

Comments
 (0)