support enter/done key in create contact & join dialogs
This commit is contained in:
parent
062b8889b8
commit
0b22039392
6 changed files with 51 additions and 31 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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>
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
Reference in a new issue