mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-24 10:51:27 +01:00
Allow call links to exist in the calls tab.
This commit is contained in:
@@ -13,6 +13,7 @@ import com.annimon.stream.Stream;
|
||||
|
||||
import org.signal.core.util.ThreadUtil;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.database.CallLinkTable;
|
||||
import org.thoughtcrime.securesms.database.DistributionListTables;
|
||||
import org.thoughtcrime.securesms.database.GroupTable;
|
||||
import org.thoughtcrime.securesms.database.model.GroupRecord;
|
||||
@@ -194,7 +195,9 @@ public final class LiveRecipient {
|
||||
details = getGroupRecipientDetails(record);
|
||||
} else if (record.getDistributionListId() != null) {
|
||||
details = getDistributionListRecipientDetails(record);
|
||||
} else {
|
||||
} else if (record.getCallLinkRoomId() != null) {
|
||||
details = getCallLinkRecipientDetails(record);
|
||||
}else {
|
||||
details = RecipientDetails.forIndividual(context, record);
|
||||
}
|
||||
|
||||
@@ -237,6 +240,19 @@ public final class LiveRecipient {
|
||||
return RecipientDetails.forDistributionList(null, null, record);
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private @NonNull RecipientDetails getCallLinkRecipientDetails(@NonNull RecipientRecord record) {
|
||||
CallLinkTable.CallLink callLink = SignalDatabase.callLinks().getCallLinkByRoomId(Objects.requireNonNull(record.getCallLinkRoomId()));
|
||||
|
||||
if (callLink != null) {
|
||||
String name = callLink.getState().getName();
|
||||
|
||||
return RecipientDetails.forCallLink(name, record);
|
||||
}
|
||||
|
||||
return RecipientDetails.forCallLink(null, record);
|
||||
}
|
||||
|
||||
synchronized void set(@NonNull Recipient recipient) {
|
||||
this.recipient.set(recipient);
|
||||
this.liveData.postValue(recipient);
|
||||
|
||||
@@ -136,6 +136,7 @@ public class Recipient {
|
||||
private final List<Badge> badges;
|
||||
private final boolean isReleaseNotesRecipient;
|
||||
private final boolean needsPniSignature;
|
||||
private final CallLinkRoomId callLinkRoomId;
|
||||
|
||||
/**
|
||||
* Returns a {@link LiveRecipient}, which contains a {@link Recipient} that may or may not be
|
||||
@@ -433,6 +434,7 @@ public class Recipient {
|
||||
this.isReleaseNotesRecipient = false;
|
||||
this.needsPniSignature = false;
|
||||
this.isActiveGroup = false;
|
||||
this.callLinkRoomId = null;
|
||||
}
|
||||
|
||||
public Recipient(@NonNull RecipientId id, @NonNull RecipientDetails details, boolean resolved) {
|
||||
@@ -489,6 +491,7 @@ public class Recipient {
|
||||
this.isReleaseNotesRecipient = details.isReleaseChannel;
|
||||
this.needsPniSignature = details.needsPniSignature;
|
||||
this.isActiveGroup = details.isActiveGroup;
|
||||
this.callLinkRoomId = details.callLinkRoomId;
|
||||
}
|
||||
|
||||
public @NonNull RecipientId getId() {
|
||||
@@ -541,6 +544,8 @@ public class Recipient {
|
||||
return Util.join(names, ", ");
|
||||
} else if (!resolving && isMyStory()) {
|
||||
return context.getString(R.string.Recipient_my_story);
|
||||
} else if (!resolving && Util.isEmpty(this.groupName) && isCallLink()){
|
||||
return context.getString(R.string.Recipient_signal_call);
|
||||
} else {
|
||||
return this.groupName;
|
||||
}
|
||||
@@ -932,6 +937,7 @@ public class Recipient {
|
||||
if (isSelf) return fallbackPhotoProvider.getPhotoForLocalNumber();
|
||||
else if (isResolving()) return fallbackPhotoProvider.getPhotoForResolvingRecipient();
|
||||
else if (isDistributionList()) return fallbackPhotoProvider.getPhotoForDistributionList();
|
||||
else if (isCallLink()) return fallbackPhotoProvider.getPhotoForCallLink();
|
||||
else if (isGroupInternal()) return fallbackPhotoProvider.getPhotoForGroup();
|
||||
else if (isGroup()) return fallbackPhotoProvider.getPhotoForGroup();
|
||||
else if (!TextUtils.isEmpty(groupName)) return fallbackPhotoProvider.getPhotoForRecipientWithName(groupName, targetSize);
|
||||
@@ -1209,11 +1215,11 @@ public class Recipient {
|
||||
}
|
||||
|
||||
public boolean isCallLink() {
|
||||
return false;
|
||||
return callLinkRoomId != null;
|
||||
}
|
||||
|
||||
public @NonNull CallLinkRoomId requireCallLinkRoomId() {
|
||||
throw new UnsupportedOperationException();
|
||||
return Objects.requireNonNull(callLinkRoomId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1348,7 +1354,8 @@ public class Recipient {
|
||||
Objects.equals(aboutEmoji, other.aboutEmoji) &&
|
||||
Objects.equals(extras, other.extras) &&
|
||||
hasGroupsInCommon == other.hasGroupsInCommon &&
|
||||
Objects.equals(badges, other.badges);
|
||||
Objects.equals(badges, other.badges) &&
|
||||
Objects.equals(callLinkRoomId, other.callLinkRoomId);
|
||||
}
|
||||
|
||||
private static boolean allContentsAreTheSame(@NonNull List<Recipient> a, @NonNull List<Recipient> b) {
|
||||
@@ -1390,6 +1397,10 @@ public class Recipient {
|
||||
public @NonNull FallbackContactPhoto getPhotoForDistributionList() {
|
||||
return new ResourceContactPhoto(R.drawable.symbol_stories_24, R.drawable.symbol_stories_24, R.drawable.symbol_stories_24);
|
||||
}
|
||||
|
||||
public @NonNull FallbackContactPhoto getPhotoForCallLink() {
|
||||
return new ResourceContactPhoto(R.drawable.symbol_video_24, R.drawable.symbol_video_24, R.drawable.symbol_video_24);
|
||||
}
|
||||
}
|
||||
|
||||
private static class MissingAddressError extends AssertionError {
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.thoughtcrime.securesms.database.model.RecipientRecord;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.profiles.ProfileName;
|
||||
import org.thoughtcrime.securesms.service.webrtc.links.CallLinkRoomId;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.wallpaper.ChatWallpaper;
|
||||
@@ -86,6 +87,7 @@ public class RecipientDetails {
|
||||
final List<Badge> badges;
|
||||
final boolean isReleaseChannel;
|
||||
final boolean needsPniSignature;
|
||||
final CallLinkRoomId callLinkRoomId;
|
||||
|
||||
public RecipientDetails(@Nullable String groupName,
|
||||
@Nullable String systemContactName,
|
||||
@@ -150,6 +152,7 @@ public class RecipientDetails {
|
||||
this.badges = record.getBadges();
|
||||
this.isReleaseChannel = isReleaseChannel;
|
||||
this.needsPniSignature = record.needsPniSignature();
|
||||
this.callLinkRoomId = record.getCallLinkRoomId();
|
||||
}
|
||||
|
||||
private RecipientDetails() {
|
||||
@@ -203,8 +206,9 @@ public class RecipientDetails {
|
||||
this.hasGroupsInCommon = false;
|
||||
this.badges = Collections.emptyList();
|
||||
this.isReleaseChannel = false;
|
||||
this.needsPniSignature = false;
|
||||
this.isActiveGroup = false;
|
||||
this.needsPniSignature = false;
|
||||
this.isActiveGroup = false;
|
||||
this.callLinkRoomId = null;
|
||||
}
|
||||
|
||||
public static @NonNull RecipientDetails forIndividual(@NonNull Context context, @NonNull RecipientRecord settings) {
|
||||
@@ -230,6 +234,10 @@ public class RecipientDetails {
|
||||
return new RecipientDetails(title, null, Optional.empty(), false, false, record.getRegistered(), record, members, false, false);
|
||||
}
|
||||
|
||||
public static @NonNull RecipientDetails forCallLink(String name, @NonNull RecipientRecord record) {
|
||||
return new RecipientDetails(name, null, Optional.empty(), false, false, record.getRegistered(), record, Collections.emptyList(), false, false);
|
||||
}
|
||||
|
||||
public static @NonNull RecipientDetails forUnknown() {
|
||||
return new RecipientDetails();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user