Unexpected-Keyboard/srcs/juloo.keyboard2/EmojiTypeButton.java

38 lines
1000 B
Java
Raw Normal View History

2015-10-24 16:32:49 +02:00
package juloo.keyboard2;
import android.content.Context;
import android.view.ContextThemeWrapper;
2015-10-24 16:32:49 +02:00
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
/* Emoji "types" are groups. This class is misnamed. */
2015-10-24 16:32:49 +02:00
public class EmojiTypeButton extends Button
implements View.OnTouchListener
2015-10-24 16:32:49 +02:00
{
private int _emojiType;
2015-10-24 16:32:49 +02:00
static private final int DEFAULT_GROUP = 0;
2015-10-27 15:05:50 +01:00
public EmojiTypeButton(Context context, int group_id, String symbol)
{
super(new ContextThemeWrapper(context, R.style.emojiTypeButton), null, 0);
_emojiType = group_id;
setText(symbol);
setOnTouchListener(this);
}
2015-10-24 16:32:49 +02:00
public boolean onTouch(View view, MotionEvent event)
{
EmojiGridView emojiGrid;
2015-10-24 16:32:49 +02:00
if (event.getAction() != MotionEvent.ACTION_DOWN)
return (false);
emojiGrid = (EmojiGridView)((ViewGroup)(getParent().getParent())).findViewById(R.id.emoji_grid);
emojiGrid.setEmojiGroup(_emojiType);
return (true);
}
2015-10-24 16:32:49 +02:00
}