mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 18:30:20 +01:00
Implement badge gifting behind feature flag.
This commit is contained in:
committed by
Greyson Parrelli
parent
5d16d1cd23
commit
a4a4665aaa
@@ -66,6 +66,9 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
import static org.thoughtcrime.securesms.database.RecipientDatabase.InsightsBannerTier;
|
||||
|
||||
public class Recipient {
|
||||
@@ -118,6 +121,7 @@ public class Recipient {
|
||||
private final Capability announcementGroupCapability;
|
||||
private final Capability changeNumberCapability;
|
||||
private final Capability storiesCapability;
|
||||
private final Capability giftBadgesCapability;
|
||||
private final InsightsBannerTier insightsBannerTier;
|
||||
private final byte[] storageId;
|
||||
private final MentionSetting mentionSetting;
|
||||
@@ -144,6 +148,25 @@ public class Recipient {
|
||||
return ApplicationDependencies.getRecipientCache().getLive(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a live recipient wrapped in an Observable. All work is done on the IO threadpool.
|
||||
*/
|
||||
@AnyThread
|
||||
public static @NonNull Observable<Recipient> observable(@NonNull RecipientId id) {
|
||||
Preconditions.checkNotNull(id, "ID cannot be null");
|
||||
return Observable.<Recipient>create(emitter -> {
|
||||
LiveRecipient live = live(id);
|
||||
emitter.onNext(live.resolve());
|
||||
|
||||
RecipientForeverObserver observer = emitter::onNext;
|
||||
|
||||
live.observeForever(observer);
|
||||
emitter.setCancellable(() -> {
|
||||
live.removeForeverObserver(observer);
|
||||
});
|
||||
}).subscribeOn(Schedulers.io());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a fully-populated {@link Recipient}. May hit the disk, and therefore should be
|
||||
* called on a background thread.
|
||||
@@ -385,6 +408,7 @@ public class Recipient {
|
||||
this.announcementGroupCapability = Capability.UNKNOWN;
|
||||
this.changeNumberCapability = Capability.UNKNOWN;
|
||||
this.storiesCapability = Capability.UNKNOWN;
|
||||
this.giftBadgesCapability = Capability.UNKNOWN;
|
||||
this.storageId = null;
|
||||
this.mentionSetting = MentionSetting.ALWAYS_NOTIFY;
|
||||
this.wallpaper = null;
|
||||
@@ -442,6 +466,7 @@ public class Recipient {
|
||||
this.announcementGroupCapability = details.announcementGroupCapability;
|
||||
this.changeNumberCapability = details.changeNumberCapability;
|
||||
this.storiesCapability = details.storiesCapability;
|
||||
this.giftBadgesCapability = details.giftBadgesCapability;
|
||||
this.storageId = details.storageId;
|
||||
this.mentionSetting = details.mentionSetting;
|
||||
this.wallpaper = details.wallpaper;
|
||||
@@ -991,6 +1016,10 @@ public class Recipient {
|
||||
return storiesCapability;
|
||||
}
|
||||
|
||||
public @NonNull Capability getGiftBadgesCapability() {
|
||||
return giftBadgesCapability;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if this recipient supports the message retry system, or false if we should use the legacy session reset system.
|
||||
*/
|
||||
|
||||
@@ -73,6 +73,7 @@ public class RecipientDetails {
|
||||
final Recipient.Capability announcementGroupCapability;
|
||||
final Recipient.Capability changeNumberCapability;
|
||||
final Recipient.Capability storiesCapability;
|
||||
final Recipient.Capability giftBadgesCapability;
|
||||
final InsightsBannerTier insightsBannerTier;
|
||||
final byte[] storageId;
|
||||
final MentionSetting mentionSetting;
|
||||
@@ -135,6 +136,7 @@ public class RecipientDetails {
|
||||
this.announcementGroupCapability = record.getAnnouncementGroupCapability();
|
||||
this.changeNumberCapability = record.getChangeNumberCapability();
|
||||
this.storiesCapability = record.getStoriesCapability();
|
||||
this.giftBadgesCapability = record.getGiftBadgesCapability();
|
||||
this.insightsBannerTier = record.getInsightsBannerTier();
|
||||
this.storageId = record.getStorageId();
|
||||
this.mentionSetting = record.getMentionSetting();
|
||||
@@ -193,6 +195,7 @@ public class RecipientDetails {
|
||||
this.announcementGroupCapability = Recipient.Capability.UNKNOWN;
|
||||
this.changeNumberCapability = Recipient.Capability.UNKNOWN;
|
||||
this.storiesCapability = Recipient.Capability.UNKNOWN;
|
||||
this.giftBadgesCapability = Recipient.Capability.UNKNOWN;
|
||||
this.storageId = null;
|
||||
this.mentionSetting = MentionSetting.ALWAYS_NOTIFY;
|
||||
this.wallpaper = null;
|
||||
|
||||
Reference in New Issue
Block a user