mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-24 19:00:26 +01:00
Added a new onboarding megaphone.
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package org.thoughtcrime.securesms.keyvalue;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
public final class OnboardingValues extends SignalStoreValues {
|
||||
|
||||
private static final String SHOW_NEW_GROUP = "onboarding.new_group";
|
||||
private static final String SHOW_INVITE_FRIENDS = "onboarding.invite_friends";
|
||||
private static final String SHOW_SMS = "onboarding.sms";
|
||||
|
||||
OnboardingValues(@NonNull KeyValueStore store) {
|
||||
super(store);
|
||||
}
|
||||
|
||||
@Override
|
||||
void onFirstEverAppLaunch() {
|
||||
putBoolean(SHOW_NEW_GROUP, true);
|
||||
putBoolean(SHOW_INVITE_FRIENDS, true);
|
||||
putBoolean(SHOW_SMS, true);
|
||||
}
|
||||
|
||||
public void clearAll() {
|
||||
setShowNewGroup(false);
|
||||
setShowInviteFriends(false);
|
||||
setShowSms(false);
|
||||
}
|
||||
|
||||
public boolean hasOnboarding(@NonNull Context context) {
|
||||
return shouldShowNewGroup() ||
|
||||
shouldShowInviteFriends() ||
|
||||
shouldShowSms(context);
|
||||
}
|
||||
|
||||
public void setShowNewGroup(boolean value) {
|
||||
putBoolean(SHOW_NEW_GROUP, value);
|
||||
}
|
||||
|
||||
public boolean shouldShowNewGroup() {
|
||||
return getBoolean(SHOW_NEW_GROUP, false);
|
||||
}
|
||||
|
||||
public void setShowInviteFriends(boolean value) {
|
||||
putBoolean(SHOW_INVITE_FRIENDS, value);
|
||||
}
|
||||
|
||||
public boolean shouldShowInviteFriends() {
|
||||
return getBoolean(SHOW_INVITE_FRIENDS, false);
|
||||
}
|
||||
|
||||
public void setShowSms(boolean value) {
|
||||
putBoolean(SHOW_SMS, value);
|
||||
}
|
||||
|
||||
public boolean shouldShowSms(@NonNull Context context) {
|
||||
return getBoolean(SHOW_SMS, false) && !Util.isDefaultSmsProvider(context) && PhoneNumberFormatter.getLocalCountryCode() != 91;
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ public final class SignalStore {
|
||||
private final SettingsValues settingsValues;
|
||||
private final CertificateValues certificateValues;
|
||||
private final PhoneNumberPrivacyValues phoneNumberPrivacyValues;
|
||||
private final OnboardingValues onboardingValues;
|
||||
|
||||
private SignalStore() {
|
||||
this.store = new KeyValueStore(ApplicationDependencies.getApplication());
|
||||
@@ -43,6 +44,7 @@ public final class SignalStore {
|
||||
this.settingsValues = new SettingsValues(store);
|
||||
this.certificateValues = new CertificateValues(store);
|
||||
this.phoneNumberPrivacyValues = new PhoneNumberPrivacyValues(store);
|
||||
this.onboardingValues = new OnboardingValues(store);
|
||||
}
|
||||
|
||||
public static void onFirstEverAppLaunch() {
|
||||
@@ -58,6 +60,7 @@ public final class SignalStore {
|
||||
settings().onFirstEverAppLaunch();
|
||||
certificateValues().onFirstEverAppLaunch();
|
||||
phoneNumberPrivacy().onFirstEverAppLaunch();
|
||||
onboarding().onFirstEverAppLaunch();
|
||||
}
|
||||
|
||||
public static @NonNull KbsValues kbsValues() {
|
||||
@@ -112,6 +115,10 @@ public final class SignalStore {
|
||||
return INSTANCE.phoneNumberPrivacyValues;
|
||||
}
|
||||
|
||||
public static @NonNull OnboardingValues onboarding() {
|
||||
return INSTANCE.onboardingValues;
|
||||
}
|
||||
|
||||
public static @NonNull GroupsV2AuthorizationSignalStoreCache groupsV2AuthorizationCache() {
|
||||
return new GroupsV2AuthorizationSignalStoreCache(getStore());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user