kopia lustrzana https://github.com/ryukoposting/Signal-Android
Inline the stories flag.
rodzic
b55954380d
commit
2b685ea89f
|
@ -19,7 +19,6 @@ import org.thoughtcrime.securesms.database.model.StoryType
|
|||
import org.thoughtcrime.securesms.mms.IncomingMediaMessage
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.testing.TestProtos
|
||||
import org.thoughtcrime.securesms.util.FeatureFlagsTestUtil
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceContent
|
||||
import org.whispersystems.signalservice.api.push.DistributionId
|
||||
import org.whispersystems.signalservice.internal.push.SignalServiceProtos.DataMessage
|
||||
|
@ -31,7 +30,6 @@ class MessageContentProcessor__handleStoryMessageTest : MessageContentProcessorT
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
FeatureFlagsTestUtil.setStoriesEnabled(true)
|
||||
SignalDatabase.mms.deleteAllThreads()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
package org.thoughtcrime.securesms.util
|
||||
|
||||
/**
|
||||
* Utility to enable / disable feature flags via forced values.
|
||||
*/
|
||||
object FeatureFlagsTestUtil {
|
||||
fun setStoriesEnabled(isEnabled: Boolean) {
|
||||
FeatureFlags.FORCED_VALUES[FeatureFlags.STORIES] = isEnabled
|
||||
}
|
||||
}
|
|
@ -15,12 +15,13 @@ public final class AppCapabilities {
|
|||
private static final boolean ANNOUNCEMENT_GROUPS = true;
|
||||
private static final boolean SENDER_KEY = true;
|
||||
private static final boolean CHANGE_NUMBER = true;
|
||||
private static final boolean STORIES = true;
|
||||
|
||||
/**
|
||||
* @param storageCapable Whether or not the user can use storage service. This is another way of
|
||||
* asking if the user has set a Signal PIN or not.
|
||||
*/
|
||||
public static AccountAttributes.Capabilities getCapabilities(boolean storageCapable) {
|
||||
return new AccountAttributes.Capabilities(UUID_CAPABLE, GV2_CAPABLE, storageCapable, GV1_MIGRATION, SENDER_KEY, ANNOUNCEMENT_GROUPS, CHANGE_NUMBER, Stories.isFeatureFlagEnabled(), FeatureFlags.giftBadgeReceiveSupport(), FeatureFlags.phoneNumberPrivacy());
|
||||
return new AccountAttributes.Capabilities(UUID_CAPABLE, GV2_CAPABLE, storageCapable, GV1_MIGRATION, SENDER_KEY, ANNOUNCEMENT_GROUPS, CHANGE_NUMBER, STORIES, FeatureFlags.giftBadgeReceiveSupport(), FeatureFlags.phoneNumberPrivacy());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ import org.thoughtcrime.securesms.components.settings.configure
|
|||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.stories.Stories.isFeatureFlagEnabled
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import org.thoughtcrime.securesms.util.adapter.mapping.LayoutFactory
|
||||
|
@ -107,15 +106,13 @@ class AppSettingsFragment : DSLSettingsFragment(R.string.text_secure_normal__men
|
|||
}
|
||||
)
|
||||
|
||||
if (isFeatureFlagEnabled()) {
|
||||
clickPref(
|
||||
title = DSLSettingsText.from(R.string.preferences__stories),
|
||||
icon = DSLSettingsIcon.from(R.drawable.ic_stories_24),
|
||||
onClick = {
|
||||
findNavController().safeNavigate(AppSettingsFragmentDirections.actionAppSettingsFragmentToStoryPrivacySettings(R.string.preferences__stories))
|
||||
}
|
||||
)
|
||||
}
|
||||
clickPref(
|
||||
title = DSLSettingsText.from(R.string.preferences__stories),
|
||||
icon = DSLSettingsIcon.from(R.drawable.ic_stories_24),
|
||||
onClick = {
|
||||
findNavController().safeNavigate(AppSettingsFragmentDirections.actionAppSettingsFragmentToStoryPrivacySettings(R.string.preferences__stories))
|
||||
}
|
||||
)
|
||||
|
||||
clickPref(
|
||||
title = DSLSettingsText.from(R.string.preferences__notifications),
|
||||
|
|
|
@ -86,7 +86,6 @@ import org.thoughtcrime.securesms.recipients.RecipientId
|
|||
import org.thoughtcrime.securesms.storage.StorageRecordUpdate
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncModels
|
||||
import org.thoughtcrime.securesms.stories.Stories.isFeatureFlagEnabled
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags
|
||||
import org.thoughtcrime.securesms.util.GroupUtil
|
||||
|
@ -1163,11 +1162,8 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
|||
* @return All storage IDs for synced records, excluding the ones that need to be deleted.
|
||||
*/
|
||||
fun getContactStorageSyncIdsMap(): Map<RecipientId, StorageId> {
|
||||
val (inPart, args) = if (isFeatureFlagEnabled()) {
|
||||
"(?, ?)" to SqlUtil.buildArgs(GroupType.NONE.id, Recipient.self().id, GroupType.SIGNAL_V1.id, GroupType.DISTRIBUTION_LIST.id)
|
||||
} else {
|
||||
"(?)" to SqlUtil.buildArgs(GroupType.NONE.id, Recipient.self().id, GroupType.SIGNAL_V1.id)
|
||||
}
|
||||
val inPart = "(?, ?)"
|
||||
val args = SqlUtil.buildArgs(GroupType.NONE.id, Recipient.self().id, GroupType.SIGNAL_V1.id, GroupType.DISTRIBUTION_LIST.id)
|
||||
|
||||
val query = """
|
||||
$STORAGE_SERVICE_ID NOT NULL AND (
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore
|
|||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.releasechannel.ReleaseChannel
|
||||
import org.thoughtcrime.securesms.s3.S3
|
||||
import org.thoughtcrime.securesms.stories.Stories.isFeatureFlagEnabled
|
||||
import org.thoughtcrime.securesms.transport.RetryLaterException
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException
|
||||
import java.util.Locale
|
||||
|
@ -51,7 +50,7 @@ class StoryOnboardingDownloadJob private constructor(parameters: Parameters) : B
|
|||
}
|
||||
|
||||
fun enqueueIfNeeded() {
|
||||
if (SignalStore.storyValues().hasDownloadedOnboardingStory || !isFeatureFlagEnabled()) {
|
||||
if (SignalStore.storyValues().hasDownloadedOnboardingStory) {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.content.Context
|
|||
import androidx.annotation.WorkerThread
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.keyvalue.SmsExportPhase
|
||||
import org.thoughtcrime.securesms.stories.Stories
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import kotlin.time.Duration.Companion.days
|
||||
|
@ -36,11 +35,7 @@ class SmsExportReminderSchedule(private val context: Context) : MegaphoneSchedul
|
|||
@Suppress("UsePropertyAccessSyntax")
|
||||
@WorkerThread
|
||||
fun shouldShowMegaphone(): Boolean {
|
||||
if (!Stories.isFeatureFlagEnabled()) {
|
||||
return false
|
||||
}
|
||||
|
||||
return if (Stories.isFeatureFlagEnabled() && SignalStore.misc().storiesFeatureAvailableTimestamp == 0L) {
|
||||
return if (SignalStore.misc().storiesFeatureAvailableTimestamp == 0L) {
|
||||
SignalStore.misc().storiesFeatureAvailableTimestamp = System.currentTimeMillis()
|
||||
false
|
||||
} else if (System.currentTimeMillis() > (SignalStore.misc().storiesFeatureAvailableTimestamp + FeatureFlags.smsExportMegaphoneDelayDays().days.inWholeMilliseconds)) {
|
||||
|
|
|
@ -1435,11 +1435,6 @@ public final class MessageContentProcessor {
|
|||
private void handleStoryMessage(@NonNull SignalServiceContent content, @NonNull SignalServiceStoryMessage message, @NonNull Recipient senderRecipient, @NonNull Recipient threadRecipient) throws StorageFailedException {
|
||||
log(content.getTimestamp(), "Story message.");
|
||||
|
||||
if (!Stories.isFeatureFlagEnabled()) {
|
||||
warn(content.getTimestamp(), "Dropping unsupported story.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!threadRecipient.isActiveGroup() && !(senderRecipient.isProfileSharing() || senderRecipient.isSystemContact())) {
|
||||
warn(content.getTimestamp(), "Dropping story from an untrusted source.");
|
||||
return;
|
||||
|
@ -1579,11 +1574,6 @@ public final class MessageContentProcessor {
|
|||
private @Nullable MessageId handleStoryReaction(@NonNull SignalServiceContent content, @NonNull SignalServiceDataMessage message, @NonNull Recipient senderRecipient) throws StorageFailedException {
|
||||
log(content.getTimestamp(), "Story reaction.");
|
||||
|
||||
if (!Stories.isFeatureFlagEnabled()) {
|
||||
warn(content.getTimestamp(), "Dropping unsupported story reaction.");
|
||||
return null;
|
||||
}
|
||||
|
||||
SignalServiceDataMessage.Reaction reaction = message.getReaction().get();
|
||||
|
||||
if (!EmojiUtil.isEmoji(reaction.getEmoji())) {
|
||||
|
@ -1682,11 +1672,6 @@ public final class MessageContentProcessor {
|
|||
private @Nullable MessageId handleStoryReply(@NonNull SignalServiceContent content, @NonNull SignalServiceDataMessage message, @NonNull Recipient senderRecipient, long receivedTime) throws StorageFailedException {
|
||||
log(content.getTimestamp(), "Story reply.");
|
||||
|
||||
if (!Stories.isFeatureFlagEnabled()) {
|
||||
warn(content.getTimestamp(), "Dropping unsupported story reply.");
|
||||
return null;
|
||||
}
|
||||
|
||||
SignalServiceDataMessage.StoryContext storyContext = message.getStoryContext().get();
|
||||
|
||||
MessageDatabase database = SignalDatabase.mms();
|
||||
|
@ -1969,11 +1954,6 @@ public final class MessageContentProcessor {
|
|||
private long handleSynchronizeSentStoryReply(@NonNull SentTranscriptMessage message, long envelopeTimestamp)
|
||||
throws MmsException, BadGroupIdException {
|
||||
|
||||
if (!Stories.isFeatureFlagEnabled()) {
|
||||
warn(envelopeTimestamp, "Dropping unsupported story reply sync message.");
|
||||
return -1L;
|
||||
}
|
||||
|
||||
log(envelopeTimestamp, "Synchronize sent story reply for " + message.getTimestamp());
|
||||
|
||||
try {
|
||||
|
|
|
@ -34,8 +34,6 @@ import org.thoughtcrime.securesms.recipients.RecipientUtil
|
|||
import org.thoughtcrime.securesms.sms.MessageSender
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
import org.thoughtcrime.securesms.util.BottomSheetUtil
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags
|
||||
import org.thoughtcrime.securesms.util.LocaleFeatureFlags
|
||||
import org.thoughtcrime.securesms.util.MediaUtil
|
||||
import org.thoughtcrime.securesms.util.hasLinkPreview
|
||||
import java.util.Optional
|
||||
|
@ -61,25 +59,12 @@ object Stories {
|
|||
@JvmField
|
||||
val MAX_VIDEO_DURATION_MILLIS: Long = (31.seconds - 1.milliseconds).inWholeMilliseconds
|
||||
|
||||
/**
|
||||
* Whether the feature is enabled at the flag level.
|
||||
*
|
||||
* `stories` will override `isInStoriesCountry` so as to not disable stories for those with
|
||||
* that flag already enabled.
|
||||
*
|
||||
* Note: In general, you should prefer `isFeatureAvailable`.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun isFeatureFlagEnabled(): Boolean {
|
||||
return SignalStore.account().isRegistered && (FeatureFlags.stories() || LocaleFeatureFlags.isInStoriesCountry())
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not the user has the Stories feature enabled.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun isFeatureEnabled(): Boolean {
|
||||
return isFeatureFlagEnabled() && !SignalStore.storyValues().isFeatureDisabled
|
||||
return !SignalStore.storyValues().isFeatureDisabled
|
||||
}
|
||||
|
||||
fun getHeaderAction(onClick: () -> Unit): HeaderAction {
|
||||
|
|
|
@ -81,7 +81,6 @@ public final class FeatureFlags {
|
|||
private static final String RETRY_RECEIPTS = "android.retryReceipts";
|
||||
private static final String MAX_GROUP_CALL_RING_SIZE = "global.calling.maxGroupCallRingSize";
|
||||
private static final String GROUP_CALL_RINGING = "android.calling.groupCallRinging";
|
||||
static final String STORIES = "android.stories.7";
|
||||
private static final String STORIES_TEXT_FUNCTIONS = "android.stories.text.functions";
|
||||
private static final String HARDWARE_AEC_BLOCKLIST_MODELS = "android.calling.hardwareAecBlockList";
|
||||
private static final String SOFTWARE_AEC_BLOCKLIST_MODELS = "android.calling.softwareAecBlockList";
|
||||
|
@ -99,7 +98,6 @@ public final class FeatureFlags {
|
|||
private static final String CAMERAX_MIXED_MODEL_BLOCKLIST = "android.cameraXMixedModelBlockList";
|
||||
private static final String RECIPIENT_MERGE_V2 = "android.recipientMergeV2";
|
||||
private static final String SMS_EXPORTER = "android.sms.exporter.2";
|
||||
public static final String STORIES_LOCALE = "android.stories.locale.3";
|
||||
private static final String HIDE_CONTACTS = "android.hide.contacts";
|
||||
private static final String SMS_EXPORT_MEGAPHONE_DELAY_DAYS = "android.smsExport.megaphoneDelayDays.2";
|
||||
public static final String CREDIT_CARD_PAYMENTS = "android.credit.card.payments.1";
|
||||
|
@ -139,7 +137,6 @@ public final class FeatureFlags {
|
|||
MAX_GROUP_CALL_RING_SIZE,
|
||||
GROUP_CALL_RINGING,
|
||||
SENDER_KEY_MAX_AGE,
|
||||
STORIES,
|
||||
STORIES_TEXT_FUNCTIONS,
|
||||
HARDWARE_AEC_BLOCKLIST_MODELS,
|
||||
SOFTWARE_AEC_BLOCKLIST_MODELS,
|
||||
|
@ -156,7 +153,6 @@ public final class FeatureFlags {
|
|||
CAMERAX_MIXED_MODEL_BLOCKLIST,
|
||||
RECIPIENT_MERGE_V2,
|
||||
SMS_EXPORTER,
|
||||
STORIES_LOCALE,
|
||||
HIDE_CONTACTS,
|
||||
SMS_EXPORT_MEGAPHONE_DELAY_DAYS,
|
||||
CREDIT_CARD_PAYMENTS,
|
||||
|
@ -222,7 +218,6 @@ public final class FeatureFlags {
|
|||
TELECOM_MODEL_BLOCKLIST,
|
||||
CAMERAX_MODEL_BLOCKLIST,
|
||||
RECIPIENT_MERGE_V2,
|
||||
STORIES,
|
||||
SMS_EXPORT_MEGAPHONE_DELAY_DAYS,
|
||||
CREDIT_CARD_PAYMENTS,
|
||||
PAYMENTS_REQUEST_ACTIVATE_FLOW,
|
||||
|
@ -250,10 +245,6 @@ public final class FeatureFlags {
|
|||
*/
|
||||
private static final Map<String, OnFlagChange> FLAG_CHANGE_LISTENERS = new HashMap<String, OnFlagChange>() {{
|
||||
put(MESSAGE_PROCESSOR_ALARM_INTERVAL, change -> MessageProcessReceiver.startOrUpdateAlarm(ApplicationDependencies.getApplication()));
|
||||
put(STORIES, change -> {
|
||||
ApplicationDependencies.getJobManager().startChain(new RefreshAttributesJob()).then(new RefreshOwnProfileJob()).enqueue();
|
||||
ApplicationDependencies.resetAllNetworkConnections();
|
||||
});
|
||||
put(GIFT_BADGE_RECEIVE_SUPPORT, change -> ApplicationDependencies.getJobManager().startChain(new RefreshAttributesJob()).then(new RefreshOwnProfileJob()).enqueue());
|
||||
}};
|
||||
|
||||
|
@ -449,15 +440,6 @@ public final class FeatureFlags {
|
|||
return getString(PAYMENTS_COUNTRY_BLOCKLIST, "98,963,53,850,7");
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not stories are available
|
||||
*
|
||||
* NOTE: This feature is still under ongoing development, do not enable.
|
||||
*/
|
||||
public static boolean stories() {
|
||||
return getBoolean(STORIES, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether users can apply alignment and scale to text posts
|
||||
*
|
||||
|
@ -467,13 +449,6 @@ public final class FeatureFlags {
|
|||
return getBoolean(STORIES_TEXT_FUNCTIONS, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* List of locales in which stories have been enabled. Overridden by the stories flag.
|
||||
*/
|
||||
public static @NonNull String storiesLocale() {
|
||||
return getString(STORIES_LOCALE, "");
|
||||
}
|
||||
|
||||
/** A comma-separated list of models that should *not* use hardware AEC for calling. */
|
||||
public static @NonNull String hardwareAecBlocklistModels() {
|
||||
return getString(HARDWARE_AEC_BLOCKLIST_MODELS, "");
|
||||
|
|
|
@ -44,13 +44,6 @@ public final class LocaleFeatureFlags {
|
|||
return Optional.ofNullable(PushMediaConstraints.MediaConfig.forLevel(level));
|
||||
}
|
||||
|
||||
/**
|
||||
* In story group for given country code
|
||||
*/
|
||||
public static boolean isInStoriesCountry() {
|
||||
return isEnabled(FeatureFlags.STORIES_LOCALE, FeatureFlags.storiesLocale());
|
||||
}
|
||||
|
||||
public static boolean shouldShowReleaseNote(@NonNull String releaseNoteUuid, @NonNull String countries) {
|
||||
return isEnabled(releaseNoteUuid, countries);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue