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: I91c044603b0aac8757cb8597d3af995f84b822f3main
parent
4c5ce3d7bb
commit
a2a057a991
|
@ -196,6 +196,8 @@ final class EmojiCategory {
|
||||||
addShownCategoryId(EmojiCategory.ID_FLAGS);
|
addShownCategoryId(EmojiCategory.ID_FLAGS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
addShownCategoryId(EmojiCategory.ID_SYMBOLS);
|
||||||
}
|
}
|
||||||
addShownCategoryId(EmojiCategory.ID_EMOTICONS);
|
addShownCategoryId(EmojiCategory.ID_EMOTICONS);
|
||||||
|
|
||||||
|
@ -204,9 +206,14 @@ final class EmojiCategory {
|
||||||
recentsKbd.loadRecentKeys(mCategoryKeyboardMap.values());
|
recentsKbd.loadRecentKeys(mCategoryKeyboardMap.values());
|
||||||
|
|
||||||
mCurrentCategoryId = Settings.readLastShownEmojiCategoryId(mPrefs, defaultCategoryId);
|
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()) {
|
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;
|
mCurrentCategoryId = defaultCategoryId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,6 +226,15 @@ final class EmojiCategory {
|
||||||
mShownCategories.add(properties);
|
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) {
|
public static String getCategoryName(final int categoryId, final int categoryPageId) {
|
||||||
return sCategoryName[categoryId] + "-" + categoryPageId;
|
return sCategoryName[categoryId] + "-" + categoryPageId;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue