mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 16:49:40 +01:00
Integrate contact hiding with message requests.
This commit is contained in:
@@ -1583,6 +1583,7 @@ class ThreadTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa
|
||||
private fun getExtrasFor(record: MessageRecord, body: ThreadBody): Extra? {
|
||||
val threadRecipient = if (record.isOutgoing) record.recipient else getRecipientForThreadId(record.threadId)
|
||||
val messageRequestAccepted = RecipientUtil.isMessageRequestAccepted(record.threadId, threadRecipient)
|
||||
val isHidden = threadRecipient?.isHidden ?: false
|
||||
val individualRecipientId = record.individualRecipient.id
|
||||
|
||||
if (!messageRequestAccepted && threadRecipient != null) {
|
||||
@@ -1609,7 +1610,7 @@ class ThreadTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return Extra.forMessageRequest(individualRecipientId)
|
||||
return Extra.forMessageRequest(individualRecipientId, isHidden)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1772,7 +1773,8 @@ class ThreadTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa
|
||||
groupAddedBy = jsonObject.getString("groupAddedBy"),
|
||||
individualRecipientId = jsonObject.getString("individualRecipientId")!!,
|
||||
bodyRanges = jsonObject.getString("bodyRanges"),
|
||||
isScheduled = jsonObject.getBoolean("isScheduled")
|
||||
isScheduled = jsonObject.getBoolean("isScheduled"),
|
||||
isRecipientHidden = jsonObject.getBoolean("isRecipientHidden")
|
||||
)
|
||||
} catch (exception: Exception) {
|
||||
null
|
||||
@@ -1855,7 +1857,10 @@ class ThreadTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa
|
||||
val bodyRanges: String? = null,
|
||||
@field:JsonProperty
|
||||
@param:JsonProperty("isScheduled")
|
||||
val isScheduled: Boolean = false
|
||||
val isScheduled: Boolean = false,
|
||||
@field:JsonProperty
|
||||
@param:JsonProperty("isRecipientHidden")
|
||||
val isRecipientHidden: Boolean = false
|
||||
) {
|
||||
|
||||
fun getIndividualRecipientId(): String {
|
||||
@@ -1879,8 +1884,8 @@ class ThreadTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa
|
||||
return Extra(isRemoteDelete = true, individualRecipientId = individualRecipient.serialize())
|
||||
}
|
||||
|
||||
fun forMessageRequest(individualRecipient: RecipientId): Extra {
|
||||
return Extra(isMessageRequestAccepted = false, individualRecipientId = individualRecipient.serialize())
|
||||
fun forMessageRequest(individualRecipient: RecipientId, isHidden: Boolean = false): Extra {
|
||||
return Extra(isMessageRequestAccepted = false, individualRecipientId = individualRecipient.serialize(), isRecipientHidden = isHidden)
|
||||
}
|
||||
|
||||
fun forGroupMessageRequest(recipientId: RecipientId, individualRecipient: RecipientId): Extra {
|
||||
|
||||
@@ -23,6 +23,7 @@ public class InMemoryMessageRecord extends MessageRecord {
|
||||
private static final int NO_GROUPS_IN_COMMON_ID = -1;
|
||||
private static final int UNIVERSAL_EXPIRE_TIMER_ID = -2;
|
||||
private static final int FORCE_BUBBLE_ID = -3;
|
||||
private static final int HIDDEN_CONTACT_WARNING_ID = -4;
|
||||
|
||||
private InMemoryMessageRecord(long id,
|
||||
String body,
|
||||
@@ -118,6 +119,29 @@ public class InMemoryMessageRecord extends MessageRecord {
|
||||
}
|
||||
}
|
||||
|
||||
public static final class RemovedContactHidden extends InMemoryMessageRecord {
|
||||
|
||||
public RemovedContactHidden(long threadId) {
|
||||
super(HIDDEN_CONTACT_WARNING_ID, "", Recipient.UNKNOWN, threadId, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable UpdateDescription getUpdateDisplayBody(@NonNull Context context, @Nullable Consumer<RecipientId> recipientClickHandler) {
|
||||
return UpdateDescription.staticDescription(context.getString(R.string.ConversationUpdateItem_hidden_contact_message_to_add_back),
|
||||
R.drawable.symbol_info_compact_16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpdate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showActionButton() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show temporary update message about setting the disappearing messages timer upon first message
|
||||
* send.
|
||||
|
||||
@@ -222,6 +222,11 @@ public final class ThreadRecord {
|
||||
else return true;
|
||||
}
|
||||
|
||||
public boolean isRecipientHidden() {
|
||||
if (extra != null) return extra.isRecipientHidden();
|
||||
else return true;
|
||||
}
|
||||
|
||||
public boolean isPinned() {
|
||||
return isPinned;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user