Support sending messages with ctrl+enter
Currently Conversations lacks any keyboard shortcut to send a message if enter_is_send is disabled. KeyboardListener has been extended to include the original KeyEvent as an argument. fixes #3829
This commit is contained in:
parent
aa47e53584
commit
e7e04837b6
|
@ -32,6 +32,7 @@ import android.util.Log;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
|
@ -2734,10 +2735,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onEnterPressed() {
|
public boolean onEnterPressed(KeyEvent event) {
|
||||||
SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
final boolean enterIsSend = p.getBoolean("enter_is_send", getResources().getBoolean(R.bool.enter_is_send));
|
final boolean enterIsSend = p.getBoolean("enter_is_send", getResources().getBoolean(R.bool.enter_is_send));
|
||||||
if (enterIsSend) {
|
if (enterIsSend || event.isCtrlPressed()) {
|
||||||
sendMessage();
|
sendMessage();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class EditMessage extends EmojiWrapperEditText {
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent e) {
|
public boolean onKeyDown(int keyCode, KeyEvent e) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_ENTER && !e.isShiftPressed()) {
|
if (keyCode == KeyEvent.KEYCODE_ENTER && !e.isShiftPressed()) {
|
||||||
lastInputWasTab = false;
|
lastInputWasTab = false;
|
||||||
if (keyboardListener != null && keyboardListener.onEnterPressed()) {
|
if (keyboardListener != null && keyboardListener.onEnterPressed(e)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (keyCode == KeyEvent.KEYCODE_TAB && !e.isAltPressed() && !e.isCtrlPressed()) {
|
} else if (keyCode == KeyEvent.KEYCODE_TAB && !e.isAltPressed() && !e.isCtrlPressed()) {
|
||||||
|
@ -191,7 +191,7 @@ public class EditMessage extends EmojiWrapperEditText {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface KeyboardListener {
|
public interface KeyboardListener {
|
||||||
boolean onEnterPressed();
|
boolean onEnterPressed(KeyEvent event);
|
||||||
|
|
||||||
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</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