aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/ui/EditMessage.java
diff options
context:
space:
mode:
authorlookshe <github@lookshe.org>2016-03-06 19:42:55 +0100
committerlookshe <github@lookshe.org>2016-03-06 19:42:55 +0100
commit3c400703e082a1b180b35d891b8fb3460c7d5b87 (patch)
tree28738dd90fc41b4ab71897f38d324828778ad2e3 /src/main/java/de/thedevstack/conversationsplus/ui/EditMessage.java
parent72114d732427266024cdd6e27cd8d1aa60afae2f (diff)
parentf28d77dc42f6bac5a026e0b1c78562dee8de45ac (diff)
Merge branch 'trz/rebase' into trz/rename
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/ui/EditMessage.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/EditMessage.java26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/EditMessage.java b/src/main/java/de/thedevstack/conversationsplus/ui/EditMessage.java
index 5c2e6164..5664434f 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/EditMessage.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/EditMessage.java
@@ -32,21 +32,32 @@ public class EditMessage extends EmojiconEditText {
private boolean isUserTyping = false;
+ private boolean lastInputWasTab = false;
+
protected KeyboardListener keyboardListener;
@Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_ENTER) {
+ public boolean onKeyDown(int keyCode, KeyEvent e) {
+ if (keyCode == KeyEvent.KEYCODE_ENTER && !e.isShiftPressed()) {
+ lastInputWasTab = false;
if (keyboardListener != null && keyboardListener.onEnterPressed()) {
return true;
}
+ } else if (keyCode == KeyEvent.KEYCODE_TAB && !e.isAltPressed() && !e.isCtrlPressed()) {
+ if (keyboardListener != null && keyboardListener.onTabPressed(this.lastInputWasTab)) {
+ lastInputWasTab = true;
+ return true;
+ }
+ } else {
+ lastInputWasTab = false;
}
- return super.onKeyDown(keyCode, event);
+ return super.onKeyDown(keyCode, e);
}
@Override
public void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
super.onTextChanged(text,start,lengthBefore,lengthAfter);
+ lastInputWasTab = false;
if (this.mTypingHandler != null && this.keyboardListener != null) {
this.mTypingHandler.removeCallbacks(mTypingTimeout);
this.mTypingHandler.postDelayed(mTypingTimeout, Config.TYPING_TIMEOUT * 1000);
@@ -69,10 +80,11 @@ public class EditMessage extends EmojiconEditText {
}
public interface KeyboardListener {
- public boolean onEnterPressed();
- public void onTypingStarted();
- public void onTypingStopped();
- public void onTextDeleted();
+ boolean onEnterPressed();
+ void onTypingStarted();
+ void onTypingStopped();
+ void onTextDeleted();
+ boolean onTabPressed(boolean repeated);
}
}