Remove Phase 1 in preparation for CFv2.

This commit is contained in:
Cody Henthorne
2023-07-14 13:51:30 -04:00
committed by GitHub
parent 7031bbae43
commit e5c3757629
9 changed files with 18 additions and 61 deletions

View File

@@ -2658,16 +2658,13 @@ public class ConversationParentFragment extends Fragment
TextView message = smsExportStub.get().findViewById(R.id.export_sms_message);
MaterialButton actionButton = smsExportStub.get().findViewById(R.id.export_sms_button);
boolean isPhase1 = SignalStore.misc().getSmsExportPhase() == SmsExportPhase.PHASE_1;
if (conversationSecurityInfo.getHasUnexportedInsecureMessages()) {
message.setText(isPhase1 ? R.string.ConversationActivity__sms_messaging_is_currently_disabled_you_can_export_your_messages_to_another_app_on_your_phone
: R.string.ConversationActivity__sms_messaging_is_no_longer_supported_in_signal_you_can_export_your_messages_to_another_app_on_your_phone);
message.setText(R.string.ConversationActivity__sms_messaging_is_no_longer_supported_in_signal_you_can_export_your_messages_to_another_app_on_your_phone);
actionButton.setText(R.string.ConversationActivity__export_sms_messages);
actionButton.setOnClickListener(v -> startActivity(SmsExportActivity.createIntent(requireContext())));
} else {
message.setText(requireContext().getString(isPhase1 ? R.string.ConversationActivity__sms_messaging_is_currently_disabled_invite_s_to_to_signal_to_keep_the_conversation_here
: R.string.ConversationActivity__sms_messaging_is_no_longer_supported_in_signal_invite_s_to_to_signal_to_keep_the_conversation_here,
message.setText(requireContext().getString(R.string.ConversationActivity__sms_messaging_is_no_longer_supported_in_signal_invite_s_to_to_signal_to_keep_the_conversation_here,
recipient.getDisplayName(requireContext())));
actionButton.setText(R.string.ConversationActivity__invite_to_signal);
actionButton.setOnClickListener(v -> handleInviteLink());

View File

@@ -699,7 +699,7 @@ public class ConversationListFragment extends MainFragment implements ActionMode
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode == SmsExportMegaphoneActivity.REQUEST_CODE && SignalStore.misc().getSmsExportPhase().isFullscreen()) {
if (requestCode == SmsExportMegaphoneActivity.REQUEST_CODE) {
ApplicationDependencies.getMegaphoneRepository().markSeen(Megaphones.Event.SMS_EXPORT);
if (resultCode == RESULT_CANCELED) {
Snackbar.make(fab, R.string.ConversationActivity__you_will_be_reminded_again_soon, Snackbar.LENGTH_LONG).show();

View File

@@ -9,11 +9,8 @@ import androidx.navigation.fragment.findNavController
import org.thoughtcrime.securesms.LoggingFragment
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.databinding.SmsRemovalInformationFragmentBinding
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.util.CommunicationActions
import org.thoughtcrime.securesms.util.DateUtils
import org.thoughtcrime.securesms.util.navigation.safeNavigate
import java.util.Locale
/**
* Fragment shown when entering the sms export flow from the basic megaphone.
@@ -42,8 +39,7 @@ class SmsRemovalInformationFragment : LoggingFragment() {
}
}
val phase3Start = DateUtils.formatDateWithMonthAndDay(Locale.getDefault(), SignalStore.misc().smsPhase3Start)
binding.bullet1Text.text = getString(R.string.SmsRemoval_info_bullet_1_s, phase3Start)
binding.bullet1Text.text = getString(R.string.SmsRemoval_info_bullet_1)
binding.toolbar.setNavigationOnClickListener(goBackClickListener)
binding.laterButton.setOnClickListener(goBackClickListener)

View File

@@ -232,24 +232,12 @@ public final class MiscellaneousValues extends SignalStoreValues {
putBoolean(PNI_INITIALIZED_DEVICES, value);
}
public void startSmsPhase1() {
if (!getStore().containsKey(SMS_PHASE_1_START_MS)) {
putLong(SMS_PHASE_1_START_MS, System.currentTimeMillis());
}
}
public @NonNull SmsExportPhase getSmsExportPhase() {
long now = System.currentTimeMillis();
long phase1StartMs = getLong(SMS_PHASE_1_START_MS, now);
return SmsExportPhase.getCurrentPhase(now - phase1StartMs);
}
public long getSmsPhase3Start() {
long now = System.currentTimeMillis();
long phase1StartMs = getLong(SMS_PHASE_1_START_MS, now);
return phase1StartMs + SmsExportPhase.PHASE_3.getDuration();
}
public void setHasLinkedDevices(boolean value) {
putBoolean(HAS_LINKED_DEVICES, value);
}

View File

@@ -5,8 +5,7 @@ import org.thoughtcrime.securesms.util.Util
import kotlin.time.Duration.Companion.days
enum class SmsExportPhase(val duration: Long) {
PHASE_1(0.days.inWholeMilliseconds),
PHASE_2(21.days.inWholeMilliseconds),
PHASE_2(0.days.inWholeMilliseconds),
PHASE_3(51.days.inWholeMilliseconds);
fun allowSmsFeatures(): Boolean {
@@ -17,10 +16,6 @@ enum class SmsExportPhase(val duration: Long) {
return this != PHASE_3
}
fun isFullscreen(): Boolean {
return this.ordinal > PHASE_1.ordinal
}
fun isBlockingUi(): Boolean {
return this == PHASE_3
}

View File

@@ -368,33 +368,19 @@ public final class Megaphones {
private static @NonNull Megaphone buildSmsExportMegaphone(@NonNull Context context) {
SmsExportPhase phase = SignalStore.misc().getSmsExportPhase();
if (phase == SmsExportPhase.PHASE_1) {
return new Megaphone.Builder(Event.SMS_EXPORT, Megaphone.Style.BASIC)
.setTitle(R.string.SmsExportMegaphone__sms_support_going_away)
.setImage(R.drawable.sms_megaphone)
.setBody(R.string.SmsExportMegaphone__dont_worry_encrypted_signal_messages_will_continue_to_work)
.setActionButton(R.string.SmsExportMegaphone__continue, (megaphone, controller) -> {
controller.onMegaphoneSnooze(Event.SMS_EXPORT);
controller.onMegaphoneNavigationRequested(SmsExportActivity.createIntent(context, true), SmsExportMegaphoneActivity.REQUEST_CODE);
})
.setSecondaryButton(R.string.Megaphones_remind_me_later, (megaphone, controller) -> controller.onMegaphoneSnooze(Event.SMS_EXPORT))
.setOnVisibleListener((megaphone, controller) -> SignalStore.misc().startSmsPhase1())
.build();
} else {
Megaphone.Builder builder = new Megaphone.Builder(Event.SMS_EXPORT, Megaphone.Style.FULLSCREEN)
.setOnVisibleListener((megaphone, controller) -> {
if (phase.isBlockingUi()) {
SmsExportReminderSchedule.setShowPhase3Megaphone(false);
}
controller.onMegaphoneNavigationRequested(new Intent(context, SmsExportMegaphoneActivity.class), SmsExportMegaphoneActivity.REQUEST_CODE);
});
Megaphone.Builder builder = new Megaphone.Builder(Event.SMS_EXPORT, Megaphone.Style.FULLSCREEN)
.setOnVisibleListener((megaphone, controller) -> {
if (phase.isBlockingUi()) {
SmsExportReminderSchedule.setShowPhase3Megaphone(false);
}
controller.onMegaphoneNavigationRequested(new Intent(context, SmsExportMegaphoneActivity.class), SmsExportMegaphoneActivity.REQUEST_CODE);
});
if (phase.isBlockingUi()) {
builder.disableSnooze();
}
return builder.build();
if (phase.isBlockingUi()) {
builder.disableSnooze();
}
return builder.build();
}
public static @NonNull Megaphone buildSetUpYourUsernameMegaphone(@NonNull Context context) {

View File

@@ -12,11 +12,9 @@ import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import org.thoughtcrime.securesms.exporter.flow.SmsExportActivity
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.util.CommunicationActions
import org.thoughtcrime.securesms.util.DateUtils
import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme
import org.thoughtcrime.securesms.util.DynamicTheme
import org.thoughtcrime.securesms.util.visible
import java.util.Locale
class SmsExportMegaphoneActivity : PassphraseRequiredActivity() {
@@ -55,8 +53,7 @@ class SmsExportMegaphoneActivity : PassphraseRequiredActivity() {
binding.laterButton.visible = false
binding.bullet1Text.setText(R.string.SmsRemoval_info_bullet_1_phase_3)
} else {
val phase3Start = DateUtils.formatDateWithMonthAndDay(Locale.getDefault(), SignalStore.misc().smsPhase3Start)
binding.bullet1Text.text = getString(R.string.SmsRemoval_info_bullet_1_s, phase3Start)
binding.bullet1Text.text = getString(R.string.SmsRemoval_info_bullet_1)
binding.headline.setText(R.string.SmsExportMegaphoneActivity__signal_will_no_longer_support_sms)
binding.laterButton.setOnClickListener {

View File

@@ -14,14 +14,12 @@ class SmsExportReminderSchedule(private val context: Context) : MegaphoneSchedul
var showPhase3Megaphone = true
}
private val basicMegaphoneSchedule = RecurringSchedule(3.days.inWholeMilliseconds)
private val fullScreenSchedule = RecurringSchedule(1.days.inWholeMilliseconds)
@WorkerThread
override fun shouldDisplay(seenCount: Int, lastSeen: Long, firstVisible: Long, currentTime: Long): Boolean {
return if (Util.isDefaultSmsProvider(context)) {
when (SignalStore.misc().smsExportPhase) {
SmsExportPhase.PHASE_1 -> basicMegaphoneSchedule.shouldDisplay(seenCount, lastSeen, firstVisible, currentTime)
SmsExportPhase.PHASE_2 -> fullScreenSchedule.shouldDisplay(seenCount, lastSeen, firstVisible, currentTime)
SmsExportPhase.PHASE_3 -> showPhase3Megaphone
}