aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorChieu Nguyen <cvnguyen@google.com>2015-11-05 23:18:56 -0800
committerChieu Nguyen <cvnguyen@google.com>2015-11-06 18:22:05 -0800
commit9cc42549d18f1e28ffc8dae94ff36728933f53f1 (patch)
tree49770466e0c45fc2f51ecf77f925cbc0ca0209f3 /java/src
parent28e65858d9f7e8f94e0b298275624703fd74af05 (diff)
downloadlatinime-9cc42549d18f1e28ffc8dae94ff36728933f53f1.tar.gz
latinime-9cc42549d18f1e28ffc8dae94ff36728933f53f1.tar.xz
latinime-9cc42549d18f1e28ffc8dae94ff36728933f53f1.zip
Unicode 8.0 emoji changes to Google Keyboard.
Squashed commit of the following: commit 1b924816665a3a2c48307dbdd1078f61dd3179f2 Author: Chieu Nguyen <cvnguyen@google.com> Date: Fri Nov 6 18:12:58 2015 -0800 Fix Material icons for new tab. Bug: 25369504 Bug: 16185905 Change-Id: I873eb9e8fc1259ac94a974c04a80a4f0d005f9c2 commit 956d5f86d2552d90d2c3240a85d5c1cddf05eda9 Author: Chieu Nguyen <cvnguyen@google.com> Date: Fri Nov 6 17:16:10 2015 -0800 Remove extraneous TalkBack descriptions. Bug: 25369504 Bug: 16185905 Change-Id: Iec4f0f46cf9dda169c5827168ef207e56d619096 commit 07357bdec69b5fc118c82401d59b61ad7b802c22 Author: Chieu Nguyen <cvnguyen@google.com> Date: Fri Nov 6 16:01:34 2015 -0800 Better checking of whether to display new emoji. Bug: 25369504 Bug: 16185905 Change-Id: I61f1b428e5a805f66eb4e9db346be8756fc84b8f commit 666a92f17034f5a1948e70f40226ed995c72d81f Author: Chieu Nguyen <cvnguyen@google.com> Date: Fri Nov 6 12:54:53 2015 -0800 Fix shading on emoji category icons. Bug: 25369504 Bug: 16185905 Change-Id: I217af3d97120e7910e9850de7ea331a461ae7e56 commit 2712432c0e7a1b90ebb7ed6bde8f87eec7bf1094 Author: Chieu Nguyen <cvnguyen@google.com> Date: Thu Nov 5 19:06:57 2015 -0800 Add new emoji categories to Holo Blue. Bug: 25369504 Bug: 16185905 Change-Id: Ie32af93e68e08b36a4a5861a06de511b2b190dca commit 04c79b1f53912b263d7f7eb8b71ac802ed960a8a Author: Chieu Nguyen <cvnguyen@google.com> Date: Thu Nov 5 18:06:35 2015 -0800 Fix default category, remove xxxhdpi Holo icons. Bug: 25369504 Bug: 16185905 Change-Id: I9bca795675297dceb93777d998e8f2935f7031a6 commit 15c0b578343db2baa873096891a69305398eb830 Merge: 77bc6fc 8604ce3 Author: Chieu Nguyen <cvnguyen@google.com> Date: Fri Nov 6 00:59:08 2015 +0000 Merge changes into jb-ub-latinimegoogle commit 77bc6fcfd760232757b5751993c0046f2a43626a Merge: b0380a0 8604ce3 Author: Chieu Nguyen <cvnguyen@google.com> Date: Fri Nov 6 00:59:04 2015 +0000 Merge "Remove Kosovo from flags (no glyph)." into jb-ub-latinimegoogle commit b0380a0744647039278ad6648b7a1bc94eeab623 Author: Chieu Nguyen <cvnguyen@google.com> Date: Thu Nov 5 16:42:24 2015 -0800 Add icons for new emoji categories. Bug: 25369504 Bug: 16185905 Change-Id: I1182e031994332b2e618406ad1cd467cb050766e commit 8604ce3a34b65598101cac37a3ed3e8087fe38ca Author: Chieu Nguyen <cvnguyen@google.com> Date: Thu Nov 5 16:29:33 2015 -0800 Remove Kosovo from flags (no glyph). Bug: 25369504 Bug: 16185905 Change-Id: I92c9ace19d3600cfa1f27678ada0cf45af42d8f5 commit e0489eab47d3a6d138bfa00a668f02bcb473cf88 Author: Chieu Nguyen <cvnguyen@google.com> Date: Thu Nov 5 14:30:58 2015 -0800 Update emoji set to blacklist non-color glyphs. Bug: 25369504 Bug: 16185905 Change-Id: I8b54217fa68da8ddaa1bbcd1845e0123ed106463 commit 9ffdcdff058d6b44cab70e4fb0bb301e39699483 Author: Chieu Nguyen <cvnguyen@google.com> Date: Wed Nov 4 17:18:22 2015 -0800 Add Unicode 8.0 emoji to emoji palette. Currently all emoji category tabs use the flower icon. A future CL will update these once the icons are finalized. If glyphs do not exist for new emoji, the old categories will be shown. Bug: 25369504 Bug: 16185905 Change-Id: Ie3759bfc4c8469a17f3205b45609ce6ef7510121 Change-Id: Ia5a5879cea828ea4cb4c678765fe5d9e5ecbfcd2
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardId.java22
-rw-r--r--java/src/com/android/inputmethod/keyboard/emoji/EmojiCategory.java137
2 files changed, 140 insertions, 19 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
index a1f7bf0e1..7352f911b 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,6 +60,16 @@ public final class KeyboardId {
public static final int ELEMENT_EMOJI_CATEGORY4 = 14;
public static final int ELEMENT_EMOJI_CATEGORY5 = 15;
public static final int ELEMENT_EMOJI_CATEGORY6 = 16;
+ public static final int ELEMENT_EMOJI_CATEGORY7 = 17;
+ public static final int ELEMENT_EMOJI_CATEGORY8 = 18;
+ public static final int ELEMENT_EMOJI_CATEGORY9 = 19;
+ public static final int ELEMENT_EMOJI_CATEGORY10 = 20;
+ public static final int ELEMENT_EMOJI_CATEGORY11 = 21;
+ public static final int ELEMENT_EMOJI_CATEGORY12 = 22;
+ public static final int ELEMENT_EMOJI_CATEGORY13 = 23;
+ public static final int ELEMENT_EMOJI_CATEGORY14 = 24;
+ public static final int ELEMENT_EMOJI_CATEGORY15 = 25;
+ public static final int ELEMENT_EMOJI_CATEGORY16 = 26;
public final RichInputMethodSubtype mSubtype;
public final int mWidth;
@@ -225,6 +235,16 @@ public final class KeyboardId {
case ELEMENT_EMOJI_CATEGORY4: return "emojiCategory4";
case ELEMENT_EMOJI_CATEGORY5: return "emojiCategory5";
case ELEMENT_EMOJI_CATEGORY6: return "emojiCategory6";
+ case ELEMENT_EMOJI_CATEGORY7: return "emojiCategory7";
+ case ELEMENT_EMOJI_CATEGORY8: return "emojiCategory8";
+ case ELEMENT_EMOJI_CATEGORY9: return "emojiCategory9";
+ case ELEMENT_EMOJI_CATEGORY10: return "emojiCategory10";
+ case ELEMENT_EMOJI_CATEGORY11: return "emojiCategory11";
+ case ELEMENT_EMOJI_CATEGORY12: return "emojiCategory12";
+ case ELEMENT_EMOJI_CATEGORY13: return "emojiCategory13";
+ case ELEMENT_EMOJI_CATEGORY14: return "emojiCategory14";
+ case ELEMENT_EMOJI_CATEGORY15: return "emojiCategory15";
+ case ELEMENT_EMOJI_CATEGORY16: return "emojiCategory16";
default: return null;
}
}
diff --git a/java/src/com/android/inputmethod/keyboard/emoji/EmojiCategory.java b/java/src/com/android/inputmethod/keyboard/emoji/EmojiCategory.java
index f2f52f85b..1f4fbe521 100644
--- a/java/src/com/android/inputmethod/keyboard/emoji/EmojiCategory.java
+++ b/java/src/com/android/inputmethod/keyboard/emoji/EmojiCategory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 The Android Open Source Project
+ * Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ package com.android.inputmethod.keyboard.emoji;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.content.res.TypedArray;
+import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Build;
import android.util.Log;
@@ -50,6 +51,16 @@ final class EmojiCategory {
private static final int ID_PLACES = 4;
private static final int ID_SYMBOLS = 5;
private static final int ID_EMOTICONS = 6;
+ private static final int ID_FLAGS = 7;
+ private static final int ID_EIGHT_SMILEY_PEOPLE = 8;
+ private static final int ID_EIGHT_ANIMALS_NATURE = 9;
+ private static final int ID_EIGHT_FOOD_DRINK = 10;
+ private static final int ID_EIGHT_TRAVEL_PLACES = 11;
+ private static final int ID_EIGHT_ACTIVITY = 12;
+ private static final int ID_EIGHT_OBJECTS = 13;
+ private static final int ID_EIGHT_SYMBOLS = 14;
+ private static final int ID_EIGHT_FLAGS = 15;
+ private static final int ID_EIGHT_SMILEY_PEOPLE_BORING = 16;
public final class CategoryProperties {
public final int mCategoryId;
@@ -67,7 +78,17 @@ final class EmojiCategory {
"nature",
"places",
"symbols",
- "emoticons" };
+ "emoticons",
+ "flags",
+ "smiley & people",
+ "animals & nature",
+ "food & drink",
+ "travel & places",
+ "activity",
+ "objects2",
+ "symbols2",
+ "flags2",
+ "smiley & people2" };
private static final int[] sCategoryTabIconAttr = {
R.styleable.EmojiPalettesView_iconEmojiRecentsTab,
@@ -76,7 +97,17 @@ final class EmojiCategory {
R.styleable.EmojiPalettesView_iconEmojiCategory3Tab,
R.styleable.EmojiPalettesView_iconEmojiCategory4Tab,
R.styleable.EmojiPalettesView_iconEmojiCategory5Tab,
- R.styleable.EmojiPalettesView_iconEmojiCategory6Tab };
+ R.styleable.EmojiPalettesView_iconEmojiCategory6Tab,
+ R.styleable.EmojiPalettesView_iconEmojiCategory7Tab,
+ R.styleable.EmojiPalettesView_iconEmojiCategory8Tab,
+ R.styleable.EmojiPalettesView_iconEmojiCategory9Tab,
+ R.styleable.EmojiPalettesView_iconEmojiCategory10Tab,
+ R.styleable.EmojiPalettesView_iconEmojiCategory11Tab,
+ R.styleable.EmojiPalettesView_iconEmojiCategory12Tab,
+ R.styleable.EmojiPalettesView_iconEmojiCategory13Tab,
+ R.styleable.EmojiPalettesView_iconEmojiCategory14Tab,
+ R.styleable.EmojiPalettesView_iconEmojiCategory15Tab,
+ R.styleable.EmojiPalettesView_iconEmojiCategory16Tab };
private static final int[] sAccessibilityDescriptionResourceIdsForCategories = {
R.string.spoken_descrption_emoji_category_recents,
@@ -85,7 +116,17 @@ final class EmojiCategory {
R.string.spoken_descrption_emoji_category_nature,
R.string.spoken_descrption_emoji_category_places,
R.string.spoken_descrption_emoji_category_symbols,
- R.string.spoken_descrption_emoji_category_emoticons };
+ R.string.spoken_descrption_emoji_category_emoticons,
+ R.string.spoken_descrption_emoji_category_flags,
+ R.string.spoken_descrption_emoji_category_eight_smiley_people,
+ R.string.spoken_descrption_emoji_category_eight_animals_nature,
+ R.string.spoken_descrption_emoji_category_eight_food_drink,
+ R.string.spoken_descrption_emoji_category_eight_travel_places,
+ R.string.spoken_descrption_emoji_category_eight_activity,
+ R.string.spoken_descrption_emoji_category_objects,
+ R.string.spoken_descrption_emoji_category_symbols,
+ R.string.spoken_descrption_emoji_category_flags,
+ R.string.spoken_descrption_emoji_category_eight_smiley_people };
private static final int[] sCategoryElementId = {
KeyboardId.ELEMENT_EMOJI_RECENTS,
@@ -94,7 +135,17 @@ final class EmojiCategory {
KeyboardId.ELEMENT_EMOJI_CATEGORY3,
KeyboardId.ELEMENT_EMOJI_CATEGORY4,
KeyboardId.ELEMENT_EMOJI_CATEGORY5,
- KeyboardId.ELEMENT_EMOJI_CATEGORY6 };
+ KeyboardId.ELEMENT_EMOJI_CATEGORY6,
+ KeyboardId.ELEMENT_EMOJI_CATEGORY7,
+ KeyboardId.ELEMENT_EMOJI_CATEGORY8,
+ KeyboardId.ELEMENT_EMOJI_CATEGORY9,
+ KeyboardId.ELEMENT_EMOJI_CATEGORY10,
+ KeyboardId.ELEMENT_EMOJI_CATEGORY11,
+ KeyboardId.ELEMENT_EMOJI_CATEGORY12,
+ KeyboardId.ELEMENT_EMOJI_CATEGORY13,
+ KeyboardId.ELEMENT_EMOJI_CATEGORY14,
+ KeyboardId.ELEMENT_EMOJI_CATEGORY15,
+ KeyboardId.ELEMENT_EMOJI_CATEGORY16 };
private final SharedPreferences mPrefs;
private final Resources mRes;
@@ -124,17 +175,37 @@ final class EmojiCategory {
int defaultCategoryId = EmojiCategory.ID_SYMBOLS;
addShownCategoryId(EmojiCategory.ID_RECENTS);
if (BuildCompatUtils.EFFECTIVE_SDK_INT >= Build.VERSION_CODES.KITKAT) {
- defaultCategoryId = EmojiCategory.ID_PEOPLE;
- addShownCategoryId(EmojiCategory.ID_PEOPLE);
- addShownCategoryId(EmojiCategory.ID_OBJECTS);
- addShownCategoryId(EmojiCategory.ID_NATURE);
- addShownCategoryId(EmojiCategory.ID_PLACES);
+ if (canShowUnicodeEightEmoji()) {
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
+ defaultCategoryId = EmojiCategory.ID_EIGHT_SMILEY_PEOPLE;
+ addShownCategoryId(EmojiCategory.ID_EIGHT_SMILEY_PEOPLE);
+ } else {
+ defaultCategoryId = EmojiCategory.ID_EIGHT_SMILEY_PEOPLE_BORING;
+ addShownCategoryId(EmojiCategory.ID_EIGHT_SMILEY_PEOPLE_BORING);
+ }
+ addShownCategoryId(EmojiCategory.ID_EIGHT_ANIMALS_NATURE);
+ addShownCategoryId(EmojiCategory.ID_EIGHT_FOOD_DRINK);
+ addShownCategoryId(EmojiCategory.ID_EIGHT_TRAVEL_PLACES);
+ addShownCategoryId(EmojiCategory.ID_EIGHT_ACTIVITY);
+ addShownCategoryId(EmojiCategory.ID_EIGHT_OBJECTS);
+ addShownCategoryId(EmojiCategory.ID_EIGHT_SYMBOLS);
+ addShownCategoryId(EmojiCategory.ID_FLAGS); // Exclude combinations without glyphs.
+ } else {
+ defaultCategoryId = EmojiCategory.ID_PEOPLE;
+ addShownCategoryId(EmojiCategory.ID_PEOPLE);
+ addShownCategoryId(EmojiCategory.ID_OBJECTS);
+ addShownCategoryId(EmojiCategory.ID_NATURE);
+ addShownCategoryId(EmojiCategory.ID_PLACES);
+ addShownCategoryId(EmojiCategory.ID_SYMBOLS);
+ if (canShowFlagEmoji()) {
+ addShownCategoryId(EmojiCategory.ID_FLAGS);
+ }
+ }
}
- addShownCategoryId(EmojiCategory.ID_SYMBOLS);
addShownCategoryId(EmojiCategory.ID_EMOTICONS);
DynamicGridKeyboard recentsKbd =
- getKeyboard(EmojiCategory.ID_RECENTS, 0 /* cagetoryPageId */);
+ getKeyboard(EmojiCategory.ID_RECENTS, 0 /* categoryPageId */);
recentsKbd.loadRecentKeys(mCategoryKeyboardMap.values());
mCurrentCategoryId = Settings.readLastShownEmojiCategoryId(mPrefs, defaultCategoryId);
@@ -147,7 +218,7 @@ final class EmojiCategory {
private void addShownCategoryId(final int categoryId) {
// Load a keyboard of categoryId
- getKeyboard(categoryId, 0 /* cagetoryPageId */);
+ getKeyboard(categoryId, 0 /* categoryPageId */);
final CategoryProperties properties =
new CategoryProperties(categoryId, getCategoryPageCount(categoryId));
mShownCategories.add(properties);
@@ -282,16 +353,16 @@ final class EmojiCategory {
public DynamicGridKeyboard getKeyboard(final int categoryId, final int id) {
synchronized (mCategoryKeyboardMap) {
- final Long categotyKeyboardMapKey = getCategoryKeyboardMapKey(categoryId, id);
- if (mCategoryKeyboardMap.containsKey(categotyKeyboardMapKey)) {
- return mCategoryKeyboardMap.get(categotyKeyboardMapKey);
+ final Long categoryKeyboardMapKey = getCategoryKeyboardMapKey(categoryId, id);
+ if (mCategoryKeyboardMap.containsKey(categoryKeyboardMapKey)) {
+ return mCategoryKeyboardMap.get(categoryKeyboardMapKey);
}
if (categoryId == EmojiCategory.ID_RECENTS) {
final DynamicGridKeyboard kbd = new DynamicGridKeyboard(mPrefs,
mLayoutSet.getKeyboard(KeyboardId.ELEMENT_EMOJI_RECENTS),
mMaxPageKeyCount, categoryId);
- mCategoryKeyboardMap.put(categotyKeyboardMapKey, kbd);
+ mCategoryKeyboardMap.put(categoryKeyboardMapKey, kbd);
return kbd;
}
@@ -311,7 +382,7 @@ final class EmojiCategory {
mCategoryKeyboardMap.put(
getCategoryKeyboardMapKey(categoryId, pageId), tempKeyboard);
}
- return mCategoryKeyboardMap.get(categotyKeyboardMapKey);
+ return mCategoryKeyboardMap.get(categoryKeyboardMapKey);
}
}
@@ -355,4 +426,34 @@ final class EmojiCategory {
}
return retval;
}
+
+ private static boolean canShowFlagEmoji() {
+ Paint paint = new Paint();
+ String switzerland = "\uD83C\uDDE8\uD83C\uDDED"; // U+1F1E8 U+1F1ED Flag for Switzerland
+ try {
+ return paint.hasGlyph(switzerland);
+ } catch (NoSuchMethodError e) {
+ // Compare display width of single-codepoint emoji to width of flag emoji to determine
+ // whether flag is rendered as single glyph or two adjacent regional indicator symbols.
+ float flagWidth = paint.measureText(switzerland);
+ float standardWidth = paint.measureText("\uD83D\uDC27"); // U+1F427 Penguin
+ return flagWidth < standardWidth * 1.25;
+ // This assumes that a valid glyph for the flag emoji must be less than 1.25 times
+ // the width of the penguin.
+ }
+ }
+
+ private static boolean canShowUnicodeEightEmoji() {
+ Paint paint = new Paint();
+ String cheese = "\uD83E\uDDC0"; // U+1F9C0 Cheese wedge
+ try {
+ return paint.hasGlyph(cheese);
+ } catch (NoSuchMethodError e) {
+ float cheeseWidth = paint.measureText(cheese);
+ float tofuWidth = paint.measureText("\uFFFE");
+ return cheeseWidth > tofuWidth;
+ // This assumes that a valid glyph for the cheese wedge must be greater than the width
+ // of the noncharacter.
+ }
+ }
}