diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-01-25 22:03:03 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-01-25 22:03:03 +0100 |
commit | 0b22039392b3745c1e3b97c58665bb8a2907e675 (patch) | |
tree | 395fb3a539b480bad76bce2260a311927f98d213 /src/main | |
parent | 062b8889b884ba111012d16fc9e6094657ab1388 (diff) |
support enter/done key in create contact & join dialogs
Diffstat (limited to 'src/main')
6 files changed, 51 insertions, 31 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/CreateConferenceDialog.java b/src/main/java/de/pixart/messenger/ui/CreateConferenceDialog.java index 900f4a42d..059a6b94c 100644 --- a/src/main/java/de/pixart/messenger/ui/CreateConferenceDialog.java +++ b/src/main/java/de/pixart/messenger/ui/CreateConferenceDialog.java @@ -60,6 +60,10 @@ public class CreateConferenceDialog extends DialogFragment { builder.setPositiveButton(R.string.choose_participants, (dialog, which) -> mListener.onCreateDialogPositiveClick(binding.account, binding.groupChatName.getText().toString().trim())); builder.setNegativeButton(R.string.cancel, null); DelayedHintHelper.setHint(R.string.providing_a_name_is_optional, binding.groupChatName); + binding.groupChatName.setOnEditorActionListener((v, actionId, event) -> { + mListener.onCreateDialogPositiveClick(binding.account, binding.groupChatName.getText().toString().trim()); + return true; + }); return builder.create(); } diff --git a/src/main/java/de/pixart/messenger/ui/EnterJidDialog.java b/src/main/java/de/pixart/messenger/ui/EnterJidDialog.java index d0c7980fd..02aa46277 100644 --- a/src/main/java/de/pixart/messenger/ui/EnterJidDialog.java +++ b/src/main/java/de/pixart/messenger/ui/EnterJidDialog.java @@ -114,42 +114,51 @@ public class EnterJidDialog extends DialogFragment implements OnBackendConnected AlertDialog dialog = builder.create(); View.OnClickListener dialogOnClick = v -> { - final Jid accountJid; - if (!binding.account.isEnabled() && account == null) { - return; - } - try { - if (Config.DOMAIN_LOCK != null) { - accountJid = Jid.of((String) binding.account.getSelectedItem(), Config.DOMAIN_LOCK, null); - } else { - accountJid = Jid.of((String) binding.account.getSelectedItem()); - } - } catch (final IllegalArgumentException e) { - return; - } - final Jid contactJid; - try { - contactJid = Jid.of(binding.jid.getText().toString()); - } catch (final IllegalArgumentException e) { - binding.jid.setError(getActivity().getString(R.string.invalid_jid)); - return; - } - - if (mListener != null) { - try { - if (mListener.onEnterJidDialogPositive(accountJid, contactJid)) { - dialog.dismiss(); - } - } catch (JidError error) { - binding.jid.setError(error.toString()); - } - } + handleEnter(binding, account, dialog); }; + binding.jid.setOnEditorActionListener((v, actionId, event) -> { + handleEnter(binding, account, dialog); + return true; + }); + dialog.show(); dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(dialogOnClick); return dialog; } + private void handleEnter(EnterJidDialogBinding binding, String account, Dialog dialog) { + final Jid accountJid; + if (!binding.account.isEnabled() && account == null) { + return; + } + try { + if (Config.DOMAIN_LOCK != null) { + accountJid = Jid.of((String) binding.account.getSelectedItem(), Config.DOMAIN_LOCK, null); + } else { + accountJid = Jid.of((String) binding.account.getSelectedItem()); + } + } catch (final IllegalArgumentException e) { + return; + } + final Jid contactJid; + try { + contactJid = Jid.of(binding.jid.getText().toString()); + } catch (final IllegalArgumentException e) { + binding.jid.setError(getActivity().getString(R.string.invalid_jid)); + return; + } + + if (mListener != null) { + try { + if (mListener.onEnterJidDialogPositive(accountJid, contactJid)) { + dialog.dismiss(); + } + } catch (JidError error) { + binding.jid.setError(error.toString()); + } + } + } + public void setOnEnterJidDialogPositiveListener(OnEnterJidDialogPositiveListener listener) { this.mListener = listener; } diff --git a/src/main/java/de/pixart/messenger/ui/JoinConferenceDialog.java b/src/main/java/de/pixart/messenger/ui/JoinConferenceDialog.java index a8702ebb6..4d05d6d2c 100644 --- a/src/main/java/de/pixart/messenger/ui/JoinConferenceDialog.java +++ b/src/main/java/de/pixart/messenger/ui/JoinConferenceDialog.java @@ -77,6 +77,10 @@ public class JoinConferenceDialog extends DialogFragment implements OnBackendCon AlertDialog dialog = builder.create(); dialog.show(); dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(view -> mListener.onJoinDialogPositiveClick(dialog, binding.account, binding.jid, binding.bookmark.isChecked())); + binding.jid.setOnEditorActionListener((v, actionId, event) -> { + mListener.onJoinDialogPositiveClick(dialog, binding.account, binding.jid, binding.bookmark.isChecked()); + return true; + }); return dialog; } diff --git a/src/main/res/layout/create_conference_dialog.xml b/src/main/res/layout/create_conference_dialog.xml index 3496b17f5..85a4cbf89 100644 --- a/src/main/res/layout/create_conference_dialog.xml +++ b/src/main/res/layout/create_conference_dialog.xml @@ -38,7 +38,8 @@ style="@style/Widget.Conversations.EditText" android:layout_width="match_parent" android:layout_height="wrap_content" - android:hint="@string/create_dialog_group_chat_name" /> + android:hint="@string/create_dialog_group_chat_name" + android:imeOptions="actionNext" /> </android.support.design.widget.TextInputLayout> </LinearLayout> </layout>
\ No newline at end of file diff --git a/src/main/res/layout/dialog_join_conference.xml b/src/main/res/layout/dialog_join_conference.xml index 15017d5c1..27acefc4a 100644 --- a/src/main/res/layout/dialog_join_conference.xml +++ b/src/main/res/layout/dialog_join_conference.xml @@ -40,6 +40,7 @@ style="@style/Widget.Conversations.EditText" android:layout_width="fill_parent" android:layout_height="wrap_content" + android:imeOptions="actionDone" android:inputType="textEmailAddress" /> </android.support.design.widget.TextInputLayout> diff --git a/src/main/res/layout/enter_jid_dialog.xml b/src/main/res/layout/enter_jid_dialog.xml index 4c0214f96..11f673916 100644 --- a/src/main/res/layout/enter_jid_dialog.xml +++ b/src/main/res/layout/enter_jid_dialog.xml @@ -40,6 +40,7 @@ style="@style/Widget.Conversations.EditText" android:layout_width="fill_parent" android:layout_height="wrap_content" + android:imeOptions="actionDone" android:inputType="textEmailAddress" android:textColor="?attr/text_Color_Main" /> </android.support.design.widget.TextInputLayout> |