blob: 5090bbf53da311286ea2f889b24ad904df247ce2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package eu.siacs.conversations.ui;
import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.widget.EditText;
public class EditMessage extends EditText {
public EditMessage(Context context, AttributeSet attrs) {
super(context, attrs);
}
public EditMessage(Context context) {
super(context);
}
protected OnEnterPressed mOnEnterPressed;
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER) {
if (mOnEnterPressed != null) {
if (mOnEnterPressed.onEnterPressed()) {
return true;
} else {
return super.onKeyDown(keyCode, event);
}
}
}
return super.onKeyDown(keyCode, event);
}
public void setOnEnterPressedListener(OnEnterPressed listener) {
this.mOnEnterPressed = listener;
}
public interface OnEnterPressed {
public boolean onEnterPressed();
}
}
|