aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-06-16 23:40:30 +0200
committerChristian Schneppe <christian@pix-art.de>2018-06-16 23:40:30 +0200
commitfa6a57784f828e5aa587d3d099c97acb1cd88bfd (patch)
treeec7f9cb9c21cbbe7c49b3b0af2cf7d34536d7930
parent0e51d1fd4121a884ad09793945e4e0b60e3ffa18 (diff)
permit empty values for subject and roster name
-rw-r--r--src/main/java/de/pixart/messenger/generator/MessageGenerator.java4
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java5
-rw-r--r--src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java16
-rw-r--r--src/main/java/de/pixart/messenger/ui/XmppActivity.java13
4 files changed, 19 insertions, 19 deletions
diff --git a/src/main/java/de/pixart/messenger/generator/MessageGenerator.java b/src/main/java/de/pixart/messenger/generator/MessageGenerator.java
index 369a1963e..e66261be7 100644
--- a/src/main/java/de/pixart/messenger/generator/MessageGenerator.java
+++ b/src/main/java/de/pixart/messenger/generator/MessageGenerator.java
@@ -215,9 +215,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;
}
diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
index c7847f64b..c55a936cd 100644
--- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
@@ -227,7 +227,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;
}
};
@@ -324,7 +324,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:
diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
index a9f2a3e51..6ce1e7e70 100644
--- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
@@ -305,16 +305,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);
diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
index ef531f5fe..73a9e2f5f 100644
--- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
@@ -710,18 +710,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);
@@ -746,7 +751,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);