Add megaphone to prompt user to enable backups.

This commit is contained in:
Alex Hart
2025-06-25 11:35:48 -03:00
committed by Cody Henthorne
parent 322a9cd97a
commit 82531630c7
3 changed files with 78 additions and 1 deletions

View File

@@ -42,6 +42,7 @@ import org.thoughtcrime.securesms.storage.StorageSyncHelper;
import org.thoughtcrime.securesms.util.DateUtils; import org.thoughtcrime.securesms.util.DateUtils;
import org.thoughtcrime.securesms.util.RemoteConfig; import org.thoughtcrime.securesms.util.RemoteConfig;
import org.thoughtcrime.securesms.util.ServiceUtil; import org.thoughtcrime.securesms.util.ServiceUtil;
import org.thoughtcrime.securesms.util.VersionTracker;
import org.thoughtcrime.securesms.util.dynamiclanguage.DynamicLanguageContextWrapper; import org.thoughtcrime.securesms.util.dynamiclanguage.DynamicLanguageContextWrapper;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@@ -126,6 +127,7 @@ public final class Megaphones {
// Feature-introduction megaphones should *probably* be added below this divider // Feature-introduction megaphones should *probably* be added below this divider
put(Event.ADD_A_PROFILE_PHOTO, shouldShowAddAProfilePhotoMegaphone(context) ? ALWAYS : NEVER); put(Event.ADD_A_PROFILE_PHOTO, shouldShowAddAProfilePhotoMegaphone(context) ? ALWAYS : NEVER);
put(Event.PNP_LAUNCH, shouldShowPnpLaunchMegaphone() ? ALWAYS : NEVER); put(Event.PNP_LAUNCH, shouldShowPnpLaunchMegaphone() ? ALWAYS : NEVER);
put(Event.TURN_ON_SIGNAL_BACKUPS, shouldShowTurnOnBackupsMegaphone(context) ? ALWAYS : NEVER);
}}; }};
} }
@@ -173,6 +175,8 @@ public final class Megaphones {
return buildNewLinkedDeviceMegaphone(context); return buildNewLinkedDeviceMegaphone(context);
case UPDATE_PIN_AFTER_AEP_REGISTRATION: case UPDATE_PIN_AFTER_AEP_REGISTRATION:
return buildUpdatePinAfterAepRegistrationMegaphone(); return buildUpdatePinAfterAepRegistrationMegaphone();
case TURN_ON_SIGNAL_BACKUPS:
return buildTurnOnSignalBackupsMegaphone();
default: default:
throw new IllegalArgumentException("Event not handled!"); throw new IllegalArgumentException("Event not handled!");
} }
@@ -453,6 +457,23 @@ public final class Megaphones {
.build(); .build();
} }
public static @NonNull Megaphone buildTurnOnSignalBackupsMegaphone() {
return new Megaphone.Builder(Event.TURN_ON_SIGNAL_BACKUPS, Megaphone.Style.BASIC)
.setImage(R.drawable.backups_megaphone_image)
.setTitle(R.string.TurnOnSignalBackups__title)
.setBody(R.string.TurnOnSignalBackups__body)
.setActionButton(R.string.TurnOnSignalBackups__turn_on, (megaphone, controller) -> {
Intent intent = AppSettingsActivity.remoteBackups(controller.getMegaphoneActivity());
controller.onMegaphoneNavigationRequested(intent);
controller.onMegaphoneCompleted(Event.TURN_ON_SIGNAL_BACKUPS);
})
.setSecondaryButton(R.string.TurnOnSignalBackups__not_now, (megaphone, controller) -> {
controller.onMegaphoneCompleted(Event.TURN_ON_SIGNAL_BACKUPS);
})
.build();
}
private static boolean shouldShowOnboardingMegaphone(@NonNull Context context) { private static boolean shouldShowOnboardingMegaphone(@NonNull Context context) {
return SignalStore.onboarding().hasOnboarding(context); return SignalStore.onboarding().hasOnboarding(context);
} }
@@ -520,6 +541,14 @@ public final class Megaphones {
return TextUtils.isEmpty(SignalStore.account().getUsername()) && !SignalStore.uiHints().hasCompletedUsernameOnboarding(); return TextUtils.isEmpty(SignalStore.account().getUsername()) && !SignalStore.uiHints().hasCompletedUsernameOnboarding();
} }
private static boolean shouldShowTurnOnBackupsMegaphone(@NonNull Context context) {
if (!RemoteConfig.messageBackups() || SignalStore.backup().getLatestBackupTier() != null) {
return false;
}
return VersionTracker.getDaysSinceFirstInstalled(context) > 7;
}
private static boolean shouldShowGrantFullScreenIntentPermission(@NonNull Context context) { private static boolean shouldShowGrantFullScreenIntentPermission(@NonNull Context context) {
return Build.VERSION.SDK_INT >= 34 && !NotificationManagerCompat.from(context).canUseFullScreenIntent(); return Build.VERSION.SDK_INT >= 34 && !NotificationManagerCompat.from(context).canUseFullScreenIntent();
} }
@@ -569,7 +598,8 @@ public final class Megaphones {
PNP_LAUNCH("pnp_launch"), PNP_LAUNCH("pnp_launch"),
GRANT_FULL_SCREEN_INTENT("grant_full_screen_intent"), GRANT_FULL_SCREEN_INTENT("grant_full_screen_intent"),
NEW_LINKED_DEVICE("new_linked_device"), NEW_LINKED_DEVICE("new_linked_device"),
UPDATE_PIN_AFTER_AEP_REGISTRATION("update_pin_after_registration"); UPDATE_PIN_AFTER_AEP_REGISTRATION("update_pin_after_registration"),
TURN_ON_SIGNAL_BACKUPS("turn_on_signal_backups");
private final String key; private final String key;

View File

@@ -0,0 +1,38 @@
<!--
~ Copyright 2025 Signal Messenger, LLC
~ SPDX-License-Identifier: AGPL-3.0-only
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="64dp"
android:height="64dp"
android:viewportWidth="64"
android:viewportHeight="64">
<path
android:pathData="M53.594,48.333C54.337,48.974 54.419,50.097 53.778,50.84V50.84C50.027,55.182 44.944,58.45 38.955,59.941C32.967,61.432 26.944,60.928 21.596,58.851V58.851C20.681,58.495 20.227,57.465 20.583,56.55V56.55C20.938,55.635 21.968,55.182 22.883,55.537V55.537C27.57,57.357 32.843,57.799 38.097,56.492C43.35,55.184 47.801,52.321 51.087,48.516V48.516C51.729,47.773 52.851,47.691 53.594,48.333V48.333Z"
android:fillColor="#A0A7FE"
android:fillType="evenOdd"/>
<path
android:pathData="M32,54.04C27.878,54.04 24.02,52.908 20.72,50.939V47.278C20.72,44.922 18.81,43.012 16.454,43.012C15.351,43.012 14.345,43.431 13.588,44.119C11.295,40.642 9.96,36.477 9.96,32C9.96,19.828 19.828,9.961 32,9.961C44.172,9.961 54.039,19.828 54.039,32C54.039,44.172 44.172,54.04 32,54.04Z"
android:fillColor="#D2D8FE"
android:fillType="evenOdd"/>
<path
android:pathData="M29.226,20.607L28.743,37.754C28.742,37.787 28.741,37.82 28.741,37.854C28.741,39.006 29.617,39.939 30.696,39.939C30.74,39.939 30.783,39.938 30.826,39.935L42.319,39.424C43.108,39.389 43.73,38.696 43.73,37.854C43.73,37.011 43.108,36.319 42.319,36.284L32.596,35.851L32.167,20.607C32.143,19.759 31.492,19.084 30.696,19.084C29.901,19.084 29.25,19.759 29.226,20.607Z"
android:fillColor="#3C46FE"/>
<path
android:pathData="M50.84,10.222C55.182,13.973 58.45,19.056 59.941,25.045C61.432,31.033 60.928,37.056 58.851,42.404V42.404C58.495,43.319 57.465,43.773 56.55,43.417V43.417C55.635,43.062 55.182,42.032 55.537,41.117V41.117C57.357,36.43 57.799,31.157 56.492,25.903C55.184,20.65 52.321,16.199 48.516,12.913V12.913C47.773,12.271 47.691,11.149 48.333,10.406V10.406C48.974,9.663 50.097,9.581 50.84,10.222V10.222Z"
android:fillColor="#3B45FD"
android:fillType="evenOdd"/>
<path
android:pathData="M43.417,7.45C43.062,8.365 42.032,8.818 41.117,8.463V8.463C36.43,6.642 31.157,6.201 25.903,7.509C20.65,8.816 16.199,11.679 12.913,15.484V15.484C12.271,16.227 11.149,16.309 10.406,15.667V15.667C9.663,15.026 9.581,13.903 10.222,13.16V13.16C13.973,8.818 19.056,5.55 25.045,4.059C31.033,2.568 37.056,3.072 42.404,5.149V5.149C43.319,5.505 43.773,6.535 43.417,7.45V7.45Z"
android:fillColor="#A0A7FE"
android:fillType="evenOdd"/>
<path
android:pathData="M16.359,45.567C17.144,45.567 17.781,46.204 17.781,46.989V53.506C17.781,54.292 17.144,54.928 16.359,54.928H9.19C8.405,54.928 7.768,54.292 7.768,53.506C7.768,52.721 8.405,52.084 9.19,52.084H14.937V46.989C14.937,46.204 15.573,45.567 16.359,45.567Z"
android:fillColor="#3B45FD"
android:fillType="evenOdd"/>
<path
android:pathData="M7.45,20.583C8.365,20.938 8.818,21.968 8.463,22.883C6.643,27.57 6.201,32.843 7.509,38.097C8.816,43.35 11.679,47.801 15.484,51.087L16.829,52.249L14.505,54.939L13.16,53.778C8.818,50.027 5.55,44.944 4.059,38.955C2.568,32.967 3.072,26.944 5.149,21.596C5.505,20.681 6.535,20.227 7.45,20.583Z"
android:fillColor="#3B45FD"
android:fillType="evenOdd"/>
</vector>

View File

@@ -7725,6 +7725,15 @@
<!-- Button text to deny all participants from joining the call --> <!-- Button text to deny all participants from joining the call -->
<string name="PendingParticipantsBottomSheet__deny_all">Deny all</string> <string name="PendingParticipantsBottomSheet__deny_all">Deny all</string>
<!-- Title of a megaphone shown at the bottom of the chat list to prompt the user to enable message backups -->
<string name="TurnOnSignalBackups__title">Turn on Signal Backups</string>
<!-- Body of a megaphone shown at the bottom of the chat list to prompt the user to enable message backups -->
<string name="TurnOnSignalBackups__body">Never lose a message when you get a new phone or reinstall Signal.</string>
<!-- Button of a megaphone shown at the bottom of the chat list to prompt the user to enable message backups that will take the user to the flow to enable backups -->
<string name="TurnOnSignalBackups__turn_on">Turn on</string>
<!-- Button of a megaphone shown at the bottom of the chat list to prompt the user to enable message backups that will simply dismiss the megaphone -->
<string name="TurnOnSignalBackups__not_now">Not now</string>
<!-- Title of a megaphone shown at the bottom of the chat list when a user has disable the system setting for showing full screen notifications used showing incoming calls --> <!-- Title of a megaphone shown at the bottom of the chat list when a user has disable the system setting for showing full screen notifications used showing incoming calls -->
<string name="GrantFullScreenIntentPermission_megaphone_title">Turn on full screen notifications?</string> <string name="GrantFullScreenIntentPermission_megaphone_title">Turn on full screen notifications?</string>
<!-- Body of a megaphone shown at the bottom of the chat list when a user has disable the system setting for showing full screen notifications used showing incoming calls --> <!-- Body of a megaphone shown at the bottom of the chat list when a user has disable the system setting for showing full screen notifications used showing incoming calls -->