show status messages in contact details
This commit is contained in:
parent
1901abd05f
commit
a9c1768107
|
@ -1,8 +1,10 @@
|
||||||
package eu.siacs.conversations.entities;
|
package eu.siacs.conversations.entities;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
|
|
||||||
|
@ -57,4 +59,16 @@ public class Presences {
|
||||||
return presences.containsKey(presence);
|
return presences.containsKey(presence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getStatusMessages() {
|
||||||
|
ArrayList<String> messages = new ArrayList<>();
|
||||||
|
synchronized (this.presences) {
|
||||||
|
for(Presence presence : this.presences.values()) {
|
||||||
|
if (presence.message != null && !presence.message.trim().isEmpty()) {
|
||||||
|
messages.add(presence.message.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
import eu.siacs.conversations.entities.Contact;
|
import eu.siacs.conversations.entities.Contact;
|
||||||
import eu.siacs.conversations.entities.ListItem;
|
import eu.siacs.conversations.entities.ListItem;
|
||||||
|
import eu.siacs.conversations.entities.Presence;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
|
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate;
|
import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate;
|
||||||
import eu.siacs.conversations.utils.CryptoHelper;
|
import eu.siacs.conversations.utils.CryptoHelper;
|
||||||
|
@ -107,6 +108,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
private TextView contactJidTv;
|
private TextView contactJidTv;
|
||||||
private TextView accountJidTv;
|
private TextView accountJidTv;
|
||||||
private TextView lastseen;
|
private TextView lastseen;
|
||||||
|
private TextView statusMessage;
|
||||||
private CheckBox send;
|
private CheckBox send;
|
||||||
private CheckBox receive;
|
private CheckBox receive;
|
||||||
private Button addContactButton;
|
private Button addContactButton;
|
||||||
|
@ -203,6 +205,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
contactJidTv = (TextView) findViewById(R.id.details_contactjid);
|
contactJidTv = (TextView) findViewById(R.id.details_contactjid);
|
||||||
accountJidTv = (TextView) findViewById(R.id.details_account);
|
accountJidTv = (TextView) findViewById(R.id.details_account);
|
||||||
lastseen = (TextView) findViewById(R.id.details_lastseen);
|
lastseen = (TextView) findViewById(R.id.details_lastseen);
|
||||||
|
statusMessage = (TextView) findViewById(R.id.status_message);
|
||||||
send = (CheckBox) findViewById(R.id.details_send_presence);
|
send = (CheckBox) findViewById(R.id.details_send_presence);
|
||||||
receive = (CheckBox) findViewById(R.id.details_receive_presence);
|
receive = (CheckBox) findViewById(R.id.details_receive_presence);
|
||||||
badge = (QuickContactBadge) findViewById(R.id.details_contact_badge);
|
badge = (QuickContactBadge) findViewById(R.id.details_contact_badge);
|
||||||
|
@ -310,6 +313,25 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
send.setOnCheckedChangeListener(null);
|
send.setOnCheckedChangeListener(null);
|
||||||
receive.setOnCheckedChangeListener(null);
|
receive.setOnCheckedChangeListener(null);
|
||||||
|
|
||||||
|
List<String> statusMessages = contact.getPresences().getStatusMessages();
|
||||||
|
if (statusMessages.size() == 0) {
|
||||||
|
statusMessage.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
statusMessage.setVisibility(View.VISIBLE);
|
||||||
|
int s = statusMessages.size();
|
||||||
|
for(int i = 0; i < s; ++i) {
|
||||||
|
if (s > 1) {
|
||||||
|
builder.append("• ");
|
||||||
|
}
|
||||||
|
builder.append(statusMessages.get(i));
|
||||||
|
if (i < s - 1) {
|
||||||
|
builder.append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
statusMessage.setText(builder);
|
||||||
|
}
|
||||||
|
|
||||||
if (contact.getOption(Contact.Options.FROM)) {
|
if (contact.getOption(Contact.Options.FROM)) {
|
||||||
send.setText(R.string.send_presence_updates);
|
send.setText(R.string.send_presence_updates);
|
||||||
send.setChecked(true);
|
send.setChecked(true);
|
||||||
|
@ -342,13 +364,13 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
receive.setEnabled(false);
|
receive.setEnabled(false);
|
||||||
send.setEnabled(false);
|
send.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
send.setOnCheckedChangeListener(this.mOnSendCheckedChange);
|
send.setOnCheckedChangeListener(this.mOnSendCheckedChange);
|
||||||
receive.setOnCheckedChangeListener(this.mOnReceiveCheckedChange);
|
receive.setOnCheckedChangeListener(this.mOnReceiveCheckedChange);
|
||||||
} else {
|
} else {
|
||||||
addContactButton.setVisibility(View.VISIBLE);
|
addContactButton.setVisibility(View.VISIBLE);
|
||||||
send.setVisibility(View.GONE);
|
send.setVisibility(View.GONE);
|
||||||
receive.setVisibility(View.GONE);
|
receive.setVisibility(View.GONE);
|
||||||
|
statusMessage.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contact.isBlocked() && !this.showDynamicTags) {
|
if (contact.isBlocked() && !this.showDynamicTags) {
|
||||||
|
|
|
@ -44,11 +44,6 @@
|
||||||
android:textSize="?attr/TextSizeHeadline"
|
android:textSize="?attr/TextSizeHeadline"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical" >
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/tags"
|
android:id="@+id/tags"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -64,7 +59,15 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="@color/black54"
|
android:textColor="@color/black54"
|
||||||
android:textSize="?attr/TextSizeBody" />
|
android:textSize="?attr/TextSizeBody" />
|
||||||
</LinearLayout>
|
|
||||||
|
<TextView
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:id="@+id/status_message"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/black87"
|
||||||
|
android:textStyle="italic"
|
||||||
|
android:textSize="?attr/TextSizeBody" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/add_contact_button"
|
android:id="@+id/add_contact_button"
|
||||||
|
|
Loading…
Reference in a new issue