support error messages in quick edit dialog
This commit is contained in:
parent
b0d83ae4b9
commit
a973833a4f
|
@ -2348,9 +2348,12 @@ public class XmppConnectionService extends Service {
|
||||||
return false;
|
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 MucOptions options = conversation.getMucOptions();
|
||||||
final Jid joinJid = options.createJoinJid(nick);
|
final Jid joinJid = options.createJoinJid(nick);
|
||||||
|
if (joinJid == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (options.online()) {
|
if (options.online()) {
|
||||||
Account account = conversation.getAccount();
|
Account account = conversation.getAccount();
|
||||||
options.setOnRenameListener(new OnRenameListener() {
|
options.setOnRenameListener(new OnRenameListener() {
|
||||||
|
@ -2395,6 +2398,7 @@ public class XmppConnectionService extends Service {
|
||||||
joinMuc(conversation);
|
joinMuc(conversation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void leaveMuc(Conversation conversation) {
|
public void leaveMuc(Conversation conversation) {
|
||||||
|
|
|
@ -204,8 +204,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
private OnValueEdited onSubjectEdited = new OnValueEdited() {
|
private OnValueEdited onSubjectEdited = new OnValueEdited() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onValueEdited(String value) {
|
public String onValueEdited(String value) {
|
||||||
xmppConnectionService.pushSubjectToConference(mConversation,value);
|
xmppConnectionService.pushSubjectToConference(mConversation,value);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -254,8 +255,12 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
new OnValueEdited() {
|
new OnValueEdited() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onValueEdited(String value) {
|
public String onValueEdited(String value) {
|
||||||
xmppConnectionService.renameInMuc(mConversation,value,renameCallback);
|
if (xmppConnectionService.renameInMuc(mConversation,value,renameCallback)) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return getString(R.string.invalid_username);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,11 +284,11 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
|
||||||
quickEdit(contact.getDisplayName(), 0, new OnValueEdited() {
|
quickEdit(contact.getDisplayName(), 0, new OnValueEdited() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onValueEdited(String value) {
|
public String onValueEdited(String value) {
|
||||||
contact.setServerName(value);
|
contact.setServerName(value);
|
||||||
ContactDetailsActivity.this.xmppConnectionService
|
ContactDetailsActivity.this.xmppConnectionService.pushContactToServer(contact);
|
||||||
.pushContactToServer(contact);
|
|
||||||
populateView();
|
populateView();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -133,9 +133,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
||||||
activity.quickPasswordEdit(password, new OnValueEdited() {
|
activity.quickPasswordEdit(password, new OnValueEdited() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onValueEdited(String value) {
|
public String onValueEdited(String value) {
|
||||||
activity.xmppConnectionService.providePasswordForMuc(
|
activity.xmppConnectionService.providePasswordForMuc(conversation, value);
|
||||||
conversation, value);
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.app.ActionBar;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.AlertDialog.Builder;
|
import android.app.AlertDialog.Builder;
|
||||||
|
import android.app.Dialog;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
|
@ -167,11 +168,11 @@ public abstract class XmppActivity extends Activity {
|
||||||
abstract protected void refreshUiReal();
|
abstract protected void refreshUiReal();
|
||||||
|
|
||||||
protected interface OnValueEdited {
|
protected interface OnValueEdited {
|
||||||
public void onValueEdited(String value);
|
String onValueEdited(String value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnPresenceSelected {
|
public interface OnPresenceSelected {
|
||||||
public void onPresenceSelected();
|
void onPresenceSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ServiceConnection mConnection = new ServiceConnection() {
|
protected ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
@ -733,23 +734,13 @@ public abstract class XmppActivity extends Activity {
|
||||||
boolean password) {
|
boolean password) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
View view = getLayoutInflater().inflate(R.layout.quickedit, null);
|
View view = getLayoutInflater().inflate(R.layout.quickedit, null);
|
||||||
final EditText editor = (EditText) view.findViewById(R.id.editor);
|
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) {
|
if (password) {
|
||||||
editor.setInputType(InputType.TYPE_CLASS_TEXT
|
editor.setInputType(InputType.TYPE_CLASS_TEXT
|
||||||
| InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
| InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||||
builder.setPositiveButton(R.string.accept, mClickListener);
|
builder.setPositiveButton(R.string.accept,null);
|
||||||
} else {
|
} else {
|
||||||
builder.setPositiveButton(R.string.edit, mClickListener);
|
builder.setPositiveButton(R.string.edit, null);
|
||||||
}
|
}
|
||||||
if (hint != 0) {
|
if (hint != 0) {
|
||||||
editor.setHint(hint);
|
editor.setHint(hint);
|
||||||
|
@ -761,7 +752,24 @@ public abstract class XmppActivity extends Activity {
|
||||||
}
|
}
|
||||||
builder.setView(view);
|
builder.setView(view);
|
||||||
builder.setNegativeButton(R.string.cancel, null);
|
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) {
|
public boolean hasStoragePermission(int requestCode) {
|
||||||
|
|
Loading…
Reference in a new issue