permit empty values for subject and roster name

This commit is contained in:
Daniel Gultsch 2018-06-10 19:12:46 +02:00
parent 30e5f9b290
commit fcfb695e7a
4 changed files with 19 additions and 19 deletions

View File

@ -180,9 +180,7 @@ public class MessageGenerator extends AbstractGenerator {
MessagePacket packet = new MessagePacket();
packet.setType(MessagePacket.TYPE_GROUPCHAT);
packet.setTo(conversation.getJid().asBareJid());
Element subjectChild = new Element("subject");
subjectChild.setContent(subject);
packet.addChild(subjectChild);
packet.addChild("subject").setContent(subject);
packet.setFrom(conversation.getAccount().getJid().asBareJid());
return packet;
}

View File

@ -181,7 +181,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
@Override
public String onValueEdited(String value) {
xmppConnectionService.pushSubjectToConference(mConversation, value);
xmppConnectionService.pushSubjectToConference(mConversation, value.trim().isEmpty() ? null : value.trim());
return null;
}
};
@ -271,7 +271,8 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
if (mConversation != null) {
quickEdit(mConversation.getMucOptions().getSubject(),
R.string.edit_subject_hint,
this.onSubjectEdited);
this.onSubjectEdited,
true);
}
break;
case R.id.action_share_http:

View File

@ -240,16 +240,12 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
case R.id.action_edit_contact:
Uri systemAccount = contact.getSystemAccount();
if (systemAccount == null) {
quickEdit(contact.getDisplayName(), 0, new OnValueEdited() {
@Override
public String onValueEdited(String value) {
contact.setServerName(value);
ContactDetailsActivity.this.xmppConnectionService.pushContactToServer(contact);
populateView();
return null;
}
});
quickEdit(contact.getDisplayName(), 0, value -> {
contact.setServerName(value);
ContactDetailsActivity.this.xmppConnectionService.pushContactToServer(contact);
populateView();
return null;
}, true);
} else {
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setDataAndType(systemAccount, Contacts.CONTENT_ITEM_TYPE);

View File

@ -688,18 +688,23 @@ public abstract class XmppActivity extends ActionBarActivity {
}
protected void quickEdit(String previousValue, int hint, OnValueEdited callback) {
quickEdit(previousValue, callback, hint, false);
quickEdit(previousValue, callback, hint, false, false);
}
protected void quickEdit(String previousValue, int hint, OnValueEdited callback, boolean permitEmpty) {
quickEdit(previousValue, callback, hint, false, permitEmpty);
}
protected void quickPasswordEdit(String previousValue, OnValueEdited callback) {
quickEdit(previousValue, callback, R.string.password, true);
quickEdit(previousValue, callback, R.string.password, true, false);
}
@SuppressLint("InflateParams")
private void quickEdit(final String previousValue,
final OnValueEdited callback,
final int hint,
boolean password) {
boolean password,
boolean permitEmpty) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
View view = getLayoutInflater().inflate(R.layout.quickedit, null);
final EditText editor = view.findViewById(R.id.editor);
@ -722,7 +727,7 @@ public abstract class XmppActivity extends ActionBarActivity {
dialog.show();
View.OnClickListener clickListener = v -> {
String value = editor.getText().toString();
if (!value.equals(previousValue) && value.trim().length() > 0) {
if (!value.equals(previousValue) && (!value.trim().isEmpty() || permitEmpty)) {
String error = callback.onValueEdited(value);
if (error != null) {
editor.setError(error);