[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;
import android.content.Context;
import android.text.SpannableString;
import androidx.annotation.NonNull;
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.MmsSmsDatabase;
import org.thoughtcrime.securesms.database.SmsDatabase;
/**
@ -68,7 +64,7 @@ public abstract class DisplayRecord {
public @NonNull String getBody() {
return body == null ? "" : body;
}
public abstract SpannableString getDisplayBody(@NonNull Context context);
public abstract CharSequence getDisplayBody(@NonNull Context context);
public Recipient getRecipient() { return recipient; }
public long getDateSent() { return dateSent; }
public long getDateReceived() { return dateReceived; }

View File

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

View File

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

View File

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

View File

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