99import android .util .AttributeSet ;
1010import android .util .Log ;
1111import android .util .Pair ;
12+ import android .view .HapticFeedbackConstants ;
13+ import android .view .KeyEvent ;
1214import android .view .LayoutInflater ;
1315import android .view .View ;
1416import android .view .ViewGroup ;
1820import android .widget .EditText ;
1921import android .widget .FrameLayout ;
2022import android .widget .GridView ;
23+ import android .widget .ImageButton ;
2124import android .widget .ImageView ;
2225import android .widget .LinearLayout ;
2326import android .widget .RelativeLayout ;
@@ -37,6 +40,7 @@ public class EmojiDrawer extends KeyboardAwareLinearLayout {
3740 private Emoji emoji ;
3841 private ViewPager pager ;
3942 private PagerSlidingTabStrip strip ;
43+ private ImageButton backspace ;
4044
4145 @ SuppressWarnings ("unused" )
4246 public EmojiDrawer (Context context ) {
@@ -76,7 +80,10 @@ private void initialize() {
7680 private void initializeResources () {
7781 this .pager = (ViewPager ) findViewById (R .id .emoji_pager );
7882 this .strip = (PagerSlidingTabStrip ) findViewById (R .id .tabs );
83+ this .backspace = (ImageButton ) findViewById (R .id .backspace );
7984 this .emoji = Emoji .getInstance (getContext ());
85+
86+ this .backspace .setOnClickListener (new BackspaceClickListener ());
8087 }
8188
8289 public void hide () {
@@ -149,6 +156,20 @@ private void insertEmoji(EditText editText, Integer unicodePoint) {
149156 }
150157 }
151158
159+ private class BackspaceClickListener implements OnClickListener {
160+
161+ private final KeyEvent deleteKeyEvent = new KeyEvent (KeyEvent .ACTION_DOWN , KeyEvent .KEYCODE_DEL );
162+
163+ @ Override
164+ public void onClick (View v ) {
165+ if (composeText .getText ().length () > 0 ) {
166+ composeText .dispatchKeyEvent (deleteKeyEvent );
167+ v .performHapticFeedback (HapticFeedbackConstants .KEYBOARD_TAP );
168+ }
169+ }
170+
171+ }
172+
152173 private class EmojiGridAdapter extends BaseAdapter {
153174
154175 private final int type ;
0 commit comments