Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 54865504 authored by Jean Chalard's avatar Jean Chalard
Browse files

Fix dead key -> space combination.

This also fixes "dead key -> same dead key" combination.
Both these key sequences should only give the non-combining
version of the combining character.

Bug: 8158374
Change-Id: I51f01685dd2997c2c5316ce6aa4f10ac9354c877
parent f4b36ad1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -180,6 +180,7 @@ public class QwertyKeyListener extends BaseKeyListener {
                    if (composed != 0) {
                        i = composed;
                        replace = true;
                        dead = false;
                    }
                }

+14 −2
Original line number Diff line number Diff line
@@ -180,6 +180,8 @@ public class KeyCharacterMap implements Parcelable {
    private static final int ACCENT_CIRCUMFLEX_LEGACY = '^';
    private static final int ACCENT_TILDE_LEGACY = '~';

    private static final int CHAR_SPACE = ' ';

    /**
     * Maps Unicode combining diacritical to display-form dead key.
     */
@@ -473,14 +475,23 @@ public class KeyCharacterMap implements Parcelable {
    }

    /**
     * Get the character that is produced by putting accent on the character c.
     * Get the character that is produced by combining the dead key producing accent
     * with the key producing character c.
     * For example, getDeadChar('`', 'e') returns è.
     * getDeadChar('^', ' ') returns '^' and getDeadChar('^', '^') returns '^'.
     *
     * @param accent The accent character.  eg. '`'
     * @param c The basic character.
     * @return The combined character, or 0 if the characters cannot be combined.
     */
    public static int getDeadChar(int accent, int c) {
        if (c == accent || CHAR_SPACE == c) {
            // The same dead character typed twice or a dead character followed by a
            // space should both produce the non-combining version of the combining char.
            // In this case we don't even need to compute the combining character.
            return accent;
        }

        int combining = sAccentToCombining.get(accent);
        if (combining == 0) {
            return 0;
@@ -495,7 +506,8 @@ public class KeyCharacterMap implements Parcelable {
                sDeadKeyBuilder.append((char)c);
                sDeadKeyBuilder.append((char)combining);
                String result = Normalizer.normalize(sDeadKeyBuilder, Normalizer.Form.NFC);
                combined = result.length() == 1 ? result.charAt(0) : 0;
                combined = result.codePointCount(0, result.length()) == 1
                        ? result.codePointAt(0) : 0;
                sDeadKeyCache.put(combination, combined);
            }
        }