From d9c573d14387817f3974892309a836713feb7fd6 Mon Sep 17 00:00:00 2001 From: Josep del Rio Date: Wed, 7 Dec 2022 18:23:46 +0000 Subject: [PATCH] Allow international characters input with apostrophe and double quotation It has been reported that the behaviour of Android in US international layout is not the same as Chromebook; according to Wikipedia, the apostrophone and double quotation mark are "dead characters" that can be used to enter characters with acute accents and umlauts: https://en.wikipedia.org/wiki/QWERTY#/media/File:KB_US-International.svg Since this seems to be the behavior in Mac and ChromeOS, this change will align Android with the rest of the platforms. I decided to follow the same pattern as MacOS, since typing the dead character twice will input the actual character, and apostrophe/quotation mark are very useful to have. Bug: 259862772 Test: confirmed on device that it works as expected Change-Id: Iaf326e07e9b07d07383be73ed65b1cac338ae0bf --- core/java/android/view/KeyCharacterMap.java | 10 ++++++++-- .../res/raw/keyboard_layout_english_us_intl.kcm | 8 ++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/core/java/android/view/KeyCharacterMap.java b/core/java/android/view/KeyCharacterMap.java index a6f88a7410c29..ea5d9a684ba46 100644 --- a/core/java/android/view/KeyCharacterMap.java +++ b/core/java/android/view/KeyCharacterMap.java @@ -177,6 +177,8 @@ public class KeyCharacterMap implements Parcelable { private static final int ACCENT_UMLAUT = '\u00A8'; private static final int ACCENT_VERTICAL_LINE_ABOVE = '\u02C8'; private static final int ACCENT_VERTICAL_LINE_BELOW = '\u02CC'; + private static final int ACCENT_APOSTROPHE = '\''; + private static final int ACCENT_QUOTATION_MARK = '"'; /* Legacy dead key display characters used in previous versions of the API. * We still support these characters by mapping them to their non-legacy version. */ @@ -204,8 +206,6 @@ public class KeyCharacterMap implements Parcelable { addCombining('\u030A', ACCENT_RING_ABOVE); addCombining('\u030B', ACCENT_DOUBLE_ACUTE); addCombining('\u030C', ACCENT_CARON); - addCombining('\u030D', ACCENT_VERTICAL_LINE_ABOVE); - //addCombining('\u030E', ACCENT_DOUBLE_VERTICAL_LINE_ABOVE); //addCombining('\u030F', ACCENT_DOUBLE_GRAVE); //addCombining('\u0310', ACCENT_CANDRABINDU); //addCombining('\u0311', ACCENT_INVERTED_BREVE); @@ -229,11 +229,17 @@ public class KeyCharacterMap implements Parcelable { sCombiningToAccent.append('\u0340', ACCENT_GRAVE); sCombiningToAccent.append('\u0341', ACCENT_ACUTE); sCombiningToAccent.append('\u0343', ACCENT_COMMA_ABOVE); + sCombiningToAccent.append('\u030D', ACCENT_APOSTROPHE); + sCombiningToAccent.append('\u030E', ACCENT_QUOTATION_MARK); // One-way legacy mappings to preserve compatibility with older applications. sAccentToCombining.append(ACCENT_GRAVE_LEGACY, '\u0300'); sAccentToCombining.append(ACCENT_CIRCUMFLEX_LEGACY, '\u0302'); sAccentToCombining.append(ACCENT_TILDE_LEGACY, '\u0303'); + + // One-way mappings to use the preferred accent + sAccentToCombining.append(ACCENT_APOSTROPHE, '\u0301'); + sAccentToCombining.append(ACCENT_QUOTATION_MARK, '\u0308'); } private static void addCombining(int combining, int accent) { diff --git a/packages/InputDevices/res/raw/keyboard_layout_english_us_intl.kcm b/packages/InputDevices/res/raw/keyboard_layout_english_us_intl.kcm index 66c1c9878fc6f..aa31493e9a02e 100644 --- a/packages/InputDevices/res/raw/keyboard_layout_english_us_intl.kcm +++ b/packages/InputDevices/res/raw/keyboard_layout_english_us_intl.kcm @@ -292,10 +292,10 @@ key SEMICOLON { key APOSTROPHE { label: '\'' - base: '\'' - shift: '"' - ralt: '\u0301' - shift+ralt: '\u0308' + base: '\u030D' + shift: '\u030E' + ralt: '\u00B4' + shift+ralt: '\u00A8' } ### ROW 4