Skip to content
Snippets Groups Projects
Commit a2a057a9 authored by Dmitry Torokhov's avatar Dmitry Torokhov
Browse files

Check if last shown Emoji category ID is still valid

When upgrading to a new version of APK we may find that the stored Emoji
category ID is no longer applicable. For example it happened when we
brought in the new Unicode 8.0 Emojis.

Also restore the "Symbols" emoji category on pre-kitkat devices which
was accidentally dropped when bringing in Unicode 8.0 Emojis.

b/25972978

Change-Id: I91c044603b0aac8757cb8597d3af995f84b822f3
parent 4c5ce3d7
No related branches found
No related tags found
No related merge requests found
......@@ -196,6 +196,8 @@ final class EmojiCategory {
addShownCategoryId(EmojiCategory.ID_FLAGS);
}
}
} else {
addShownCategoryId(EmojiCategory.ID_SYMBOLS);
}
addShownCategoryId(EmojiCategory.ID_EMOTICONS);
......@@ -204,9 +206,14 @@ final class EmojiCategory {
recentsKbd.loadRecentKeys(mCategoryKeyboardMap.values());
mCurrentCategoryId = Settings.readLastShownEmojiCategoryId(mPrefs, defaultCategoryId);
if (mCurrentCategoryId == EmojiCategory.ID_RECENTS &&
Log.i(TAG, "Last Emoji category id is " + mCurrentCategoryId);
if (!isShownCategoryId(mCurrentCategoryId)) {
Log.i(TAG, "Last emoji category " + mCurrentCategoryId +
" is invalid, starting in " + defaultCategoryId);
mCurrentCategoryId = defaultCategoryId;
} else if (mCurrentCategoryId == EmojiCategory.ID_RECENTS &&
recentsKbd.getSortedKeys().isEmpty()) {
Log.i(TAG, "No recent emojis found, starting in category " + mCurrentCategoryId);
Log.i(TAG, "No recent emojis found, starting in category " + defaultCategoryId);
mCurrentCategoryId = defaultCategoryId;
}
}
......@@ -219,6 +226,15 @@ final class EmojiCategory {
mShownCategories.add(properties);
}
private boolean isShownCategoryId(final int categoryId) {
for (final CategoryProperties prop : mShownCategories) {
if (prop.mCategoryId == categoryId) {
return true;
}
}
return false;
}
public static String getCategoryName(final int categoryId, final int categoryPageId) {
return sCategoryName[categoryId] + "-" + categoryPageId;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment