[SES-2695] Incorrect message request approval on home screen

This commit is contained in:
fanchao 2024-09-06 14:41:26 +10:00
parent 2174976716
commit aef0adb714
5 changed files with 20 additions and 16 deletions

View File

@ -17,15 +17,11 @@
package org.thoughtcrime.securesms.database.model; package org.thoughtcrime.securesms.database.model;
import android.content.Context; import android.content.Context;
import android.text.SpannableString;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import org.session.libsession.utilities.recipients.Recipient; import org.session.libsession.utilities.recipients.Recipient;
import org.session.libsignal.utilities.Log;
import org.thoughtcrime.securesms.database.MmsDatabase;
import org.thoughtcrime.securesms.database.MmsSmsColumns; import org.thoughtcrime.securesms.database.MmsSmsColumns;
import org.thoughtcrime.securesms.database.MmsSmsDatabase;
import org.thoughtcrime.securesms.database.SmsDatabase; import org.thoughtcrime.securesms.database.SmsDatabase;
/** /**
@ -68,7 +64,7 @@ public abstract class DisplayRecord {
public @NonNull String getBody() { public @NonNull String getBody() {
return body == null ? "" : body; return body == null ? "" : body;
} }
public abstract SpannableString getDisplayBody(@NonNull Context context); public abstract CharSequence getDisplayBody(@NonNull Context context);
public Recipient getRecipient() { return recipient; } public Recipient getRecipient() { return recipient; }
public long getDateSent() { return dateSent; } public long getDateSent() { return dateSent; }
public long getDateReceived() { return dateReceived; } public long getDateReceived() { return dateReceived; }

View File

@ -17,7 +17,6 @@
package org.thoughtcrime.securesms.database.model; package org.thoughtcrime.securesms.database.model;
import android.content.Context; import android.content.Context;
import android.text.SpannableString;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -27,14 +26,11 @@ import org.session.libsession.utilities.Contact;
import org.session.libsession.utilities.IdentityKeyMismatch; import org.session.libsession.utilities.IdentityKeyMismatch;
import org.session.libsession.utilities.NetworkFailure; import org.session.libsession.utilities.NetworkFailure;
import org.session.libsession.utilities.recipients.Recipient; import org.session.libsession.utilities.recipients.Recipient;
import org.thoughtcrime.securesms.database.MmsDatabase;
import org.thoughtcrime.securesms.database.SmsDatabase.Status; import org.thoughtcrime.securesms.database.SmsDatabase.Status;
import org.thoughtcrime.securesms.mms.SlideDeck; import org.thoughtcrime.securesms.mms.SlideDeck;
import java.util.List; import java.util.List;
import network.loki.messenger.R;
/** /**
* Represents the message record model for MMS messages that contain * Represents the message record model for MMS messages that contain
* media (ie: they've been downloaded). * media (ie: they've been downloaded).
@ -76,7 +72,7 @@ public class MediaMmsMessageRecord extends MmsMessageRecord {
} }
@Override @Override
public SpannableString getDisplayBody(@NonNull Context context) { public CharSequence getDisplayBody(@NonNull Context context) {
return super.getDisplayBody(context); return super.getDisplayBody(context);
} }
} }

View File

@ -115,7 +115,7 @@ public abstract class MessageRecord extends DisplayRecord {
} }
@Override @Override
public SpannableString getDisplayBody(@NonNull Context context) { public CharSequence getDisplayBody(@NonNull Context context) {
if (isGroupUpdateMessage()) { if (isGroupUpdateMessage()) {
UpdateMessageData updateMessageData = UpdateMessageData.Companion.fromJSON(getBody()); UpdateMessageData updateMessageData = UpdateMessageData.Companion.fromJSON(getBody());
return new SpannableString(UpdateMessageBuilder.INSTANCE.buildGroupUpdateMessage(context, updateMessageData, getIndividualRecipient().getAddress().serialize(), isOutgoing())); return new SpannableString(UpdateMessageBuilder.INSTANCE.buildGroupUpdateMessage(context, updateMessageData, getIndividualRecipient().getAddress().serialize(), isOutgoing()));

View File

@ -18,14 +18,13 @@
package org.thoughtcrime.securesms.database.model; package org.thoughtcrime.securesms.database.model;
import android.content.Context; import android.content.Context;
import android.text.SpannableString;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import org.session.libsession.utilities.IdentityKeyMismatch; import org.session.libsession.utilities.IdentityKeyMismatch;
import org.session.libsession.utilities.recipients.Recipient; import org.session.libsession.utilities.recipients.Recipient;
import org.thoughtcrime.securesms.database.SmsDatabase;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import network.loki.messenger.R;
/** /**
* The message record model which represents standard SMS messages. * The message record model which represents standard SMS messages.
@ -56,7 +55,7 @@ public class SmsMessageRecord extends MessageRecord {
} }
@Override @Override
public SpannableString getDisplayBody(@NonNull Context context) { public CharSequence getDisplayBody(@NonNull Context context) {
return super.getDisplayBody(context); return super.getDisplayBody(context);
} }

View File

@ -32,10 +32,14 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.squareup.phrase.Phrase; import com.squareup.phrase.Phrase;
import org.session.libsession.utilities.ExpirationUtil; import org.session.libsession.utilities.ExpirationUtil;
import org.session.libsession.utilities.TextSecurePreferences;
import org.session.libsession.utilities.recipients.Recipient; import org.session.libsession.utilities.recipients.Recipient;
import org.session.libsignal.utilities.Log; import org.session.libsignal.utilities.Log;
import org.thoughtcrime.securesms.database.MmsSmsColumns; import org.thoughtcrime.securesms.database.MmsSmsColumns;
import org.thoughtcrime.securesms.database.SmsDatabase; import org.thoughtcrime.securesms.database.SmsDatabase;
import org.thoughtcrime.securesms.ui.UtilKt;
import kotlin.Pair;
import network.loki.messenger.R; import network.loki.messenger.R;
/** /**
@ -113,7 +117,7 @@ public class ThreadRecord extends DisplayRecord {
} }
@Override @Override
public SpannableString getDisplayBody(@NonNull Context context) { public CharSequence getDisplayBody(@NonNull Context context) {
if (isGroupUpdateMessage()) { if (isGroupUpdateMessage()) {
return emphasisAdded(context.getString(R.string.groupUpdated)); return emphasisAdded(context.getString(R.string.groupUpdated));
} else if (isOpenGroupInvitation()) { } else if (isOpenGroupInvitation()) {
@ -173,6 +177,15 @@ public class ThreadRecord extends DisplayRecord {
return emphasisAdded(txt); return emphasisAdded(txt);
} else if (MmsSmsColumns.Types.isMessageRequestResponse(type)) { } else if (MmsSmsColumns.Types.isMessageRequestResponse(type)) {
if (lastMessage.getRecipient().getAddress().serialize().equals(
TextSecurePreferences.getLocalNumber(context))) {
return UtilKt.getSubbedCharSequence(
context,
R.string.messageRequestYouHaveAccepted,
new Pair<>(NAME_KEY, getName())
);
}
return emphasisAdded(context.getString(R.string.messageRequestsAccepted)); return emphasisAdded(context.getString(R.string.messageRequestsAccepted));
} else if (getCount() == 0) { } else if (getCount() == 0) {
return new SpannableString(context.getString(R.string.messageEmpty)); return new SpannableString(context.getString(R.string.messageEmpty));