Skip to content

Commit b9d8868

Browse files
Added a new onboarding megaphone.
1 parent bec0353 commit b9d8868

61 files changed

Lines changed: 1154 additions & 357 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/src/main/java/org/thoughtcrime/securesms/AppInitialization.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public static void onPostBackupRestore(@NonNull Context context) {
5252

5353
ApplicationDependencies.getMegaphoneRepository().onFirstEverAppLaunch();
5454
SignalStore.onFirstEverAppLaunch();
55+
SignalStore.onboarding().clearAll();
5556
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forInstall(BlessedPacks.ZOZO.getPackId(), BlessedPacks.ZOZO.getPackKey(), false));
5657
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forInstall(BlessedPacks.BANDIT.getPackId(), BlessedPacks.BANDIT.getPackKey(), false));
5758
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forReference(BlessedPacks.SWOON_HANDS.getPackId(), BlessedPacks.SWOON_HANDS.getPackKey()));

app/src/main/java/org/thoughtcrime/securesms/components/reminder/DefaultSmsReminder.java

Lines changed: 0 additions & 47 deletions
This file was deleted.

app/src/main/java/org/thoughtcrime/securesms/components/reminder/ShareReminder.java

Lines changed: 0 additions & 45 deletions
This file was deleted.

app/src/main/java/org/thoughtcrime/securesms/conversationlist/ConversationListFragment.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,13 @@
8080
import org.thoughtcrime.securesms.components.SearchToolbar;
8181
import org.thoughtcrime.securesms.components.recyclerview.DeleteItemAnimator;
8282
import org.thoughtcrime.securesms.components.registration.PulsingFloatingActionButton;
83-
import org.thoughtcrime.securesms.components.reminder.DefaultSmsReminder;
8483
import org.thoughtcrime.securesms.components.reminder.DozeReminder;
8584
import org.thoughtcrime.securesms.components.reminder.ExpiredBuildReminder;
8685
import org.thoughtcrime.securesms.components.reminder.OutdatedBuildReminder;
8786
import org.thoughtcrime.securesms.components.reminder.PushRegistrationReminder;
8887
import org.thoughtcrime.securesms.components.reminder.Reminder;
8988
import org.thoughtcrime.securesms.components.reminder.ReminderView;
9089
import org.thoughtcrime.securesms.components.reminder.ServiceOutageReminder;
91-
import org.thoughtcrime.securesms.components.reminder.ShareReminder;
92-
import org.thoughtcrime.securesms.components.reminder.SystemSmsImportReminder;
9390
import org.thoughtcrime.securesms.components.reminder.UnauthorizedReminder;
9491
import org.thoughtcrime.securesms.conversation.ConversationFragment;
9592
import org.thoughtcrime.securesms.conversationlist.model.Conversation;
@@ -103,6 +100,7 @@
103100
import org.thoughtcrime.securesms.events.ReminderUpdateEvent;
104101
import org.thoughtcrime.securesms.insights.InsightsLauncher;
105102
import org.thoughtcrime.securesms.jobs.ServiceOutageDetectionJob;
103+
import org.thoughtcrime.securesms.keyvalue.SignalStore;
106104
import org.thoughtcrime.securesms.lock.v2.CreateKbsPinActivity;
107105
import org.thoughtcrime.securesms.mediasend.MediaSendActivity;
108106
import org.thoughtcrime.securesms.megaphone.Megaphone;
@@ -124,7 +122,6 @@
124122
import org.thoughtcrime.securesms.util.StickyHeaderDecoration;
125123
import org.thoughtcrime.securesms.util.Stopwatch;
126124
import org.thoughtcrime.securesms.util.TextSecurePreferences;
127-
import org.thoughtcrime.securesms.util.Util;
128125
import org.thoughtcrime.securesms.util.ViewUtil;
129126
import org.thoughtcrime.securesms.util.WindowUtil;
130127
import org.thoughtcrime.securesms.util.concurrent.SimpleTask;
@@ -156,12 +153,6 @@ public class ConversationListFragment extends MainFragment implements ActionMode
156153

157154
private static final int MAXIMUM_PINNED_CONVERSATIONS = 4;
158155

159-
private static final int[] EMPTY_IMAGES = new int[] { R.drawable.empty_inbox_1,
160-
R.drawable.empty_inbox_2,
161-
R.drawable.empty_inbox_3,
162-
R.drawable.empty_inbox_4,
163-
R.drawable.empty_inbox_5 };
164-
165156
private ActionMode actionMode;
166157
private RecyclerView list;
167158
private Stub<ReminderView> reminderView;
@@ -613,14 +604,8 @@ private void updateReminders() {
613604
return Optional.of(new ServiceOutageReminder(context));
614605
} else if (OutdatedBuildReminder.isEligible()) {
615606
return Optional.of(new OutdatedBuildReminder(context));
616-
} else if (DefaultSmsReminder.isEligible(context)) {
617-
return Optional.of(new DefaultSmsReminder(this, SMS_ROLE_REQUEST_CODE));
618-
} else if (Util.isDefaultSmsProvider(context) && SystemSmsImportReminder.isEligible(context)) {
619-
return Optional.of((new SystemSmsImportReminder(context)));
620607
} else if (PushRegistrationReminder.isEligible(context)) {
621608
return Optional.of((new PushRegistrationReminder(context)));
622-
} else if (ShareReminder.isEligible(context)) {
623-
return Optional.of(new ShareReminder(context));
624609
} else if (DozeReminder.isEligible(context)) {
625610
return Optional.of(new DozeReminder(context));
626611
} else {
@@ -858,8 +843,8 @@ private void updateEmptyState(boolean isConversationEmpty) {
858843
fab.startPulse(3 * 1000);
859844
cameraFab.startPulse(3 * 1000);
860845

861-
ImageView emptyImage = emptyState.get().findViewById(R.id.empty);
862-
emptyImage.setImageResource(EMPTY_IMAGES[(int) (Math.random() * EMPTY_IMAGES.length)]);
846+
SignalStore.onboarding().setShowNewGroup(true);
847+
SignalStore.onboarding().setShowInviteFriends(true);
863848
} else {
864849
list.setVisibility(View.VISIBLE);
865850
fab.stopPulse();
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package org.thoughtcrime.securesms.keyvalue;
2+
3+
import android.content.Context;
4+
5+
import androidx.annotation.NonNull;
6+
7+
import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter;
8+
import org.thoughtcrime.securesms.util.Util;
9+
10+
public final class OnboardingValues extends SignalStoreValues {
11+
12+
private static final String SHOW_NEW_GROUP = "onboarding.new_group";
13+
private static final String SHOW_INVITE_FRIENDS = "onboarding.invite_friends";
14+
private static final String SHOW_SMS = "onboarding.sms";
15+
16+
OnboardingValues(@NonNull KeyValueStore store) {
17+
super(store);
18+
}
19+
20+
@Override
21+
void onFirstEverAppLaunch() {
22+
putBoolean(SHOW_NEW_GROUP, true);
23+
putBoolean(SHOW_INVITE_FRIENDS, true);
24+
putBoolean(SHOW_SMS, true);
25+
}
26+
27+
public void clearAll() {
28+
setShowNewGroup(false);
29+
setShowInviteFriends(false);
30+
setShowSms(false);
31+
}
32+
33+
public boolean hasOnboarding(@NonNull Context context) {
34+
return shouldShowNewGroup() ||
35+
shouldShowInviteFriends() ||
36+
shouldShowSms(context);
37+
}
38+
39+
public void setShowNewGroup(boolean value) {
40+
putBoolean(SHOW_NEW_GROUP, value);
41+
}
42+
43+
public boolean shouldShowNewGroup() {
44+
return getBoolean(SHOW_NEW_GROUP, false);
45+
}
46+
47+
public void setShowInviteFriends(boolean value) {
48+
putBoolean(SHOW_INVITE_FRIENDS, value);
49+
}
50+
51+
public boolean shouldShowInviteFriends() {
52+
return getBoolean(SHOW_INVITE_FRIENDS, false);
53+
}
54+
55+
public void setShowSms(boolean value) {
56+
putBoolean(SHOW_SMS, value);
57+
}
58+
59+
public boolean shouldShowSms(@NonNull Context context) {
60+
return getBoolean(SHOW_SMS, false) && !Util.isDefaultSmsProvider(context) && PhoneNumberFormatter.getLocalCountryCode() != 91;
61+
}
62+
}

app/src/main/java/org/thoughtcrime/securesms/keyvalue/SignalStore.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public final class SignalStore {
2727
private final SettingsValues settingsValues;
2828
private final CertificateValues certificateValues;
2929
private final PhoneNumberPrivacyValues phoneNumberPrivacyValues;
30+
private final OnboardingValues onboardingValues;
3031

3132
private SignalStore() {
3233
this.store = new KeyValueStore(ApplicationDependencies.getApplication());
@@ -43,6 +44,7 @@ private SignalStore() {
4344
this.settingsValues = new SettingsValues(store);
4445
this.certificateValues = new CertificateValues(store);
4546
this.phoneNumberPrivacyValues = new PhoneNumberPrivacyValues(store);
47+
this.onboardingValues = new OnboardingValues(store);
4648
}
4749

4850
public static void onFirstEverAppLaunch() {
@@ -58,6 +60,7 @@ public static void onFirstEverAppLaunch() {
5860
settings().onFirstEverAppLaunch();
5961
certificateValues().onFirstEverAppLaunch();
6062
phoneNumberPrivacy().onFirstEverAppLaunch();
63+
onboarding().onFirstEverAppLaunch();
6164
}
6265

6366
public static @NonNull KbsValues kbsValues() {
@@ -112,6 +115,10 @@ public static void onFirstEverAppLaunch() {
112115
return INSTANCE.phoneNumberPrivacyValues;
113116
}
114117

118+
public static @NonNull OnboardingValues onboarding() {
119+
return INSTANCE.onboardingValues;
120+
}
121+
115122
public static @NonNull GroupsV2AuthorizationSignalStoreCache groupsV2AuthorizationCache() {
116123
return new GroupsV2AuthorizationSignalStoreCache(getStore());
117124
}

app/src/main/java/org/thoughtcrime/securesms/megaphone/Megaphone.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ enum Style {
200200
/** Specialized style for announcing link previews. */
201201
LINK_PREVIEWS,
202202

203+
/** Specialized style for onboarding. */
204+
ONBOARDING,
205+
203206
/** Basic bottom of the screen megaphone with optional snooze and action buttons. */
204207
BASIC,
205208

app/src/main/java/org/thoughtcrime/securesms/megaphone/MegaphoneViewBuilder.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public class MegaphoneViewBuilder {
2424
return buildReactionsMegaphone(context, megaphone, listener);
2525
case LINK_PREVIEWS:
2626
return buildLinkPreviewsMegaphone(context, megaphone, listener);
27+
case ONBOARDING:
28+
return buildOnboardingMegaphone(context, megaphone, listener);
2729
case POPUP:
2830
return buildPopupMegaphone(context, megaphone, listener);
2931
default:
@@ -58,6 +60,15 @@ public class MegaphoneViewBuilder {
5860
return view;
5961
}
6062

63+
private static @NonNull View buildOnboardingMegaphone(@NonNull Context context,
64+
@NonNull Megaphone megaphone,
65+
@NonNull MegaphoneActionController listener)
66+
{
67+
OnboardingMegaphoneView view = new OnboardingMegaphoneView(context);
68+
view.present(megaphone, listener);
69+
return view;
70+
}
71+
6172
private static @NonNull View buildPopupMegaphone(@NonNull Context context,
6273
@NonNull Megaphone megaphone,
6374
@NonNull MegaphoneActionController listener)

app/src/main/java/org/thoughtcrime/securesms/megaphone/Megaphones.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ private static Map<Event, MegaphoneSchedule> buildDisplayOrder(@NonNull Context
9393
put(Event.RESEARCH, shouldShowResearchMegaphone(context) ? ShowForDurationSchedule.showForDays(7) : NEVER);
9494
put(Event.DONATE, shouldShowDonateMegaphone(context) ? ShowForDurationSchedule.showForDays(7) : NEVER);
9595
put(Event.GROUP_CALLING, shouldShowGroupCallingMegaphone() ? ALWAYS : NEVER);
96+
put(Event.ONBOARDING, shouldShowOnboardingMegaphone(context) ? ALWAYS : NEVER);
9697
}};
9798
}
9899

@@ -116,6 +117,8 @@ private static Map<Event, MegaphoneSchedule> buildDisplayOrder(@NonNull Context
116117
return buildDonateMegaphone(context);
117118
case GROUP_CALLING:
118119
return buildGroupCallingMegaphone(context);
120+
case ONBOARDING:
121+
return buildOnboardingMegaphone();
119122
default:
120123
throw new IllegalArgumentException("Event not handled!");
121124
}
@@ -255,6 +258,12 @@ public void onReminderCompleted(@NonNull String pin, boolean includedFailure) {
255258
.build();
256259
}
257260

261+
private static @NonNull Megaphone buildOnboardingMegaphone() {
262+
return new Megaphone.Builder(Event.ONBOARDING, Megaphone.Style.ONBOARDING)
263+
.setPriority(Megaphone.Priority.DEFAULT)
264+
.build();
265+
}
266+
258267
private static boolean shouldShowMessageRequestsMegaphone() {
259268
return Recipient.self().getProfileName() == ProfileName.EMPTY;
260269
}
@@ -275,6 +284,10 @@ private static boolean shouldShowGroupCallingMegaphone() {
275284
return FeatureFlags.groupCalling();
276285
}
277286

287+
private static boolean shouldShowOnboardingMegaphone(@NonNull Context context) {
288+
return SignalStore.onboarding().hasOnboarding(context);
289+
}
290+
278291
public enum Event {
279292
REACTIONS("reactions"),
280293
PINS_FOR_ALL("pins_for_all"),
@@ -284,7 +297,8 @@ public enum Event {
284297
CLIENT_DEPRECATED("client_deprecated"),
285298
RESEARCH("research"),
286299
DONATE("donate"),
287-
GROUP_CALLING("group_calling");
300+
GROUP_CALLING("group_calling"),
301+
ONBOARDING("onboarding");
288302

289303
private final String key;
290304

0 commit comments

Comments
 (0)