aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorSatoshi Kataoka <satok@google.com>2013-10-11 07:04:41 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-10-11 07:04:42 +0000
commit6026a9581685b2d91fc5bd6cf33a506d5560c238 (patch)
tree0f71cc52599287e7ffa839c1cc3df77c1c7f601e /java/src
parent9514ed5c2a49e645e2d468f7191d54d77d9f127f (diff)
parent6dc99dc20097dedc18861b264ae2566915cede64 (diff)
downloadlatinime-6026a9581685b2d91fc5bd6cf33a506d5560c238.tar.gz
latinime-6026a9581685b2d91fc5bd6cf33a506d5560c238.tar.xz
latinime-6026a9581685b2d91fc5bd6cf33a506d5560c238.zip
Merge "Save / restore the last used emoji category"
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java11
-rw-r--r--java/src/com/android/inputmethod/latin/settings/Settings.java25
2 files changed, 25 insertions, 11 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java b/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java
index 9779c683c..f12373503 100644
--- a/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java
+++ b/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java
@@ -162,9 +162,11 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
addShownCategoryId(CATEGORY_ID_OBJECTS);
addShownCategoryId(CATEGORY_ID_NATURE);
addShownCategoryId(CATEGORY_ID_PLACES);
- mCurrentCategoryId = CATEGORY_ID_PEOPLE;
+ mCurrentCategoryId =
+ Settings.readLastShownEmojiCategoryId(mPrefs, CATEGORY_ID_PEOPLE);
} else {
- mCurrentCategoryId = CATEGORY_ID_SYMBOLS;
+ mCurrentCategoryId =
+ Settings.readLastShownEmojiCategoryId(mPrefs, CATEGORY_ID_SYMBOLS);
}
addShownCategoryId(CATEGORY_ID_SYMBOLS);
addShownCategoryId(CATEGORY_ID_EMOTICONS);
@@ -222,6 +224,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
public void setCurrentCategoryId(int categoryId) {
mCurrentCategoryId = categoryId;
+ Settings.writeLastShownEmojiCategoryId(mPrefs, categoryId);
}
public void setCurrentCategoryPageId(int id) {
@@ -233,7 +236,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
}
public void saveLastTypedCategoryPage() {
- Settings.writeEmojiCategoryLastTypedId(
+ Settings.writeLastTypedEmojiCategoryPageId(
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
public int getPageIdFromCategoryId(int categoryId) {
final int lastSavedCategoryPageId =
- Settings.readEmojiCategoryLastTypedId(mPrefs, categoryId);
+ Settings.readLastTypedEmojiCategoryPageId(mPrefs, categoryId);
int sum = 0;
for (int i = 0; i < mShownCategories.size(); ++i) {
final CategoryProperties props = mShownCategories.get(i);
diff --git a/java/src/com/android/inputmethod/latin/settings/Settings.java b/java/src/com/android/inputmethod/latin/settings/Settings.java
index 1a0fecc62..dc005bbdf 100644
--- a/java/src/com/android/inputmethod/latin/settings/Settings.java
+++ b/java/src/com/android/inputmethod/latin/settings/Settings.java
@@ -101,6 +101,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
// Emoji
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_LAST_SHOWN_EMOJI_CATEGORY_ID = "last_shown_emoji_category_id";
private Resources mRes;
private SharedPreferences mPrefs;
@@ -383,15 +384,25 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
return prefs.getString(PREF_EMOJI_RECENT_KEYS, "");
}
- public static void writeEmojiCategoryLastTypedId(
- final SharedPreferences prefs, final int category, final int id) {
- final String key = PREF_EMOJI_CATEGORY_LAST_TYPED_ID + category;
- prefs.edit().putInt(key, id).apply();
+ public static void writeLastTypedEmojiCategoryPageId(
+ final SharedPreferences prefs, final int categoryId, final int categoryPageId) {
+ final String key = PREF_EMOJI_CATEGORY_LAST_TYPED_ID + categoryId;
+ prefs.edit().putInt(key, categoryPageId).apply();
}
- public static int readEmojiCategoryLastTypedId(
- final SharedPreferences prefs, final int category) {
- final String key = PREF_EMOJI_CATEGORY_LAST_TYPED_ID + category;
+ public static int readLastTypedEmojiCategoryPageId(
+ final SharedPreferences prefs, final int categoryId) {
+ final String key = PREF_EMOJI_CATEGORY_LAST_TYPED_ID + categoryId;
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);
+ }
}