Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
Show counts if message is received from same private/stream
Browse files Browse the repository at this point in the history
  • Loading branch information
kunall17 authored and timabbott committed Jan 16, 2017
1 parent 568c360 commit a4374c1
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions app/src/main/java/com/zulip/android/activities/ZulipActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2070,13 +2070,20 @@ private void setupSnackBar() {
TypedValue tv = new TypedValue();
if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
mToolbarHeightInPx = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
snackbar.setCallback(new Snackbar.Callback() {
@Override
public void onDismissed(Snackbar snackbar, int event) {
super.onDismissed(snackbar, event);
if (event == Snackbar.Callback.DISMISS_EVENT_TIMEOUT) prevMessageSameCount = -1;
}
});
}

NarrowFilter narrowFilter;

String prevId = null;
int prevMessageSameCount = -1;
private void showSnackbarNotification(Message[] messages) {
MutedTopics mutedTopics = MutedTopics.get();
String prevId = null;
int nonMutedMessagesCount = 0;
Message tempMessage = null; //Stores a temporary message which is non-muted, later used for retrieving Stream/Topic
for (Message message : messages) { //Check if all messages from same topic/private and remove all the muted messages
Expand All @@ -2086,13 +2093,16 @@ private void showSnackbarNotification(Message[] messages) {
if (prevId != null && !prevId.equals(message.getIdForHolder())) {
prevId = null;
tempMessage = null;
prevMessageSameCount = 0;
break;
} else {
prevMessageSameCount++;
}
prevId = message.getIdForHolder();
if (tempMessage == null) tempMessage = message;
}
if (nonMutedMessagesCount == 0) return;
if (prevId == null) {
if (prevId == null && messages.length > 1) {
snackbar.setText(getResources().getQuantityString(R.plurals.new_message_mul_sender, nonMutedMessagesCount, nonMutedMessagesCount));
narrowFilter = null;
if (narrowedList != null) {
Expand All @@ -2107,7 +2117,9 @@ public void onClick(View view) {
}
});
} else {
if (messages.length == 1) tempMessage = messages[0];
String name = (tempMessage.getType() == MessageType.PRIVATE_MESSAGE) ? getString(R.string.notify_private, tempMessage.getSenderFullName()) : getString(R.string.notify_stream, tempMessage.getStream().getName() , tempMessage.getSubject());
if (prevMessageSameCount > 0) name += " (" + prevMessageSameCount + ")";
snackbar.setText(getResources().getQuantityString(R.plurals.new_message, nonMutedMessagesCount, nonMutedMessagesCount, name));
narrowFilter = (tempMessage.getType() == MessageType.PRIVATE_MESSAGE) ? new NarrowFilterPM(Arrays.asList(tempMessage.getRecipients(app))) : new NarrowFilterStream(tempMessage.getStream(), tempMessage.getSubject());
snackbar.setAction(R.string.SHOW, new View.OnClickListener() {
Expand Down

0 comments on commit a4374c1

Please sign in to comment.