Skip to content

Commit

Permalink
Revert "Reland "Hardware Keyboard: Android" (#33567)" (#33589)
Browse files Browse the repository at this point in the history
This reverts commit ea9c2ec.
  • Loading branch information
dkwingsmt authored May 24, 2022
1 parent ea9c2ec commit 789b554
Show file tree
Hide file tree
Showing 16 changed files with 150 additions and 2,973 deletions.
3 changes: 0 additions & 3 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1313,10 +1313,7 @@ FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/Flutt
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/FlutterTextureView.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/FlutterView.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/KeyChannelResponder.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/KeyData.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/KeyEmbedderResponder.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/KeyboardManager.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/KeyboardMap.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/MotionEventTracker.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/RenderMode.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/SplashScreen.java
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/key.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class KeyData {

String? _escapeCharacter() {
if (character == null) {
return '<none>';
return character ?? '<none>';
}
switch (character!) {
case '\n':
Expand Down
3 changes: 0 additions & 3 deletions lib/ui/window/key_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ enum class KeyEventType : int64_t {
// a different way in KeyDataPacket.
//
// This structure is unpacked by hooks.dart.
//
// Changes to this struct must also be made to
// io/flutter/embedding/android/KeyData.java.
struct alignas(8) KeyData {
// Timestamp in microseconds from an arbitrary and consistent start point
uint64_t timestamp;
Expand Down
3 changes: 0 additions & 3 deletions lib/ui/window/key_data_packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
namespace flutter {

// A byte stream representing a key event, to be sent to the framework.
//
// Changes to the marshalling format here must also be made to
// io/flutter/embedding/android/KeyData.java.
class KeyDataPacket {
public:
// Build the key data packet by providing information.
Expand Down
3 changes: 0 additions & 3 deletions shell/platform/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,7 @@ android_java_sources = [
"io/flutter/embedding/android/FlutterTextureView.java",
"io/flutter/embedding/android/FlutterView.java",
"io/flutter/embedding/android/KeyChannelResponder.java",
"io/flutter/embedding/android/KeyData.java",
"io/flutter/embedding/android/KeyEmbedderResponder.java",
"io/flutter/embedding/android/KeyboardManager.java",
"io/flutter/embedding/android/KeyboardMap.java",
"io/flutter/embedding/android/MotionEventTracker.java",
"io/flutter/embedding/android/RenderMode.java",
"io/flutter/embedding/android/SplashScreen.java",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package io.flutter.embedding.android;

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

@NonNull private final KeyEventChannel keyEventChannel;

@NonNull
private final KeyboardManager.CharacterCombiner characterCombiner =
new KeyboardManager.CharacterCombiner();
private int combiningCharacter;

public KeyChannelResponder(@NonNull KeyEventChannel keyEventChannel) {
this.keyEventChannel = keyEventChannel;
}

/**
* Applies the given Unicode character in {@code newCharacterCodePoint} to a previously entered
* Unicode combining character and returns the combination of these characters if a combination
* exists.
*
* <p>This method mutates {@link #combiningCharacter} over time to combine characters.
*
* <p>One of the following things happens in this method:
*
* <ul>
* <li>If no previous {@link #combiningCharacter} exists and the {@code newCharacterCodePoint}
* is not a combining character, then {@code newCharacterCodePoint} is returned.
* <li>If no previous {@link #combiningCharacter} exists and the {@code newCharacterCodePoint}
* is a combining character, then {@code newCharacterCodePoint} is saved as the {@link
* #combiningCharacter} and null is returned.
* <li>If a previous {@link #combiningCharacter} exists and the {@code newCharacterCodePoint} is
* also a combining character, then the {@code newCharacterCodePoint} is combined with the
* existing {@link #combiningCharacter} and null is returned.
* <li>If a previous {@link #combiningCharacter} exists and the {@code newCharacterCodePoint} is
* not a combining character, then the {@link #combiningCharacter} is applied to the regular
* {@code newCharacterCodePoint} and the resulting complex character is returned. The {@link
* #combiningCharacter} is cleared.
* </ul>
*
* <p>The following reference explains the concept of a "combining character":
* https://en.wikipedia.org/wiki/Combining_character
*/
Character applyCombiningCharacterToBaseCharacter(int newCharacterCodePoint) {
char complexCharacter = (char) newCharacterCodePoint;
boolean isNewCodePointACombiningCharacter =
(newCharacterCodePoint & KeyCharacterMap.COMBINING_ACCENT) != 0;
if (isNewCodePointACombiningCharacter) {
// If a combining character was entered before, combine this one with that one.
int plainCodePoint = newCharacterCodePoint & KeyCharacterMap.COMBINING_ACCENT_MASK;
if (combiningCharacter != 0) {
combiningCharacter = KeyCharacterMap.getDeadChar(combiningCharacter, plainCodePoint);
} else {
combiningCharacter = plainCodePoint;
}
} else {
// The new character is a regular character. Apply combiningCharacter to it, if
// it exists.
if (combiningCharacter != 0) {
int combinedChar = KeyCharacterMap.getDeadChar(combiningCharacter, newCharacterCodePoint);
if (combinedChar > 0) {
complexCharacter = (char) combinedChar;
}
combiningCharacter = 0;
}
}

return complexCharacter;
}

@Override
public void handleEvent(
@NonNull KeyEvent keyEvent, @NonNull OnKeyEventHandledCallback onKeyEventHandledCallback) {
Expand All @@ -40,7 +92,7 @@ public void handleEvent(
}

final Character complexCharacter =
characterCombiner.applyCombiningCharacterToBaseCharacter(keyEvent.getUnicodeChar());
applyCombiningCharacterToBaseCharacter(keyEvent.getUnicodeChar());
KeyEventChannel.FlutterKeyEvent flutterEvent =
new KeyEventChannel.FlutterKeyEvent(keyEvent, complexCharacter);

Expand Down
140 changes: 0 additions & 140 deletions shell/platform/android/io/flutter/embedding/android/KeyData.java

This file was deleted.

Loading

0 comments on commit 789b554

Please sign in to comment.