Skip to content

Commit 3597915

Browse files
veetimcginty
authored andcommitted
Add a backspace key to the emoji drawer
1 parent 40ce0ce commit 3597915

3 files changed

Lines changed: 41 additions & 5 deletions

File tree

res/layout/emoji_drawer.xml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,25 @@
66
android:layout_width="match_parent"
77
android:layout_height="match_parent">
88

9-
<com.astuetz.PagerSlidingTabStrip android:id="@+id/tabs"
10-
android:background="#ff333333"
11-
android:layout_width="match_parent"
12-
android:layout_height="45dp" />
9+
<LinearLayout android:background="#ff333333"
10+
android:orientation="horizontal"
11+
android:layout_width="match_parent"
12+
android:layout_height="wrap_content">
13+
14+
<com.astuetz.PagerSlidingTabStrip android:id="@+id/tabs"
15+
android:layout_weight="1"
16+
android:layout_width="0dp"
17+
android:layout_height="45dp" />
18+
19+
<ImageButton android:id="@+id/backspace"
20+
android:src="@drawable/ic_emoji_backspace"
21+
android:background="@color/emoji_tab_underline"
22+
android:paddingLeft="@dimen/emoji_drawer_left_right_padding"
23+
android:paddingRight="@dimen/emoji_drawer_left_right_padding"
24+
android:layout_width="wrap_content"
25+
android:layout_height="match_parent" />
26+
27+
</LinearLayout>
1328

1429
<android.support.v4.view.ViewPager android:id="@+id/emoji_pager"
1530
android:visibility="visible"

res/values/dimens.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<dimen name="min_emoji_drawer_height">200dp</dimen>
55
<dimen name="emoji_drawer_item_padding">8dp</dimen>
66
<dimen name="emoji_drawer_indicator_height">2dp</dimen>
7-
<dimen name="emoji_drawer_left_right_padding">15dp</dimen>
7+
<dimen name="emoji_drawer_left_right_padding">8dp</dimen>
88
<dimen name="conversation_item_corner_radius">3dp</dimen>
99
<dimen name="conversation_item_drop_shadow_dist">2dp</dimen>
1010
<dimen name="contact_selection_photo_size">50dp</dimen>

src/org/thoughtcrime/securesms/components/EmojiDrawer.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import android.util.AttributeSet;
1010
import android.util.Log;
1111
import android.util.Pair;
12+
import android.view.HapticFeedbackConstants;
13+
import android.view.KeyEvent;
1214
import android.view.LayoutInflater;
1315
import android.view.View;
1416
import android.view.ViewGroup;
@@ -18,6 +20,7 @@
1820
import android.widget.EditText;
1921
import android.widget.FrameLayout;
2022
import android.widget.GridView;
23+
import android.widget.ImageButton;
2124
import android.widget.ImageView;
2225
import android.widget.LinearLayout;
2326
import 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

Comments
 (0)