forked from extern/Unexpected-Keyboard
Refactor: Make KeyValue final
The class has a complicated internal logic, it is no longer reasonable to extend it.
This commit is contained in:
parent
088d46d6e6
commit
9aac7900c0
@ -8,19 +8,30 @@ import java.io.BufferedReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Emoji extends KeyValue
|
||||
public class Emoji
|
||||
{
|
||||
private final KeyValue _kv;
|
||||
private final String _desc;
|
||||
|
||||
private static HashMap<String, Emoji> emojis_by_name = new HashMap<String, Emoji>();
|
||||
|
||||
protected Emoji(String name, String bytecode, String desc)
|
||||
{
|
||||
super(name, bytecode, KIND_STRING, 0, 0);
|
||||
_kv = new KeyValue(name, bytecode, KeyValue.KIND_STRING, 0, 0);
|
||||
_desc = desc;
|
||||
emojis_by_name.put(name, this);
|
||||
}
|
||||
|
||||
public String name()
|
||||
{
|
||||
return _kv.name;
|
||||
}
|
||||
|
||||
public KeyValue kv()
|
||||
{
|
||||
return _kv;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return (_desc);
|
||||
|
@ -55,7 +55,7 @@ public class EmojiGridView extends GridView
|
||||
Config config = Config.globalConfig();
|
||||
Integer used = _lastUsed.get(_emojiArray[pos]);
|
||||
_lastUsed.put(_emojiArray[pos], (used == null) ? 1 : used.intValue() + 1);
|
||||
config.handler.handleKeyUp(_emojiArray[pos], Pointers.Modifiers.EMPTY);
|
||||
config.handler.handleKeyUp(_emojiArray[pos].kv(), Pointers.Modifiers.EMPTY);
|
||||
saveLastUsed(); // TODO: opti
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ public class EmojiGridView extends GridView
|
||||
HashSet<String> set = new HashSet<String>();
|
||||
|
||||
for (Emoji emoji : _lastUsed.keySet())
|
||||
set.add(String.valueOf(_lastUsed.get(emoji)) + "-" + emoji.name);
|
||||
set.add(String.valueOf(_lastUsed.get(emoji)) + "-" + emoji.name());
|
||||
edit.putStringSet(LAST_USE_PREF, set);
|
||||
edit.apply();
|
||||
}
|
||||
@ -126,7 +126,7 @@ public class EmojiGridView extends GridView
|
||||
|
||||
public void setEmoji(Emoji emoji)
|
||||
{
|
||||
setText(emoji.getString());
|
||||
setText(emoji.kv().getString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ public class EmojiGroupButtonsBar extends LinearLayout
|
||||
for (int i = 0; i < Emoji.num_groups; i++)
|
||||
{
|
||||
Emoji first = Emoji.getEmojisByGroup(i)[0];
|
||||
add_group(i, first.getString());
|
||||
add_group(i, first.kv().getString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import android.view.KeyCharacterMap;
|
||||
import android.view.KeyEvent;
|
||||
import java.util.HashMap;
|
||||
|
||||
class KeyValue
|
||||
final class KeyValue
|
||||
{
|
||||
public static enum Event
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user