Do not merge. Save / restore the last used emoji category
Bug: 11029983 Change-Id: I5547910c7b5dd7974292fc075af33568940f4e81main
parent
2d74136e57
commit
7d3f53a1cb
|
@ -162,9 +162,11 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
addShownCategoryId(CATEGORY_ID_OBJECTS);
|
addShownCategoryId(CATEGORY_ID_OBJECTS);
|
||||||
addShownCategoryId(CATEGORY_ID_NATURE);
|
addShownCategoryId(CATEGORY_ID_NATURE);
|
||||||
addShownCategoryId(CATEGORY_ID_PLACES);
|
addShownCategoryId(CATEGORY_ID_PLACES);
|
||||||
mCurrentCategoryId = CATEGORY_ID_PEOPLE;
|
mCurrentCategoryId =
|
||||||
|
Settings.readLastShownEmojiCategoryId(mPrefs, CATEGORY_ID_PEOPLE);
|
||||||
} else {
|
} else {
|
||||||
mCurrentCategoryId = CATEGORY_ID_SYMBOLS;
|
mCurrentCategoryId =
|
||||||
|
Settings.readLastShownEmojiCategoryId(mPrefs, CATEGORY_ID_SYMBOLS);
|
||||||
}
|
}
|
||||||
addShownCategoryId(CATEGORY_ID_SYMBOLS);
|
addShownCategoryId(CATEGORY_ID_SYMBOLS);
|
||||||
addShownCategoryId(CATEGORY_ID_EMOTICONS);
|
addShownCategoryId(CATEGORY_ID_EMOTICONS);
|
||||||
|
@ -222,6 +224,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
|
|
||||||
public void setCurrentCategoryId(int categoryId) {
|
public void setCurrentCategoryId(int categoryId) {
|
||||||
mCurrentCategoryId = categoryId;
|
mCurrentCategoryId = categoryId;
|
||||||
|
Settings.writeLastShownEmojiCategoryId(mPrefs, categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentCategoryPageId(int id) {
|
public void setCurrentCategoryPageId(int id) {
|
||||||
|
@ -233,7 +236,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveLastTypedCategoryPage() {
|
public void saveLastTypedCategoryPage() {
|
||||||
Settings.writeEmojiCategoryLastTypedId(
|
Settings.writeLastTypedEmojiCategoryPageId(
|
||||||
mPrefs, mCurrentCategoryId, mCurrentCategoryPageId);
|
mPrefs, mCurrentCategoryId, mCurrentCategoryPageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +257,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
// Returns the view pager's page position for the categoryId
|
// Returns the view pager's page position for the categoryId
|
||||||
public int getPageIdFromCategoryId(int categoryId) {
|
public int getPageIdFromCategoryId(int categoryId) {
|
||||||
final int lastSavedCategoryPageId =
|
final int lastSavedCategoryPageId =
|
||||||
Settings.readEmojiCategoryLastTypedId(mPrefs, categoryId);
|
Settings.readLastTypedEmojiCategoryPageId(mPrefs, categoryId);
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for (int i = 0; i < mShownCategories.size(); ++i) {
|
for (int i = 0; i < mShownCategories.size(); ++i) {
|
||||||
final CategoryProperties props = mShownCategories.get(i);
|
final CategoryProperties props = mShownCategories.get(i);
|
||||||
|
|
|
@ -101,6 +101,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
||||||
// Emoji
|
// Emoji
|
||||||
public static final String PREF_EMOJI_RECENT_KEYS = "emoji_recent_keys";
|
public static final String PREF_EMOJI_RECENT_KEYS = "emoji_recent_keys";
|
||||||
public static final String PREF_EMOJI_CATEGORY_LAST_TYPED_ID = "emoji_category_last_typed_id";
|
public static final String PREF_EMOJI_CATEGORY_LAST_TYPED_ID = "emoji_category_last_typed_id";
|
||||||
|
public static final String PREF_LAST_SHOWN_EMOJI_CATEGORY_ID = "last_shown_emoji_category_id";
|
||||||
|
|
||||||
private Resources mRes;
|
private Resources mRes;
|
||||||
private SharedPreferences mPrefs;
|
private SharedPreferences mPrefs;
|
||||||
|
@ -383,15 +384,25 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
||||||
return prefs.getString(PREF_EMOJI_RECENT_KEYS, "");
|
return prefs.getString(PREF_EMOJI_RECENT_KEYS, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeEmojiCategoryLastTypedId(
|
public static void writeLastTypedEmojiCategoryPageId(
|
||||||
final SharedPreferences prefs, final int category, final int id) {
|
final SharedPreferences prefs, final int categoryId, final int categoryPageId) {
|
||||||
final String key = PREF_EMOJI_CATEGORY_LAST_TYPED_ID + category;
|
final String key = PREF_EMOJI_CATEGORY_LAST_TYPED_ID + categoryId;
|
||||||
prefs.edit().putInt(key, id).apply();
|
prefs.edit().putInt(key, categoryPageId).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int readEmojiCategoryLastTypedId(
|
public static int readLastTypedEmojiCategoryPageId(
|
||||||
final SharedPreferences prefs, final int category) {
|
final SharedPreferences prefs, final int categoryId) {
|
||||||
final String key = PREF_EMOJI_CATEGORY_LAST_TYPED_ID + category;
|
final String key = PREF_EMOJI_CATEGORY_LAST_TYPED_ID + categoryId;
|
||||||
return prefs.getInt(key, 0);
|
return prefs.getInt(key, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void writeLastShownEmojiCategoryId(
|
||||||
|
final SharedPreferences prefs, final int categoryId) {
|
||||||
|
prefs.edit().putInt(PREF_LAST_SHOWN_EMOJI_CATEGORY_ID, categoryId).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int readLastShownEmojiCategoryId(
|
||||||
|
final SharedPreferences prefs, final int defValue) {
|
||||||
|
return prefs.getInt(PREF_LAST_SHOWN_EMOJI_CATEGORY_ID, defValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue