2014-10-22 16:38:44 +00:00
|
|
|
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) {
|
2015-01-09 18:23:26 +00:00
|
|
|
if (mOnEnterPressed.onEnterPressed()) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return super.onKeyDown(keyCode, event);
|
|
|
|
}
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return super.onKeyDown(keyCode, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setOnEnterPressedListener(OnEnterPressed listener) {
|
|
|
|
this.mOnEnterPressed = listener;
|
|
|
|
}
|
|
|
|
|
|
|
|
public interface OnEnterPressed {
|
2015-01-09 18:23:26 +00:00
|
|
|
public boolean onEnterPressed();
|
2014-10-22 16:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|