Sync the 'hasCompletedUsernameOnboarding' flag.
This commit is contained in:
parent
ce09e9a217
commit
252aa3714e
6 changed files with 39 additions and 20 deletions
|
@ -716,13 +716,6 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
|||
}
|
||||
)
|
||||
|
||||
clickPref(
|
||||
title = DSLSettingsText.from("Clear Username education ui hint"),
|
||||
onClick = {
|
||||
SignalStore.uiHints().clearHasSeenUsernameEducation()
|
||||
}
|
||||
)
|
||||
|
||||
clickPref(
|
||||
title = DSLSettingsText.from("Corrupt username"),
|
||||
summary = DSLSettingsText.from("Changes our local username without telling the server so it falls out of sync. Refresh profile afterwards to trigger corruption."),
|
||||
|
|
|
@ -14,7 +14,6 @@ public class UiHints extends SignalStoreValues {
|
|||
private static final String HAS_SET_OR_SKIPPED_USERNAME_CREATION = "uihints.has_set_or_skipped_username_creation";
|
||||
private static final String NEVER_DISPLAY_PULL_TO_FILTER_TIP = "uihints.never_display_pull_to_filter_tip";
|
||||
private static final String HAS_SEEN_SCHEDULED_MESSAGES_INFO_ONCE = "uihints.has_seen_scheduled_messages_info_once";
|
||||
private static final String HAS_SEEN_USERNAME_EDUCATION = "uihints.has_seen_username_education";
|
||||
private static final String HAS_SEEN_TEXT_FORMATTING_ALERT = "uihints.text_formatting.has_seen_alert";
|
||||
private static final String HAS_NOT_SEEN_EDIT_MESSAGE_BETA_ALERT = "uihints.edit_message.has_not_seen_beta_alert";
|
||||
private static final String HAS_SEEN_SAFETY_NUMBER_NUX = "uihints.has_seen_safety_number_nux";
|
||||
|
@ -23,6 +22,7 @@ public class UiHints extends SignalStoreValues {
|
|||
private static final String DISMISSED_BATTERY_SAVER_PROMPT = "uihints.declined_battery_saver_prompt";
|
||||
private static final String LAST_BATTERY_SAVER_PROMPT = "uihints.last_battery_saver_prompt";
|
||||
private static final String LAST_CRASH_PROMPT = "uihints.last_crash_prompt";
|
||||
private static final String HAS_COMPLETED_USERNAME_ONBOARDING = "uihints.has_completed_username_onboarding";
|
||||
|
||||
UiHints(@NonNull KeyValueStore store) {
|
||||
super(store);
|
||||
|
@ -35,7 +35,7 @@ public class UiHints extends SignalStoreValues {
|
|||
|
||||
@Override
|
||||
@NonNull List<String> getKeysToIncludeInBackup() {
|
||||
return Arrays.asList(NEVER_DISPLAY_PULL_TO_FILTER_TIP, HAS_SEEN_USERNAME_EDUCATION, HAS_SEEN_TEXT_FORMATTING_ALERT);
|
||||
return Arrays.asList(NEVER_DISPLAY_PULL_TO_FILTER_TIP, HAS_COMPLETED_USERNAME_ONBOARDING, HAS_SEEN_TEXT_FORMATTING_ALERT);
|
||||
}
|
||||
|
||||
public void markHasSeenGroupSettingsMenuToast() {
|
||||
|
@ -70,19 +70,14 @@ public class UiHints extends SignalStoreValues {
|
|||
putBoolean(HAS_SET_OR_SKIPPED_USERNAME_CREATION, true);
|
||||
}
|
||||
|
||||
public void markHasSeenUsernameEducation() {
|
||||
putBoolean(HAS_SEEN_USERNAME_EDUCATION, true);
|
||||
public void setHasCompletedUsernameOnboarding(boolean value) {
|
||||
putBoolean(HAS_COMPLETED_USERNAME_ONBOARDING, value);
|
||||
}
|
||||
|
||||
public boolean hasSeenUsernameEducation() {
|
||||
return getBoolean(HAS_SEEN_USERNAME_EDUCATION, false);
|
||||
public boolean hasCompletedUsernameOnboarding() {
|
||||
return getBoolean(HAS_COMPLETED_USERNAME_ONBOARDING, false);
|
||||
}
|
||||
|
||||
public void clearHasSeenUsernameEducation() {
|
||||
putBoolean(HAS_SEEN_USERNAME_EDUCATION, false);
|
||||
}
|
||||
|
||||
|
||||
public void resetNeverDisplayPullToRefreshCount() {
|
||||
putInteger(NEVER_DISPLAY_PULL_TO_FILTER_TIP, 0);
|
||||
}
|
||||
|
|
|
@ -14,12 +14,14 @@ import androidx.core.app.NotificationManagerCompat;
|
|||
import com.annimon.stream.Stream;
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.signal.core.util.MapUtil;
|
||||
import org.signal.core.util.SetUtil;
|
||||
import org.signal.core.util.TranslationDetection;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.components.settings.app.AppSettingsActivity;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.MegaphoneRecord;
|
||||
import org.thoughtcrime.securesms.database.model.RemoteMegaphoneRecord;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
|
@ -37,6 +39,7 @@ import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
|||
import org.thoughtcrime.securesms.profiles.manage.EditProfileActivity;
|
||||
import org.thoughtcrime.securesms.profiles.username.NewWaysToConnectDialogFragment;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||
import org.thoughtcrime.securesms.util.dynamiclanguage.DynamicLanguageContextWrapper;
|
||||
|
@ -342,9 +345,18 @@ public final class Megaphones {
|
|||
.setImage(R.drawable.usernames_megaphone)
|
||||
.setActionButton(R.string.PnpLaunchMegaphone_learn_more, (megaphone, controller) -> {
|
||||
controller.onMegaphoneDialogFragmentRequested(new NewWaysToConnectDialogFragment());
|
||||
controller.onMegaphoneCompleted(Event.PNP_LAUNCH);
|
||||
|
||||
SignalStore.uiHints().setHasCompletedUsernameOnboarding(true);
|
||||
SignalDatabase.recipients().markNeedsSync(Recipient.self().getId());
|
||||
StorageSyncHelper.scheduleSyncForDataChange();
|
||||
})
|
||||
.setSecondaryButton(R.string.PnpLaunchMegaphone_dismiss, (megaphone, controller) -> {
|
||||
controller.onMegaphoneCompleted(Event.PNP_LAUNCH);
|
||||
|
||||
SignalStore.uiHints().setHasCompletedUsernameOnboarding(true);
|
||||
SignalDatabase.recipients().markNeedsSync(Recipient.self().getId());
|
||||
StorageSyncHelper.scheduleSyncForDataChange();
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
@ -423,7 +435,7 @@ public final class Megaphones {
|
|||
}
|
||||
|
||||
private static boolean shouldShowPnpLaunchMegaphone() {
|
||||
return TextUtils.isEmpty(SignalStore.account().getUsername());
|
||||
return TextUtils.isEmpty(SignalStore.account().getUsername()) && !SignalStore.uiHints().hasCompletedUsernameOnboarding();
|
||||
}
|
||||
|
||||
private static boolean shouldShowGrantFullScreenIntentPermission(@NonNull Context context) {
|
||||
|
|
|
@ -125,6 +125,7 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
|||
boolean hasViewedOnboardingStory = remote.hasViewedOnboardingStory() || local.hasViewedOnboardingStory();
|
||||
boolean storiesDisabled = remote.isStoriesDisabled();
|
||||
boolean hasSeenGroupStoryEducation = remote.hasSeenGroupStoryEducationSheet() || local.hasSeenGroupStoryEducationSheet();
|
||||
boolean hasSeenUsernameOnboarding = remote.hasCompletedUsernameOnboarding() || local.hasCompletedUsernameOnboarding();
|
||||
String username = remote.getUsername();
|
||||
AccountRecord.UsernameLink usernameLink = remote.getUsernameLink();
|
||||
boolean matchesRemote = doParamsMatch(remote, unknownFields, givenName, familyName, avatarUrlPath, profileKey, noteToSelfArchived, noteToSelfForcedUnread, readReceipts, typingIndicators, sealedSenderIndicators, linkPreviews, phoneNumberSharingMode, unlisted, pinnedConversations, preferContactAvatars, payments, universalExpireTimer, primarySendsSms, e164, defaultReactions, subscriber, displayBadgesOnProfile, subscriptionManuallyCancelled, keepMutedChatsArchived, hasSetMyStoriesPrivacy, hasViewedOnboardingStory, storiesDisabled, storyViewReceiptsState, username, usernameLink);
|
||||
|
@ -163,6 +164,7 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
|||
.setHasViewedOnboardingStory(hasViewedOnboardingStory)
|
||||
.setStoriesDisabled(storiesDisabled)
|
||||
.setHasSeenGroupStoryEducationSheet(hasSeenGroupStoryEducation)
|
||||
.setHasCompletedUsernameOnboarding(hasSeenUsernameOnboarding)
|
||||
.setUsername(username)
|
||||
.setUsernameLink(usernameLink);
|
||||
|
||||
|
@ -216,6 +218,7 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
|||
boolean keepMutedChatsArchived,
|
||||
boolean hasSetMyStoriesPrivacy,
|
||||
boolean hasViewedOnboardingStory,
|
||||
boolean hasCompletedUsernameOnboarding,
|
||||
boolean storiesDisabled,
|
||||
@NonNull OptionalBool storyViewReceiptsState,
|
||||
@Nullable String username,
|
||||
|
@ -247,6 +250,7 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
|||
contact.isKeepMutedChatsArchived() == keepMutedChatsArchived &&
|
||||
contact.hasSetMyStoriesPrivacy() == hasSetMyStoriesPrivacy &&
|
||||
contact.hasViewedOnboardingStory() == hasViewedOnboardingStory &&
|
||||
contact.hasCompletedUsernameOnboarding() == hasCompletedUsernameOnboarding &&
|
||||
contact.isStoriesDisabled() == storiesDisabled &&
|
||||
contact.getStoryViewReceiptsState().equals(storyViewReceiptsState) &&
|
||||
Objects.equals(contact.getUsername(), username) &&
|
||||
|
|
|
@ -165,7 +165,8 @@ public final class StorageSyncHelper {
|
|||
.setStoriesDisabled(SignalStore.storyValues().isFeatureDisabled())
|
||||
.setStoryViewReceiptsState(storyViewReceiptsState)
|
||||
.setHasSeenGroupStoryEducationSheet(SignalStore.storyValues().getUserHasSeenGroupStoryEducationSheet())
|
||||
.setUsername(SignalStore.account().getUsername());
|
||||
.setUsername(SignalStore.account().getUsername())
|
||||
.setHasCompletedUsernameOnboarding(SignalStore.uiHints().hasCompletedUsernameOnboarding());
|
||||
|
||||
if (!self.getPnpCapability().isSupported()) {
|
||||
account.setE164(self.requireE164());
|
||||
|
@ -209,6 +210,7 @@ public final class StorageSyncHelper {
|
|||
SignalStore.storyValues().setUserHasViewedOnboardingStory(update.getNew().hasViewedOnboardingStory());
|
||||
SignalStore.storyValues().setFeatureDisabled(update.getNew().isStoriesDisabled());
|
||||
SignalStore.storyValues().setUserHasSeenGroupStoryEducationSheet(update.getNew().hasSeenGroupStoryEducationSheet());
|
||||
SignalStore.uiHints().setHasCompletedUsernameOnboarding(update.getNew().hasCompletedUsernameOnboarding());
|
||||
|
||||
if (update.getNew().getStoryViewReceiptsState() == OptionalBool.UNSET) {
|
||||
SignalStore.storyValues().setViewedReceiptsEnabled(update.getNew().isReadReceiptsEnabled());
|
||||
|
|
|
@ -203,6 +203,10 @@ public final class SignalAccountRecord implements SignalRecord {
|
|||
diff.add("Username");
|
||||
}
|
||||
|
||||
if (hasCompletedUsernameOnboarding() != that.hasCompletedUsernameOnboarding()) {
|
||||
diff.add("HasCompletedUsernameOnboarding");
|
||||
}
|
||||
|
||||
return diff.toString();
|
||||
} else {
|
||||
return "Different class. " + getClass().getSimpleName() + " | " + other.getClass().getSimpleName();
|
||||
|
@ -329,6 +333,10 @@ public final class SignalAccountRecord implements SignalRecord {
|
|||
return proto.hasSeenGroupStoryEducationSheet;
|
||||
}
|
||||
|
||||
public boolean hasCompletedUsernameOnboarding() {
|
||||
return proto.hasCompletedUsernameOnboarding;
|
||||
}
|
||||
|
||||
public @Nullable String getUsername() {
|
||||
return proto.username;
|
||||
}
|
||||
|
@ -698,6 +706,11 @@ public final class SignalAccountRecord implements SignalRecord {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder setHasCompletedUsernameOnboarding(boolean hasCompletedUsernameOnboarding) {
|
||||
builder.hasCompletedUsernameOnboarding(hasCompletedUsernameOnboarding);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setUsername(@Nullable String username) {
|
||||
if (username == null || username.isEmpty()) {
|
||||
builder.username(StorageRecordProtoUtil.getDefaultAccountRecord().username);
|
||||
|
|
Loading…
Add table
Reference in a new issue