kopia lustrzana https://github.com/ryukoposting/Signal-Android
Add new story-based AccountRecord fields and wiring.
rodzic
b5300c877c
commit
4882a4d11c
|
@ -7,6 +7,7 @@ import org.signal.ringrtc.CallManager
|
|||
import org.thoughtcrime.securesms.jobs.StoryOnboardingDownloadJob
|
||||
import org.thoughtcrime.securesms.keyvalue.InternalValues
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.stories.Stories
|
||||
import org.thoughtcrime.securesms.util.livedata.Store
|
||||
|
||||
|
@ -130,6 +131,7 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
|
|||
fun onClearOnboardingState() {
|
||||
SignalStore.storyValues().hasDownloadedOnboardingStory = false
|
||||
SignalStore.storyValues().userHasSeenOnboardingStory = false
|
||||
Stories.onStorySettingsChanged(Recipient.self().id)
|
||||
refresh()
|
||||
StoryOnboardingDownloadJob.enqueueIfNeeded()
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ public final class SettingsValues extends SignalStoreValues {
|
|||
private static final String UNIVERSAL_EXPIRE_TIMER = "settings.universal.expire.timer";
|
||||
private static final String SENT_MEDIA_QUALITY = "settings.sentMediaQuality";
|
||||
private static final String CENSORSHIP_CIRCUMVENTION_ENABLED = "settings.censorshipCircumventionEnabled";
|
||||
private static final String KEEP_MUTED_CHATS_ARCHIVED = "settings.keepMutedChatsArchived";
|
||||
|
||||
private final SingleLiveEvent<String> onConfigurationSettingChanged = new SingleLiveEvent<>();
|
||||
|
||||
|
@ -111,7 +112,8 @@ public final class SettingsValues extends SignalStoreValues {
|
|||
CALL_VIBRATE_ENABLED,
|
||||
NOTIFY_WHEN_CONTACT_JOINS_SIGNAL,
|
||||
UNIVERSAL_EXPIRE_TIMER,
|
||||
SENT_MEDIA_QUALITY);
|
||||
SENT_MEDIA_QUALITY,
|
||||
KEEP_MUTED_CHATS_ARCHIVED);
|
||||
}
|
||||
|
||||
public @NonNull LiveData<String> getOnConfigurationSettingChanged() {
|
||||
|
@ -430,6 +432,14 @@ public final class SettingsValues extends SignalStoreValues {
|
|||
putInteger(CENSORSHIP_CIRCUMVENTION_ENABLED, enabled ? CensorshipCircumventionEnabled.ENABLED.serialize() : CensorshipCircumventionEnabled.DISABLED.serialize());
|
||||
}
|
||||
|
||||
public void setKeepMutedChatsArchived(boolean enabled) {
|
||||
putBoolean(KEEP_MUTED_CHATS_ARCHIVED, enabled);
|
||||
}
|
||||
|
||||
public boolean shouldKeepMutedChatsArchived() {
|
||||
return getBoolean(KEEP_MUTED_CHATS_ARCHIVED, false);
|
||||
}
|
||||
|
||||
private @Nullable Uri getUri(@NonNull String key) {
|
||||
String uri = getString(key, "");
|
||||
|
||||
|
|
|
@ -111,8 +111,12 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
|||
List<String> defaultReactions = remote.getDefaultReactions().size() > 0 ? remote.getDefaultReactions() : local.getDefaultReactions();
|
||||
boolean displayBadgesOnProfile = remote.isDisplayBadgesOnProfile();
|
||||
boolean subscriptionManuallyCancelled = remote.isSubscriptionManuallyCancelled();
|
||||
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);
|
||||
boolean matchesLocal = doParamsMatch(local, unknownFields, givenName, familyName, avatarUrlPath, profileKey, noteToSelfArchived, noteToSelfForcedUnread, readReceipts, typingIndicators, sealedSenderIndicators, linkPreviews, phoneNumberSharingMode, unlisted, pinnedConversations, preferContactAvatars, payments, universalExpireTimer, primarySendsSms, e164, defaultReactions, subscriber, displayBadgesOnProfile, subscriptionManuallyCancelled);
|
||||
boolean keepMutedChatsArchived = remote.isKeepMutedChatsArchived();
|
||||
boolean hasSetMyStoriesPrivacy = remote.hasSetMyStoriesPrivacy();
|
||||
boolean hasViewedOnboardingStory = remote.hasViewedOnboardingStory();
|
||||
boolean storiesDisabled = remote.isStoriesDisabled();
|
||||
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);
|
||||
boolean matchesLocal = doParamsMatch(local, 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);
|
||||
|
||||
if (matchesRemote) {
|
||||
return remote;
|
||||
|
@ -143,6 +147,10 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
|||
.setSubscriber(subscriber)
|
||||
.setDisplayBadgesOnProfile(displayBadgesOnProfile)
|
||||
.setSubscriptionManuallyCancelled(subscriptionManuallyCancelled)
|
||||
.setKeepMutedChatsArchived(keepMutedChatsArchived)
|
||||
.setHasSetMyStoriesPrivacy(hasSetMyStoriesPrivacy)
|
||||
.setHasViewedOnboardingStory(hasViewedOnboardingStory)
|
||||
.setStoriesDisabled(storiesDisabled)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +193,11 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
|||
@NonNull List <String> defaultReactions,
|
||||
@NonNull SignalAccountRecord.Subscriber subscriber,
|
||||
boolean displayBadgesOnProfile,
|
||||
boolean subscriptionManuallyCancelled)
|
||||
boolean subscriptionManuallyCancelled,
|
||||
boolean keepMutedChatsArchived,
|
||||
boolean hasSetMyStoriesPrivacy,
|
||||
boolean hasViewedOnboardingStory,
|
||||
boolean storiesDisabled)
|
||||
{
|
||||
return Arrays.equals(contact.serializeUnknownFields(), unknownFields) &&
|
||||
Objects.equals(contact.getGivenName().orElse(""), givenName) &&
|
||||
|
@ -209,6 +221,10 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
|||
Objects.equals(contact.getPinnedConversations(), pinnedConversations) &&
|
||||
Objects.equals(contact.getSubscriber(), subscriber) &&
|
||||
contact.isDisplayBadgesOnProfile() == displayBadgesOnProfile &&
|
||||
contact.isSubscriptionManuallyCancelled() == subscriptionManuallyCancelled;
|
||||
contact.isSubscriptionManuallyCancelled() == subscriptionManuallyCancelled &&
|
||||
contact.isKeepMutedChatsArchived() == keepMutedChatsArchived &&
|
||||
contact.hasSetMyStoriesPrivacy() == hasSetMyStoriesPrivacy &&
|
||||
contact.hasViewedOnboardingStory() == hasViewedOnboardingStory &&
|
||||
contact.isStoriesDisabled() == storiesDisabled;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,6 +134,10 @@ public final class StorageSyncHelper {
|
|||
.setSubscriber(StorageSyncModels.localToRemoteSubscriber(SignalStore.donationsValues().getSubscriber()))
|
||||
.setDisplayBadgesOnProfile(SignalStore.donationsValues().getDisplayBadgesOnProfile())
|
||||
.setSubscriptionManuallyCancelled(SignalStore.donationsValues().isUserManuallyCancelled())
|
||||
.setKeepMutedChatsArchived(SignalStore.settings().shouldKeepMutedChatsArchived())
|
||||
.setHasSetMyStoriesPrivacy(SignalStore.storyValues().getUserHasBeenNotifiedAboutStories())
|
||||
.setHasViewedOnboardingStory(SignalStore.storyValues().getUserHasSeenOnboardingStory())
|
||||
.setStoriesDisabled(SignalStore.storyValues().isFeatureDisabled())
|
||||
.build();
|
||||
|
||||
return SignalStorageRecord.forAccount(account);
|
||||
|
@ -158,6 +162,10 @@ public final class StorageSyncHelper {
|
|||
SignalStore.settings().setUniversalExpireTimer(update.getNew().getUniversalExpireTimer());
|
||||
SignalStore.emojiValues().setReactions(update.getNew().getDefaultReactions());
|
||||
SignalStore.donationsValues().setDisplayBadgesOnProfile(update.getNew().isDisplayBadgesOnProfile());
|
||||
SignalStore.settings().setKeepMutedChatsArchived(update.getNew().isKeepMutedChatsArchived());
|
||||
SignalStore.storyValues().setUserHasBeenNotifiedAboutStories(update.getNew().hasSetMyStoriesPrivacy());
|
||||
SignalStore.storyValues().setUserHasSeenOnboardingStory(update.getNew().hasViewedOnboardingStory());
|
||||
SignalStore.storyValues().setFeatureDisabled(update.getNew().isStoriesDisabled());
|
||||
|
||||
if (update.getNew().isSubscriptionManuallyCancelled()) {
|
||||
SignalStore.donationsValues().updateLocalStateForManualCancellation();
|
||||
|
|
|
@ -8,7 +8,9 @@ import io.reactivex.rxjava3.disposables.CompositeDisposable
|
|||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
import org.thoughtcrime.securesms.database.model.DistributionListPrivacyMode
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.stories.Stories
|
||||
import org.thoughtcrime.securesms.stories.settings.my.MyStorySettingsRepository
|
||||
import org.thoughtcrime.securesms.util.rx.RxStore
|
||||
|
||||
|
@ -40,6 +42,7 @@ class ChooseInitialMyStoryMembershipViewModel @JvmOverloads constructor(
|
|||
fun save(): Single<RecipientId> {
|
||||
return Single.fromCallable<RecipientId> {
|
||||
SignalStore.storyValues().userHasBeenNotifiedAboutStories = true
|
||||
Stories.onStorySettingsChanged(Recipient.self().id)
|
||||
store.state.recipientId
|
||||
}.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package org.thoughtcrime.securesms.stories.settings.story
|
||||
|
||||
import io.reactivex.rxjava3.core.Completable
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.stories.Stories
|
||||
|
||||
class StoriesPrivacySettingsRepository {
|
||||
fun markGroupsAsStories(groups: List<RecipientId>): Completable {
|
||||
|
@ -13,4 +16,11 @@ class StoriesPrivacySettingsRepository {
|
|||
.forEach { SignalDatabase.groups.markDisplayAsStory(it.requireGroupId()) }
|
||||
}
|
||||
}
|
||||
|
||||
fun setStoriesEnabled(isEnabled: Boolean): Completable {
|
||||
return Completable.fromAction {
|
||||
SignalStore.storyValues().isFeatureDisabled = !isEnabled
|
||||
Stories.onStorySettingsChanged(Recipient.self().id)
|
||||
}.subscribeOn(Schedulers.io())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,5 +4,6 @@ import org.thoughtcrime.securesms.contacts.paged.ContactSearchData
|
|||
|
||||
data class StoriesPrivacySettingsState(
|
||||
val areStoriesEnabled: Boolean,
|
||||
val isUpdatingEnabledState: Boolean = false,
|
||||
val storyContactItems: List<ContactSearchData> = emptyList()
|
||||
)
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.signal.paging.ProxyPagingController
|
|||
import org.thoughtcrime.securesms.contacts.paged.ContactSearchConfiguration
|
||||
import org.thoughtcrime.securesms.contacts.paged.ContactSearchKey
|
||||
import org.thoughtcrime.securesms.contacts.paged.ContactSearchPagedDataSource
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.stories.Stories
|
||||
import org.thoughtcrime.securesms.util.rx.RxStore
|
||||
|
@ -70,8 +69,15 @@ class StoriesPrivacySettingsViewModel : ViewModel() {
|
|||
}
|
||||
|
||||
fun setStoriesEnabled(isEnabled: Boolean) {
|
||||
SignalStore.storyValues().isFeatureDisabled = !isEnabled
|
||||
store.update { it.copy(areStoriesEnabled = Stories.isFeatureEnabled()) }
|
||||
store.update { it.copy(isUpdatingEnabledState = true) }
|
||||
disposables += repository.setStoriesEnabled(isEnabled).subscribe {
|
||||
store.update {
|
||||
it.copy(
|
||||
isUpdatingEnabledState = false,
|
||||
areStoriesEnabled = Stories.isFeatureEnabled()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun displayGroupsAsStories(recipientIds: List<RecipientId>) {
|
||||
|
|
|
@ -175,6 +175,7 @@ open class StoryViewerPageRepository(context: Context) {
|
|||
|
||||
if (storyPost.sender.isReleaseNotes) {
|
||||
SignalStore.storyValues().userHasSeenOnboardingStory = true
|
||||
Stories.onStorySettingsChanged(Recipient.self().id)
|
||||
} else {
|
||||
ApplicationDependencies.getJobManager().add(
|
||||
SendViewedReceiptJob(
|
||||
|
|
|
@ -166,6 +166,22 @@ public final class SignalAccountRecord implements SignalRecord {
|
|||
diff.add("SubscriptionManuallyCancelled");
|
||||
}
|
||||
|
||||
if (isKeepMutedChatsArchived() != that.isKeepMutedChatsArchived()) {
|
||||
diff.add("KeepMutedChatsArchived");
|
||||
}
|
||||
|
||||
if (hasSetMyStoriesPrivacy() != that.hasSetMyStoriesPrivacy()) {
|
||||
diff.add("HasSetMyStoryPrivacy");
|
||||
}
|
||||
|
||||
if (hasViewedOnboardingStory() != that.hasViewedOnboardingStory()) {
|
||||
diff.add("HasViewedOnboardingStory");
|
||||
}
|
||||
|
||||
if (isStoriesDisabled() != that.isStoriesDisabled()) {
|
||||
diff.add("StoriesDisabled");
|
||||
}
|
||||
|
||||
return diff.toString();
|
||||
} else {
|
||||
return "Different class. " + getClass().getSimpleName() + " | " + other.getClass().getSimpleName();
|
||||
|
@ -268,6 +284,22 @@ public final class SignalAccountRecord implements SignalRecord {
|
|||
return proto.getSubscriptionManuallyCancelled();
|
||||
}
|
||||
|
||||
public boolean isKeepMutedChatsArchived() {
|
||||
return proto.getKeepMutedChatsArchived();
|
||||
}
|
||||
|
||||
public boolean hasSetMyStoriesPrivacy() {
|
||||
return proto.getHasSetMyStoriesPrivacy();
|
||||
}
|
||||
|
||||
public boolean hasViewedOnboardingStory() {
|
||||
return proto.getHasViewedOnboardingStory();
|
||||
}
|
||||
|
||||
public boolean isStoriesDisabled() {
|
||||
return proto.getStoriesDisabled();
|
||||
}
|
||||
|
||||
public AccountRecord toProto() {
|
||||
return proto;
|
||||
}
|
||||
|
@ -605,6 +637,26 @@ public final class SignalAccountRecord implements SignalRecord {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder setKeepMutedChatsArchived(boolean keepMutedChatsArchived) {
|
||||
builder.setKeepMutedChatsArchived(keepMutedChatsArchived);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setHasSetMyStoriesPrivacy(boolean hasSetMyStoriesPrivacy) {
|
||||
builder.setHasSetMyStoriesPrivacy(hasSetMyStoriesPrivacy);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setHasViewedOnboardingStory(boolean hasViewedOnboardingStory) {
|
||||
builder.setHasViewedOnboardingStory(hasViewedOnboardingStory);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setStoriesDisabled(boolean storiesDisabled) {
|
||||
builder.setStoriesDisabled(storiesDisabled);
|
||||
return this;
|
||||
}
|
||||
|
||||
private static AccountRecord.Builder parseUnknowns(byte[] serializedUnknowns) {
|
||||
try {
|
||||
return AccountRecord.parseFrom(serializedUnknowns).toBuilder();
|
||||
|
|
|
@ -158,6 +158,10 @@ message AccountRecord {
|
|||
string subscriberCurrencyCode = 22;
|
||||
bool displayBadgesOnProfile = 23;
|
||||
bool subscriptionManuallyCancelled = 24;
|
||||
bool keepMutedChatsArchived = 25;
|
||||
bool hasSetMyStoriesPrivacy = 26;
|
||||
bool hasViewedOnboardingStory = 27;
|
||||
bool storiesDisabled = 28;
|
||||
}
|
||||
|
||||
message StoryDistributionListRecord {
|
||||
|
|
Ładowanie…
Reference in New Issue