aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/github/ankushsachdeva/emojicon/EmojiconRecentsManager.java14
-rw-r--r--src/github/ankushsachdeva/emojicon/EmojiconsPopup.java9
-rw-r--r--src/github/ankushsachdeva/emojicon/emoji/Emojicon.java17
3 files changed, 12 insertions, 28 deletions
diff --git a/src/github/ankushsachdeva/emojicon/EmojiconRecentsManager.java b/src/github/ankushsachdeva/emojicon/EmojiconRecentsManager.java
index ce9cc67..9fbb987 100644
--- a/src/github/ankushsachdeva/emojicon/EmojiconRecentsManager.java
+++ b/src/github/ankushsachdeva/emojicon/EmojiconRecentsManager.java
@@ -75,23 +75,20 @@ public class EmojiconRecentsManager extends ArrayList<Emojicon> {
@Override
public boolean add(Emojicon object) {
boolean ret = super.add(object);
- saveRecents();
return ret;
}
@Override
public void add(int index, Emojicon object) {
super.add(index, object);
- saveRecents();
}
@Override
public boolean remove(Object object) {
boolean ret = super.remove(object);
- saveRecents();
return ret;
}
-
+
private SharedPreferences getPreferences() {
return mContext.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
}
@@ -102,21 +99,20 @@ public class EmojiconRecentsManager extends ArrayList<Emojicon> {
StringTokenizer tokenizer = new StringTokenizer(str, "~");
while (tokenizer.hasMoreTokens()) {
try {
- int codepoint = Integer.parseInt(tokenizer.nextToken());
- add(Emojicon.fromCodePoint(codepoint));
+ add(new Emojicon(tokenizer.nextToken()));
}
catch (NumberFormatException e) {
// ignored
}
}
}
-
- private void saveRecents() {
+
+ public void saveRecents() {
StringBuilder str = new StringBuilder();
int c = size();
for (int i = 0; i < c; i++) {
Emojicon e = get(i);
- str.append(e.getEmoji().codePointAt(0));
+ str.append(e.getEmoji());
if (i < (c - 1)) {
str.append('~');
}
diff --git a/src/github/ankushsachdeva/emojicon/EmojiconsPopup.java b/src/github/ankushsachdeva/emojicon/EmojiconsPopup.java
index f6c0fbd..91dab5c 100644
--- a/src/github/ankushsachdeva/emojicon/EmojiconsPopup.java
+++ b/src/github/ankushsachdeva/emojicon/EmojiconsPopup.java
@@ -46,8 +46,6 @@ import android.view.WindowManager.LayoutParams;
import android.widget.EditText;
import android.widget.PopupWindow;
-import github.ankushsachdeva.emojicon.R;
-
/**
* @author Ankush Sachdeva (sankush@yahoo.co.in).
@@ -100,6 +98,13 @@ public class EmojiconsPopup extends PopupWindow implements ViewPager.OnPageChang
return isOpened;
}
+ @Override
+ public void dismiss() {
+ super.dismiss();
+ EmojiconRecentsManager
+ .getInstance(mContext).saveRecents();
+ }
+
public void setSizeForSoftKeyboard(){
rootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
diff --git a/src/github/ankushsachdeva/emojicon/emoji/Emojicon.java b/src/github/ankushsachdeva/emojicon/emoji/Emojicon.java
index f5c9e55..2ba8ca1 100644
--- a/src/github/ankushsachdeva/emojicon/emoji/Emojicon.java
+++ b/src/github/ankushsachdeva/emojicon/emoji/Emojicon.java
@@ -23,20 +23,11 @@ import java.io.Serializable;
*/
public class Emojicon implements Serializable {
private static final long serialVersionUID = 1L;
- private int icon;
- private char value;
private String emoji;
private Emojicon() {
}
- public static Emojicon fromResource(int icon, int value) {
- Emojicon emoji = new Emojicon();
- emoji.icon = icon;
- emoji.value = (char) value;
- return emoji;
- }
-
public static Emojicon fromCodePoint(int codePoint) {
Emojicon emoji = new Emojicon();
emoji.emoji = newString(codePoint);
@@ -59,14 +50,6 @@ public class Emojicon implements Serializable {
this.emoji = emoji;
}
- public char getValue() {
- return value;
- }
-
- public int getIcon() {
- return icon;
- }
-
public String getEmoji() {
return emoji;
}