aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/de/pixart/messenger/entities/Conversation.java8
-rw-r--r--src/main/java/de/pixart/messenger/entities/MucOptions.java15
-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
-rw-r--r--src/main/java/de/pixart/messenger/utils/UIHelper.java10
-rw-r--r--src/main/res/values-de/strings.xml4
-rw-r--r--src/main/res/values/strings.xml6
7 files changed, 106 insertions, 49 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java
index 082877ef7..fac28056f 100644
--- a/src/main/java/de/pixart/messenger/entities/Conversation.java
+++ b/src/main/java/de/pixart/messenger/entities/Conversation.java
@@ -515,6 +515,14 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
}
}
+ public int getNumberOfParticipants() {
+ if (getMode() == MODE_MULTI) {
+ return getMucOptions().NumberOfUsers();
+ } else {
+ return 0;
+ }
+ }
+
public String getAccountUuid() {
return this.accountUuid;
}
diff --git a/src/main/java/de/pixart/messenger/entities/MucOptions.java b/src/main/java/de/pixart/messenger/entities/MucOptions.java
index d3d0e3e9e..51345df04 100644
--- a/src/main/java/de/pixart/messenger/entities/MucOptions.java
+++ b/src/main/java/de/pixart/messenger/entities/MucOptions.java
@@ -542,12 +542,15 @@ public class MucOptions {
}
}
- public ArrayList<User> getUsersWithChatState(ChatState state) {
+ public ArrayList<User> getUsersWithChatState(ChatState state, int max) {
synchronized (users) {
ArrayList<User> list = new ArrayList<>();
for (User user : users) {
if (user.chatState == state) {
list.add(user);
+ if (list.size() >= max) {
+ break;
+ }
}
}
return list;
@@ -628,6 +631,16 @@ public class MucOptions {
return this.subject;
}
+ public int NumberOfUsers() {
+ if (users.size() >= 1) {
+ return users.size();
+ } else {
+ return 0;
+ }
+ }
+
+
+
public String createNameFromParticipants() {
if (users.size() >= 1) {
StringBuilder builder = new StringBuilder();
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 {
diff --git a/src/main/java/de/pixart/messenger/utils/UIHelper.java b/src/main/java/de/pixart/messenger/utils/UIHelper.java
index c350268d6..02d8f5789 100644
--- a/src/main/java/de/pixart/messenger/utils/UIHelper.java
+++ b/src/main/java/de/pixart/messenger/utils/UIHelper.java
@@ -21,6 +21,7 @@ import de.pixart.messenger.entities.Contact;
import de.pixart.messenger.entities.Conversation;
import de.pixart.messenger.entities.ListItem;
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.xmpp.jid.Jid;
@@ -260,6 +261,15 @@ public class UIHelper {
|| ((body.charAt(pos + 1) == '<') && (body.length() == pos + 2 || Character.isWhitespace(body.charAt(pos + 2))));
}
+ public static String getDisplayName(MucOptions.User user) {
+ Contact contact = user.getContact();
+ if (contact != null) {
+ return contact.getDisplayName();
+ } else {
+ return user.getName();
+ }
+ }
+
public static String getFileDescriptionString(final Context context, final Message message) {
if (message.getType() == Message.TYPE_IMAGE) {
return context.getString(R.string.image);
diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml
index ae3d33496..7780b68ab 100644
--- a/src/main/res/values-de/strings.xml
+++ b/src/main/res/values-de/strings.xml
@@ -697,5 +697,9 @@
<string name="video_high">hoch (720p)</string>
<string name="video_low">niedrig (144p)</string>
<string name="video_mid">mittelmäßig (360p)</string>
+ <string name="contact_is_typing">%s schreibt…</string>
+ <string name="contacts_are_typing">%s tippen…</string>
+ <string name="more_participants">%d Teilnehmer</string>
+ <string name="one_participant">Ein Teilnehmer</string>
</resources>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index c16c7b921..0c665884f 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -167,7 +167,7 @@
<string name="mgmt_account_are_you_sure">Are you sure?</string>
<string name="mgmt_account_delete_confirm_text">If you delete your account your entire conversation history will be lost</string>
<string name="attach_record_voice">Record voice</string>
- <string name="account_settings_jabber_id">Jabber ID</string>
+ <string name="account_settings_jabber_id">Jabber-ID</string>
<string name="account_settings_password">Password</string>
<string name="account_settings_example_jabber_id">username@pix-art.de</string>
<string name="account_settings_confirm_password">Confirm password</string>
@@ -752,4 +752,8 @@
<string name="pref_notifications_from_strangers">Notifications from strangers</string>
<string name="pref_notifications_from_strangers_summary">Notify for messages received from strangers.</string>
<string name="received_message_from_stranger">Received message from stranger</string>
+ <string name="contacts_are_typing">%s are typing…</string>
+ <string name="contact_is_typing">%s is typing…</string>
+ <string name="one_participant">one participant</string>
+ <string name="more_participants">%d participants</string>
</resources>