diff options
author | Daniel Gultsch <inputmice@siacs.eu> | 2015-01-09 19:23:26 +0100 |
---|---|---|
committer | Daniel Gultsch <inputmice@siacs.eu> | 2015-01-09 19:23:26 +0100 |
commit | 06eae476ee7e19029fe1ac28eae75fdcc1d4d1e6 (patch) | |
tree | 54180483627e4d9470f566d17033d6dbc5790c74 /src | |
parent | 0a48f777acefa29443743f68f242136309169ba2 (diff) |
Introduced expert options to control enter-is-send
(default == off)
Diffstat (limited to 'src')
5 files changed, 27 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index ba5b3e59..a461656e 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -1058,4 +1058,8 @@ public class ConversationActivity extends XmppActivity public void blockConversation(final Blockable conversation) { xmppConnectionService.sendBlockRequest(conversation); } + + public boolean enterIsSend() { + return getPreferences().getBoolean("enter_is_send",false); + } } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 93a4cc7e..5eb81e64 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -316,8 +316,13 @@ public class ConversationFragment extends Fragment { mEditMessage.setOnEnterPressedListener(new OnEnterPressed() { @Override - public void onEnterPressed() { - sendMessage(); + public boolean onEnterPressed() { + if (activity.enterIsSend()) { + sendMessage(); + return true; + } else { + return false; + } } }); diff --git a/src/main/java/eu/siacs/conversations/ui/EditMessage.java b/src/main/java/eu/siacs/conversations/ui/EditMessage.java index f8302050..5090bbf5 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditMessage.java +++ b/src/main/java/eu/siacs/conversations/ui/EditMessage.java @@ -21,9 +21,12 @@ public class EditMessage extends EditText { public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { if (mOnEnterPressed != null) { - mOnEnterPressed.onEnterPressed(); + if (mOnEnterPressed.onEnterPressed()) { + return true; + } else { + return super.onKeyDown(keyCode, event); + } } - return true; } return super.onKeyDown(keyCode, event); } @@ -33,7 +36,7 @@ public class EditMessage extends EditText { } public interface OnEnterPressed { - public void onEnterPressed(); + public boolean onEnterPressed(); } } diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 9cb60cf8..31f4dbea 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -434,4 +434,7 @@ <string name="two_hours">2 hours</string> <string name="eight_hours">8 hours</string> <string name="until_further_notice">Until further notice</string> + <string name="pref_input_options">Input options</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> </resources> diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 9974f14d..3f18512b 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -122,6 +122,13 @@ android:summary="@string/pref_enable_legacy_ssl_summary" android:title="@string/pref_enable_legacy_ssl" /> </PreferenceCategory> + <PreferenceCategory android:title="@string/pref_input_options"> + <CheckBoxPreference + android:defaultValue="false" + android:key="enter_is_send" + android:title="@string/pref_enter_is_send" + android:summary="@string/pref_enter_is_send_summary" /> + </PreferenceCategory> <PreferenceCategory android:title="@string/pref_expert_options_other" > <CheckBoxPreference android:defaultValue="false" |