From a103c7dcb612bb663d6d41428e4ba8f4b89119d5 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Wed, 7 Oct 2020 13:35:31 -0400 Subject: [PATCH] Apply storage service values for phone number privacy. --- .../securesms/storage/StorageSyncHelper.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/main/java/org/thoughtcrime/securesms/storage/StorageSyncHelper.java b/app/src/main/java/org/thoughtcrime/securesms/storage/StorageSyncHelper.java index eeac3087d..ca7cb5687 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/storage/StorageSyncHelper.java +++ b/app/src/main/java/org/thoughtcrime/securesms/storage/StorageSyncHelper.java @@ -440,6 +440,15 @@ public final class StorageSyncHelper { } } + private static PhoneNumberPrivacyValues.PhoneNumberSharingMode remoteToLocalPhoneNumberSharingMode(AccountRecord.PhoneNumberSharingMode phoneNumberPhoneNumberSharingMode) { + switch (phoneNumberPhoneNumberSharingMode) { + case EVERYBODY : return PhoneNumberPrivacyValues.PhoneNumberSharingMode.EVERYONE; + case CONTACTS_ONLY: return PhoneNumberPrivacyValues.PhoneNumberSharingMode.CONTACTS; + case NOBODY : return PhoneNumberPrivacyValues.PhoneNumberSharingMode.NOBODY; + default : return PhoneNumberPrivacyValues.PhoneNumberSharingMode.CONTACTS; + } + } + public static void applyAccountStorageSyncUpdates(@NonNull Context context, Optional> update) { if (!update.isPresent()) { return; @@ -454,6 +463,8 @@ public final class StorageSyncHelper { TextSecurePreferences.setTypingIndicatorsEnabled(context, update.isTypingIndicatorsEnabled()); TextSecurePreferences.setShowUnidentifiedDeliveryIndicatorsEnabled(context, update.isSealedSenderIndicatorsEnabled()); SignalStore.settings().setLinkPreviewsEnabled(update.isLinkPreviewsEnabled()); + SignalStore.phoneNumberPrivacy().setPhoneNumberListingMode(update.isPhoneNumberUnlisted() ? PhoneNumberPrivacyValues.PhoneNumberListingMode.UNLISTED : PhoneNumberPrivacyValues.PhoneNumberListingMode.LISTED); + SignalStore.phoneNumberPrivacy().setPhoneNumberSharingMode(remoteToLocalPhoneNumberSharingMode(update.getPhoneNumberSharingMode())); if (fetchProfile && update.getAvatarUrlPath().isPresent()) { ApplicationDependencies.getJobManager().add(new RetrieveProfileAvatarJob(Recipient.self(), update.getAvatarUrlPath().get()));