diff options
Diffstat (limited to '')
5 files changed, 41 insertions, 25 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index bc3f6e0bf..3a32f02a0 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -2537,9 +2537,12 @@ public class XmppConnectionService extends Service { return false; } - public void renameInMuc(final Conversation conversation, final String nick, final UiCallback<Conversation> callback) { + public boolean renameInMuc(final Conversation conversation, final String nick, final UiCallback<Conversation> callback) { final MucOptions options = conversation.getMucOptions(); final Jid joinJid = options.createJoinJid(nick); + if (joinJid == null) { + return false; + } if (options.online()) { Account account = conversation.getAccount(); options.setOnRenameListener(new OnRenameListener() { @@ -2584,6 +2587,7 @@ public class XmppConnectionService extends Service { joinMuc(conversation); } } + return true; } public void leaveMuc(Conversation conversation) { diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java index 3479e7081..94faf59ec 100644 --- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java @@ -223,8 +223,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers private OnValueEdited onSubjectEdited = new OnValueEdited() { @Override - public void onValueEdited(String value) { + public String onValueEdited(String value) { xmppConnectionService.pushSubjectToConference(mConversation, value); + return null; } }; @@ -274,8 +275,12 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers new OnValueEdited() { @Override - public void onValueEdited(String value) { - xmppConnectionService.renameInMuc(mConversation, value, renameCallback); + public String onValueEdited(String value) { + if (xmppConnectionService.renameInMuc(mConversation, value, renameCallback)) { + return null; + } else { + return getString(R.string.invalid_username); + } } }); } diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java index e42f6b49b..38a7689bf 100644 --- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java @@ -343,11 +343,11 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp quickEdit(contact.getDisplayName(), 0, new OnValueEdited() { @Override - public void onValueEdited(String value) { + public String onValueEdited(String value) { contact.setServerName(value); - ContactDetailsActivity.this.xmppConnectionService - .pushContactToServer(contact); + ContactDetailsActivity.this.xmppConnectionService.pushContactToServer(contact); populateView(); + return null; } }); } else { diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 1cbf8c1eb..5413dcf6f 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -139,9 +139,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa activity.quickPasswordEdit(password, new OnValueEdited() { @Override - public void onValueEdited(String value) { - activity.xmppConnectionService.providePasswordForMuc( - conversation, value); + public String onValueEdited(String value) { + activity.xmppConnectionService.providePasswordForMuc(conversation, value); + return null; } }); } diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java index 568fe4d16..d12d3aa01 100644 --- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java +++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java @@ -172,11 +172,11 @@ public abstract class XmppActivity extends Activity { abstract protected void refreshUiReal(); protected interface OnValueEdited { - public void onValueEdited(String value); + String onValueEdited(String value); } public interface OnPresenceSelected { - public void onPresenceSelected(); + void onPresenceSelected(); } protected ServiceConnection mConnection = new ServiceConnection() { @@ -744,22 +744,12 @@ public abstract class XmppActivity extends Activity { AlertDialog.Builder builder = new AlertDialog.Builder(this); View view = getLayoutInflater().inflate(R.layout.quickedit, null); final EditText editor = view.findViewById(R.id.editor); - OnClickListener mClickListener = new OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - String value = editor.getText().toString(); - if (!value.equals(previousValue) && value.trim().length() > 0) { - callback.onValueEdited(value); - } - } - }; if (password) { editor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); - builder.setPositiveButton(R.string.accept, mClickListener); + builder.setPositiveButton(R.string.accept, null); } else { - builder.setPositiveButton(R.string.ok, mClickListener); + builder.setPositiveButton(R.string.ok, null); } if (hint != 0) { editor.setHint(hint); @@ -771,7 +761,24 @@ public abstract class XmppActivity extends Activity { } builder.setView(view); builder.setNegativeButton(R.string.cancel, null); - builder.create().show(); + final AlertDialog dialog = builder.create(); + dialog.show(); + View.OnClickListener clickListener = new View.OnClickListener() { + + @Override + public void onClick(View v) { + String value = editor.getText().toString(); + if (!value.equals(previousValue) && value.trim().length() > 0) { + String error = callback.onValueEdited(value); + if (error != null) { + editor.setError(error); + return; + } + } + dialog.dismiss(); + } + }; + dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(clickListener); } public boolean hasStoragePermission(int requestCode) { |