mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Implement badge gifting behind feature flag.
This commit is contained in:
committed by
Greyson Parrelli
parent
5d16d1cd23
commit
a4a4665aaa
@@ -98,6 +98,7 @@ public final class FeatureFlags {
|
||||
private static final String PNP_CDS = "android.pnp.cds";
|
||||
private static final String USE_FCM_FOREGROUND_SERVICE = "android.useFcmForegroundService";
|
||||
private static final String STORIES_AUTO_DOWNLOAD_MAXIMUM = "android.stories.autoDownloadMaximum";
|
||||
private static final String GIFT_BADGES = "android.giftBadges";
|
||||
|
||||
/**
|
||||
* We will only store remote values for flags in this set. If you want a flag to be controllable
|
||||
@@ -147,7 +148,8 @@ public final class FeatureFlags {
|
||||
USE_AEC3,
|
||||
PAYMENTS_COUNTRY_BLOCKLIST,
|
||||
USE_FCM_FOREGROUND_SERVICE,
|
||||
STORIES_AUTO_DOWNLOAD_MAXIMUM
|
||||
STORIES_AUTO_DOWNLOAD_MAXIMUM,
|
||||
GIFT_BADGES
|
||||
);
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -234,6 +236,7 @@ public final class FeatureFlags {
|
||||
put(MESSAGE_PROCESSOR_ALARM_INTERVAL, change -> MessageProcessReceiver.startOrUpdateAlarm(ApplicationDependencies.getApplication()));
|
||||
put(SENDER_KEY, change -> ApplicationDependencies.getJobManager().add(new RefreshAttributesJob()));
|
||||
put(STORIES, change -> ApplicationDependencies.getJobManager().add(new RefreshAttributesJob()));
|
||||
put(GIFT_BADGES, change -> ApplicationDependencies.getJobManager().add(new RefreshAttributesJob()));
|
||||
}};
|
||||
|
||||
private static final Map<String, Object> REMOTE_VALUES = new TreeMap<>();
|
||||
@@ -520,6 +523,14 @@ public final class FeatureFlags {
|
||||
public static int storiesAutoDownloadMaximum() {
|
||||
return getInteger(STORIES_AUTO_DOWNLOAD_MAXIMUM, 2);
|
||||
}
|
||||
/**
|
||||
* Whether or not Gifting Badges should be available on this client.
|
||||
*
|
||||
* NOTE: This feature is under development and should not be enabled on prod. Doing so is solely at your own risk.
|
||||
*/
|
||||
public static boolean giftBadges() {
|
||||
return getBoolean(GIFT_BADGES, Environment.IS_STAGING);
|
||||
}
|
||||
|
||||
/** Only for rendering debug info. */
|
||||
public static synchronized @NonNull Map<String, Object> getMemoryValues() {
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.thoughtcrime.securesms.database.MmsSmsColumns
|
||||
import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.GiftBadge
|
||||
import org.thoughtcrime.securesms.mms.TextSlide
|
||||
import org.thoughtcrime.securesms.stickers.StickerUrl
|
||||
|
||||
@@ -101,6 +102,14 @@ fun MessageRecord.hasBigImageLinkPreview(context: Context): Boolean {
|
||||
return linkPreview.thumbnail.isPresent && linkPreview.thumbnail.get().width >= minWidth && !StickerUrl.isValidShareLink(linkPreview.url)
|
||||
}
|
||||
|
||||
fun MessageRecord.hasGiftBadge(): Boolean {
|
||||
return (this as? MmsMessageRecord)?.giftBadge != null
|
||||
}
|
||||
|
||||
fun MessageRecord.requireGiftBadge(): GiftBadge {
|
||||
return (this as MmsMessageRecord).giftBadge!!
|
||||
}
|
||||
|
||||
fun MessageRecord.isTextOnly(context: Context): Boolean {
|
||||
return !isMms ||
|
||||
(
|
||||
@@ -114,6 +123,7 @@ fun MessageRecord.isTextOnly(context: Context): Boolean {
|
||||
!hasLocation() &&
|
||||
!hasSharedContact() &&
|
||||
!hasSticker() &&
|
||||
!isCaptionlessMms(context)
|
||||
!isCaptionlessMms(context) &&
|
||||
!hasGiftBadge()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -115,10 +115,10 @@ public final class Projection {
|
||||
}
|
||||
|
||||
public @NonNull Projection scale(float scale) {
|
||||
Corners newCorners = new Corners(this.corners.topLeft * scale,
|
||||
this.corners.topRight * scale,
|
||||
this.corners.bottomRight * scale,
|
||||
this.corners.bottomLeft * scale);
|
||||
Corners newCorners = this.corners == null ? null : new Corners(this.corners.topLeft * scale,
|
||||
this.corners.topRight * scale,
|
||||
this.corners.bottomRight * scale,
|
||||
this.corners.bottomLeft * scale);
|
||||
return set(x, y, (int) (width * scale), (int) (height * scale), newCorners);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user