aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-03-11 17:20:21 +0100
committerChristian Schneppe <christian@pix-art.de>2017-03-11 20:14:57 +0100
commit38ae1c31d4b038d846874d100c97bd4aa81c2448 (patch)
treef13761f7f26dd719bbb491f4d0e6f76d2219dfa2 /src/main/java/de/pixart/messenger/ui
parent3e932930713e1dfaf141878dfb6dea8fea23ab7a (diff)
display chat states in conferences
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationActivity.java98
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java14
2 files changed, 65 insertions, 47 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
index d60fbcbe4..4630fbcba 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
@@ -67,6 +67,7 @@ import de.pixart.messenger.entities.Blockable;
import de.pixart.messenger.entities.Contact;
import de.pixart.messenger.entities.Conversation;
import de.pixart.messenger.entities.Message;
+import de.pixart.messenger.entities.MucOptions;
import de.pixart.messenger.entities.Presence;
import de.pixart.messenger.entities.Transferable;
import de.pixart.messenger.persistance.FileBackend;
@@ -423,58 +424,73 @@ public class ConversationActivity extends XmppActivity
ab.setCustomView(R.layout.ab_title);
TextView abtitle = (TextView) findViewById(android.R.id.text1);
TextView absubtitle = (TextView) findViewById(android.R.id.text2);
- if (conversation.getMode() == Conversation.MODE_SINGLE || useSubjectToIdentifyConference()) {
- abtitle.setText(conversation.getName());
- abtitle.setOnClickListener(this);
- abtitle.setSelected(true);
- if (conversation.getMode() == Conversation.MODE_SINGLE && !this.getSelectedConversation().withSelf()) {
- if (conversation.getContact().getShownStatus() == Presence.Status.OFFLINE) {
- absubtitle.setText(getString(R.string.account_status_offline));
+ abtitle.setText(conversation.getName());
+ abtitle.setOnClickListener(this);
+ abtitle.setSelected(true);
+ if (conversation.getMode() == Conversation.MODE_SINGLE && !this.getSelectedConversation().withSelf()) {
+ ChatState state = conversation.getIncomingChatState();
+ if (conversation.getContact().getShownStatus() == Presence.Status.OFFLINE) {
+ absubtitle.setText(getString(R.string.account_status_offline));
+ absubtitle.setSelected(true);
+ absubtitle.setOnClickListener(this);
+ } else {
+ if (state == ChatState.COMPOSING) {
+ absubtitle.setText(getString(R.string.is_typing));
+ absubtitle.setTypeface(null, Typeface.BOLD_ITALIC);
absubtitle.setSelected(true);
absubtitle.setOnClickListener(this);
} else {
- ChatState state = conversation.getIncomingChatState();
- if (state == ChatState.COMPOSING) {
- absubtitle.setText(getString(R.string.is_typing));
- absubtitle.setTypeface(null, Typeface.BOLD_ITALIC);
- absubtitle.setSelected(true);
- absubtitle.setOnClickListener(this);
- } else if (state == ChatState.PAUSED) {
- if (showLastSeen && conversation.getContact().getLastseen() > 0) {
- absubtitle.setText(UIHelper.lastseen(getApplicationContext(), conversation.getContact().isActive(), conversation.getContact().getLastseen()));
- } else {
- absubtitle.setText(getString(R.string.account_status_online));
- }
- absubtitle.setSelected(true);
- absubtitle.setOnClickListener(this);
+ if (showLastSeen && conversation.getContact().getLastseen() > 0) {
+ absubtitle.setText(UIHelper.lastseen(getApplicationContext(), conversation.getContact().isActive(), conversation.getContact().getLastseen()));
} else {
- if (showLastSeen && conversation.getContact().getLastseen() > 0) {
- absubtitle.setText(UIHelper.lastseen(getApplicationContext(), conversation.getContact().isActive(), conversation.getContact().getLastseen()));
- } else {
- absubtitle.setText(getString(R.string.account_status_online));
- }
- absubtitle.setSelected(true);
- absubtitle.setOnClickListener(this);
+ absubtitle.setText(getString(R.string.account_status_online));
}
- }
- } else if (useSubjectToIdentifyConference()) {
- if (conversation.getParticipants() != null) {
- absubtitle.setText(conversation.getParticipants());
absubtitle.setSelected(true);
absubtitle.setOnClickListener(this);
- } else {
- absubtitle.setText(R.string.no_participants);
- abtitle.setSelected(true);
- absubtitle.setOnClickListener(this);
}
}
} else {
- abtitle.setText(conversation.getJid().toBareJid().toString());
- abtitle.setOnClickListener(this);
- abtitle.setSelected(true);
- absubtitle.setText("");
- absubtitle.setOnClickListener(this);
+ if (conversation.getParticipants() != null) {
+ ChatState state = ChatState.COMPOSING;
+ List<MucOptions.User> userWithChatStates = conversation.getMucOptions().getUsersWithChatState(state, 5);
+ if (userWithChatStates.size() == 0) {
+ state = ChatState.PAUSED;
+ userWithChatStates = conversation.getMucOptions().getUsersWithChatState(state, 5);
+
+ }
+ List<MucOptions.User> users = conversation.getMucOptions().getUsers(true);
+ if (state == ChatState.COMPOSING) {
+ if (userWithChatStates.size() > 0) {
+ if (userWithChatStates.size() == 1) {
+ MucOptions.User user = userWithChatStates.get(0);
+ absubtitle.setText(getString(R.string.contact_is_typing, UIHelper.getDisplayName(user)));
+ } else {
+ StringBuilder builder = new StringBuilder();
+ for (MucOptions.User user : userWithChatStates) {
+ if (builder.length() != 0) {
+ builder.append(", ");
+ }
+ builder.append(UIHelper.getDisplayName(user));
+ }
+ absubtitle.setText(getString(R.string.contacts_are_typing, builder.toString()));
+ }
+ }
+ } else {
+ if (users.size() == 1) {
+ absubtitle.setText(getString(R.string.one_participant));
+ } else {
+ absubtitle.setText(getString(R.string.more_participants, users.size()));
+ }
+ }
+ absubtitle.setSelected(true);
+ absubtitle.setOnClickListener(this);
+ } else {
+ absubtitle.setText(R.string.no_participants);
+ abtitle.setSelected(true);
+ absubtitle.setOnClickListener(this);
+ }
}
+
} else {
if ((ab.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) == ActionBar.DISPLAY_HOME_AS_UP) {
ab.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE);
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
index 6c87196fe..17dcb9d0f 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
@@ -835,7 +835,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
}
return view;
} else {
- loadAvatar(message, viewHolder.contact_picture);
+ loadAvatar(message, viewHolder.contact_picture, activity.getPixel(48));
}
viewHolder.contact_picture
@@ -1156,14 +1156,16 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
class BitmapWorkerTask extends AsyncTask<Message, Void, Bitmap> {
private final WeakReference<ImageView> imageViewReference;
private Message message = null;
+ private final int size;
- public BitmapWorkerTask(ImageView imageView) {
+ public BitmapWorkerTask(ImageView imageView, int size) {
imageViewReference = new WeakReference<>(imageView);
+ this.size = size;
}
@Override
protected Bitmap doInBackground(Message... params) {
- return activity.avatarService().get(params[0], activity.getPixel(48), isCancelled());
+ return activity.avatarService().get(params[0], size, isCancelled());
}
@Override
@@ -1178,9 +1180,9 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
}
}
- public void loadAvatar(Message message, ImageView imageView) {
+ public void loadAvatar(Message message, ImageView imageView, int size) {
if (cancelPotentialWork(message, imageView)) {
- final Bitmap bm = activity.avatarService().get(message, activity.getPixel(48), true);
+ final Bitmap bm = activity.avatarService().get(message, size, true);
if (bm != null) {
cancelPotentialWork(message, imageView);
imageView.setImageBitmap(bm);
@@ -1188,7 +1190,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
} else {
imageView.setBackgroundColor(UIHelper.getColorForName(UIHelper.getMessageDisplayName(message)));
imageView.setImageDrawable(null);
- final BitmapWorkerTask task = new BitmapWorkerTask(imageView);
+ final BitmapWorkerTask task = new BitmapWorkerTask(imageView, size);
final AsyncDrawable asyncDrawable = new AsyncDrawable(activity.getResources(), null, task);
imageView.setImageDrawable(asyncDrawable);
try {