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(); MessagePacket packet = new MessagePacket();
packet.setType(MessagePacket.TYPE_GROUPCHAT); packet.setType(MessagePacket.TYPE_GROUPCHAT);
packet.setTo(conversation.getJid().asBareJid()); packet.setTo(conversation.getJid().asBareJid());
Element subjectChild = new Element("subject"); packet.addChild("subject").setContent(subject);
subjectChild.setContent(subject);
packet.addChild(subjectChild);
packet.setFrom(conversation.getAccount().getJid().asBareJid()); packet.setFrom(conversation.getAccount().getJid().asBareJid());
return packet; return packet;
} }

View file

@ -181,7 +181,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
@Override @Override
public String onValueEdited(String value) { public String onValueEdited(String value) {
xmppConnectionService.pushSubjectToConference(mConversation, value); xmppConnectionService.pushSubjectToConference(mConversation, value.trim().isEmpty() ? null : value.trim());
return null; return null;
} }
}; };
@ -271,7 +271,8 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
if (mConversation != null) { if (mConversation != null) {
quickEdit(mConversation.getMucOptions().getSubject(), quickEdit(mConversation.getMucOptions().getSubject(),
R.string.edit_subject_hint, R.string.edit_subject_hint,
this.onSubjectEdited); this.onSubjectEdited,
true);
} }
break; break;
case R.id.action_share_http: 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: case R.id.action_edit_contact:
Uri systemAccount = contact.getSystemAccount(); Uri systemAccount = contact.getSystemAccount();
if (systemAccount == null) { if (systemAccount == null) {
quickEdit(contact.getDisplayName(), 0, new OnValueEdited() { quickEdit(contact.getDisplayName(), 0, value -> {
@Override
public String onValueEdited(String value) {
contact.setServerName(value); contact.setServerName(value);
ContactDetailsActivity.this.xmppConnectionService.pushContactToServer(contact); ContactDetailsActivity.this.xmppConnectionService.pushContactToServer(contact);
populateView(); populateView();
return null; return null;
} }, true);
});
} else { } else {
Intent intent = new Intent(Intent.ACTION_EDIT); Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setDataAndType(systemAccount, Contacts.CONTENT_ITEM_TYPE); 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) { 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) { protected void quickPasswordEdit(String previousValue, OnValueEdited callback) {
quickEdit(previousValue, callback, R.string.password, true); quickEdit(previousValue, callback, R.string.password, true, false);
} }
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
private void quickEdit(final String previousValue, private void quickEdit(final String previousValue,
final OnValueEdited callback, final OnValueEdited callback,
final int hint, final int hint,
boolean password) { boolean password,
boolean permitEmpty) {
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 = view.findViewById(R.id.editor); final EditText editor = view.findViewById(R.id.editor);
@ -722,7 +727,7 @@ public abstract class XmppActivity extends ActionBarActivity {
dialog.show(); dialog.show();
View.OnClickListener clickListener = v -> { View.OnClickListener clickListener = v -> {
String value = editor.getText().toString(); 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); String error = callback.onValueEdited(value);
if (error != null) { if (error != null) {
editor.setError(error); editor.setError(error);