support enter/done key in create contact & join dialogs
This commit is contained in:
parent
7cabb2c377
commit
394e252777
|
@ -8,9 +8,11 @@ import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -50,6 +52,10 @@ public class CreateConferenceDialog extends DialogFragment {
|
||||||
builder.setPositiveButton(R.string.choose_participants, (dialog, which) -> mListener.onCreateDialogPositiveClick(binding.account, binding.groupChatName.getText().toString().trim()));
|
builder.setPositiveButton(R.string.choose_participants, (dialog, which) -> mListener.onCreateDialogPositiveClick(binding.account, binding.groupChatName.getText().toString().trim()));
|
||||||
builder.setNegativeButton(R.string.cancel, null);
|
builder.setNegativeButton(R.string.cancel, null);
|
||||||
DelayedHintHelper.setHint(R.string.providing_a_name_is_optional, binding.groupChatName);
|
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();
|
return builder.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,12 @@ import android.os.Bundle;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.AutoCompleteTextView;
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -103,48 +105,60 @@ public class EnterJidDialog extends DialogFragment implements OnBackendConnected
|
||||||
binding.account.setAdapter(adapter);
|
binding.account.setAdapter(adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
builder.setView(binding.getRoot());
|
builder.setView(binding.getRoot());
|
||||||
builder.setNegativeButton(R.string.cancel, null);
|
builder.setNegativeButton(R.string.cancel, null);
|
||||||
builder.setPositiveButton(getArguments().getString(POSITIVE_BUTTON_KEY), null);
|
builder.setPositiveButton(getArguments().getString(POSITIVE_BUTTON_KEY), null);
|
||||||
AlertDialog dialog = builder.create();
|
AlertDialog dialog = builder.create();
|
||||||
|
|
||||||
View.OnClickListener dialogOnClick = v -> {
|
View.OnClickListener dialogOnClick = v -> {
|
||||||
final Jid accountJid;
|
handleEnter(binding, account, dialog);
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
binding.jid.setOnEditorActionListener((v, actionId, event) -> {
|
||||||
|
handleEnter(binding, account, dialog);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(dialogOnClick);
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(dialogOnClick);
|
||||||
return dialog;
|
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) {
|
public void setOnEnterJidDialogPositiveListener(OnEnterJidDialogPositiveListener listener) {
|
||||||
this.mListener = listener;
|
this.mListener = listener;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,10 @@ import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.widget.AutoCompleteTextView;
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -64,6 +66,10 @@ public class JoinConferenceDialog extends DialogFragment implements OnBackendCon
|
||||||
AlertDialog dialog = builder.create();
|
AlertDialog dialog = builder.create();
|
||||||
dialog.show();
|
dialog.show();
|
||||||
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(view -> mListener.onJoinDialogPositiveClick(dialog, binding.account, binding.jid, binding.bookmark.isChecked()));
|
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;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@
|
||||||
style="@style/Widget.Conversations.EditText"
|
style="@style/Widget.Conversations.EditText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
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>
|
</android.support.design.widget.TextInputLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -35,7 +35,8 @@
|
||||||
style="@style/Widget.Conversations.EditText"
|
style="@style/Widget.Conversations.EditText"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:inputType="textEmailAddress"/>
|
android:inputType="textEmailAddress"
|
||||||
|
android:imeOptions="actionDone"/>
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
|
|
|
@ -35,7 +35,8 @@
|
||||||
style="@style/Widget.Conversations.EditText"
|
style="@style/Widget.Conversations.EditText"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:inputType="textEmailAddress"/>
|
android:inputType="textEmailAddress"
|
||||||
|
android:imeOptions="actionDone"/>
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
Loading…
Reference in New Issue