fixups and code clean up for 'Ctrl+Enter'
This commit is contained in:
parent
e7e04837b6
commit
c9e6653e33
|
@ -2735,15 +2735,17 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onEnterPressed(KeyEvent event) {
|
public boolean onEnterPressed(final boolean isCtrlPressed) {
|
||||||
SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
if (isCtrlPressed || enterIsSend()) {
|
||||||
final boolean enterIsSend = p.getBoolean("enter_is_send", getResources().getBoolean(R.bool.enter_is_send));
|
|
||||||
if (enterIsSend || event.isCtrlPressed()) {
|
|
||||||
sendMessage();
|
sendMessage();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean enterIsSend() {
|
||||||
|
final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
|
return p.getBoolean("enter_is_send", getResources().getBoolean(R.bool.enter_is_send));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -54,13 +54,14 @@ public class EditMessage extends EmojiWrapperEditText {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent e) {
|
public boolean onKeyDown(final int keyCode, final KeyEvent e) {
|
||||||
|
final boolean isCtrlPressed = e.isCtrlPressed();
|
||||||
if (keyCode == KeyEvent.KEYCODE_ENTER && !e.isShiftPressed()) {
|
if (keyCode == KeyEvent.KEYCODE_ENTER && !e.isShiftPressed()) {
|
||||||
lastInputWasTab = false;
|
lastInputWasTab = false;
|
||||||
if (keyboardListener != null && keyboardListener.onEnterPressed(e)) {
|
if (keyboardListener != null && keyboardListener.onEnterPressed(isCtrlPressed)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (keyCode == KeyEvent.KEYCODE_TAB && !e.isAltPressed() && !e.isCtrlPressed()) {
|
} else if (keyCode == KeyEvent.KEYCODE_TAB && !e.isAltPressed() && !isCtrlPressed) {
|
||||||
if (keyboardListener != null && keyboardListener.onTabPressed(this.lastInputWasTab)) {
|
if (keyboardListener != null && keyboardListener.onTabPressed(this.lastInputWasTab)) {
|
||||||
lastInputWasTab = true;
|
lastInputWasTab = true;
|
||||||
return true;
|
return true;
|
||||||
|
@ -191,7 +192,7 @@ public class EditMessage extends EmojiWrapperEditText {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface KeyboardListener {
|
public interface KeyboardListener {
|
||||||
boolean onEnterPressed(KeyEvent event);
|
boolean onEnterPressed(boolean isCtrlPressed);
|
||||||
|
|
||||||
void onTypingStarted();
|
void onTypingStarted();
|
||||||
|
|
||||||
|
|
|
@ -401,7 +401,7 @@
|
||||||
<string name="mark_as_read">Mark as read</string>
|
<string name="mark_as_read">Mark as read</string>
|
||||||
<string name="pref_input_options">Input</string>
|
<string name="pref_input_options">Input</string>
|
||||||
<string name="pref_enter_is_send">Enter is send</string>
|
<string name="pref_enter_is_send">Enter is send</string>
|
||||||
<string name="pref_enter_is_send_summary">Use enter key to send message. You can always use ctrl+enter to send message, even if this option is disabled.</string>
|
<string name="pref_enter_is_send_summary">Use Enter key to send message. You can always use Ctrl+Enter to send message, even if this option is disabled.</string>
|
||||||
<string name="pref_display_enter_key">Show enter key</string>
|
<string name="pref_display_enter_key">Show enter key</string>
|
||||||
<string name="pref_display_enter_key_summary">Change the emoticons key to an enter key</string>
|
<string name="pref_display_enter_key_summary">Change the emoticons key to an enter key</string>
|
||||||
<string name="audio">audio</string>
|
<string name="audio">audio</string>
|
||||||
|
|
Loading…
Reference in New Issue