This commit is contained in:
B. Petersen
2019-02-14 12:16:45 +01:00
parent f146c1c966
commit a5ccd9da79
5 changed files with 19 additions and 19 deletions
@@ -282,14 +282,14 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
titleView.setTitle(glideRequests, dcChat);
MessageNotifier.updateVisibleThread(this, threadId);
MessageNotifier.updateVisibleChat(this, threadId);
markThreadAsRead();
}
@Override
protected void onPause() {
super.onPause();
MessageNotifier.updateVisibleThread(this, MessageNotifier.NO_VISIBLE_THREAD);
MessageNotifier.updateVisibleChat(this, MessageNotifier.NO_VISIBLE_CHAT_ID);
if (isFinishing()) overridePendingTransition(R.anim.fade_scale_in, R.anim.slide_to_right);
quickAttachmentDrawer.onPause();
inputPanel.onPause();
@@ -987,7 +987,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
if (refreshFragment) {
fragment.reload(recipient, threadId);
MessageNotifier.updateVisibleThread(this, threadId);
MessageNotifier.updateVisibleChat(this, threadId);
}
fragment.scrollToBottom();
@@ -76,23 +76,23 @@ public class MessageNotifier {
static final String EXTRA_REMOTE_REPLY = "extra_remote_reply";
public static final long NO_VISIBLE_THREAD = -1L;
public static final long NO_VISIBLE_CHAT_ID = -1L;
private static final int SUMMARY_NOTIFICATION_ID = 1338;
private static final int PENDING_MESSAGES_ID = 1111;
private static final String NOTIFICATION_GROUP = "messages";
private static final long MIN_AUDIBLE_PERIOD_MILLIS = TimeUnit.SECONDS.toMillis(20);
private static final long DESKTOP_ACTIVITY_PERIOD = TimeUnit.MINUTES.toMillis(1);
private volatile static long visibleThread = -1;
private volatile static long visibleChatId = NO_VISIBLE_CHAT_ID;
private volatile static long lastDesktopActivityTimestamp = -1;
private volatile static long lastAudibleNotification = -1;
private static final CancelableExecutor executor = new CancelableExecutor();
private static LinkedList<Pair<Integer, Boolean>> pendingNotifications = new LinkedList<>();
public static void updateVisibleThread(Context context, long threadId) {
visibleThread = threadId;
if (visibleThread == NO_VISIBLE_THREAD && pendingNotifications.size() > 0) {
public static void updateVisibleChat(Context context, long chatId) {
visibleChatId = chatId;
if (visibleChatId == NO_VISIBLE_CHAT_ID && pendingNotifications.size() > 0) {
updatePendingNotifications(context);
}
}
@@ -174,7 +174,7 @@ public class MessageNotifier {
int threadId,
boolean signal)
{
boolean isVisible = visibleThread == threadId;
boolean isVisible = visibleChatId == threadId;
ApplicationDcContext dcContext = DcHelper.getContext(context);
if (isVisible) {
@@ -189,7 +189,7 @@ public class MessageNotifier {
if (isVisible && signal) {
sendInThreadNotification(context, threadId);
} else if (visibleThread != NO_VISIBLE_THREAD) {
} else if (visibleChatId != NO_VISIBLE_CHAT_ID) {
pendingNotifications.push(new Pair<>(threadId, signal));
} else {
updateNotification(context, signal, 0);
@@ -254,7 +254,7 @@ public class MessageNotifier {
Recipient recipient = notifications.get(0).getRecipient();
int notificationId = (SUMMARY_NOTIFICATION_ID + (bundled ? notifications.get(0).getChatId() : 0));
builder.setThread(notifications.get(0).getRecipient());
builder.setChat(notifications.get(0).getRecipient());
builder.setMessageCount(notificationState.getMessageCount());
builder.setPrimaryMessageBody(recipient, notifications.get(0).getIndividualRecipient(),
notifications.get(0).getText(""), notifications.get(0).getSlideDeck());
@@ -52,9 +52,9 @@ public class MultipleRecipientNotificationBuilder extends AbstractNotificationBu
setGroupSummary(true);
}
public void setMessageCount(int messageCount, int threadCount) {
public void setMessageCount(int messageCount, int chatCount) {
setSubText(context.getString(R.string.notify_n_messages_in_m_chats,
messageCount, threadCount));
messageCount, chatCount));
setContentInfo(String.valueOf(messageCount));
setNumber(messageCount);
}
@@ -59,7 +59,7 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
setCategory(NotificationCompat.CATEGORY_MESSAGE);
}
public void setThread(@NonNull Recipient recipient) {
public void setChat(@NonNull Recipient recipient) {
if (privacy.isDisplayContact()) {
setContentTitle(recipient.toShortString());
@@ -98,14 +98,14 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
setNumber(messageCount);
}
public void setPrimaryMessageBody(@NonNull Recipient threadRecipients,
public void setPrimaryMessageBody(@NonNull Recipient chatRecipients,
@NonNull Recipient individualRecipient,
@NonNull CharSequence message,
@Nullable SlideDeck slideDeck)
{
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
if (privacy.isDisplayContact() && threadRecipients.isGroupRecipient()) {
if (privacy.isDisplayContact() && chatRecipients.isGroupRecipient()) {
stringBuilder.append(Util.getBoldedString(individualRecipient.toShortString() + ": "));
}
@@ -173,13 +173,13 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
.addAction(wearableReplyAction));
}
public void addMessageBody(@NonNull Recipient threadRecipient,
public void addMessageBody(@NonNull Recipient chatRecipient,
@NonNull Recipient individualRecipient,
@Nullable CharSequence messageBody)
{
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
if (privacy.isDisplayContact() && threadRecipient.isGroupRecipient()) {
if (privacy.isDisplayContact() && chatRecipient.isGroupRecipient()) {
stringBuilder.append(Util.getBoldedString(individualRecipient.toShortString() + ": "));
}
@@ -159,7 +159,7 @@ public class Prefs {
}
}
public static boolean isInThreadNotifications(Context context) {
public static boolean isInChatNotifications(Context context) {
return getBooleanPreference(context, IN_THREAD_NOTIFICATION_PREF, true);
}