mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Reimplement Phase 0 for SMS removal.
This commit is contained in:
committed by
Greyson Parrelli
parent
690e1e60ba
commit
a535b4f97c
@@ -26,7 +26,8 @@ public final class MiscellaneousValues extends SignalStoreValues {
|
||||
private static final String LAST_FCM_FOREGROUND_TIME = "misc.last_fcm_foreground_time";
|
||||
private static final String LAST_FOREGROUND_TIME = "misc.last_foreground_time";
|
||||
private static final String PNI_INITIALIZED_DEVICES = "misc.pni_initialized_devices";
|
||||
private static final String SMS_EXPORT_TIME = "misc.sms_export_time";
|
||||
private static final String SMS_PHASE_1_START_MS = "misc.sms_export.phase_1_start";
|
||||
private static final String STORIES_FEATURE_AVAILABLE_MS = "misc.stories_feature_available_ms";
|
||||
|
||||
MiscellaneousValues(@NonNull KeyValueStore store) {
|
||||
super(store);
|
||||
@@ -40,7 +41,8 @@ public final class MiscellaneousValues extends SignalStoreValues {
|
||||
@Override
|
||||
@NonNull List<String> getKeysToIncludeInBackup() {
|
||||
return Arrays.asList(
|
||||
SMS_EXPORT_TIME
|
||||
SMS_PHASE_1_START_MS,
|
||||
STORIES_FEATURE_AVAILABLE_MS
|
||||
);
|
||||
}
|
||||
|
||||
@@ -188,14 +190,26 @@ public final class MiscellaneousValues extends SignalStoreValues {
|
||||
putBoolean(PNI_INITIALIZED_DEVICES, value);
|
||||
}
|
||||
|
||||
public void setHasSeenSmsExportMegaphone() {
|
||||
if (!getStore().containsKey(SMS_EXPORT_TIME)) {
|
||||
putLong(SMS_EXPORT_TIME, System.currentTimeMillis());
|
||||
public void startSmsPhase1() {
|
||||
if (!getStore().containsKey(SMS_PHASE_1_START_MS)) {
|
||||
putLong(SMS_PHASE_1_START_MS, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
public long getStoriesFeatureAvailableTimestamp() {
|
||||
return getLong(STORIES_FEATURE_AVAILABLE_MS, 0);
|
||||
}
|
||||
|
||||
public void setStoriesFeatureAvailableTimestamp(long timestamp) {
|
||||
putLong(STORIES_FEATURE_AVAILABLE_MS, timestamp);
|
||||
}
|
||||
|
||||
public @NonNull SmsExportPhase getSmsExportPhase() {
|
||||
if (getLong(SMS_PHASE_1_START_MS, 0) == 0) {
|
||||
return SmsExportPhase.PHASE_0;
|
||||
}
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
return SmsExportPhase.getCurrentPhase(now - getLong(SMS_EXPORT_TIME, now));
|
||||
return SmsExportPhase.getCurrentPhase(now - getLong(SMS_PHASE_1_START_MS, now));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,35 @@
|
||||
package org.thoughtcrime.securesms.keyvalue
|
||||
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import kotlin.time.Duration.Companion.days
|
||||
|
||||
enum class SmsExportPhase(val duration: Long) {
|
||||
PHASE_0(-1),
|
||||
PHASE_1(0.days.inWholeMilliseconds),
|
||||
PHASE_2(45.days.inWholeMilliseconds),
|
||||
PHASE_3(105.days.inWholeMilliseconds);
|
||||
|
||||
fun allowSmsFeatures(): Boolean {
|
||||
return this == PHASE_0 || (Util.isDefaultSmsProvider(ApplicationDependencies.getApplication()) && SignalStore.misc().smsExportPhase.isSmsSupported())
|
||||
}
|
||||
|
||||
fun isSmsSupported(): Boolean {
|
||||
return this != PHASE_3
|
||||
}
|
||||
|
||||
fun isFullscreen(): Boolean {
|
||||
return this != PHASE_1
|
||||
return this.ordinal > PHASE_1.ordinal
|
||||
}
|
||||
|
||||
fun isBlockingUi(): Boolean {
|
||||
return this == PHASE_3
|
||||
}
|
||||
|
||||
fun isAtLeastPhase1(): Boolean {
|
||||
return this.ordinal >= PHASE_1.ordinal
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun getCurrentPhase(duration: Long): SmsExportPhase {
|
||||
|
||||
Reference in New Issue
Block a user