mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-10 21:38:34 +00:00
Jump to the relevant message when tapping a reaction notification.
Fixes #9503
This commit is contained in:
parent
5637f132d4
commit
dc791487c5
@ -537,7 +537,7 @@ public class MessageNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (threadRecipients == null || !threadRecipients.isMuted()) {
|
if (threadRecipients == null || !threadRecipients.isMuted()) {
|
||||||
notificationState.addNotification(new NotificationItem(id, mms, recipient, conversationRecipient, threadRecipients, threadId, body, timestamp, slideDeck));
|
notificationState.addNotification(new NotificationItem(id, mms, recipient, conversationRecipient, threadRecipients, threadId, body, timestamp, timestamp, slideDeck, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -571,7 +571,7 @@ public class MessageNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (threadRecipients == null || !threadRecipients.isMuted()) {
|
if (threadRecipients == null || !threadRecipients.isMuted()) {
|
||||||
notificationState.addNotification(new NotificationItem(id, mms, reactionSender, conversationRecipient, threadRecipients, threadId, body, reaction.getDateReceived(), null));
|
notificationState.addNotification(new NotificationItem(id, mms, reactionSender, conversationRecipient, threadRecipients, threadId, body, reaction.getDateReceived(), timestamp, null, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,43 +3,53 @@ package org.thoughtcrime.securesms.notifications;
|
|||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.app.TaskStackBuilder;
|
import androidx.core.app.TaskStackBuilder;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.conversation.ConversationActivity;
|
import org.thoughtcrime.securesms.conversation.ConversationActivity;
|
||||||
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
|
|
||||||
public class NotificationItem {
|
public class NotificationItem {
|
||||||
|
|
||||||
private final long id;
|
private final long id;
|
||||||
private final boolean mms;
|
private final boolean mms;
|
||||||
private final @NonNull Recipient conversationRecipient;
|
@NonNull private final Recipient conversationRecipient;
|
||||||
private final @NonNull Recipient individualRecipient;
|
@NonNull private final Recipient individualRecipient;
|
||||||
private final @Nullable Recipient threadRecipient;
|
@Nullable private final Recipient threadRecipient;
|
||||||
private final long threadId;
|
private final long threadId;
|
||||||
private final @Nullable CharSequence text;
|
@Nullable private final CharSequence text;
|
||||||
private final long timestamp;
|
private final long notificationTimestamp;
|
||||||
private final @Nullable SlideDeck slideDeck;
|
private final long messageReceivedTimestamp;
|
||||||
|
@Nullable private final SlideDeck slideDeck;
|
||||||
|
private final boolean jumpToMessage;
|
||||||
|
|
||||||
public NotificationItem(long id, boolean mms,
|
public NotificationItem(long id,
|
||||||
@NonNull Recipient individualRecipient,
|
boolean mms,
|
||||||
@NonNull Recipient conversationRecipient,
|
@NonNull Recipient individualRecipient,
|
||||||
@Nullable Recipient threadRecipient,
|
@NonNull Recipient conversationRecipient,
|
||||||
long threadId, @Nullable CharSequence text, long timestamp,
|
@Nullable Recipient threadRecipient,
|
||||||
@Nullable SlideDeck slideDeck)
|
long threadId,
|
||||||
|
@Nullable CharSequence text,
|
||||||
|
long notificationTimestamp,
|
||||||
|
long messageReceivedTimestamp,
|
||||||
|
@Nullable SlideDeck slideDeck,
|
||||||
|
boolean jumpToMessage)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.mms = mms;
|
this.mms = mms;
|
||||||
this.individualRecipient = individualRecipient;
|
this.individualRecipient = individualRecipient;
|
||||||
this.conversationRecipient = conversationRecipient;
|
this.conversationRecipient = conversationRecipient;
|
||||||
this.threadRecipient = threadRecipient;
|
this.threadRecipient = threadRecipient;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.threadId = threadId;
|
this.threadId = threadId;
|
||||||
this.timestamp = timestamp;
|
this.notificationTimestamp = notificationTimestamp;
|
||||||
this.slideDeck = slideDeck;
|
this.messageReceivedTimestamp = messageReceivedTimestamp;
|
||||||
|
this.slideDeck = slideDeck;
|
||||||
|
this.jumpToMessage = jumpToMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NonNull Recipient getRecipient() {
|
public @NonNull Recipient getRecipient() {
|
||||||
@ -55,7 +65,7 @@ public class NotificationItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long getTimestamp() {
|
public long getTimestamp() {
|
||||||
return timestamp;
|
return notificationTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getThreadId() {
|
public long getThreadId() {
|
||||||
@ -67,12 +77,9 @@ public class NotificationItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PendingIntent getPendingIntent(Context context) {
|
public PendingIntent getPendingIntent(Context context) {
|
||||||
Intent intent = new Intent(context, ConversationActivity.class);
|
Recipient recipient = threadRecipient != null ? threadRecipient : conversationRecipient;
|
||||||
Recipient notifyRecipients = threadRecipient != null ? threadRecipient : conversationRecipient;
|
int startingPosition = jumpToMessage ? getStartingPosition(context, threadId, messageReceivedTimestamp) : -1;
|
||||||
|
Intent intent = ConversationActivity.buildIntent(context, recipient.getId(), threadId, 0, -1, startingPosition);
|
||||||
intent.putExtra(ConversationActivity.RECIPIENT_EXTRA, notifyRecipients.getId());
|
|
||||||
intent.putExtra("thread_id", threadId);
|
|
||||||
intent.setData((Uri.parse("custom://"+System.currentTimeMillis())));
|
|
||||||
|
|
||||||
return TaskStackBuilder.create(context)
|
return TaskStackBuilder.create(context)
|
||||||
.addNextIntentWithParentStack(intent)
|
.addNextIntentWithParentStack(intent)
|
||||||
@ -86,4 +93,8 @@ public class NotificationItem {
|
|||||||
public boolean isMms() {
|
public boolean isMms() {
|
||||||
return mms;
|
return mms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int getStartingPosition(@NonNull Context context, long threadId, long receivedTimestampMs) {
|
||||||
|
return DatabaseFactory.getMmsSmsDatabase(context).getMessagePositionInConversation(threadId, receivedTimestampMs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user