From c6a48773918a83089f226515543ad65fa85cd4ef Mon Sep 17 00:00:00 2001 From: Rhodey Orbits Date: Wed, 15 Apr 2015 11:07:49 -0700 Subject: [PATCH] Fix recent emoji sort order The recent emoji tab was sorting emoji as last in last out instead of last in first out. Also, if an emoji was already in the recent emoji cache its order would not be updated on reinsert. Fixes #2967 Closes #2946 // FREEBIE --- src/org/thoughtcrime/securesms/util/Emoji.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/util/Emoji.java b/src/org/thoughtcrime/securesms/util/Emoji.java index 1d8e34d61e..e50b33b8e9 100644 --- a/src/org/thoughtcrime/securesms/util/Emoji.java +++ b/src/org/thoughtcrime/securesms/util/Emoji.java @@ -263,7 +263,8 @@ public class Emoji { } public Pair getRecentlyUsed(int position, double size, PageLoadedListener pageLoadedListener) { - String code = EmojiLRU.getRecentlyUsed(context)[position]; + String[] recentlyUsed = EmojiLRU.getRecentlyUsed(context); + String code = recentlyUsed[recentlyUsed.length - 1 - position]; return new Pair(Integer.parseInt(code, 16), getEmojiDrawable(code, size, pageLoadedListener)); } @@ -329,6 +330,7 @@ public class Emoji { prefs = PreferenceManager.getDefaultSharedPreferences(context); } + recentlyUsed.remove(asset); recentlyUsed.add(asset); if (recentlyUsed.size() > EMOJI_LRU_SIZE) {