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

38 lines
976 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
{
private int _emojiType;
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);
2015-10-24 16:32:49 +02:00
setOnTouchListener(this);
}
public boolean onTouch(View view, MotionEvent event)
{
EmojiGridView emojiGrid;
if (event.getAction() != MotionEvent.ACTION_DOWN)
return (false);
emojiGrid = (EmojiGridView)((ViewGroup)(getParent().getParent())).findViewById(R.id.emoji_grid);
emojiGrid.setEmojiGroup(_emojiType);
2015-10-24 16:32:49 +02:00
return (true);
}
}