mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-07-13 17:23:56 +01:00
Convert SignalStore to kotlin.
This commit is contained in:
@@ -83,11 +83,11 @@ class BackupTest {
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
SignalStore.account().setE164(SELF_E164)
|
||||
SignalStore.account().setAci(SELF_ACI)
|
||||
SignalStore.account().setPni(SELF_PNI)
|
||||
SignalStore.account().generateAciIdentityKeyIfNecessary()
|
||||
SignalStore.account().generatePniIdentityKeyIfNecessary()
|
||||
SignalStore.account.setE164(SELF_E164)
|
||||
SignalStore.account.setAci(SELF_ACI)
|
||||
SignalStore.account.setPni(SELF_PNI)
|
||||
SignalStore.account.generateAciIdentityKeyIfNecessary()
|
||||
SignalStore.account.generatePniIdentityKeyIfNecessary()
|
||||
}
|
||||
|
||||
@Ignore("Will likely be removed soon")
|
||||
@@ -251,34 +251,34 @@ class BackupTest {
|
||||
// TODO note-to-self archived
|
||||
// TODO note-to-self unread
|
||||
|
||||
SignalStore.account().setAci(SELF_ACI)
|
||||
SignalStore.account().setPni(SELF_PNI)
|
||||
SignalStore.account().setE164(SELF_E164)
|
||||
SignalStore.account().generateAciIdentityKeyIfNecessary()
|
||||
SignalStore.account().generatePniIdentityKeyIfNecessary()
|
||||
SignalStore.account.setAci(SELF_ACI)
|
||||
SignalStore.account.setPni(SELF_PNI)
|
||||
SignalStore.account.setE164(SELF_E164)
|
||||
SignalStore.account.generateAciIdentityKeyIfNecessary()
|
||||
SignalStore.account.generatePniIdentityKeyIfNecessary()
|
||||
|
||||
SignalDatabase.recipients.setProfileKey(self.id, ProfileKey(Random.nextBytes(32)))
|
||||
SignalDatabase.recipients.setProfileName(self.id, ProfileName.fromParts("Peter", "Parker"))
|
||||
SignalDatabase.recipients.setProfileAvatar(self.id, "https://example.com/")
|
||||
|
||||
InAppPaymentsRepository.setSubscriber(InAppPaymentSubscriberRecord(SubscriberId.generate(), Currency.getInstance("USD"), InAppPaymentSubscriberRecord.Type.DONATION, false, InAppPaymentData.PaymentMethodType.UNKNOWN))
|
||||
SignalStore.donationsValues().setDisplayBadgesOnProfile(false)
|
||||
SignalStore.donations.setDisplayBadgesOnProfile(false)
|
||||
|
||||
SignalStore.phoneNumberPrivacy().phoneNumberDiscoverabilityMode = PhoneNumberPrivacyValues.PhoneNumberDiscoverabilityMode.NOT_DISCOVERABLE
|
||||
SignalStore.phoneNumberPrivacy().phoneNumberSharingMode = PhoneNumberPrivacyValues.PhoneNumberSharingMode.NOBODY
|
||||
SignalStore.phoneNumberPrivacy.phoneNumberDiscoverabilityMode = PhoneNumberPrivacyValues.PhoneNumberDiscoverabilityMode.NOT_DISCOVERABLE
|
||||
SignalStore.phoneNumberPrivacy.phoneNumberSharingMode = PhoneNumberPrivacyValues.PhoneNumberSharingMode.NOBODY
|
||||
|
||||
SignalStore.settings().isLinkPreviewsEnabled = false
|
||||
SignalStore.settings().isPreferSystemContactPhotos = true
|
||||
SignalStore.settings().universalExpireTimer = 42
|
||||
SignalStore.settings().setKeepMutedChatsArchived(true)
|
||||
SignalStore.settings.isLinkPreviewsEnabled = false
|
||||
SignalStore.settings.isPreferSystemContactPhotos = true
|
||||
SignalStore.settings.universalExpireTimer = 42
|
||||
SignalStore.settings.setKeepMutedChatsArchived(true)
|
||||
|
||||
SignalStore.storyValues().viewedReceiptsEnabled = false
|
||||
SignalStore.storyValues().userHasViewedOnboardingStory = true
|
||||
SignalStore.storyValues().isFeatureDisabled = false
|
||||
SignalStore.storyValues().userHasBeenNotifiedAboutStories = true
|
||||
SignalStore.storyValues().userHasSeenGroupStoryEducationSheet = true
|
||||
SignalStore.story.viewedReceiptsEnabled = false
|
||||
SignalStore.story.userHasViewedOnboardingStory = true
|
||||
SignalStore.story.isFeatureDisabled = false
|
||||
SignalStore.story.userHasBeenNotifiedAboutStories = true
|
||||
SignalStore.story.userHasSeenGroupStoryEducationSheet = true
|
||||
|
||||
SignalStore.emojiValues().reactions = listOf("a", "b", "c")
|
||||
SignalStore.emoji.reactions = listOf("a", "b", "c")
|
||||
|
||||
TextSecurePreferences.setTypingIndicatorsEnabled(context, false)
|
||||
TextSecurePreferences.setReadReceiptsEnabled(context, false)
|
||||
|
||||
@@ -156,12 +156,12 @@ class ImportExportTest {
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
SignalStore.svr().setMasterKey(MasterKey(MASTER_KEY), "1234")
|
||||
SignalStore.account().setE164(SELF_E164)
|
||||
SignalStore.account().setAci(SELF_ACI)
|
||||
SignalStore.account().setPni(SELF_PNI)
|
||||
SignalStore.account().generateAciIdentityKeyIfNecessary()
|
||||
SignalStore.account().generatePniIdentityKeyIfNecessary()
|
||||
SignalStore.svr.setMasterKey(MasterKey(MASTER_KEY), "1234")
|
||||
SignalStore.account.setE164(SELF_E164)
|
||||
SignalStore.account.setAci(SELF_ACI)
|
||||
SignalStore.account.setPni(SELF_PNI)
|
||||
SignalStore.account.generateAciIdentityKeyIfNecessary()
|
||||
SignalStore.account.generatePniIdentityKeyIfNecessary()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1424,8 +1424,8 @@ class ImportExportTest {
|
||||
private fun exportFrames(vararg objects: Any): ByteArray {
|
||||
val outputStream = ByteArrayOutputStream()
|
||||
val writer = EncryptedBackupWriter(
|
||||
key = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey(),
|
||||
aci = SignalStore.account().aci!!,
|
||||
key = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey(),
|
||||
aci = SignalStore.account.aci!!,
|
||||
outputStream = outputStream,
|
||||
append = { mac -> outputStream.write(mac) }
|
||||
)
|
||||
@@ -1453,7 +1453,7 @@ class ImportExportTest {
|
||||
|
||||
private fun validate(importData: ByteArray): MessageBackup.ValidationResult {
|
||||
val factory = { ByteArrayInputStream(importData) }
|
||||
val masterKey = SignalStore.svr().getOrCreateMasterKey()
|
||||
val masterKey = SignalStore.svr.getOrCreateMasterKey()
|
||||
val key = MessageBackupKey(masterKey.serialize(), org.signal.libsignal.protocol.ServiceId.Aci.parseFromBinary(SELF_ACI.toByteArray()))
|
||||
|
||||
return MessageBackup.validate(key, MessageBackup.Purpose.REMOTE_BACKUP, factory, importData.size.toLong())
|
||||
@@ -1470,8 +1470,8 @@ class ImportExportTest {
|
||||
private fun importExport(vararg objects: Any) {
|
||||
val outputStream = ByteArrayOutputStream()
|
||||
val writer = EncryptedBackupWriter(
|
||||
key = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey(),
|
||||
aci = SignalStore.account().aci!!,
|
||||
key = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey(),
|
||||
aci = SignalStore.account.aci!!,
|
||||
outputStream = outputStream,
|
||||
append = { mac -> outputStream.write(mac) }
|
||||
)
|
||||
@@ -1613,7 +1613,7 @@ class ImportExportTest {
|
||||
private fun readAllFrames(import: ByteArray, selfData: BackupRepository.SelfData): List<Frame> {
|
||||
val inputFactory = { ByteArrayInputStream(import) }
|
||||
val frameReader = EncryptedBackupReader(
|
||||
key = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey(),
|
||||
key = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey(),
|
||||
aci = selfData.aci,
|
||||
length = import.size.toLong(),
|
||||
dataStream = inputFactory
|
||||
|
||||
+12
-12
@@ -63,7 +63,7 @@ class ChangeNumberViewModelTest {
|
||||
localNumber = harness.self.requireE164(),
|
||||
changeNumberRepository = ChangeNumberRepository(),
|
||||
savedState = SavedStateHandle(),
|
||||
password = SignalStore.account().servicePassword!!,
|
||||
password = SignalStore.account.servicePassword!!,
|
||||
verifyAccountRepository = VerifyAccountRepository(harness.application)
|
||||
)
|
||||
|
||||
@@ -136,7 +136,7 @@ class ChangeNumberViewModelTest {
|
||||
processor.isServerSentError() assertIs true
|
||||
Recipient.self().requireE164() assertIs oldE164
|
||||
Recipient.self().requirePni() assertIs oldPni
|
||||
SignalStore.misc().pendingChangeNumberMetadata.assertIsNull()
|
||||
SignalStore.misc.pendingChangeNumberMetadata.assertIsNull()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,8 +170,8 @@ class ChangeNumberViewModelTest {
|
||||
processor.isServerSentError() assertIs false
|
||||
Recipient.self().requireE164() assertIs oldE164
|
||||
Recipient.self().requirePni() assertIs oldPni
|
||||
SignalStore.misc().isChangeNumberLocked assertIs false
|
||||
SignalStore.misc().pendingChangeNumberMetadata.assertIsNull()
|
||||
SignalStore.misc.isChangeNumberLocked assertIs false
|
||||
SignalStore.misc.pendingChangeNumberMetadata.assertIsNull()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,8 +220,8 @@ class ChangeNumberViewModelTest {
|
||||
processor.isServerSentError() assertIs false
|
||||
Recipient.self().requireE164() assertIs oldE164
|
||||
Recipient.self().requirePni() assertIs oldPni
|
||||
SignalStore.misc().isChangeNumberLocked assertIs true
|
||||
SignalStore.misc().pendingChangeNumberMetadata.assertIsNotNull()
|
||||
SignalStore.misc.isChangeNumberLocked assertIs true
|
||||
SignalStore.misc.pendingChangeNumberMetadata.assertIsNotNull()
|
||||
|
||||
// WHEN AGAIN Processing lock
|
||||
val scenario = harness.launchActivity<ChangeNumberLockActivity>()
|
||||
@@ -268,7 +268,7 @@ class ChangeNumberViewModelTest {
|
||||
viewModel.verifyCodeWithoutRegistrationLock("123456").blockingGet().also { processor ->
|
||||
processor.registrationLock() assertIs true
|
||||
Recipient.self().requirePni() assertIsNot newPni
|
||||
SignalStore.misc().pendingChangeNumberMetadata.assertIsNull()
|
||||
SignalStore.misc.pendingChangeNumberMetadata.assertIsNull()
|
||||
}
|
||||
|
||||
viewModel.verifyCodeAndRegisterAccountWithRegistrationLock("pin").blockingGet().resultOrThrow
|
||||
@@ -378,7 +378,7 @@ class ChangeNumberViewModelTest {
|
||||
viewModel.verifyCodeWithoutRegistrationLock("123456").blockingGet().also { processor ->
|
||||
processor.registrationLock() assertIs true
|
||||
Recipient.self().requirePni() assertIsNot newPni
|
||||
SignalStore.misc().pendingChangeNumberMetadata.assertIsNull()
|
||||
SignalStore.misc.pendingChangeNumberMetadata.assertIsNull()
|
||||
}
|
||||
|
||||
viewModel.verifyCodeAndRegisterAccountWithRegistrationLock("pin").blockingGet().resultOrThrow
|
||||
@@ -389,13 +389,13 @@ class ChangeNumberViewModelTest {
|
||||
|
||||
private fun assertSuccess(newPni: ServiceId, changeNumberRequest: ChangePhoneNumberRequest, setPreKeysRequest: PreKeyState) {
|
||||
val pniProtocolStore = AppDependencies.protocolStore.pni()
|
||||
val pniMetadataStore = SignalStore.account().pniPreKeys
|
||||
val pniMetadataStore = SignalStore.account.pniPreKeys
|
||||
|
||||
Recipient.self().requireE164() assertIs "+15555550102"
|
||||
Recipient.self().requirePni() assertIs newPni
|
||||
|
||||
SignalStore.account().pniRegistrationId assertIs changeNumberRequest.pniRegistrationIds["1"]!!
|
||||
SignalStore.account().pniIdentityKey.publicKey assertIs changeNumberRequest.pniIdentityKey
|
||||
SignalStore.account.pniRegistrationId assertIs changeNumberRequest.pniRegistrationIds["1"]!!
|
||||
SignalStore.account.pniIdentityKey.publicKey assertIs changeNumberRequest.pniIdentityKey
|
||||
pniMetadataStore.activeSignedPreKeyId assertIs changeNumberRequest.devicePniSignedPrekeys["1"]!!.keyId
|
||||
|
||||
val activeSignedPreKey: SignedPreKeyRecord = pniProtocolStore.loadSignedPreKey(pniMetadataStore.activeSignedPreKeyId)
|
||||
@@ -405,6 +405,6 @@ class ChangeNumberViewModelTest {
|
||||
setPreKeysRequest.signedPreKey.publicKey assertIs activeSignedPreKey.keyPair.publicKey
|
||||
setPreKeysRequest.preKeys assertIsSize 100
|
||||
|
||||
SignalStore.misc().pendingChangeNumberMetadata.assertIsNull()
|
||||
SignalStore.misc.pendingChangeNumberMetadata.assertIsNull()
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -50,9 +50,9 @@ class AttachmentTableTest_deduping {
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
SignalStore.account().setAci(ServiceId.ACI.from(UUID.randomUUID()))
|
||||
SignalStore.account().setPni(ServiceId.PNI.from(UUID.randomUUID()))
|
||||
SignalStore.account().setE164("+15558675309")
|
||||
SignalStore.account.setAci(ServiceId.ACI.from(UUID.randomUUID()))
|
||||
SignalStore.account.setPni(ServiceId.PNI.from(UUID.randomUUID()))
|
||||
SignalStore.account.setE164("+15558675309")
|
||||
|
||||
SignalDatabase.attachments.deleteAllAttachments()
|
||||
}
|
||||
|
||||
+2
-2
@@ -30,8 +30,8 @@ class MessageTableTest_gifts {
|
||||
|
||||
mms.deleteAllThreads()
|
||||
|
||||
SignalStore.account().setAci(localAci)
|
||||
SignalStore.account().setPni(localPni)
|
||||
SignalStore.account.setAci(localAci)
|
||||
SignalStore.account.setPni(localPni)
|
||||
|
||||
recipients = (0 until 5).map { SignalDatabase.recipients.getOrInsertFromServiceId(ACI.from(UUID.randomUUID())) }
|
||||
}
|
||||
|
||||
+3
-3
@@ -40,14 +40,14 @@ class MmsTableTest_stories {
|
||||
|
||||
mms.deleteAllThreads()
|
||||
|
||||
SignalStore.account().setAci(localAci)
|
||||
SignalStore.account().setPni(localPni)
|
||||
SignalStore.account.setAci(localAci)
|
||||
SignalStore.account.setPni(localPni)
|
||||
|
||||
myStory = Recipient.resolved(SignalDatabase.recipients.getOrInsertFromDistributionListId(DistributionListId.MY_STORY))
|
||||
recipients = (0 until 5).map { SignalDatabase.recipients.getOrInsertFromServiceId(ACI.from(UUID.randomUUID())) }
|
||||
releaseChannelRecipient = Recipient.resolved(SignalDatabase.recipients.insertReleaseChannelRecipient())
|
||||
|
||||
SignalStore.releaseChannelValues().setReleaseChannelRecipientId(releaseChannelRecipient.id)
|
||||
SignalStore.releaseChannel.setReleaseChannelRecipientId(releaseChannelRecipient.id)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+3
-3
@@ -53,9 +53,9 @@ class RecipientTableTest_getAndPossiblyMerge {
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
SignalStore.account().setE164(E164_SELF)
|
||||
SignalStore.account().setAci(ACI_SELF)
|
||||
SignalStore.account().setPni(PNI_SELF)
|
||||
SignalStore.account.setE164(E164_SELF)
|
||||
SignalStore.account.setAci(ACI_SELF)
|
||||
SignalStore.account.setPni(PNI_SELF)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+3
-3
@@ -46,8 +46,8 @@ class SmsDatabaseTest_collapseJoinRequestEventsIfPossible {
|
||||
recipients = SignalDatabase.recipients
|
||||
sms = SignalDatabase.messages
|
||||
|
||||
SignalStore.account().setAci(localAci)
|
||||
SignalStore.account().setPni(localPni)
|
||||
SignalStore.account.setAci(localAci)
|
||||
SignalStore.account.setPni(localPni)
|
||||
|
||||
alice = recipients.getOrInsertFromServiceId(aliceServiceId)
|
||||
bob = recipients.getOrInsertFromServiceId(bobServiceId)
|
||||
@@ -291,7 +291,7 @@ class SmsDatabaseTest_collapseJoinRequestEventsIfPossible {
|
||||
|
||||
val updateDescription = GV2UpdateDescription(
|
||||
gv2ChangeDescription = groupContext,
|
||||
groupChangeUpdate = GroupsV2UpdateMessageConverter.translateDecryptedChangeUpdate(SignalStore.account().getServiceIds(), groupContext)
|
||||
groupChangeUpdate = GroupsV2UpdateMessageConverter.translateDecryptedChangeUpdate(SignalStore.account.getServiceIds(), groupContext)
|
||||
)
|
||||
|
||||
return IncomingMessage.groupUpdate(
|
||||
|
||||
@@ -145,7 +145,7 @@ class MessageHelper(private val harness: SignalActivityRule, var startTime: Long
|
||||
|
||||
val updateDescription = GV2UpdateDescription.Builder()
|
||||
.gv2ChangeDescription(decryptedGroupV2Context)
|
||||
.groupChangeUpdate(GroupsV2UpdateMessageConverter.translateDecryptedChange(SignalStore.account().getServiceIds(), decryptedGroupV2Context))
|
||||
.groupChangeUpdate(GroupsV2UpdateMessageConverter.translateDecryptedChange(SignalStore.account.getServiceIds(), decryptedGroupV2Context))
|
||||
.build()
|
||||
|
||||
val outgoingMessage = OutgoingMessage.groupUpdateMessage(groupRecipient, updateDescription, startTime)
|
||||
|
||||
+4
-4
@@ -36,10 +36,10 @@ class SubscriberIdMigrationJobTest {
|
||||
@Test
|
||||
fun givenUSDSubscriber_whenIRunSubscriberIdMigrationJob_thenIExpectASingleEntry() {
|
||||
val subscriberId = SubscriberId.generate()
|
||||
SignalStore.donationsValues().setSubscriberCurrency(Currency.getInstance("USD"), InAppPaymentSubscriberRecord.Type.DONATION)
|
||||
SignalStore.donationsValues().setSubscriber("USD", subscriberId)
|
||||
SignalStore.donationsValues().setSubscriptionPaymentSourceType(PaymentSourceType.PayPal)
|
||||
SignalStore.donationsValues().shouldCancelSubscriptionBeforeNextSubscribeAttempt = true
|
||||
SignalStore.donations.setSubscriberCurrency(Currency.getInstance("USD"), InAppPaymentSubscriberRecord.Type.DONATION)
|
||||
SignalStore.donations.setSubscriber("USD", subscriberId)
|
||||
SignalStore.donations.setSubscriptionPaymentSourceType(PaymentSourceType.PayPal)
|
||||
SignalStore.donations.shouldCancelSubscriptionBeforeNextSubscribeAttempt = true
|
||||
|
||||
testSubject.run()
|
||||
|
||||
|
||||
+3
-3
@@ -24,9 +24,9 @@ class ContactRecordProcessorTest {
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
SignalStore.account().setE164(E164_SELF)
|
||||
SignalStore.account().setAci(ACI_SELF)
|
||||
SignalStore.account().setPni(PNI_SELF)
|
||||
SignalStore.account.setE164(E164_SELF)
|
||||
SignalStore.account.setAci(ACI_SELF)
|
||||
SignalStore.account.setPni(PNI_SELF)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -30,7 +30,7 @@ class AliceClient(val serviceId: ServiceId, val e164: String, val trustRoot: ECK
|
||||
uuid = serviceId.rawUuid,
|
||||
e164 = e164,
|
||||
deviceId = 1,
|
||||
identityKey = SignalStore.account().aciIdentityKey.publicKey.publicKey,
|
||||
identityKey = SignalStore.account.aciIdentityKey.publicKey.publicKey,
|
||||
expires = 31337
|
||||
)
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class BobClient(val serviceId: ServiceId, val e164: String, val identityKeyPair:
|
||||
}
|
||||
|
||||
private fun getAliceServiceId(): ServiceId {
|
||||
return SignalStore.account().requireAci()
|
||||
return SignalStore.account.requireAci()
|
||||
}
|
||||
|
||||
private fun getAlicePreKeyBundle(): PreKeyBundle {
|
||||
@@ -103,7 +103,7 @@ class BobClient(val serviceId: ServiceId, val e164: String, val identityKeyPair:
|
||||
val selfSignedPreKeyRecord = SignalDatabase.signedPreKeys.get(getAliceServiceId(), selfSignedPreKeyId)!!
|
||||
|
||||
return PreKeyBundle(
|
||||
SignalStore.account().registrationId,
|
||||
SignalStore.account.registrationId,
|
||||
1,
|
||||
selfPreKeyId,
|
||||
selfPreKeyRecord.keyPair.publicKey,
|
||||
@@ -115,11 +115,11 @@ class BobClient(val serviceId: ServiceId, val e164: String, val identityKeyPair:
|
||||
}
|
||||
|
||||
private fun getAliceProtocolAddress(): SignalProtocolAddress {
|
||||
return SignalProtocolAddress(SignalStore.account().requireAci().toString(), 1)
|
||||
return SignalProtocolAddress(SignalStore.account.requireAci().toString(), 1)
|
||||
}
|
||||
|
||||
private fun getAlicePublicKey(): IdentityKey {
|
||||
return SignalStore.account().aciIdentityKey.publicKey
|
||||
return SignalStore.account.aciIdentityKey.publicKey
|
||||
}
|
||||
|
||||
private fun getAliceProfileKey(): ProfileKey {
|
||||
@@ -144,7 +144,7 @@ class BobClient(val serviceId: ServiceId, val e164: String, val identityKeyPair:
|
||||
}
|
||||
override fun getSubDeviceSessions(name: String?): List<Int> = emptyList()
|
||||
override fun containsSession(address: SignalProtocolAddress?): Boolean = aliceSessionRecord != null
|
||||
override fun getIdentity(address: SignalProtocolAddress?): IdentityKey = SignalStore.account().aciIdentityKey.publicKey
|
||||
override fun getIdentity(address: SignalProtocolAddress?): IdentityKey = SignalStore.account.aciIdentityKey.publicKey
|
||||
override fun loadPreKey(preKeyId: Int): PreKeyRecord = throw UnsupportedOperationException()
|
||||
override fun storePreKey(preKeyId: Int, record: PreKeyRecord?) = throw UnsupportedOperationException()
|
||||
override fun containsPreKey(preKeyId: Int): Boolean = throw UnsupportedOperationException()
|
||||
|
||||
@@ -68,7 +68,7 @@ object MockProvider {
|
||||
}
|
||||
}
|
||||
|
||||
fun createPreKeyResponse(identity: IdentityKeyPair = SignalStore.account().aciIdentityKey, deviceId: Int): PreKeyResponse {
|
||||
fun createPreKeyResponse(identity: IdentityKeyPair = SignalStore.account.aciIdentityKey, deviceId: Int): PreKeyResponse {
|
||||
val signedPreKeyRecord = PreKeyUtil.generateSignedPreKey(SecureRandom().nextInt(Medium.MAX_VALUE), identity.privateKey)
|
||||
val oneTimePreKey = PreKeyRecord(SecureRandom().nextInt(Medium.MAX_VALUE), Curve.generateKeyPair())
|
||||
|
||||
|
||||
@@ -90,8 +90,8 @@ class SignalActivityRule(private val othersCount: Int = 4, private val createGro
|
||||
val preferences: SharedPreferences = application.getSharedPreferences(MasterSecretUtil.PREFERENCES_NAME, 0)
|
||||
preferences.edit().putBoolean("passphrase_initialized", true).commit()
|
||||
|
||||
SignalStore.account().generateAciIdentityKeyIfNecessary()
|
||||
SignalStore.account().generatePniIdentityKeyIfNecessary()
|
||||
SignalStore.account.generateAciIdentityKeyIfNecessary()
|
||||
SignalStore.account.generatePniIdentityKeyIfNecessary()
|
||||
|
||||
val registrationRepository = RegistrationRepository(application)
|
||||
|
||||
@@ -111,19 +111,19 @@ class SignalActivityRule(private val othersCount: Int = 4, private val createGro
|
||||
verifyAccountResponse = VerifyAccountResponse(UUID.randomUUID().toString(), UUID.randomUUID().toString(), false),
|
||||
masterKey = null,
|
||||
pin = null,
|
||||
aciPreKeyCollection = RegistrationRepository.generateSignedAndLastResortPreKeys(SignalStore.account().aciIdentityKey, SignalStore.account().aciPreKeys),
|
||||
pniPreKeyCollection = RegistrationRepository.generateSignedAndLastResortPreKeys(SignalStore.account().aciIdentityKey, SignalStore.account().pniPreKeys)
|
||||
aciPreKeyCollection = RegistrationRepository.generateSignedAndLastResortPreKeys(SignalStore.account.aciIdentityKey, SignalStore.account.aciPreKeys),
|
||||
pniPreKeyCollection = RegistrationRepository.generateSignedAndLastResortPreKeys(SignalStore.account.aciIdentityKey, SignalStore.account.pniPreKeys)
|
||||
),
|
||||
false
|
||||
).blockingGet()
|
||||
|
||||
ServiceResponseProcessor.DefaultProcessor(response).resultOrThrow
|
||||
|
||||
SignalStore.svr().optOut()
|
||||
SignalStore.svr.optOut()
|
||||
RegistrationUtil.maybeMarkRegistrationComplete()
|
||||
SignalDatabase.recipients.setProfileName(Recipient.self().id, ProfileName.fromParts("Tester", "McTesterson"))
|
||||
|
||||
SignalStore.settings().isMessageNotificationsEnabled = false
|
||||
SignalStore.settings.isMessageNotificationsEnabled = false
|
||||
|
||||
return Recipient.self()
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ class SignalDatabaseRule(
|
||||
override fun starting(description: Description?) {
|
||||
deleteAllThreads()
|
||||
|
||||
SignalStore.account().setAci(localAci)
|
||||
SignalStore.account().setPni(localPni)
|
||||
SignalStore.account.setAci(localAci)
|
||||
SignalStore.account.setPni(localPni)
|
||||
}
|
||||
|
||||
override fun finished(description: Description?) {
|
||||
|
||||
@@ -44,8 +44,8 @@ object TestUsers {
|
||||
val preferences: SharedPreferences = application.getSharedPreferences(MasterSecretUtil.PREFERENCES_NAME, 0)
|
||||
preferences.edit().putBoolean("passphrase_initialized", true).commit()
|
||||
|
||||
SignalStore.account().generateAciIdentityKeyIfNecessary()
|
||||
SignalStore.account().generatePniIdentityKeyIfNecessary()
|
||||
SignalStore.account.generateAciIdentityKeyIfNecessary()
|
||||
SignalStore.account.generatePniIdentityKeyIfNecessary()
|
||||
|
||||
val registrationRepository = RegistrationRepository(application)
|
||||
val registrationData = RegistrationData(
|
||||
@@ -63,8 +63,8 @@ object TestUsers {
|
||||
VerifyAccountResponse(UUID.randomUUID().toString(), UUID.randomUUID().toString(), false),
|
||||
masterKey = null,
|
||||
pin = null,
|
||||
aciPreKeyCollection = RegistrationRepository.generateSignedAndLastResortPreKeys(SignalStore.account().aciIdentityKey, SignalStore.account().aciPreKeys),
|
||||
pniPreKeyCollection = RegistrationRepository.generateSignedAndLastResortPreKeys(SignalStore.account().aciIdentityKey, SignalStore.account().pniPreKeys)
|
||||
aciPreKeyCollection = RegistrationRepository.generateSignedAndLastResortPreKeys(SignalStore.account.aciIdentityKey, SignalStore.account.aciPreKeys),
|
||||
pniPreKeyCollection = RegistrationRepository.generateSignedAndLastResortPreKeys(SignalStore.account.aciIdentityKey, SignalStore.account.pniPreKeys)
|
||||
)
|
||||
|
||||
AccountManagerFactory.setInstance(DummyAccountManagerFactory())
|
||||
@@ -77,7 +77,7 @@ object TestUsers {
|
||||
|
||||
ServiceResponseProcessor.DefaultProcessor(response).resultOrThrow
|
||||
|
||||
SignalStore.svr().optOut()
|
||||
SignalStore.svr.optOut()
|
||||
RegistrationUtil.maybeMarkRegistrationComplete()
|
||||
SignalDatabase.recipients.setProfileName(Recipient.self().id, ProfileName.fromParts("Tester", "McTesterson"))
|
||||
|
||||
|
||||
@@ -440,7 +440,7 @@ public class ApplicationContext extends MultiDexApplication implements AppForegr
|
||||
if (RemoteConfig.callingFieldTrialAnyAddressPortsKillSwitch()) {
|
||||
fieldTrials.put("RingRTC-AnyAddressPortsKillSwitch", "Enabled");
|
||||
}
|
||||
if (!SignalStore.internalValues().callingDisableLBRed()) {
|
||||
if (!SignalStore.internal().callingDisableLBRed()) {
|
||||
fieldTrials.put("RingRTC-Audio-LBRed-For-Opus", "Enabled,bitrate_pri:22000");
|
||||
}
|
||||
CallManager.initialize(this, new RingRtcLogger(), fieldTrials);
|
||||
@@ -461,7 +461,7 @@ public class ApplicationContext extends MultiDexApplication implements AppForegr
|
||||
}
|
||||
|
||||
private void ensureProfileUploaded() {
|
||||
if (SignalStore.account().isRegistered() && !SignalStore.registrationValues().hasUploadedProfile() && !Recipient.self().getProfileName().isEmpty()) {
|
||||
if (SignalStore.account().isRegistered() && !SignalStore.registration().hasUploadedProfile() && !Recipient.self().getProfileName().isEmpty()) {
|
||||
Log.w(TAG, "User has a profile, but has not uploaded one. Uploading now.");
|
||||
AppDependencies.getJobManager().add(new ProfileUploadJob());
|
||||
}
|
||||
|
||||
@@ -189,19 +189,19 @@ public abstract class PassphraseRequiredActivity extends BaseActivity implements
|
||||
}
|
||||
|
||||
private boolean userCanTransferOrRestore() {
|
||||
return !SignalStore.registrationValues().isRegistrationComplete() && RemoteConfig.restoreAfterRegistration() && !SignalStore.registrationValues().hasSkippedTransferOrRestore();
|
||||
return !SignalStore.registration().isRegistrationComplete() && RemoteConfig.restoreAfterRegistration() && !SignalStore.registration().hasSkippedTransferOrRestore();
|
||||
}
|
||||
|
||||
private boolean userMustCreateSignalPin() {
|
||||
return !SignalStore.registrationValues().isRegistrationComplete() && !SignalStore.svr().hasPin() && !SignalStore.svr().lastPinCreateFailed() && !SignalStore.svr().hasOptedOut();
|
||||
return !SignalStore.registration().isRegistrationComplete() && !SignalStore.svr().hasPin() && !SignalStore.svr().lastPinCreateFailed() && !SignalStore.svr().hasOptedOut();
|
||||
}
|
||||
|
||||
private boolean userHasSkippedOrForgottenPin() {
|
||||
return !SignalStore.registrationValues().isRegistrationComplete() && !SignalStore.svr().hasPin() && !SignalStore.svr().hasOptedOut() && SignalStore.svr().isPinForgottenOrSkipped();
|
||||
return !SignalStore.registration().isRegistrationComplete() && !SignalStore.svr().hasPin() && !SignalStore.svr().hasOptedOut() && SignalStore.svr().isPinForgottenOrSkipped();
|
||||
}
|
||||
|
||||
private boolean userMustSetProfileName() {
|
||||
return !SignalStore.registrationValues().isRegistrationComplete() && Recipient.self().getProfileName().isEmpty();
|
||||
return !SignalStore.registration().isRegistrationComplete() && Recipient.self().getProfileName().isEmpty();
|
||||
}
|
||||
|
||||
private Intent getCreatePassphraseIntent() {
|
||||
|
||||
@@ -17,19 +17,19 @@ object SvrAuthTokens : AndroidBackupItem {
|
||||
}
|
||||
|
||||
override fun getDataForBackup(): ByteArray {
|
||||
val proto = SvrAuthToken(svr2Tokens = SignalStore.svr().svr2AuthTokens)
|
||||
val proto = SvrAuthToken(svr2Tokens = SignalStore.svr.svr2AuthTokens)
|
||||
return proto.encode()
|
||||
}
|
||||
|
||||
override fun restoreData(data: ByteArray) {
|
||||
if (SignalStore.svr().svr2AuthTokens.isNotEmpty()) {
|
||||
if (SignalStore.svr.svr2AuthTokens.isNotEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
val proto = SvrAuthToken.ADAPTER.decode(data)
|
||||
|
||||
SignalStore.svr().putSvr2AuthTokens(proto.svr2Tokens)
|
||||
SignalStore.svr.putSvr2AuthTokens(proto.svr2Tokens)
|
||||
} catch (e: IOException) {
|
||||
Log.w(TAG, "Cannot restore KbsAuthToken from backup service.")
|
||||
}
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ class ApkUpdateDownloadManagerReceiver : BroadcastReceiver() {
|
||||
}
|
||||
|
||||
val downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -2)
|
||||
if (downloadId != SignalStore.apkUpdate().downloadId) {
|
||||
if (downloadId != SignalStore.apkUpdate.downloadId) {
|
||||
Log.w(TAG, "downloadId doesn't match the one we're waiting for! Ignoring.")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -38,30 +38,30 @@ object ApkUpdateInstaller {
|
||||
* [userInitiated] = true, and then everything installs.
|
||||
*/
|
||||
fun installOrPromptForInstall(context: Context, downloadId: Long, userInitiated: Boolean) {
|
||||
if (downloadId != SignalStore.apkUpdate().downloadId) {
|
||||
Log.w(TAG, "DownloadId doesn't match the one we're waiting for (current: $downloadId, expected: ${SignalStore.apkUpdate().downloadId})! We likely have newer data. Ignoring.")
|
||||
if (downloadId != SignalStore.apkUpdate.downloadId) {
|
||||
Log.w(TAG, "DownloadId doesn't match the one we're waiting for (current: $downloadId, expected: ${SignalStore.apkUpdate.downloadId})! We likely have newer data. Ignoring.")
|
||||
ApkUpdateNotifications.dismissInstallPrompt(context)
|
||||
AppDependencies.jobManager.add(ApkUpdateJob())
|
||||
return
|
||||
}
|
||||
|
||||
val digest = SignalStore.apkUpdate().digest
|
||||
val digest = SignalStore.apkUpdate.digest
|
||||
if (digest == null) {
|
||||
Log.w(TAG, "DownloadId matches, but digest is null! Inconsistent state. Failing and clearing state.")
|
||||
SignalStore.apkUpdate().clearDownloadAttributes()
|
||||
SignalStore.apkUpdate.clearDownloadAttributes()
|
||||
ApkUpdateNotifications.showInstallFailed(context, ApkUpdateNotifications.FailureReason.UNKNOWN)
|
||||
return
|
||||
}
|
||||
|
||||
if (!isMatchingDigest(context, downloadId, digest)) {
|
||||
Log.w(TAG, "DownloadId matches, but digest does not! Bad download or inconsistent state. Failing and clearing state.")
|
||||
SignalStore.apkUpdate().clearDownloadAttributes()
|
||||
SignalStore.apkUpdate.clearDownloadAttributes()
|
||||
ApkUpdateNotifications.showInstallFailed(context, ApkUpdateNotifications.FailureReason.UNKNOWN)
|
||||
return
|
||||
}
|
||||
|
||||
if (!userInitiated && !shouldAutoUpdate()) {
|
||||
Log.w(TAG, "Not user-initiated and not eligible for auto-update. Prompting. (API=${Build.VERSION.SDK_INT}, Foreground=${AppDependencies.appForegroundObserver.isForegrounded}, AutoUpdate=${SignalStore.apkUpdate().autoUpdate})")
|
||||
Log.w(TAG, "Not user-initiated and not eligible for auto-update. Prompting. (API=${Build.VERSION.SDK_INT}, Foreground=${AppDependencies.appForegroundObserver.isForegrounded}, AutoUpdate=${SignalStore.apkUpdate.autoUpdate})")
|
||||
ApkUpdateNotifications.showInstallPrompt(context, downloadId)
|
||||
return
|
||||
}
|
||||
@@ -70,11 +70,11 @@ object ApkUpdateInstaller {
|
||||
installApk(context, downloadId, userInitiated)
|
||||
} catch (e: IOException) {
|
||||
Log.w(TAG, "Hit IOException when trying to install APK!", e)
|
||||
SignalStore.apkUpdate().clearDownloadAttributes()
|
||||
SignalStore.apkUpdate.clearDownloadAttributes()
|
||||
ApkUpdateNotifications.showInstallFailed(context, ApkUpdateNotifications.FailureReason.UNKNOWN)
|
||||
} catch (e: SecurityException) {
|
||||
Log.w(TAG, "Hit SecurityException when trying to install APK!", e)
|
||||
SignalStore.apkUpdate().clearDownloadAttributes()
|
||||
SignalStore.apkUpdate.clearDownloadAttributes()
|
||||
ApkUpdateNotifications.showInstallFailed(context, ApkUpdateNotifications.FailureReason.UNKNOWN)
|
||||
}
|
||||
}
|
||||
@@ -145,6 +145,6 @@ object ApkUpdateInstaller {
|
||||
|
||||
private fun shouldAutoUpdate(): Boolean {
|
||||
// TODO Auto-updates temporarily restricted to nightlies. Once we have designs for allowing users to opt-out of auto-updates, we can re-enable this
|
||||
return Environment.IS_NIGHTLY && Build.VERSION.SDK_INT >= 31 && SignalStore.apkUpdate().autoUpdate && !AppDependencies.appForegroundObserver.isForegrounded
|
||||
return Environment.IS_NIGHTLY && Build.VERSION.SDK_INT >= 31 && SignalStore.apkUpdate.autoUpdate && !AppDependencies.appForegroundObserver.isForegrounded
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -36,9 +36,9 @@ class ApkUpdatePackageInstallerReceiver : BroadcastReceiver() {
|
||||
|
||||
when (statusCode) {
|
||||
PackageInstaller.STATUS_SUCCESS -> {
|
||||
if (SignalStore.apkUpdate().lastApkUploadTime != SignalStore.apkUpdate().pendingApkUploadTime) {
|
||||
Log.i(TAG, "Update installed successfully! Updating our lastApkUploadTime to ${SignalStore.apkUpdate().pendingApkUploadTime}")
|
||||
SignalStore.apkUpdate().lastApkUploadTime = SignalStore.apkUpdate().pendingApkUploadTime
|
||||
if (SignalStore.apkUpdate.lastApkUploadTime != SignalStore.apkUpdate.pendingApkUploadTime) {
|
||||
Log.i(TAG, "Update installed successfully! Updating our lastApkUploadTime to ${SignalStore.apkUpdate.pendingApkUploadTime}")
|
||||
SignalStore.apkUpdate.lastApkUploadTime = SignalStore.apkUpdate.pendingApkUploadTime
|
||||
ApkUpdateNotifications.showAutoUpdateSuccess(context)
|
||||
} else {
|
||||
Log.i(TAG, "Spurious 'success' notification?")
|
||||
|
||||
@@ -93,12 +93,12 @@ object BackupRepository {
|
||||
when (error.code) {
|
||||
401 -> {
|
||||
Log.i(TAG, "Resetting initialized state due to 401.")
|
||||
SignalStore.backup().backupsInitialized = false
|
||||
SignalStore.backup.backupsInitialized = false
|
||||
}
|
||||
|
||||
403 -> {
|
||||
Log.i(TAG, "Bad auth credential. Clearing stored credentials.")
|
||||
SignalStore.backup().clearAllCredentials()
|
||||
SignalStore.backup.clearAllCredentials()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,8 +106,8 @@ object BackupRepository {
|
||||
@WorkerThread
|
||||
fun turnOffAndDeleteBackup() {
|
||||
RecurringInAppPaymentRepository.cancelActiveSubscriptionSync(InAppPaymentSubscriberRecord.Type.BACKUP)
|
||||
SignalStore.backup().areBackupsEnabled = false
|
||||
SignalStore.backup().backupTier = null
|
||||
SignalStore.backup.areBackupsEnabled = false
|
||||
SignalStore.backup.backupTier = null
|
||||
}
|
||||
|
||||
private fun createSignalDatabaseSnapshot(): SignalDatabase {
|
||||
@@ -155,14 +155,14 @@ object BackupRepository {
|
||||
PlainTextBackupWriter(outputStream)
|
||||
} else {
|
||||
EncryptedBackupWriter(
|
||||
key = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey(),
|
||||
aci = SignalStore.account().aci!!,
|
||||
key = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey(),
|
||||
aci = SignalStore.account.aci!!,
|
||||
outputStream = outputStream,
|
||||
append = append
|
||||
)
|
||||
}
|
||||
|
||||
val exportState = ExportState(backupTime = System.currentTimeMillis(), allowMediaBackup = SignalStore.backup().backsUpMedia)
|
||||
val exportState = ExportState(backupTime = System.currentTimeMillis(), allowMediaBackup = SignalStore.backup.backsUpMedia)
|
||||
|
||||
writer.use {
|
||||
writer.write(
|
||||
@@ -219,7 +219,7 @@ object BackupRepository {
|
||||
}
|
||||
|
||||
fun validate(length: Long, inputStreamFactory: () -> InputStream, selfData: SelfData): ValidationResult {
|
||||
val masterKey = SignalStore.svr().getOrCreateMasterKey()
|
||||
val masterKey = SignalStore.svr.getOrCreateMasterKey()
|
||||
val key = MessageBackupKey(masterKey.serialize(), Aci.parseFromBinary(selfData.aci.toByteArray()))
|
||||
|
||||
return MessageBackup.validate(key, MessageBackup.Purpose.REMOTE_BACKUP, inputStreamFactory, length)
|
||||
@@ -228,7 +228,7 @@ object BackupRepository {
|
||||
fun import(length: Long, inputStreamFactory: () -> InputStream, selfData: SelfData, plaintext: Boolean = false) {
|
||||
val eventTimer = EventTimer()
|
||||
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
|
||||
val frameReader = if (plaintext) {
|
||||
PlainTextBackupReader(inputStreamFactory(), length)
|
||||
@@ -334,7 +334,7 @@ object BackupRepository {
|
||||
|
||||
fun listRemoteMediaObjects(limit: Int, cursor: String? = null): NetworkResult<ArchiveGetMediaItemsResponse> {
|
||||
val api = AppDependencies.signalServiceAccountManager.archiveApi
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
|
||||
return initBackupAndFetchAuth(backupKey)
|
||||
.then { credential ->
|
||||
@@ -344,7 +344,7 @@ object BackupRepository {
|
||||
|
||||
fun getRemoteBackupUsedSpace(): NetworkResult<Long?> {
|
||||
val api = AppDependencies.signalServiceAccountManager.archiveApi
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
|
||||
return initBackupAndFetchAuth(backupKey)
|
||||
.then { credential ->
|
||||
@@ -355,7 +355,7 @@ object BackupRepository {
|
||||
|
||||
private fun getBackupTier(): NetworkResult<MessageBackupTier> {
|
||||
val api = AppDependencies.signalServiceAccountManager.archiveApi
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
|
||||
return initBackupAndFetchAuth(backupKey)
|
||||
.map { credential ->
|
||||
@@ -373,7 +373,7 @@ object BackupRepository {
|
||||
*/
|
||||
fun getRemoteBackupState(): NetworkResult<BackupMetadata> {
|
||||
val api = AppDependencies.signalServiceAccountManager.archiveApi
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
|
||||
return initBackupAndFetchAuth(backupKey)
|
||||
.then { credential ->
|
||||
@@ -400,7 +400,7 @@ object BackupRepository {
|
||||
*/
|
||||
fun uploadBackupFile(backupStream: InputStream, backupStreamLength: Long): Boolean {
|
||||
val api = AppDependencies.signalServiceAccountManager.archiveApi
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
|
||||
return initBackupAndFetchAuth(backupKey)
|
||||
.then { credential ->
|
||||
@@ -422,7 +422,7 @@ object BackupRepository {
|
||||
|
||||
fun downloadBackupFile(destination: File, listener: ProgressListener? = null): Boolean {
|
||||
val api = AppDependencies.signalServiceAccountManager.archiveApi
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
|
||||
return initBackupAndFetchAuth(backupKey)
|
||||
.then { credential ->
|
||||
@@ -438,7 +438,7 @@ object BackupRepository {
|
||||
|
||||
fun getBackupFileLastModified(): NetworkResult<ZonedDateTime?> {
|
||||
val api = AppDependencies.signalServiceAccountManager.archiveApi
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
|
||||
return initBackupAndFetchAuth(backupKey)
|
||||
.then { credential ->
|
||||
@@ -459,7 +459,7 @@ object BackupRepository {
|
||||
*/
|
||||
fun debugGetArchivedMediaState(): NetworkResult<List<ArchiveGetMediaItemsResponse.StoredMediaObject>> {
|
||||
val api = AppDependencies.signalServiceAccountManager.archiveApi
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
|
||||
return initBackupAndFetchAuth(backupKey)
|
||||
.then { credential ->
|
||||
@@ -472,7 +472,7 @@ object BackupRepository {
|
||||
*/
|
||||
fun getMediaUploadSpec(secretKey: ByteArray? = null): NetworkResult<ResumableUploadSpec> {
|
||||
val api = AppDependencies.signalServiceAccountManager.archiveApi
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
|
||||
return initBackupAndFetchAuth(backupKey)
|
||||
.then { credential ->
|
||||
@@ -485,7 +485,7 @@ object BackupRepository {
|
||||
|
||||
fun archiveThumbnail(thumbnailAttachment: Attachment, parentAttachment: DatabaseAttachment): NetworkResult<ArchiveMediaResponse> {
|
||||
val api = AppDependencies.signalServiceAccountManager.archiveApi
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
val request = thumbnailAttachment.toArchiveMediaRequest(parentAttachment.getThumbnailMediaName(), backupKey)
|
||||
|
||||
return initBackupAndFetchAuth(backupKey)
|
||||
@@ -500,7 +500,7 @@ object BackupRepository {
|
||||
|
||||
fun archiveMedia(attachment: DatabaseAttachment): NetworkResult<Unit> {
|
||||
val api = AppDependencies.signalServiceAccountManager.archiveApi
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
|
||||
return initBackupAndFetchAuth(backupKey)
|
||||
.then { credential ->
|
||||
@@ -523,7 +523,7 @@ object BackupRepository {
|
||||
|
||||
fun archiveMedia(databaseAttachments: List<DatabaseAttachment>): NetworkResult<BatchArchiveMediaResult> {
|
||||
val api = AppDependencies.signalServiceAccountManager.archiveApi
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
|
||||
return initBackupAndFetchAuth(backupKey)
|
||||
.then { credential ->
|
||||
@@ -563,7 +563,7 @@ object BackupRepository {
|
||||
|
||||
fun deleteArchivedMedia(attachments: List<DatabaseAttachment>): NetworkResult<Unit> {
|
||||
val api = AppDependencies.signalServiceAccountManager.archiveApi
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
|
||||
val mediaToDelete = attachments
|
||||
.filter { it.archiveMediaId != null }
|
||||
@@ -595,7 +595,7 @@ object BackupRepository {
|
||||
|
||||
fun deleteAbandonedMediaObjects(mediaObjects: Collection<ArchivedMediaObject>): NetworkResult<Unit> {
|
||||
val api = AppDependencies.signalServiceAccountManager.archiveApi
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
|
||||
val mediaToDelete = mediaObjects
|
||||
.map {
|
||||
@@ -623,7 +623,7 @@ object BackupRepository {
|
||||
|
||||
fun debugDeleteAllArchivedMedia(): NetworkResult<Unit> {
|
||||
val api = AppDependencies.signalServiceAccountManager.archiveApi
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
|
||||
return debugGetArchivedMediaState()
|
||||
.then { archivedMedia ->
|
||||
@@ -659,13 +659,13 @@ object BackupRepository {
|
||||
* Retrieve credentials for reading from the backup cdn.
|
||||
*/
|
||||
fun getCdnReadCredentials(cdnNumber: Int): NetworkResult<GetArchiveCdnCredentialsResponse> {
|
||||
val cached = SignalStore.backup().cdnReadCredentials
|
||||
val cached = SignalStore.backup.cdnReadCredentials
|
||||
if (cached != null) {
|
||||
return NetworkResult.Success(cached)
|
||||
}
|
||||
|
||||
val api = AppDependencies.signalServiceAccountManager.archiveApi
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
|
||||
return initBackupAndFetchAuth(backupKey)
|
||||
.then { credential ->
|
||||
@@ -677,7 +677,7 @@ object BackupRepository {
|
||||
}
|
||||
.also {
|
||||
if (it is NetworkResult.Success) {
|
||||
SignalStore.backup().cdnReadCredentials = it.result
|
||||
SignalStore.backup.cdnReadCredentials = it.result
|
||||
}
|
||||
}
|
||||
.also { Log.i(TAG, "getCdnReadCredentialsResult: $it") }
|
||||
@@ -688,20 +688,20 @@ object BackupRepository {
|
||||
try {
|
||||
val lastModified = getBackupFileLastModified().successOrThrow()
|
||||
if (lastModified != null) {
|
||||
SignalStore.backup().lastBackupTime = lastModified.toMillis()
|
||||
SignalStore.backup.lastBackupTime = lastModified.toMillis()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.i(TAG, "Could not check for backup file.", e)
|
||||
SignalStore.backup().backupTier = null
|
||||
SignalStore.backup.backupTier = null
|
||||
return null
|
||||
}
|
||||
SignalStore.backup().backupTier = try {
|
||||
SignalStore.backup.backupTier = try {
|
||||
getBackupTier().successOrThrow()
|
||||
} catch (e: Exception) {
|
||||
Log.i(TAG, "Could not retrieve backup tier.", e)
|
||||
null
|
||||
}
|
||||
return SignalStore.backup().backupTier
|
||||
return SignalStore.backup.backupTier
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -710,8 +710,8 @@ object BackupRepository {
|
||||
* These will only ever change if the backup expires.
|
||||
*/
|
||||
fun getCdnBackupDirectories(): NetworkResult<BackupDirectories> {
|
||||
val cachedBackupDirectory = SignalStore.backup().cachedBackupDirectory
|
||||
val cachedBackupMediaDirectory = SignalStore.backup().cachedBackupMediaDirectory
|
||||
val cachedBackupDirectory = SignalStore.backup.cachedBackupDirectory
|
||||
val cachedBackupMediaDirectory = SignalStore.backup.cachedBackupMediaDirectory
|
||||
|
||||
if (cachedBackupDirectory != null && cachedBackupMediaDirectory != null) {
|
||||
return NetworkResult.Success(
|
||||
@@ -723,19 +723,19 @@ object BackupRepository {
|
||||
}
|
||||
|
||||
val api = AppDependencies.signalServiceAccountManager.archiveApi
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
|
||||
return initBackupAndFetchAuth(backupKey)
|
||||
.then { credential ->
|
||||
api.getBackupInfo(backupKey, credential).map {
|
||||
SignalStore.backup().usedBackupMediaSpace = it.usedSpace ?: 0L
|
||||
SignalStore.backup.usedBackupMediaSpace = it.usedSpace ?: 0L
|
||||
BackupDirectories(it.backupDir!!, it.mediaDir!!)
|
||||
}
|
||||
}
|
||||
.also {
|
||||
if (it is NetworkResult.Success) {
|
||||
SignalStore.backup().cachedBackupDirectory = it.result.backupDir
|
||||
SignalStore.backup().cachedBackupMediaDirectory = it.result.mediaDir
|
||||
SignalStore.backup.cachedBackupDirectory = it.result.backupDir
|
||||
SignalStore.backup.cachedBackupMediaDirectory = it.result.mediaDir
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -745,7 +745,7 @@ object BackupRepository {
|
||||
}
|
||||
|
||||
suspend fun getBackupsType(tier: MessageBackupTier): MessageBackupsType {
|
||||
val backupCurrency = SignalStore.donationsValues().getSubscriptionCurrency(InAppPaymentSubscriberRecord.Type.BACKUP)
|
||||
val backupCurrency = SignalStore.donations.getSubscriptionCurrency(InAppPaymentSubscriberRecord.Type.BACKUP)
|
||||
return when (tier) {
|
||||
MessageBackupTier.FREE -> getFreeType(backupCurrency)
|
||||
MessageBackupTier.PAID -> getPaidType(backupCurrency)
|
||||
@@ -823,14 +823,14 @@ object BackupRepository {
|
||||
private fun initBackupAndFetchAuth(backupKey: BackupKey): NetworkResult<ArchiveServiceCredential> {
|
||||
val api = AppDependencies.signalServiceAccountManager.archiveApi
|
||||
|
||||
return if (SignalStore.backup().backupsInitialized) {
|
||||
return if (SignalStore.backup.backupsInitialized) {
|
||||
getAuthCredential().runOnStatusCodeError(resetInitializedStateErrorAction)
|
||||
} else {
|
||||
return api
|
||||
.triggerBackupIdReservation(backupKey)
|
||||
.then { getAuthCredential() }
|
||||
.then { credential -> api.setPublicKey(backupKey, credential).map { credential } }
|
||||
.runIfSuccessful { SignalStore.backup().backupsInitialized = true }
|
||||
.runIfSuccessful { SignalStore.backup.backupsInitialized = true }
|
||||
.runOnStatusCodeError(resetInitializedStateErrorAction)
|
||||
}
|
||||
}
|
||||
@@ -841,7 +841,7 @@ object BackupRepository {
|
||||
private fun getAuthCredential(): NetworkResult<ArchiveServiceCredential> {
|
||||
val currentTime = System.currentTimeMillis()
|
||||
|
||||
val credential = SignalStore.backup().credentialsByDay.getForCurrentTime(currentTime.milliseconds)
|
||||
val credential = SignalStore.backup.credentialsByDay.getForCurrentTime(currentTime.milliseconds)
|
||||
|
||||
if (credential != null) {
|
||||
return NetworkResult.Success(credential)
|
||||
@@ -850,9 +850,9 @@ object BackupRepository {
|
||||
Log.w(TAG, "No credentials found for today, need to fetch new ones! This shouldn't happen under normal circumstances. We should ensure the routine fetch is running properly.")
|
||||
|
||||
return AppDependencies.signalServiceAccountManager.archiveApi.getServiceCredentials(currentTime).map { result ->
|
||||
SignalStore.backup().addCredentials(result.credentials.toList())
|
||||
SignalStore.backup().clearCredentialsOlderThan(currentTime)
|
||||
SignalStore.backup().credentialsByDay.getForCurrentTime(currentTime.milliseconds)!!
|
||||
SignalStore.backup.addCredentials(result.credentials.toList())
|
||||
SignalStore.backup.clearCredentialsOlderThan(currentTime)
|
||||
SignalStore.backup.credentialsByDay.getForCurrentTime(currentTime.milliseconds)!!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -328,7 +328,7 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
|
||||
val decoded: ByteArray = Base64.decode(this.body)
|
||||
val context = DecryptedGroupV2Context.ADAPTER.decode(decoded)
|
||||
ChatUpdateMessage(
|
||||
groupChange = GroupsV2UpdateMessageConverter.translateDecryptedChange(selfIds = SignalStore.account().getServiceIds(), context)
|
||||
groupChange = GroupsV2UpdateMessageConverter.translateDecryptedChange(selfIds = SignalStore.account.getServiceIds(), context)
|
||||
)
|
||||
} catch (e: IOException) {
|
||||
null
|
||||
|
||||
+1
-1
@@ -210,7 +210,7 @@ fun RecipientTable.restoreContactFromBackup(contact: Contact): RecipientId {
|
||||
|
||||
fun RecipientTable.restoreReleaseNotes(): RecipientId {
|
||||
val releaseChannelId: RecipientId = insertReleaseChannelRecipient()
|
||||
SignalStore.releaseChannelValues().setReleaseChannelRecipientId(releaseChannelId)
|
||||
SignalStore.releaseChannel.setReleaseChannelRecipientId(releaseChannelId)
|
||||
|
||||
setProfileName(releaseChannelId, ProfileName.asGiven("Signal"))
|
||||
setMuted(releaseChannelId, Long.MAX_VALUE)
|
||||
|
||||
+35
-35
@@ -35,10 +35,10 @@ object AccountDataProcessor {
|
||||
fun export(db: SignalDatabase, emitter: BackupFrameEmitter) {
|
||||
val context = AppDependencies.application
|
||||
|
||||
val selfId = db.recipientTable.getByAci(SignalStore.account().aci!!).get()
|
||||
val selfId = db.recipientTable.getByAci(SignalStore.account.aci!!).get()
|
||||
val selfRecord = db.recipientTable.getRecordForSync(selfId)!!
|
||||
|
||||
val donationCurrency = SignalStore.donationsValues().getSubscriptionCurrency(InAppPaymentSubscriberRecord.Type.DONATION)
|
||||
val donationCurrency = SignalStore.donations.getSubscriptionCurrency(InAppPaymentSubscriberRecord.Type.DONATION)
|
||||
val donationSubscriber = SignalDatabase.inAppPaymentSubscribers.getByCurrencyCode(donationCurrency.currencyCode, InAppPaymentSubscriberRecord.Type.DONATION)
|
||||
|
||||
emitter.emit(
|
||||
@@ -50,23 +50,23 @@ object AccountDataProcessor {
|
||||
avatarUrlPath = selfRecord.signalProfileAvatar ?: "",
|
||||
username = selfRecord.username,
|
||||
accountSettings = AccountData.AccountSettings(
|
||||
storyViewReceiptsEnabled = SignalStore.storyValues().viewedReceiptsEnabled,
|
||||
storyViewReceiptsEnabled = SignalStore.story.viewedReceiptsEnabled,
|
||||
typingIndicators = TextSecurePreferences.isTypingIndicatorsEnabled(context),
|
||||
readReceipts = TextSecurePreferences.isReadReceiptsEnabled(context),
|
||||
sealedSenderIndicators = TextSecurePreferences.isShowUnidentifiedDeliveryIndicatorsEnabled(context),
|
||||
linkPreviews = SignalStore.settings().isLinkPreviewsEnabled,
|
||||
notDiscoverableByPhoneNumber = SignalStore.phoneNumberPrivacy().phoneNumberDiscoverabilityMode == PhoneNumberDiscoverabilityMode.NOT_DISCOVERABLE,
|
||||
phoneNumberSharingMode = SignalStore.phoneNumberPrivacy().phoneNumberSharingMode.toBackupPhoneNumberSharingMode(),
|
||||
preferContactAvatars = SignalStore.settings().isPreferSystemContactPhotos,
|
||||
universalExpireTimer = SignalStore.settings().universalExpireTimer,
|
||||
preferredReactionEmoji = SignalStore.emojiValues().rawReactions,
|
||||
storiesDisabled = SignalStore.storyValues().isFeatureDisabled,
|
||||
hasViewedOnboardingStory = SignalStore.storyValues().userHasViewedOnboardingStory,
|
||||
hasSetMyStoriesPrivacy = SignalStore.storyValues().userHasBeenNotifiedAboutStories,
|
||||
keepMutedChatsArchived = SignalStore.settings().shouldKeepMutedChatsArchived(),
|
||||
displayBadgesOnProfile = SignalStore.donationsValues().getDisplayBadgesOnProfile(),
|
||||
hasSeenGroupStoryEducationSheet = SignalStore.storyValues().userHasSeenGroupStoryEducationSheet,
|
||||
hasCompletedUsernameOnboarding = SignalStore.uiHints().hasCompletedUsernameOnboarding()
|
||||
linkPreviews = SignalStore.settings.isLinkPreviewsEnabled,
|
||||
notDiscoverableByPhoneNumber = SignalStore.phoneNumberPrivacy.phoneNumberDiscoverabilityMode == PhoneNumberDiscoverabilityMode.NOT_DISCOVERABLE,
|
||||
phoneNumberSharingMode = SignalStore.phoneNumberPrivacy.phoneNumberSharingMode.toBackupPhoneNumberSharingMode(),
|
||||
preferContactAvatars = SignalStore.settings.isPreferSystemContactPhotos,
|
||||
universalExpireTimer = SignalStore.settings.universalExpireTimer,
|
||||
preferredReactionEmoji = SignalStore.emoji.rawReactions,
|
||||
storiesDisabled = SignalStore.story.isFeatureDisabled,
|
||||
hasViewedOnboardingStory = SignalStore.story.userHasViewedOnboardingStory,
|
||||
hasSetMyStoriesPrivacy = SignalStore.story.userHasBeenNotifiedAboutStories,
|
||||
keepMutedChatsArchived = SignalStore.settings.shouldKeepMutedChatsArchived(),
|
||||
displayBadgesOnProfile = SignalStore.donations.getDisplayBadgesOnProfile(),
|
||||
hasSeenGroupStoryEducationSheet = SignalStore.story.userHasSeenGroupStoryEducationSheet,
|
||||
hasCompletedUsernameOnboarding = SignalStore.uiHints.hasCompletedUsernameOnboarding()
|
||||
),
|
||||
donationSubscriberData = AccountData.SubscriberData(
|
||||
subscriberId = donationSubscriber?.subscriberId?.bytes?.toByteString() ?: defaultAccountRecord.subscriberId,
|
||||
@@ -81,7 +81,7 @@ object AccountDataProcessor {
|
||||
fun import(accountData: AccountData, selfId: RecipientId) {
|
||||
SignalDatabase.recipients.restoreSelfFromBackup(accountData, selfId)
|
||||
|
||||
SignalStore.account().setRegistered(true)
|
||||
SignalStore.account.setRegistered(true)
|
||||
|
||||
val context = AppDependencies.application
|
||||
val settings = accountData.accountSettings
|
||||
@@ -90,19 +90,19 @@ object AccountDataProcessor {
|
||||
TextSecurePreferences.setReadReceiptsEnabled(context, settings.readReceipts)
|
||||
TextSecurePreferences.setTypingIndicatorsEnabled(context, settings.typingIndicators)
|
||||
TextSecurePreferences.setShowUnidentifiedDeliveryIndicatorsEnabled(context, settings.sealedSenderIndicators)
|
||||
SignalStore.settings().isLinkPreviewsEnabled = settings.linkPreviews
|
||||
SignalStore.phoneNumberPrivacy().phoneNumberDiscoverabilityMode = if (settings.notDiscoverableByPhoneNumber) PhoneNumberDiscoverabilityMode.NOT_DISCOVERABLE else PhoneNumberDiscoverabilityMode.DISCOVERABLE
|
||||
SignalStore.phoneNumberPrivacy().phoneNumberSharingMode = settings.phoneNumberSharingMode.toLocalPhoneNumberMode()
|
||||
SignalStore.settings().isPreferSystemContactPhotos = settings.preferContactAvatars
|
||||
SignalStore.settings().universalExpireTimer = settings.universalExpireTimer
|
||||
SignalStore.emojiValues().reactions = settings.preferredReactionEmoji
|
||||
SignalStore.donationsValues().setDisplayBadgesOnProfile(settings.displayBadgesOnProfile)
|
||||
SignalStore.settings().setKeepMutedChatsArchived(settings.keepMutedChatsArchived)
|
||||
SignalStore.storyValues().userHasBeenNotifiedAboutStories = settings.hasSetMyStoriesPrivacy
|
||||
SignalStore.storyValues().userHasViewedOnboardingStory = settings.hasViewedOnboardingStory
|
||||
SignalStore.storyValues().isFeatureDisabled = settings.storiesDisabled
|
||||
SignalStore.storyValues().userHasSeenGroupStoryEducationSheet = settings.hasSeenGroupStoryEducationSheet
|
||||
SignalStore.storyValues().viewedReceiptsEnabled = settings.storyViewReceiptsEnabled ?: settings.readReceipts
|
||||
SignalStore.settings.isLinkPreviewsEnabled = settings.linkPreviews
|
||||
SignalStore.phoneNumberPrivacy.phoneNumberDiscoverabilityMode = if (settings.notDiscoverableByPhoneNumber) PhoneNumberDiscoverabilityMode.NOT_DISCOVERABLE else PhoneNumberDiscoverabilityMode.DISCOVERABLE
|
||||
SignalStore.phoneNumberPrivacy.phoneNumberSharingMode = settings.phoneNumberSharingMode.toLocalPhoneNumberMode()
|
||||
SignalStore.settings.isPreferSystemContactPhotos = settings.preferContactAvatars
|
||||
SignalStore.settings.universalExpireTimer = settings.universalExpireTimer
|
||||
SignalStore.emoji.reactions = settings.preferredReactionEmoji
|
||||
SignalStore.donations.setDisplayBadgesOnProfile(settings.displayBadgesOnProfile)
|
||||
SignalStore.settings.setKeepMutedChatsArchived(settings.keepMutedChatsArchived)
|
||||
SignalStore.story.userHasBeenNotifiedAboutStories = settings.hasSetMyStoriesPrivacy
|
||||
SignalStore.story.userHasViewedOnboardingStory = settings.hasViewedOnboardingStory
|
||||
SignalStore.story.isFeatureDisabled = settings.storiesDisabled
|
||||
SignalStore.story.userHasSeenGroupStoryEducationSheet = settings.hasSeenGroupStoryEducationSheet
|
||||
SignalStore.story.viewedReceiptsEnabled = settings.storyViewReceiptsEnabled ?: settings.readReceipts
|
||||
|
||||
if (accountData.donationSubscriberData != null) {
|
||||
if (accountData.donationSubscriberData.subscriberId.size > 0) {
|
||||
@@ -121,7 +121,7 @@ object AccountDataProcessor {
|
||||
}
|
||||
|
||||
if (accountData.donationSubscriberData.manuallyCancelled) {
|
||||
SignalStore.donationsValues().updateLocalStateForManualCancellation(InAppPaymentSubscriberRecord.Type.DONATION)
|
||||
SignalStore.donations.updateLocalStateForManualCancellation(InAppPaymentSubscriberRecord.Type.DONATION)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,19 +130,19 @@ object AccountDataProcessor {
|
||||
}
|
||||
|
||||
if (accountData.usernameLink != null) {
|
||||
SignalStore.account().usernameLink = UsernameLinkComponents(
|
||||
SignalStore.account.usernameLink = UsernameLinkComponents(
|
||||
accountData.usernameLink.entropy.toByteArray(),
|
||||
UuidUtil.parseOrThrow(accountData.usernameLink.serverId.toByteArray())
|
||||
)
|
||||
SignalStore.misc().usernameQrCodeColorScheme = accountData.usernameLink.color.toLocalUsernameColor()
|
||||
SignalStore.misc.usernameQrCodeColorScheme = accountData.usernameLink.color.toLocalUsernameColor()
|
||||
}
|
||||
|
||||
if (settings.preferredReactionEmoji.isNotEmpty()) {
|
||||
SignalStore.emojiValues().reactions = settings.preferredReactionEmoji
|
||||
SignalStore.emoji.reactions = settings.preferredReactionEmoji
|
||||
}
|
||||
|
||||
if (settings.hasCompletedUsernameOnboarding) {
|
||||
SignalStore.uiHints().setHasCompletedUsernameOnboarding(true)
|
||||
SignalStore.uiHints.setHasCompletedUsernameOnboarding(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -31,8 +31,8 @@ object RecipientBackupProcessor {
|
||||
val TAG = Log.tag(RecipientBackupProcessor::class.java)
|
||||
|
||||
fun export(db: SignalDatabase, state: ExportState, emitter: BackupFrameEmitter) {
|
||||
val selfId = db.recipientTable.getByAci(SignalStore.account().aci!!).get().toLong()
|
||||
val releaseChannelId = SignalStore.releaseChannelValues().releaseChannelRecipientId
|
||||
val selfId = db.recipientTable.getByAci(SignalStore.account.aci!!).get().toLong()
|
||||
val releaseChannelId = SignalStore.releaseChannel.releaseChannelRecipientId
|
||||
if (releaseChannelId != null) {
|
||||
emitter.emit(
|
||||
Frame(
|
||||
|
||||
+3
-3
@@ -12,13 +12,13 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.lock.v2.PinKeyboardType
|
||||
|
||||
data class MessageBackupsFlowState(
|
||||
val selectedMessageBackupTier: MessageBackupTier? = SignalStore.backup().backupTier,
|
||||
val currentMessageBackupTier: MessageBackupTier? = SignalStore.backup().backupTier,
|
||||
val selectedMessageBackupTier: MessageBackupTier? = SignalStore.backup.backupTier,
|
||||
val currentMessageBackupTier: MessageBackupTier? = SignalStore.backup.backupTier,
|
||||
val availableBackupTypes: List<MessageBackupsType> = emptyList(),
|
||||
val selectedPaymentMethod: InAppPaymentData.PaymentMethodType? = null,
|
||||
val availablePaymentMethods: List<InAppPaymentData.PaymentMethodType> = emptyList(),
|
||||
val pin: String = "",
|
||||
val pinKeyboardType: PinKeyboardType = SignalStore.pinValues().keyboardType,
|
||||
val pinKeyboardType: PinKeyboardType = SignalStore.pin.keyboardType,
|
||||
val inAppPayment: InAppPaymentTable.InAppPayment? = null,
|
||||
val startScreen: MessageBackupsScreen,
|
||||
val screen: MessageBackupsScreen = startScreen
|
||||
|
||||
+5
-5
@@ -35,9 +35,9 @@ class MessageBackupsFlowViewModel : ViewModel() {
|
||||
private val internalState = mutableStateOf(
|
||||
MessageBackupsFlowState(
|
||||
availableBackupTypes = emptyList(),
|
||||
selectedMessageBackupTier = SignalStore.backup().backupTier,
|
||||
selectedMessageBackupTier = SignalStore.backup.backupTier,
|
||||
availablePaymentMethods = GatewayOrderStrategy.getStrategy().orderedGateways.filter { InAppDonations.isPaymentSourceAvailable(it.toPaymentSourceType(), InAppPaymentType.RECURRING_BACKUP) },
|
||||
startScreen = if (SignalStore.backup().backupTier == null) MessageBackupsScreen.EDUCATION else MessageBackupsScreen.TYPE_SELECTION
|
||||
startScreen = if (SignalStore.backup.backupTier == null) MessageBackupsScreen.EDUCATION else MessageBackupsScreen.TYPE_SELECTION
|
||||
)
|
||||
)
|
||||
|
||||
@@ -103,7 +103,7 @@ class MessageBackupsFlowViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
private fun validatePinAndUpdateState(): MessageBackupsScreen {
|
||||
val pinHash = SignalStore.svr().localPinHash
|
||||
val pinHash = SignalStore.svr.localPinHash
|
||||
val pin = state.value.pin
|
||||
|
||||
if (pinHash == null || TextUtils.isEmpty(pin) || pin.length < SvrConstants.MINIMUM_PIN_LENGTH) return MessageBackupsScreen.PIN_CONFIRMATION
|
||||
@@ -115,8 +115,8 @@ class MessageBackupsFlowViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
private fun validateTypeAndUpdateState(): MessageBackupsScreen {
|
||||
SignalStore.backup().areBackupsEnabled = true
|
||||
SignalStore.backup().backupTier = state.value.selectedMessageBackupTier!!
|
||||
SignalStore.backup.areBackupsEnabled = true
|
||||
SignalStore.backup.backupTier = state.value.selectedMessageBackupTier!!
|
||||
|
||||
// TODO [message-backups] - Does anything need to be kicked off?
|
||||
|
||||
|
||||
+2
-2
@@ -34,8 +34,8 @@ class RemoteRestoreViewModel : ViewModel() {
|
||||
|
||||
private val _state: MutableState<ScreenState> = mutableStateOf(
|
||||
ScreenState(
|
||||
backupTier = SignalStore.backup().backupTier,
|
||||
backupTime = SignalStore.backup().lastBackupTime,
|
||||
backupTier = SignalStore.backup.backupTier,
|
||||
backupTime = SignalStore.backup.lastBackupTime,
|
||||
importState = ImportState.NONE,
|
||||
restoreProgress = null
|
||||
)
|
||||
|
||||
@@ -45,7 +45,7 @@ class BadgeRepository(context: Context) {
|
||||
|
||||
Log.d(TAG, "[setVisibilityForAllBadgesSync] Uploading profile...", true)
|
||||
ProfileUtil.uploadProfileWithBadges(context, badges)
|
||||
SignalStore.donationsValues().setDisplayBadgesOnProfile(displayBadgesOnProfile)
|
||||
SignalStore.donations.setDisplayBadgesOnProfile(displayBadgesOnProfile)
|
||||
recipientTable.markNeedsSync(Recipient.self().id)
|
||||
|
||||
Log.d(TAG, "[setVisibilityForAllBadgesSync] Requesting data change sync...", true)
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ object ExpiredGiftSheetConfiguration {
|
||||
)
|
||||
)
|
||||
|
||||
if (SignalStore.donationsValues().isLikelyASustainer()) {
|
||||
if (SignalStore.donations.isLikelyASustainer()) {
|
||||
primaryButton(
|
||||
text = DSLSettingsText.from(
|
||||
stringId = android.R.string.ok
|
||||
|
||||
@@ -33,7 +33,7 @@ class GiftFlowViewModel(
|
||||
|
||||
private val store = RxStore(
|
||||
GiftFlowState(
|
||||
currency = SignalStore.donationsValues().getOneTimeCurrency()
|
||||
currency = SignalStore.donations.getOneTimeCurrency()
|
||||
)
|
||||
)
|
||||
private val disposables = CompositeDisposable()
|
||||
@@ -66,7 +66,7 @@ class GiftFlowViewModel(
|
||||
|
||||
fun refresh() {
|
||||
disposables.clear()
|
||||
disposables += SignalStore.donationsValues().observableOneTimeCurrency.subscribe { currency ->
|
||||
disposables += SignalStore.donations.observableOneTimeCurrency.subscribe { currency ->
|
||||
store.update {
|
||||
it.copy(
|
||||
currency = currency
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ class ViewReceivedGiftViewModel(
|
||||
.subscribe { badge ->
|
||||
val otherBadges = Recipient.self().badges.filterNot { it.id == badge.id }
|
||||
val hasOtherBadges = otherBadges.isNotEmpty()
|
||||
val displayingBadges = SignalStore.donationsValues().getDisplayBadgesOnProfile()
|
||||
val displayingBadges = SignalStore.donations.getDisplayBadgesOnProfile()
|
||||
val displayingOtherBadges = hasOtherBadges && displayingBadges
|
||||
|
||||
store.update {
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ class ExpiredOneTimeBadgeBottomSheetDialogFragment : DSLSettingsBottomSheetFragm
|
||||
private fun getConfiguration(): DSLConfiguration {
|
||||
val args = ExpiredOneTimeBadgeBottomSheetDialogFragmentArgs.fromBundle(requireArguments())
|
||||
val badge: Badge = args.badge
|
||||
val isLikelyASustainer = SignalStore.donationsValues().isLikelyASustainer()
|
||||
val isLikelyASustainer = SignalStore.donations.isLikelyASustainer()
|
||||
|
||||
Log.d(TAG, "Displaying Expired Badge Fragment with bundle: ${requireArguments()}", true)
|
||||
|
||||
|
||||
+1
-1
@@ -96,7 +96,7 @@ class MonthlyDonationCanceledBottomSheetDialogFragment : ComposeBottomSheetDialo
|
||||
dismissAllowingStateLoss()
|
||||
},
|
||||
onNotNowClicked = {
|
||||
SignalStore.donationsValues().showMonthlyDonationCanceledDialog = false
|
||||
SignalStore.donations.showMonthlyDonationCanceledDialog = false
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
)
|
||||
|
||||
+2
-3
@@ -10,7 +10,6 @@ import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -59,8 +58,8 @@ class MonthlyDonationCanceledViewModel(
|
||||
private fun initializeFromSignalStore() {
|
||||
internalState.value = MonthlyDonationCanceledState(
|
||||
loadState = MonthlyDonationCanceledState.LoadState.READY,
|
||||
badge = SignalStore.donationsValues().getExpiredBadge(),
|
||||
errorMessage = getErrorMessage(SignalStore.donationsValues().getUnexpectedSubscriptionCancelationChargeFailure())
|
||||
badge = SignalStore.donations.getExpiredBadge(),
|
||||
errorMessage = getErrorMessage(SignalStore.donations.getUnexpectedSubscriptionCancelationChargeFailure())
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ class BadgesOverviewViewModel(
|
||||
state.copy(
|
||||
stage = if (state.stage == BadgesOverviewState.Stage.INIT) BadgesOverviewState.Stage.READY else state.stage,
|
||||
allUnlockedBadges = recipient.badges,
|
||||
displayBadgesOnProfile = SignalStore.donationsValues().getDisplayBadgesOnProfile(),
|
||||
displayBadgesOnProfile = SignalStore.donations.getDisplayBadgesOnProfile(),
|
||||
featuredBadge = recipient.featuredBadge
|
||||
)
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ class CallLogFragment : Fragment(R.layout.call_log_fragment), CallLogAdapter.Cal
|
||||
}
|
||||
|
||||
FilterPullState.OPEN_APEX -> if (source === ConversationFilterSource.DRAG) {
|
||||
// TODO[alex] -- hint here? SignalStore.uiHints().incrementNeverDisplayPullToFilterTip()
|
||||
// TODO[alex] -- hint here? SignalStore.uiHints.incrementNeverDisplayPullToFilterTip()
|
||||
}
|
||||
|
||||
FilterPullState.CLOSE_APEX -> ViewUtil.setMinimumHeight(collapsingToolbarLayout, 0)
|
||||
|
||||
@@ -42,7 +42,7 @@ class NewCallActivity : ContactSelectionActivity(), ContactSelectionListFragment
|
||||
launch(Recipient.resolved(recipientId.get()))
|
||||
} else {
|
||||
Log.i(TAG, "[onContactSelected] Maybe creating a new recipient.")
|
||||
if (SignalStore.account().isRegistered) {
|
||||
if (SignalStore.account.isRegistered) {
|
||||
Log.i(TAG, "[onContactSelected] Doing contact refresh.")
|
||||
|
||||
val progress = SimpleProgressDialog.show(this)
|
||||
|
||||
+3
-3
@@ -48,8 +48,8 @@ class DebugLogsPromptDialogFragment : FixedRoundedCornerBottomSheetDialogFragmen
|
||||
}.show(activity.supportFragmentManager, BottomSheetUtil.STANDARD_BOTTOM_SHEET_FRAGMENT_TAG)
|
||||
|
||||
when (purpose) {
|
||||
Purpose.NOTIFICATIONS -> SignalStore.uiHints().lastNotificationLogsPrompt = System.currentTimeMillis()
|
||||
Purpose.CRASH -> SignalStore.uiHints().lastCrashPrompt = System.currentTimeMillis()
|
||||
Purpose.NOTIFICATIONS -> SignalStore.uiHints.lastNotificationLogsPrompt = System.currentTimeMillis()
|
||||
Purpose.CRASH -> SignalStore.uiHints.lastCrashPrompt = System.currentTimeMillis()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ class DebugLogsPromptDialogFragment : FixedRoundedCornerBottomSheetDialogFragmen
|
||||
|
||||
binding.decline.setOnClickListener {
|
||||
if (purpose == Purpose.NOTIFICATIONS) {
|
||||
SignalStore.uiHints().markDeclinedShareNotificationLogs()
|
||||
SignalStore.uiHints.markDeclinedShareNotificationLogs()
|
||||
}
|
||||
|
||||
dismissAllowingStateLoss()
|
||||
|
||||
+2
-2
@@ -47,7 +47,7 @@ class DeleteSyncEducationDialog : ComposeBottomSheetDialogFragment() {
|
||||
@JvmStatic
|
||||
fun shouldShow(): Boolean {
|
||||
return TextSecurePreferences.isMultiDevice(AppDependencies.application) &&
|
||||
!SignalStore.uiHints().hasSeenDeleteSyncEducationSheet &&
|
||||
!SignalStore.uiHints.hasSeenDeleteSyncEducationSheet &&
|
||||
Recipient.self().deleteSyncCapability.isSupported
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class DeleteSyncEducationDialog : ComposeBottomSheetDialogFragment() {
|
||||
val dialog = DeleteSyncEducationDialog()
|
||||
|
||||
dialog.show(fragmentManager, null)
|
||||
SignalStore.uiHints().hasSeenDeleteSyncEducationSheet = true
|
||||
SignalStore.uiHints.hasSeenDeleteSyncEducationSheet = true
|
||||
|
||||
val subject = CompletableSubject.create()
|
||||
dialog.subject = subject
|
||||
|
||||
+4
-4
@@ -157,9 +157,9 @@ open class InsetAwareConstraintLayout @JvmOverloads constructor(
|
||||
|
||||
private fun getKeyboardHeight(): Int {
|
||||
val height = if (isLandscape()) {
|
||||
SignalStore.misc().keyboardLandscapeHeight
|
||||
SignalStore.misc.keyboardLandscapeHeight
|
||||
} else {
|
||||
SignalStore.misc().keyboardPortraitHeight
|
||||
SignalStore.misc.keyboardPortraitHeight
|
||||
}
|
||||
|
||||
val minHeight = resources.getDimensionPixelSize(R.dimen.default_custom_keyboard_size)
|
||||
@@ -173,9 +173,9 @@ open class InsetAwareConstraintLayout @JvmOverloads constructor(
|
||||
|
||||
private fun setKeyboardHeight(height: Int) {
|
||||
if (isLandscape()) {
|
||||
SignalStore.misc().keyboardLandscapeHeight = height
|
||||
SignalStore.misc.keyboardLandscapeHeight = height
|
||||
} else {
|
||||
SignalStore.misc().keyboardPortraitHeight = height
|
||||
SignalStore.misc.keyboardPortraitHeight = height
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ class PromptBatterySaverDialogFragment : FixedRoundedCornerBottomSheetDialogFrag
|
||||
PromptBatterySaverDialogFragment().apply {
|
||||
arguments = bundleOf()
|
||||
}.show(fragmentManager, BottomSheetUtil.STANDARD_BOTTOM_SHEET_FRAGMENT_TAG)
|
||||
SignalStore.uiHints().lastBatterySaverPrompt = System.currentTimeMillis()
|
||||
SignalStore.uiHints.lastBatterySaverPrompt = System.currentTimeMillis()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ class PromptBatterySaverDialogFragment : FixedRoundedCornerBottomSheetDialogFrag
|
||||
}
|
||||
binding.dismissButton.setOnClickListener {
|
||||
Log.i(TAG, "User denied request to ignore battery optimizations.")
|
||||
SignalStore.uiHints().markDismissedBatterySaverPrompt()
|
||||
SignalStore.uiHints.markDismissedBatterySaverPrompt()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ open class SimpleEmojiTextView @JvmOverloads constructor(
|
||||
private val spoilerRendererDelegate: SpoilerRendererDelegate
|
||||
|
||||
init {
|
||||
isEmojiCompatEnabled = isInEditMode || SignalStore.settings().isPreferSystemEmoji
|
||||
isEmojiCompatEnabled = isInEditMode || SignalStore.settings.isPreferSystemEmoji
|
||||
spoilerRendererDelegate = SpoilerRendererDelegate(this)
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ open class SimpleEmojiTextView @JvmOverloads constructor(
|
||||
override fun setText(text: CharSequence?, type: BufferType?) {
|
||||
bufferType = type
|
||||
val candidates = if (isInEditMode) null else EmojiProvider.getCandidates(text)
|
||||
if (SignalStore.settings().isPreferSystemEmoji || candidates == null || candidates.size() == 0) {
|
||||
if (SignalStore.settings.isPreferSystemEmoji || candidates == null || candidates.size() == 0) {
|
||||
super.setText(Optional.ofNullable(text).orElse(""), type)
|
||||
} else {
|
||||
val startDrawableSize: Int = compoundDrawables[0]?.let { it.intrinsicWidth + compoundDrawablePadding } ?: 0
|
||||
|
||||
+2
-2
@@ -35,8 +35,8 @@ class CdsPermanentErrorReminder : Reminder(R.string.reminder_cds_permanent_error
|
||||
|
||||
@JvmStatic
|
||||
fun isEligible(): Boolean {
|
||||
val timeUntilUnblock = SignalStore.misc().cdsBlockedUtil - System.currentTimeMillis()
|
||||
return SignalStore.misc().isCdsBlocked && timeUntilUnblock >= PERMANENT_TIME_CUTOFF
|
||||
val timeUntilUnblock = SignalStore.misc.cdsBlockedUtil - System.currentTimeMillis()
|
||||
return SignalStore.misc.isCdsBlocked && timeUntilUnblock >= PERMANENT_TIME_CUTOFF
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -28,8 +28,8 @@ class CdsTemporaryErrorReminder : Reminder(R.string.reminder_cds_warning_body) {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun isEligible(): Boolean {
|
||||
val timeUntilUnblock = SignalStore.misc().cdsBlockedUtil - System.currentTimeMillis()
|
||||
return SignalStore.misc().isCdsBlocked && timeUntilUnblock < CdsPermanentErrorReminder.PERMANENT_TIME_CUTOFF
|
||||
val timeUntilUnblock = SignalStore.misc.cdsBlockedUtil - System.currentTimeMillis()
|
||||
return SignalStore.misc.isCdsBlocked && timeUntilUnblock < CdsPermanentErrorReminder.PERMANENT_TIME_CUTOFF
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -12,7 +12,7 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
class UsernameOutOfSyncReminder : Reminder(NO_RESOURCE) {
|
||||
|
||||
init {
|
||||
val action = if (SignalStore.account().usernameSyncState == UsernameSyncState.USERNAME_AND_LINK_CORRUPTED) {
|
||||
val action = if (SignalStore.account.usernameSyncState == UsernameSyncState.USERNAME_AND_LINK_CORRUPTED) {
|
||||
R.id.reminder_action_fix_username_and_link
|
||||
} else {
|
||||
R.id.reminder_action_fix_username_link
|
||||
@@ -27,7 +27,7 @@ class UsernameOutOfSyncReminder : Reminder(NO_RESOURCE) {
|
||||
}
|
||||
|
||||
override fun getText(context: Context): CharSequence {
|
||||
return if (SignalStore.account().usernameSyncState == UsernameSyncState.USERNAME_AND_LINK_CORRUPTED) {
|
||||
return if (SignalStore.account.usernameSyncState == UsernameSyncState.USERNAME_AND_LINK_CORRUPTED) {
|
||||
context.getString(R.string.UsernameOutOfSyncReminder__username_and_link_corrupt)
|
||||
} else {
|
||||
context.getString(R.string.UsernameOutOfSyncReminder__link_corrupt)
|
||||
@@ -41,7 +41,7 @@ class UsernameOutOfSyncReminder : Reminder(NO_RESOURCE) {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun isEligible(): Boolean {
|
||||
return when (SignalStore.account().usernameSyncState) {
|
||||
return when (SignalStore.account.usernameSyncState) {
|
||||
UsernameSyncState.USERNAME_AND_LINK_CORRUPTED -> true
|
||||
UsernameSyncState.LINK_CORRUPTED -> true
|
||||
UsernameSyncState.IN_SYNC -> false
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ class AppSettingsActivity : DSLSettingsActivity(), InAppPaymentComponent {
|
||||
navController.safeNavigate(it)
|
||||
}
|
||||
|
||||
SignalStore.settings().onConfigurationSettingChanged.observe(this) { key ->
|
||||
SignalStore.settings.onConfigurationSettingChanged.observe(this) { key ->
|
||||
if (key == SettingsValues.THEME) {
|
||||
DynamicTheme.setDefaultDayNightMode(this)
|
||||
recreate()
|
||||
|
||||
+3
-3
@@ -139,7 +139,7 @@ class AppSettingsFragment : DSLSettingsFragment(
|
||||
findNavController().safeNavigate(R.id.action_appSettingsFragment_to_manageProfileActivity)
|
||||
},
|
||||
onQrButtonClicked = {
|
||||
if (SignalStore.account().username != null) {
|
||||
if (SignalStore.account.username != null) {
|
||||
findNavController().safeNavigate(R.id.action_appSettingsFragment_to_usernameLinkSettingsFragment)
|
||||
} else {
|
||||
findNavController().safeNavigate(R.id.action_appSettingsFragment_to_usernameEducationFragment)
|
||||
@@ -253,7 +253,7 @@ class AppSettingsFragment : DSLSettingsFragment(
|
||||
|
||||
dividerPref()
|
||||
|
||||
if (SignalStore.paymentsValues().paymentsAvailability.showPaymentsMenu()) {
|
||||
if (SignalStore.payments.paymentsAvailability.showPaymentsMenu()) {
|
||||
customPref(
|
||||
PaymentsPreference(
|
||||
unreadCount = state.unreadPaymentsCount
|
||||
@@ -370,7 +370,7 @@ class AppSettingsFragment : DSLSettingsFragment(
|
||||
summaryView.visibility = View.VISIBLE
|
||||
avatarView.visibility = View.VISIBLE
|
||||
|
||||
if (SignalStore.account().username.isNotNullOrBlank()) {
|
||||
if (SignalStore.account.username.isNotNullOrBlank()) {
|
||||
qrButton.visibility = View.VISIBLE
|
||||
qrButton.isClickable = true
|
||||
qrButton.setOnClickListener { model.onQrButtonClicked() }
|
||||
|
||||
+7
-7
@@ -21,10 +21,10 @@ class AppSettingsViewModel : ViewModel() {
|
||||
AppSettingsState(
|
||||
Recipient.self(),
|
||||
0,
|
||||
SignalStore.donationsValues().getExpiredGiftBadge() != null,
|
||||
SignalStore.donationsValues().isLikelyASustainer() || InAppDonations.hasAtLeastOnePaymentMethodAvailable(),
|
||||
TextSecurePreferences.isUnauthorizedReceived(AppDependencies.application) || !SignalStore.account().isRegistered,
|
||||
SignalStore.misc().isClientDeprecated
|
||||
SignalStore.donations.getExpiredGiftBadge() != null,
|
||||
SignalStore.donations.isLikelyASustainer() || InAppDonations.hasAtLeastOnePaymentMethodAvailable(),
|
||||
TextSecurePreferences.isUnauthorizedReceived(AppDependencies.application) || !SignalStore.account.isRegistered,
|
||||
SignalStore.misc.isClientDeprecated
|
||||
)
|
||||
)
|
||||
|
||||
@@ -55,13 +55,13 @@ class AppSettingsViewModel : ViewModel() {
|
||||
fun refreshDeprecatedOrUnregistered() {
|
||||
store.update {
|
||||
it.copy(
|
||||
clientDeprecated = SignalStore.misc().isClientDeprecated,
|
||||
userUnregistered = TextSecurePreferences.isUnauthorizedReceived(AppDependencies.application) || !SignalStore.account().isRegistered
|
||||
clientDeprecated = SignalStore.misc.isClientDeprecated,
|
||||
userUnregistered = TextSecurePreferences.isUnauthorizedReceived(AppDependencies.application) || !SignalStore.account.isRegistered
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun refreshExpiredGiftBadge() {
|
||||
store.update { it.copy(hasExpiredGiftBadge = SignalStore.donationsValues().getExpiredGiftBadge() != null) }
|
||||
store.update { it.copy(hasExpiredGiftBadge = SignalStore.donations.getExpiredGiftBadge() != null) }
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -112,7 +112,7 @@ class AccountSettingsFragment : DSLSettingsFragment(R.string.AccountSettingsFrag
|
||||
|
||||
sectionHeaderPref(R.string.AccountSettingsFragment__account)
|
||||
|
||||
if (SignalStore.account().isRegistered) {
|
||||
if (SignalStore.account.isRegistered) {
|
||||
clickPref(
|
||||
title = DSLSettingsText.from(R.string.AccountSettingsFragment__change_phone_number),
|
||||
isEnabled = state.isDeprecatedOrUnregistered(),
|
||||
@@ -227,7 +227,7 @@ class AccountSettingsFragment : DSLSettingsFragment(R.string.AccountSettingsFrag
|
||||
|
||||
ViewCompat.setAutofillHints(pinEditText, HintConstants.AUTOFILL_HINT_PASSWORD)
|
||||
|
||||
when (SignalStore.pinValues().keyboardType) {
|
||||
when (SignalStore.pin.keyboardType) {
|
||||
PinKeyboardType.NUMERIC -> {
|
||||
pinEditText.inputType = InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD
|
||||
changeKeyboard.setIconResource(PinKeyboardType.ALPHA_NUMERIC.iconResource)
|
||||
@@ -247,9 +247,9 @@ class AccountSettingsFragment : DSLSettingsFragment(R.string.AccountSettingsFrag
|
||||
pinEditText.typeface = Typeface.DEFAULT
|
||||
turnOffButton.setOnClickListener {
|
||||
val pin = pinEditText.text.toString()
|
||||
val correct = PinHashUtil.verifyLocalPinHash(SignalStore.svr().localPinHash!!, pin)
|
||||
val correct = PinHashUtil.verifyLocalPinHash(SignalStore.svr.localPinHash!!, pin)
|
||||
if (correct) {
|
||||
SignalStore.pinValues().setPinRemindersEnabled(false)
|
||||
SignalStore.pin.setPinRemindersEnabled(false)
|
||||
viewModel.refreshState()
|
||||
dialog.dismiss()
|
||||
} else {
|
||||
@@ -259,7 +259,7 @@ class AccountSettingsFragment : DSLSettingsFragment(R.string.AccountSettingsFrag
|
||||
|
||||
cancelButton.setOnClickListener { dialog.dismiss() }
|
||||
} else {
|
||||
SignalStore.pinValues().setPinRemindersEnabled(true)
|
||||
SignalStore.pin.setPinRemindersEnabled(true)
|
||||
viewModel.refreshState()
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -18,11 +18,11 @@ class AccountSettingsViewModel : ViewModel() {
|
||||
|
||||
private fun getCurrentState(): AccountSettingsState {
|
||||
return AccountSettingsState(
|
||||
hasPin = SignalStore.svr().hasPin() && !SignalStore.svr().hasOptedOut(),
|
||||
pinRemindersEnabled = SignalStore.pinValues().arePinRemindersEnabled(),
|
||||
registrationLockEnabled = SignalStore.svr().isRegistrationLockEnabled,
|
||||
hasPin = SignalStore.svr.hasPin() && !SignalStore.svr.hasOptedOut(),
|
||||
pinRemindersEnabled = SignalStore.pin.arePinRemindersEnabled(),
|
||||
registrationLockEnabled = SignalStore.svr.isRegistrationLockEnabled,
|
||||
userUnregistered = TextSecurePreferences.isUnauthorizedReceived(AppDependencies.application),
|
||||
clientDeprecated = SignalStore.misc().isClientDeprecated
|
||||
clientDeprecated = SignalStore.misc.isClientDeprecated
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -24,27 +24,27 @@ class AppearanceSettingsViewModel : ViewModel() {
|
||||
|
||||
fun setTheme(activity: Activity?, theme: Theme) {
|
||||
store.update { it.copy(theme = theme) }
|
||||
SignalStore.settings().theme = theme
|
||||
SignalStore.settings.theme = theme
|
||||
SplashScreenUtil.setSplashScreenThemeIfNecessary(activity, theme)
|
||||
}
|
||||
|
||||
fun setLanguage(language: String) {
|
||||
store.update { it.copy(language = language) }
|
||||
SignalStore.settings().language = language
|
||||
SignalStore.settings.language = language
|
||||
EmojiSearchIndexDownloadJob.scheduleImmediately()
|
||||
}
|
||||
|
||||
fun setMessageFontSize(size: Int) {
|
||||
store.update { it.copy(messageFontSize = size) }
|
||||
SignalStore.settings().messageFontSize = size
|
||||
SignalStore.settings.messageFontSize = size
|
||||
}
|
||||
|
||||
private fun getState(): AppearanceSettingsState {
|
||||
return AppearanceSettingsState(
|
||||
SignalStore.settings().theme,
|
||||
SignalStore.settings().messageFontSize,
|
||||
SignalStore.settings().language,
|
||||
SignalStore.settings().useCompactNavigationBar
|
||||
SignalStore.settings.theme,
|
||||
SignalStore.settings.messageFontSize,
|
||||
SignalStore.settings.language,
|
||||
SignalStore.settings.useCompactNavigationBar
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ class ChooseNavigationBarStyleFragment : DialogFragment(R.layout.choose_navigati
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
presentToggleState(SignalStore.settings().useCompactNavigationBar)
|
||||
presentToggleState(SignalStore.settings.useCompactNavigationBar)
|
||||
|
||||
binding.toggle.addOnButtonCheckedListener { group, checkedId, isChecked ->
|
||||
if (isChecked) {
|
||||
@@ -38,7 +38,7 @@ class ChooseNavigationBarStyleFragment : DialogFragment(R.layout.choose_navigati
|
||||
|
||||
binding.ok.setOnClickListener {
|
||||
val isCompact = binding.toggle.checkedButtonId == R.id.compact
|
||||
SignalStore.settings().useCompactNavigationBar = isCompact
|
||||
SignalStore.settings.useCompactNavigationBar = isCompact
|
||||
dismissAllowingStateLoss()
|
||||
setFragmentResult(REQUEST_KEY, bundleOf(REQUEST_KEY to true))
|
||||
}
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ class ChangeNumberEnterSmsCodeFragment : BaseEnterSmsCodeFragment<ChangeNumberVi
|
||||
}
|
||||
|
||||
private fun navigateUp() {
|
||||
if (SignalStore.misc().isChangeNumberLocked) {
|
||||
if (SignalStore.misc.isChangeNumberLocked) {
|
||||
Log.d(TAG, "Change number locked, navigateUp")
|
||||
startActivity(ChangeNumberLockActivity.createIntent(requireContext()))
|
||||
} else {
|
||||
|
||||
+5
-5
@@ -55,11 +55,11 @@ class ChangeNumberLockActivity : PassphraseRequiredActivity() {
|
||||
disposables += changeNumberRepository
|
||||
.whoAmI()
|
||||
.flatMap { whoAmI ->
|
||||
if (Objects.equals(whoAmI.number, SignalStore.account().e164)) {
|
||||
if (Objects.equals(whoAmI.number, SignalStore.account.e164)) {
|
||||
Log.i(TAG, "Local and remote numbers match, nothing needs to be done.")
|
||||
Single.just(false)
|
||||
} else {
|
||||
Log.i(TAG, "Local (${SignalStore.account().e164}) and remote (${whoAmI.number}) numbers do not match, updating local.")
|
||||
Log.i(TAG, "Local (${SignalStore.account.e164}) and remote (${whoAmI.number}) numbers do not match, updating local.")
|
||||
Single
|
||||
.just(true)
|
||||
.flatMap { changeNumberRepository.changeLocalNumber(whoAmI.number, PNI.parseOrThrow(whoAmI.pni)) }
|
||||
@@ -72,12 +72,12 @@ class ChangeNumberLockActivity : PassphraseRequiredActivity() {
|
||||
}
|
||||
|
||||
private fun onChangeStatusConfirmed() {
|
||||
SignalStore.misc().unlockChangeNumber()
|
||||
SignalStore.misc().clearPendingChangeNumberMetadata()
|
||||
SignalStore.misc.unlockChangeNumber()
|
||||
SignalStore.misc.clearPendingChangeNumberMetadata()
|
||||
|
||||
MaterialAlertDialogBuilder(this)
|
||||
.setTitle(R.string.ChangeNumberLockActivity__change_status_confirmed)
|
||||
.setMessage(getString(R.string.ChangeNumberLockActivity__your_number_has_been_confirmed_as_s, PhoneNumberFormatter.prettyPrint(SignalStore.account().e164!!)))
|
||||
.setMessage(getString(R.string.ChangeNumberLockActivity__your_number_has_been_confirmed_as_s, PhoneNumberFormatter.prettyPrint(SignalStore.account.e164!!)))
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
startActivity(MainActivity.clearTop(this))
|
||||
finish()
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ class ChangeNumberRegistrationLockFragment : BaseRegistrationLockFragment(R.layo
|
||||
}
|
||||
|
||||
override fun handleSuccessfulPinEntry(pin: String) {
|
||||
val pinsDiffer: Boolean = SignalStore.svr().localPinHash?.let { !PinHashUtil.verifyLocalPinHash(it, pin) } ?: false
|
||||
val pinsDiffer: Boolean = SignalStore.svr.localPinHash?.let { !PinHashUtil.verifyLocalPinHash(it, pin) } ?: false
|
||||
|
||||
pinButton.cancelSpinning()
|
||||
|
||||
@@ -72,7 +72,7 @@ class ChangeNumberRegistrationLockFragment : BaseRegistrationLockFragment(R.layo
|
||||
}
|
||||
|
||||
private fun navigateUp() {
|
||||
if (SignalStore.misc().isChangeNumberLocked) {
|
||||
if (SignalStore.misc.isChangeNumberLocked) {
|
||||
startActivity(ChangeNumberLockActivity.createIntent(requireContext()))
|
||||
} else {
|
||||
findNavController().navigateUp()
|
||||
|
||||
+17
-17
@@ -76,7 +76,7 @@ class ChangeNumberRepository(
|
||||
fun <T : Any> acquireReleaseChangeNumberLock(upstream: Single<T>): Single<T> {
|
||||
return upstream.doOnSubscribe {
|
||||
CHANGE_NUMBER_LOCK.lock()
|
||||
SignalStore.misc().lockChangeNumber()
|
||||
SignalStore.misc.lockChangeNumber()
|
||||
}
|
||||
.subscribeOn(Schedulers.single())
|
||||
.observeOn(Schedulers.single())
|
||||
@@ -127,7 +127,7 @@ class ChangeNumberRepository(
|
||||
newE164 = newE164
|
||||
)
|
||||
|
||||
SignalStore.misc().setPendingChangeNumberMetadata(metadata)
|
||||
SignalStore.misc.setPendingChangeNumberMetadata(metadata)
|
||||
|
||||
changeNumberResponse = accountManager.changeNumber(request)
|
||||
|
||||
@@ -183,7 +183,7 @@ class ChangeNumberRepository(
|
||||
registrationLock = registrationLock
|
||||
)
|
||||
|
||||
SignalStore.misc().setPendingChangeNumberMetadata(metadata)
|
||||
SignalStore.misc.setPendingChangeNumberMetadata(metadata)
|
||||
|
||||
changeNumberResponse = accountManager.changeNumber(request)
|
||||
|
||||
@@ -219,7 +219,7 @@ class ChangeNumberRepository(
|
||||
SignalDatabase.recipients.updateSelfE164(e164, pni)
|
||||
val newStorageId: ByteArray? = Recipient.self().storageId
|
||||
|
||||
if (e164 != SignalStore.account().requireE164() && MessageDigest.isEqual(oldStorageId, newStorageId)) {
|
||||
if (e164 != SignalStore.account.requireE164() && MessageDigest.isEqual(oldStorageId, newStorageId)) {
|
||||
Log.w(TAG, "Self storage id was not rotated, attempting to rotate again")
|
||||
SignalDatabase.recipients.rotateStorageId(Recipient.self().id)
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
@@ -231,13 +231,13 @@ class ChangeNumberRepository(
|
||||
|
||||
AppDependencies.recipientCache.clear()
|
||||
|
||||
SignalStore.account().setE164(e164)
|
||||
SignalStore.account().setPni(pni)
|
||||
SignalStore.account.setE164(e164)
|
||||
SignalStore.account.setPni(pni)
|
||||
AppDependencies.resetProtocolStores()
|
||||
|
||||
AppDependencies.groupsV2Authorization.clear()
|
||||
|
||||
val metadata: PendingChangeNumberMetadata? = SignalStore.misc().pendingChangeNumberMetadata
|
||||
val metadata: PendingChangeNumberMetadata? = SignalStore.misc.pendingChangeNumberMetadata
|
||||
if (metadata == null) {
|
||||
Log.w(TAG, "No change number metadata, this shouldn't happen")
|
||||
throw AssertionError("No change number metadata")
|
||||
@@ -254,10 +254,10 @@ class ChangeNumberRepository(
|
||||
val pniLastResortKyberPreKeyId = metadata.pniLastResortKyberPreKeyId
|
||||
|
||||
val pniProtocolStore = AppDependencies.protocolStore.pni()
|
||||
val pniMetadataStore = SignalStore.account().pniPreKeys
|
||||
val pniMetadataStore = SignalStore.account.pniPreKeys
|
||||
|
||||
SignalStore.account().pniRegistrationId = pniRegistrationId
|
||||
SignalStore.account().setPniIdentityKeyAfterChangeNumber(pniIdentityKeyPair)
|
||||
SignalStore.account.pniRegistrationId = pniRegistrationId
|
||||
SignalStore.account.setPniIdentityKeyAfterChangeNumber(pniIdentityKeyPair)
|
||||
|
||||
val signedPreKey = pniProtocolStore.loadSignedPreKey(pniSignedPreyKeyId)
|
||||
val oneTimeEcPreKeys = PreKeyUtil.generateAndStoreOneTimeEcPreKeys(pniProtocolStore, pniMetadataStore)
|
||||
@@ -291,7 +291,7 @@ class ChangeNumberRepository(
|
||||
true
|
||||
)
|
||||
|
||||
SignalStore.misc().hasPniInitializedDevices = true
|
||||
SignalStore.misc.hasPniInitializedDevices = true
|
||||
AppDependencies.groupsV2Authorization.clear()
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ class ChangeNumberRepository(
|
||||
|
||||
@Suppress("UsePropertyAccessSyntax")
|
||||
private fun rotateCertificates(): Single<Unit> {
|
||||
val certificateTypes = SignalStore.phoneNumberPrivacy().allCertificateTypes
|
||||
val certificateTypes = SignalStore.phoneNumberPrivacy.allCertificateTypes
|
||||
|
||||
Log.i(TAG, "Rotating these certificates $certificateTypes")
|
||||
|
||||
@@ -322,7 +322,7 @@ class ChangeNumberRepository(
|
||||
|
||||
Log.i(TAG, "Successfully got $certificateType certificate")
|
||||
|
||||
SignalStore.certificateValues().setUnidentifiedAccessCertificate(certificateType, certificate)
|
||||
SignalStore.certificate.setUnidentifiedAccessCertificate(certificateType, certificate)
|
||||
}
|
||||
}.subscribeOn(Schedulers.single())
|
||||
}
|
||||
@@ -334,7 +334,7 @@ class ChangeNumberRepository(
|
||||
newE164: String,
|
||||
registrationLock: String? = null
|
||||
): ChangeNumberRequestData {
|
||||
val selfIdentifier: String = SignalStore.account().requireAci().toString()
|
||||
val selfIdentifier: String = SignalStore.account.requireAci().toString()
|
||||
val aciProtocolStore: SignalProtocolStore = AppDependencies.protocolStore.aci()
|
||||
|
||||
val pniIdentity: IdentityKeyPair = IdentityKeyUtil.generateIdentityKeyPair()
|
||||
@@ -351,7 +351,7 @@ class ChangeNumberRepository(
|
||||
.forEach { deviceId ->
|
||||
// Signed Prekeys
|
||||
val signedPreKeyRecord: SignedPreKeyRecord = if (deviceId == primaryDeviceId) {
|
||||
PreKeyUtil.generateAndStoreSignedPreKey(AppDependencies.protocolStore.pni(), SignalStore.account().pniPreKeys, pniIdentity.privateKey)
|
||||
PreKeyUtil.generateAndStoreSignedPreKey(AppDependencies.protocolStore.pni(), SignalStore.account.pniPreKeys, pniIdentity.privateKey)
|
||||
} else {
|
||||
PreKeyUtil.generateSignedPreKey(SecureRandom().nextInt(Medium.MAX_VALUE), pniIdentity.privateKey)
|
||||
}
|
||||
@@ -359,7 +359,7 @@ class ChangeNumberRepository(
|
||||
|
||||
// Last-resort kyber prekeys
|
||||
val lastResortKyberPreKeyRecord: KyberPreKeyRecord = if (deviceId == primaryDeviceId) {
|
||||
PreKeyUtil.generateAndStoreLastResortKyberPreKey(AppDependencies.protocolStore.pni(), SignalStore.account().pniPreKeys, pniIdentity.privateKey)
|
||||
PreKeyUtil.generateAndStoreLastResortKyberPreKey(AppDependencies.protocolStore.pni(), SignalStore.account.pniPreKeys, pniIdentity.privateKey)
|
||||
} else {
|
||||
PreKeyUtil.generateLastResortKyberPreKey(SecureRandom().nextInt(Medium.MAX_VALUE), pniIdentity.privateKey)
|
||||
}
|
||||
@@ -400,7 +400,7 @@ class ChangeNumberRepository(
|
||||
)
|
||||
|
||||
val metadata = PendingChangeNumberMetadata(
|
||||
previousPni = SignalStore.account().pni!!.toByteString(),
|
||||
previousPni = SignalStore.account.pni!!.toByteString(),
|
||||
pniIdentityKeyPair = pniIdentity.serialize().toByteString(),
|
||||
pniRegistrationId = pniRegistrationIds[primaryDeviceId]!!,
|
||||
pniSignedPreKeyId = devicePniSignedPreKeys[primaryDeviceId]!!.keyId,
|
||||
|
||||
+8
-8
@@ -136,16 +136,16 @@ class ChangeNumberViewModel(
|
||||
|
||||
private fun <T : VerifyResponseProcessor> attemptToUnlockChangeNumber(processor: T): Single<T> {
|
||||
return if (processor.hasResult() || processor.isServerSentError()) {
|
||||
SignalStore.misc().unlockChangeNumber()
|
||||
SignalStore.misc().clearPendingChangeNumberMetadata()
|
||||
SignalStore.misc.unlockChangeNumber()
|
||||
SignalStore.misc.clearPendingChangeNumberMetadata()
|
||||
Single.just(processor)
|
||||
} else {
|
||||
changeNumberRepository.whoAmI()
|
||||
.map { whoAmI ->
|
||||
if (Objects.equals(whoAmI.number, localNumber)) {
|
||||
Log.i(TAG, "Local and remote numbers match, we can unlock.")
|
||||
SignalStore.misc().unlockChangeNumber()
|
||||
SignalStore.misc().clearPendingChangeNumberMetadata()
|
||||
SignalStore.misc.unlockChangeNumber()
|
||||
SignalStore.misc.clearPendingChangeNumberMetadata()
|
||||
}
|
||||
processor
|
||||
}
|
||||
@@ -202,9 +202,9 @@ class ChangeNumberViewModel(
|
||||
}
|
||||
|
||||
fun changeNumberWithRecoveryPassword(): Single<Boolean> {
|
||||
val recoveryPassword = SignalStore.svr().recoveryPassword
|
||||
val recoveryPassword = SignalStore.svr.recoveryPassword
|
||||
|
||||
return if (SignalStore.svr().hasPin() && recoveryPassword != null) {
|
||||
return if (SignalStore.svr.hasPin() && recoveryPassword != null) {
|
||||
changeNumberRepository.changeNumber(recoveryPassword = recoveryPassword, newE164 = number.e164Number)
|
||||
.map { r -> VerifyResponseWithoutKbs(r) }
|
||||
.flatMap { p ->
|
||||
@@ -223,8 +223,8 @@ class ChangeNumberViewModel(
|
||||
|
||||
override fun <T : ViewModel> create(key: String, modelClass: Class<T>, handle: SavedStateHandle): T {
|
||||
val context: Application = AppDependencies.application
|
||||
val localNumber: String = SignalStore.account().e164!!
|
||||
val password: String = SignalStore.account().servicePassword!!
|
||||
val localNumber: String = SignalStore.account.e164!!
|
||||
val password: String = SignalStore.account.servicePassword!!
|
||||
|
||||
val viewModel = ChangeNumberViewModel(
|
||||
localNumber = localNumber,
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@ class ChangeNumberEnterCodeV2Fragment : LoggingFragment(R.layout.fragment_change
|
||||
}
|
||||
|
||||
private fun navigateUp() {
|
||||
if (SignalStore.misc().isChangeNumberLocked) {
|
||||
if (SignalStore.misc.isChangeNumberLocked) {
|
||||
Log.d(TAG, "Change number locked, navigateUp")
|
||||
startActivity(ChangeNumberLockV2Activity.createIntent(requireContext()))
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -68,11 +68,11 @@ class ChangeNumberLockV2Activity : PassphraseRequiredActivity() {
|
||||
}
|
||||
|
||||
private fun onChangeStatusConfirmed() {
|
||||
SignalStore.misc().clearPendingChangeNumberMetadata()
|
||||
SignalStore.misc.clearPendingChangeNumberMetadata()
|
||||
|
||||
MaterialAlertDialogBuilder(this)
|
||||
.setTitle(R.string.ChangeNumberLockActivity__change_status_confirmed)
|
||||
.setMessage(getString(R.string.ChangeNumberLockActivity__your_number_has_been_confirmed_as_s, PhoneNumberFormatter.prettyPrint(SignalStore.account().e164!!)))
|
||||
.setMessage(getString(R.string.ChangeNumberLockActivity__your_number_has_been_confirmed_as_s, PhoneNumberFormatter.prettyPrint(SignalStore.account.e164!!)))
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
startActivity(MainActivity.clearTop(this))
|
||||
finish()
|
||||
|
||||
+2
-2
@@ -299,7 +299,7 @@ class ChangeNumberRegistrationLockV2Fragment : LoggingFragment(R.layout.fragment
|
||||
}
|
||||
|
||||
private fun handleSuccessfulPinEntry(pin: String) {
|
||||
val pinsDiffer: Boolean = SignalStore.svr().localPinHash?.let { !PinHashUtil.verifyLocalPinHash(it, pin) } ?: false
|
||||
val pinsDiffer: Boolean = SignalStore.svr.localPinHash?.let { !PinHashUtil.verifyLocalPinHash(it, pin) } ?: false
|
||||
|
||||
binding.kbsLockPinConfirm.cancelSpinning()
|
||||
|
||||
@@ -319,7 +319,7 @@ class ChangeNumberRegistrationLockV2Fragment : LoggingFragment(R.layout.fragment
|
||||
}
|
||||
|
||||
private fun navigateUp() {
|
||||
if (SignalStore.misc().isChangeNumberLocked) {
|
||||
if (SignalStore.misc.isChangeNumberLocked) {
|
||||
startActivity(ChangeNumberLockV2Activity.createIntent(requireContext()))
|
||||
} else {
|
||||
findNavController().navigateUp()
|
||||
|
||||
+15
-15
@@ -108,7 +108,7 @@ class ChangeNumberV2Repository(
|
||||
SignalDatabase.recipients.updateSelfE164(e164, pni)
|
||||
val newStorageId: ByteArray? = Recipient.self().storageId
|
||||
|
||||
if (e164 != SignalStore.account().requireE164() && MessageDigest.isEqual(oldStorageId, newStorageId)) {
|
||||
if (e164 != SignalStore.account.requireE164() && MessageDigest.isEqual(oldStorageId, newStorageId)) {
|
||||
Log.w(TAG, "Self storage id was not rotated, attempting to rotate again")
|
||||
SignalDatabase.recipients.rotateStorageId(Recipient.self().id)
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
@@ -120,13 +120,13 @@ class ChangeNumberV2Repository(
|
||||
|
||||
AppDependencies.recipientCache.clear()
|
||||
|
||||
SignalStore.account().setE164(e164)
|
||||
SignalStore.account().setPni(pni)
|
||||
SignalStore.account.setE164(e164)
|
||||
SignalStore.account.setPni(pni)
|
||||
AppDependencies.resetProtocolStores()
|
||||
|
||||
AppDependencies.groupsV2Authorization.clear()
|
||||
|
||||
val metadata: PendingChangeNumberMetadata? = SignalStore.misc().pendingChangeNumberMetadata
|
||||
val metadata: PendingChangeNumberMetadata? = SignalStore.misc.pendingChangeNumberMetadata
|
||||
if (metadata == null) {
|
||||
Log.w(TAG, "No change number metadata, this shouldn't happen")
|
||||
throw AssertionError("No change number metadata")
|
||||
@@ -143,10 +143,10 @@ class ChangeNumberV2Repository(
|
||||
val pniLastResortKyberPreKeyId = metadata.pniLastResortKyberPreKeyId
|
||||
|
||||
val pniProtocolStore = AppDependencies.protocolStore.pni()
|
||||
val pniMetadataStore = SignalStore.account().pniPreKeys
|
||||
val pniMetadataStore = SignalStore.account.pniPreKeys
|
||||
|
||||
SignalStore.account().pniRegistrationId = pniRegistrationId
|
||||
SignalStore.account().setPniIdentityKeyAfterChangeNumber(pniIdentityKeyPair)
|
||||
SignalStore.account.pniRegistrationId = pniRegistrationId
|
||||
SignalStore.account.setPniIdentityKeyAfterChangeNumber(pniIdentityKeyPair)
|
||||
|
||||
val signedPreKey = pniProtocolStore.loadSignedPreKey(pniSignedPreyKeyId)
|
||||
val oneTimeEcPreKeys = PreKeyUtil.generateAndStoreOneTimeEcPreKeys(pniProtocolStore, pniMetadataStore)
|
||||
@@ -182,7 +182,7 @@ class ChangeNumberV2Repository(
|
||||
true
|
||||
)
|
||||
|
||||
SignalStore.misc().hasPniInitializedDevices = true
|
||||
SignalStore.misc.hasPniInitializedDevices = true
|
||||
AppDependencies.groupsV2Authorization.clear()
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ class ChangeNumberV2Repository(
|
||||
|
||||
@WorkerThread
|
||||
private fun rotateCertificates() {
|
||||
val certificateTypes = SignalStore.phoneNumberPrivacy().allCertificateTypes
|
||||
val certificateTypes = SignalStore.phoneNumberPrivacy.allCertificateTypes
|
||||
|
||||
Log.i(TAG, "Rotating these certificates $certificateTypes")
|
||||
|
||||
@@ -212,7 +212,7 @@ class ChangeNumberV2Repository(
|
||||
|
||||
Log.i(TAG, "Successfully got $certificateType certificate")
|
||||
|
||||
SignalStore.certificateValues().setUnidentifiedAccessCertificate(certificateType, certificate)
|
||||
SignalStore.certificate.setUnidentifiedAccessCertificate(certificateType, certificate)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ class ChangeNumberV2Repository(
|
||||
registrationLock = registrationLock
|
||||
)
|
||||
|
||||
SignalStore.misc().setPendingChangeNumberMetadata(metadata)
|
||||
SignalStore.misc.setPendingChangeNumberMetadata(metadata)
|
||||
withContext(Dispatchers.IO) {
|
||||
result = accountManager.registrationApi.changeNumber(request)
|
||||
}
|
||||
@@ -297,7 +297,7 @@ class ChangeNumberV2Repository(
|
||||
newE164: String,
|
||||
registrationLock: String? = null
|
||||
): ChangeNumberRequestData {
|
||||
val selfIdentifier: String = SignalStore.account().requireAci().toString()
|
||||
val selfIdentifier: String = SignalStore.account.requireAci().toString()
|
||||
val aciProtocolStore: SignalProtocolStore = AppDependencies.protocolStore.aci()
|
||||
|
||||
val pniIdentity: IdentityKeyPair = IdentityKeyUtil.generateIdentityKeyPair()
|
||||
@@ -314,7 +314,7 @@ class ChangeNumberV2Repository(
|
||||
.forEach { deviceId ->
|
||||
// Signed Prekeys
|
||||
val signedPreKeyRecord: SignedPreKeyRecord = if (deviceId == primaryDeviceId) {
|
||||
PreKeyUtil.generateAndStoreSignedPreKey(AppDependencies.protocolStore.pni(), SignalStore.account().pniPreKeys, pniIdentity.privateKey)
|
||||
PreKeyUtil.generateAndStoreSignedPreKey(AppDependencies.protocolStore.pni(), SignalStore.account.pniPreKeys, pniIdentity.privateKey)
|
||||
} else {
|
||||
PreKeyUtil.generateSignedPreKey(SecureRandom().nextInt(Medium.MAX_VALUE), pniIdentity.privateKey)
|
||||
}
|
||||
@@ -322,7 +322,7 @@ class ChangeNumberV2Repository(
|
||||
|
||||
// Last-resort kyber prekeys
|
||||
val lastResortKyberPreKeyRecord: KyberPreKeyRecord = if (deviceId == primaryDeviceId) {
|
||||
PreKeyUtil.generateAndStoreLastResortKyberPreKey(AppDependencies.protocolStore.pni(), SignalStore.account().pniPreKeys, pniIdentity.privateKey)
|
||||
PreKeyUtil.generateAndStoreLastResortKyberPreKey(AppDependencies.protocolStore.pni(), SignalStore.account.pniPreKeys, pniIdentity.privateKey)
|
||||
} else {
|
||||
PreKeyUtil.generateLastResortKyberPreKey(SecureRandom().nextInt(Medium.MAX_VALUE), pniIdentity.privateKey)
|
||||
}
|
||||
@@ -363,7 +363,7 @@ class ChangeNumberV2Repository(
|
||||
)
|
||||
|
||||
val metadata = PendingChangeNumberMetadata(
|
||||
previousPni = SignalStore.account().pni!!.toByteString(),
|
||||
previousPni = SignalStore.account.pni!!.toByteString(),
|
||||
pniIdentityKeyPair = pniIdentity.serialize().toByteString(),
|
||||
pniRegistrationId = pniRegistrationIds[primaryDeviceId]!!,
|
||||
pniSignedPreKeyId = devicePniSignedPreKeys[primaryDeviceId]!!.keyId,
|
||||
|
||||
+10
-10
@@ -56,8 +56,8 @@ class ChangeNumberV2ViewModel : ViewModel() {
|
||||
private val serialContext = SignalExecutors.SERIAL.asCoroutineDispatcher()
|
||||
private val smsRetrieverReceiver: SmsRetrieverReceiver = SmsRetrieverReceiver(AppDependencies.application)
|
||||
|
||||
private val initialLocalNumber = SignalStore.account().e164
|
||||
private val password = SignalStore.account().servicePassword!!
|
||||
private val initialLocalNumber = SignalStore.account.e164
|
||||
private val password = SignalStore.account.servicePassword!!
|
||||
|
||||
val uiState = store.asLiveData()
|
||||
val liveOldNumberState = store.map { it.oldPhoneNumber }.asLiveData()
|
||||
@@ -68,7 +68,7 @@ class ChangeNumberV2ViewModel : ViewModel() {
|
||||
init {
|
||||
try {
|
||||
val countryCode: Int = PhoneNumberUtil.getInstance()
|
||||
.parse(SignalStore.account().e164!!, null)
|
||||
.parse(SignalStore.account.e164!!, null)
|
||||
.countryCode
|
||||
|
||||
store.update {
|
||||
@@ -186,11 +186,11 @@ class ChangeNumberV2ViewModel : ViewModel() {
|
||||
try {
|
||||
val whoAmI = repository.whoAmI()
|
||||
|
||||
if (whoAmI.number == SignalStore.account().e164) {
|
||||
if (whoAmI.number == SignalStore.account.e164) {
|
||||
return@launch bail { Log.i(TAG, "Local and remote numbers match, nothing needs to be done.") }
|
||||
}
|
||||
|
||||
Log.i(TAG, "Local (${SignalStore.account().e164}) and remote (${whoAmI.number}) numbers do not match, updating local.")
|
||||
Log.i(TAG, "Local (${SignalStore.account.e164}) and remote (${whoAmI.number}) numbers do not match, updating local.")
|
||||
|
||||
withLockOnSerialExecutor {
|
||||
repository.changeLocalNumber(whoAmI.number, ServiceId.PNI.parseOrThrow(whoAmI.pni))
|
||||
@@ -391,8 +391,8 @@ class ChangeNumberV2ViewModel : ViewModel() {
|
||||
|
||||
private suspend fun changeNumberWithRecoveryPassword(): Boolean {
|
||||
Log.v(TAG, "changeNumberWithRecoveryPassword()")
|
||||
SignalStore.svr().recoveryPassword?.let { recoveryPassword ->
|
||||
if (SignalStore.svr().hasPin()) {
|
||||
SignalStore.svr.recoveryPassword?.let { recoveryPassword ->
|
||||
if (SignalStore.svr.hasPin()) {
|
||||
val result = repository.changeNumberWithRecoveryPassword(recoveryPassword = recoveryPassword, newE164 = number.e164Number)
|
||||
|
||||
if (result is ChangeNumberResult.Success) {
|
||||
@@ -506,7 +506,7 @@ class ChangeNumberV2ViewModel : ViewModel() {
|
||||
val currentState = store.value
|
||||
val code = currentState.enteredCode ?: throw IllegalStateException("Can't construct registration data without entered code!")
|
||||
val e164: String = number.e164Number ?: throw IllegalStateException("Can't construct registration data without E164!")
|
||||
val recoveryPassword = if (currentState.sessionId == null) SignalStore.svr().getRecoveryPassword() else null
|
||||
val recoveryPassword = if (currentState.sessionId == null) SignalStore.svr.getRecoveryPassword() else null
|
||||
val fcmToken = RegistrationRepository.getFcmToken(context)
|
||||
return RegistrationData(code, e164, password, RegistrationRepository.getRegistrationId(), RegistrationRepository.getProfileKey(e164), fcmToken, RegistrationRepository.getPniRegistrationId(), recoveryPassword)
|
||||
}
|
||||
@@ -533,12 +533,12 @@ class ChangeNumberV2ViewModel : ViewModel() {
|
||||
private suspend fun <T> withLockOnSerialExecutor(action: () -> T): T = withContext(serialContext) {
|
||||
Log.v(TAG, "withLock()")
|
||||
val result = CHANGE_NUMBER_LOCK.withLock {
|
||||
SignalStore.misc().lockChangeNumber()
|
||||
SignalStore.misc.lockChangeNumber()
|
||||
Log.v(TAG, "Change number lock acquired.")
|
||||
try {
|
||||
action()
|
||||
} finally {
|
||||
SignalStore.misc().unlockChangeNumber()
|
||||
SignalStore.misc.unlockChangeNumber()
|
||||
}
|
||||
}
|
||||
Log.v(TAG, "Change number lock released.")
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ class ChatsSettingsRepository {
|
||||
|
||||
fun syncLinkPreviewsState() {
|
||||
SignalExecutors.BOUNDED.execute {
|
||||
val isLinkPreviewsEnabled = SignalStore.settings().isLinkPreviewsEnabled
|
||||
val isLinkPreviewsEnabled = SignalStore.settings.isLinkPreviewsEnabled
|
||||
|
||||
SignalDatabase.recipients.markNeedsSync(Recipient.self().id)
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
|
||||
+14
-14
@@ -17,13 +17,13 @@ class ChatsSettingsViewModel @JvmOverloads constructor(
|
||||
|
||||
private val store: Store<ChatsSettingsState> = Store(
|
||||
ChatsSettingsState(
|
||||
generateLinkPreviews = SignalStore.settings().isLinkPreviewsEnabled,
|
||||
useAddressBook = SignalStore.settings().isPreferSystemContactPhotos,
|
||||
keepMutedChatsArchived = SignalStore.settings().shouldKeepMutedChatsArchived(),
|
||||
useSystemEmoji = SignalStore.settings().isPreferSystemEmoji,
|
||||
enterKeySends = SignalStore.settings().isEnterKeySends,
|
||||
localBackupsEnabled = SignalStore.settings().isBackupEnabled && BackupUtil.canUserAccessBackupDirectory(AppDependencies.application),
|
||||
remoteBackupsEnabled = SignalStore.backup().areBackupsEnabled
|
||||
generateLinkPreviews = SignalStore.settings.isLinkPreviewsEnabled,
|
||||
useAddressBook = SignalStore.settings.isPreferSystemContactPhotos,
|
||||
keepMutedChatsArchived = SignalStore.settings.shouldKeepMutedChatsArchived(),
|
||||
useSystemEmoji = SignalStore.settings.isPreferSystemEmoji,
|
||||
enterKeySends = SignalStore.settings.isEnterKeySends,
|
||||
localBackupsEnabled = SignalStore.settings.isBackupEnabled && BackupUtil.canUserAccessBackupDirectory(AppDependencies.application),
|
||||
remoteBackupsEnabled = SignalStore.backup.areBackupsEnabled
|
||||
)
|
||||
)
|
||||
|
||||
@@ -31,36 +31,36 @@ class ChatsSettingsViewModel @JvmOverloads constructor(
|
||||
|
||||
fun setGenerateLinkPreviewsEnabled(enabled: Boolean) {
|
||||
store.update { it.copy(generateLinkPreviews = enabled) }
|
||||
SignalStore.settings().isLinkPreviewsEnabled = enabled
|
||||
SignalStore.settings.isLinkPreviewsEnabled = enabled
|
||||
repository.syncLinkPreviewsState()
|
||||
}
|
||||
|
||||
fun setUseAddressBook(enabled: Boolean) {
|
||||
store.update { it.copy(useAddressBook = enabled) }
|
||||
refreshDebouncer.publish { ConversationUtil.refreshRecipientShortcuts() }
|
||||
SignalStore.settings().isPreferSystemContactPhotos = enabled
|
||||
SignalStore.settings.isPreferSystemContactPhotos = enabled
|
||||
repository.syncPreferSystemContactPhotos()
|
||||
}
|
||||
|
||||
fun setKeepMutedChatsArchived(enabled: Boolean) {
|
||||
store.update { it.copy(keepMutedChatsArchived = enabled) }
|
||||
SignalStore.settings().setKeepMutedChatsArchived(enabled)
|
||||
SignalStore.settings.setKeepMutedChatsArchived(enabled)
|
||||
repository.syncKeepMutedChatsArchivedState()
|
||||
}
|
||||
|
||||
fun setUseSystemEmoji(enabled: Boolean) {
|
||||
store.update { it.copy(useSystemEmoji = enabled) }
|
||||
SignalStore.settings().isPreferSystemEmoji = enabled
|
||||
SignalStore.settings.isPreferSystemEmoji = enabled
|
||||
}
|
||||
|
||||
fun setEnterKeySends(enabled: Boolean) {
|
||||
store.update { it.copy(enterKeySends = enabled) }
|
||||
SignalStore.settings().isEnterKeySends = enabled
|
||||
SignalStore.settings.isEnterKeySends = enabled
|
||||
}
|
||||
|
||||
fun refresh() {
|
||||
val backupsEnabled = SignalStore.settings().isBackupEnabled && BackupUtil.canUserAccessBackupDirectory(AppDependencies.application)
|
||||
val remoteBackupsEnabled = SignalStore.backup().areBackupsEnabled
|
||||
val backupsEnabled = SignalStore.settings.isBackupEnabled && BackupUtil.canUserAccessBackupDirectory(AppDependencies.application)
|
||||
val remoteBackupsEnabled = SignalStore.backup.areBackupsEnabled
|
||||
|
||||
if (store.state.localBackupsEnabled != backupsEnabled ||
|
||||
store.state.remoteBackupsEnabled != remoteBackupsEnabled
|
||||
|
||||
+11
-11
@@ -31,9 +31,9 @@ class RemoteBackupsSettingsViewModel : ViewModel() {
|
||||
private val internalState = MutableStateFlow(
|
||||
RemoteBackupsSettingsState(
|
||||
messageBackupsType = null,
|
||||
lastBackupTimestamp = SignalStore.backup().lastBackupTime,
|
||||
backupSize = SignalStore.backup().totalBackupSize,
|
||||
backupsFrequency = SignalStore.backup().backupFrequency
|
||||
lastBackupTimestamp = SignalStore.backup.lastBackupTime,
|
||||
backupSize = SignalStore.backup.totalBackupSize,
|
||||
backupsFrequency = SignalStore.backup.backupFrequency
|
||||
)
|
||||
)
|
||||
|
||||
@@ -44,12 +44,12 @@ class RemoteBackupsSettingsViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
fun setCanBackUpUsingCellular(canBackUpUsingCellular: Boolean) {
|
||||
SignalStore.backup().backupWithCellular = canBackUpUsingCellular
|
||||
SignalStore.backup.backupWithCellular = canBackUpUsingCellular
|
||||
internalState.update { it.copy(canBackUpUsingCellular = canBackUpUsingCellular) }
|
||||
}
|
||||
|
||||
fun setBackupsFrequency(backupsFrequency: BackupFrequency) {
|
||||
SignalStore.backup().backupFrequency = backupsFrequency
|
||||
SignalStore.backup.backupFrequency = backupsFrequency
|
||||
internalState.update { it.copy(backupsFrequency = backupsFrequency) }
|
||||
MessageBackupListener.setNextBackupTimeToIntervalFromNow()
|
||||
MessageBackupListener.schedule(AppDependencies.application)
|
||||
@@ -65,15 +65,15 @@ class RemoteBackupsSettingsViewModel : ViewModel() {
|
||||
|
||||
fun refresh() {
|
||||
viewModelScope.launch {
|
||||
val tier = SignalStore.backup().backupTier
|
||||
val tier = SignalStore.backup.backupTier
|
||||
val backupType = if (tier != null) BackupRepository.getBackupsType(tier) else null
|
||||
|
||||
internalState.update {
|
||||
it.copy(
|
||||
messageBackupsType = backupType,
|
||||
lastBackupTimestamp = SignalStore.backup().lastBackupTime,
|
||||
backupSize = SignalStore.backup().totalBackupSize,
|
||||
backupsFrequency = SignalStore.backup().backupFrequency
|
||||
lastBackupTimestamp = SignalStore.backup.lastBackupTime,
|
||||
backupSize = SignalStore.backup.totalBackupSize,
|
||||
backupsFrequency = SignalStore.backup.backupFrequency
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -103,8 +103,8 @@ class RemoteBackupsSettingsViewModel : ViewModel() {
|
||||
private fun refreshBackupState() {
|
||||
internalState.update {
|
||||
it.copy(
|
||||
lastBackupTimestamp = SignalStore.backup().lastBackupTime,
|
||||
backupSize = SignalStore.backup().totalBackupSize
|
||||
lastBackupTimestamp = SignalStore.backup.lastBackupTime,
|
||||
backupSize = SignalStore.backup.totalBackupSize
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ class BackupsTypeSettingsViewModel : ViewModel() {
|
||||
|
||||
fun refresh() {
|
||||
viewModelScope.launch {
|
||||
val tier = SignalStore.backup().backupTier
|
||||
val tier = SignalStore.backup.backupTier
|
||||
internalState.value = state.value.copy(
|
||||
messageBackupsType = if (tier != null) BackupRepository.getBackupsType(tier) else null
|
||||
)
|
||||
|
||||
+5
-5
@@ -42,13 +42,13 @@ class DataAndStorageSettingsViewModel(
|
||||
}
|
||||
|
||||
fun setCallDataMode(callDataMode: CallDataMode) {
|
||||
SignalStore.settings().callDataMode = callDataMode
|
||||
SignalStore.settings.callDataMode = callDataMode
|
||||
AppDependencies.signalCallManager.dataModeUpdate()
|
||||
getStateAndCopyStorageUsage()
|
||||
}
|
||||
|
||||
fun setSentMediaQuality(sentMediaQuality: SentMediaQuality) {
|
||||
SignalStore.settings().sentMediaQuality = sentMediaQuality
|
||||
SignalStore.settings.sentMediaQuality = sentMediaQuality
|
||||
getStateAndCopyStorageUsage()
|
||||
}
|
||||
|
||||
@@ -67,9 +67,9 @@ class DataAndStorageSettingsViewModel(
|
||||
roamingAutoDownloadValues = TextSecurePreferences.getRoamingMediaDownloadAllowed(
|
||||
AppDependencies.application
|
||||
),
|
||||
callDataMode = SignalStore.settings().callDataMode,
|
||||
isProxyEnabled = SignalStore.proxy().isProxyEnabled,
|
||||
sentMediaQuality = SignalStore.settings().sentMediaQuality
|
||||
callDataMode = SignalStore.settings.callDataMode,
|
||||
isProxyEnabled = SignalStore.proxy.isProxyEnabled,
|
||||
sentMediaQuality = SignalStore.settings.sentMediaQuality
|
||||
)
|
||||
|
||||
class Factory(
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ class InternalPendingOneTimeDonationConfigurationFragment : ComposeFragment() {
|
||||
viewModel.state.value = viewModel.state.value.copy(error = viewModel.state.value.error!!.copy(code = it))
|
||||
},
|
||||
onSave = {
|
||||
SignalStore.donationsValues().setPendingOneTimeDonation(viewModel.state.value)
|
||||
SignalStore.donations.setPendingOneTimeDonation(viewModel.state.value)
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
)
|
||||
|
||||
+19
-19
@@ -82,13 +82,13 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
||||
super.onPause()
|
||||
val firstVisiblePosition: Int? = layoutManager?.findFirstVisibleItemPosition()
|
||||
if (firstVisiblePosition != null) {
|
||||
SignalStore.internalValues().lastScrollPosition = firstVisiblePosition
|
||||
SignalStore.internal.lastScrollPosition = firstVisiblePosition
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
scrollToPosition = SignalStore.internalValues().lastScrollPosition
|
||||
scrollToPosition = SignalStore.internal.lastScrollPosition
|
||||
}
|
||||
|
||||
override fun bindAdapter(adapter: MappingAdapter) {
|
||||
@@ -557,9 +557,9 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
||||
clickPref(
|
||||
title = DSLSettingsText.from("Clear keep-alive timestamps"),
|
||||
onClick = {
|
||||
SignalStore.donationsValues().subscriptionEndOfPeriodRedemptionStarted = 0L
|
||||
SignalStore.donationsValues().subscriptionEndOfPeriodConversionStarted = 0L
|
||||
SignalStore.donationsValues().setLastEndOfPeriod(0L)
|
||||
SignalStore.donations.subscriptionEndOfPeriodRedemptionStarted = 0L
|
||||
SignalStore.donations.subscriptionEndOfPeriodConversionStarted = 0L
|
||||
SignalStore.donations.setLastEndOfPeriod(0L)
|
||||
Toast.makeText(context, "Cleared", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
)
|
||||
@@ -570,7 +570,7 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
||||
clickPref(
|
||||
title = DSLSettingsText.from("Clear pending one-time donation."),
|
||||
onClick = {
|
||||
SignalStore.donationsValues().setPendingOneTimeDonation(null)
|
||||
SignalStore.donations.setPendingOneTimeDonation(null)
|
||||
}
|
||||
)
|
||||
} else {
|
||||
@@ -596,7 +596,7 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
||||
clickPref(
|
||||
title = DSLSettingsText.from("Set last version seen back 10 versions"),
|
||||
onClick = {
|
||||
SignalStore.releaseChannelValues().highestVersionNoteReceived = max(SignalStore.releaseChannelValues().highestVersionNoteReceived - 10, 0)
|
||||
SignalStore.releaseChannel.highestVersionNoteReceived = max(SignalStore.releaseChannel.highestVersionNoteReceived - 10, 0)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -616,7 +616,7 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
||||
clickPref(
|
||||
title = DSLSettingsText.from("Fetch release channel"),
|
||||
onClick = {
|
||||
SignalStore.releaseChannelValues().previousManifestMd5 = ByteArray(0)
|
||||
SignalStore.releaseChannel.previousManifestMd5 = ByteArray(0)
|
||||
RetrieveRemoteAnnouncementsJob.enqueue(force = true)
|
||||
}
|
||||
)
|
||||
@@ -687,7 +687,7 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
||||
title = DSLSettingsText.from("Clear choose initial my story privacy state"),
|
||||
isEnabled = true,
|
||||
onClick = {
|
||||
SignalStore.storyValues().userHasBeenNotifiedAboutStories = false
|
||||
SignalStore.story.userHasBeenNotifiedAboutStories = false
|
||||
}
|
||||
)
|
||||
|
||||
@@ -695,7 +695,7 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
||||
title = DSLSettingsText.from("Clear first time navigation state"),
|
||||
isEnabled = true,
|
||||
onClick = {
|
||||
SignalStore.storyValues().userHasSeenFirstNavView = false
|
||||
SignalStore.story.userHasSeenFirstNavView = false
|
||||
}
|
||||
)
|
||||
|
||||
@@ -746,7 +746,7 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
val random = "${(1..5).map { ('a'..'z').random() }.joinToString(separator = "") }.${Random.nextInt(10, 100)}"
|
||||
|
||||
SignalStore.account().username = random
|
||||
SignalStore.account.username = random
|
||||
SignalDatabase.recipients.setUsername(Recipient.self().id, random)
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
|
||||
@@ -765,9 +765,9 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
||||
.setTitle("Corrupt your username link?")
|
||||
.setMessage("Are you sure? You'll have to reset your link.")
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
SignalStore.account().usernameLink = UsernameLinkComponents(
|
||||
SignalStore.account.usernameLink = UsernameLinkComponents(
|
||||
entropy = Util.getSecretBytes(32),
|
||||
serverId = SignalStore.account().usernameLink?.serverId ?: UUID.randomUUID()
|
||||
serverId = SignalStore.account.usernameLink?.serverId ?: UUID.randomUUID()
|
||||
)
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
Toast.makeText(context, "Done", Toast.LENGTH_SHORT).show()
|
||||
@@ -782,7 +782,7 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
||||
clickPref(
|
||||
title = DSLSettingsText.from("Reset pull to refresh tip count"),
|
||||
onClick = {
|
||||
SignalStore.uiHints().resetNeverDisplayPullToRefreshCount()
|
||||
SignalStore.uiHints.resetNeverDisplayPullToRefreshCount()
|
||||
}
|
||||
)
|
||||
|
||||
@@ -813,10 +813,10 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
||||
ThreadUtil.runOnMain {
|
||||
when (it) {
|
||||
AdvancedPrivacySettingsRepository.DisablePushMessagesResult.SUCCESS -> {
|
||||
SignalStore.account().setRegistered(false)
|
||||
SignalStore.registrationValues().clearRegistrationComplete()
|
||||
SignalStore.registrationValues().clearHasUploadedProfile()
|
||||
SignalStore.registrationValues().clearSkippedTransferOrRestore()
|
||||
SignalStore.account.setRegistered(false)
|
||||
SignalStore.registration.clearRegistrationComplete()
|
||||
SignalStore.registration.clearHasUploadedProfile()
|
||||
SignalStore.registration.clearSkippedTransferOrRestore()
|
||||
Toast.makeText(context, "Unregistered!", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
@@ -939,7 +939,7 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
||||
|
||||
private fun clearCdsHistory() {
|
||||
SignalDatabase.cds.clearAll()
|
||||
SignalStore.misc().cdsToken = null
|
||||
SignalStore.misc.cdsToken = null
|
||||
Toast.makeText(context, "Cleared all CDS history.", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ class InternalSettingsRepository(context: Context) {
|
||||
val bodyRangeList = BodyRangeList.Builder()
|
||||
.addStyle(BodyRangeList.BodyRange.Style.BOLD, 0, title.length)
|
||||
|
||||
val recipientId = SignalStore.releaseChannelValues().releaseChannelRecipientId!!
|
||||
val recipientId = SignalStore.releaseChannel.releaseChannelRecipientId!!
|
||||
val threadId = SignalDatabase.threads.getOrCreateThreadIdFor(Recipient.resolved(recipientId))
|
||||
|
||||
val insertResult: MessageTable.InsertResult? = ReleaseChannel.insertReleaseChannelMessage(
|
||||
|
||||
+24
-24
@@ -23,7 +23,7 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
|
||||
store.update { it.copy(emojiVersion = version) }
|
||||
}
|
||||
|
||||
val pendingOneTimeDonation: Observable<Boolean> = SignalStore.donationsValues().observablePendingOneTimeDonation
|
||||
val pendingOneTimeDonation: Observable<Boolean> = SignalStore.donations.observablePendingOneTimeDonation
|
||||
.distinctUntilChanged()
|
||||
.map { it.isPresent }
|
||||
|
||||
@@ -70,7 +70,7 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
|
||||
}
|
||||
|
||||
fun resetPnpInitializedState() {
|
||||
SignalStore.misc().hasPniInitializedDevices = false
|
||||
SignalStore.misc.hasPniInitializedDevices = false
|
||||
refresh()
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
|
||||
}
|
||||
|
||||
fun setUseConversationItemV2Media(enabled: Boolean) {
|
||||
SignalStore.internalValues().setUseConversationItemV2Media(enabled)
|
||||
SignalStore.internal.setUseConversationItemV2Media(enabled)
|
||||
refresh()
|
||||
}
|
||||
|
||||
@@ -140,31 +140,31 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
|
||||
}
|
||||
|
||||
private fun getState() = InternalSettingsState(
|
||||
seeMoreUserDetails = SignalStore.internalValues().recipientDetails(),
|
||||
shakeToReport = SignalStore.internalValues().shakeToReport(),
|
||||
gv2forceInvites = SignalStore.internalValues().gv2ForceInvites(),
|
||||
gv2ignoreP2PChanges = SignalStore.internalValues().gv2IgnoreP2PChanges(),
|
||||
allowCensorshipSetting = SignalStore.internalValues().allowChangingCensorshipSetting(),
|
||||
forceWebsocketMode = SignalStore.internalValues().isWebsocketModeForced,
|
||||
callingServer = SignalStore.internalValues().groupCallingServer(),
|
||||
callingAudioProcessingMethod = SignalStore.internalValues().callingAudioProcessingMethod(),
|
||||
callingDataMode = SignalStore.internalValues().callingDataMode(),
|
||||
callingDisableTelecom = SignalStore.internalValues().callingDisableTelecom(),
|
||||
callingDisableLBRed = SignalStore.internalValues().callingDisableLBRed(),
|
||||
useBuiltInEmojiSet = SignalStore.internalValues().forceBuiltInEmoji(),
|
||||
seeMoreUserDetails = SignalStore.internal.recipientDetails(),
|
||||
shakeToReport = SignalStore.internal.shakeToReport(),
|
||||
gv2forceInvites = SignalStore.internal.gv2ForceInvites(),
|
||||
gv2ignoreP2PChanges = SignalStore.internal.gv2IgnoreP2PChanges(),
|
||||
allowCensorshipSetting = SignalStore.internal.allowChangingCensorshipSetting(),
|
||||
forceWebsocketMode = SignalStore.internal.isWebsocketModeForced,
|
||||
callingServer = SignalStore.internal.groupCallingServer(),
|
||||
callingAudioProcessingMethod = SignalStore.internal.callingAudioProcessingMethod(),
|
||||
callingDataMode = SignalStore.internal.callingDataMode(),
|
||||
callingDisableTelecom = SignalStore.internal.callingDisableTelecom(),
|
||||
callingDisableLBRed = SignalStore.internal.callingDisableLBRed(),
|
||||
useBuiltInEmojiSet = SignalStore.internal.forceBuiltInEmoji(),
|
||||
emojiVersion = null,
|
||||
removeSenderKeyMinimium = SignalStore.internalValues().removeSenderKeyMinimum(),
|
||||
delayResends = SignalStore.internalValues().delayResends(),
|
||||
disableStorageService = SignalStore.internalValues().storageServiceDisabled(),
|
||||
canClearOnboardingState = SignalStore.storyValues().hasDownloadedOnboardingStory && Stories.isFeatureEnabled(),
|
||||
pnpInitialized = SignalStore.misc().hasPniInitializedDevices,
|
||||
useConversationItemV2ForMedia = SignalStore.internalValues().useConversationItemV2Media(),
|
||||
hasPendingOneTimeDonation = SignalStore.donationsValues().getPendingOneTimeDonation() != null
|
||||
removeSenderKeyMinimium = SignalStore.internal.removeSenderKeyMinimum(),
|
||||
delayResends = SignalStore.internal.delayResends(),
|
||||
disableStorageService = SignalStore.internal.storageServiceDisabled(),
|
||||
canClearOnboardingState = SignalStore.story.hasDownloadedOnboardingStory && Stories.isFeatureEnabled(),
|
||||
pnpInitialized = SignalStore.misc.hasPniInitializedDevices,
|
||||
useConversationItemV2ForMedia = SignalStore.internal.useConversationItemV2Media(),
|
||||
hasPendingOneTimeDonation = SignalStore.donations.getPendingOneTimeDonation() != null
|
||||
)
|
||||
|
||||
fun onClearOnboardingState() {
|
||||
SignalStore.storyValues().hasDownloadedOnboardingStory = false
|
||||
SignalStore.storyValues().userHasViewedOnboardingStory = false
|
||||
SignalStore.story.hasDownloadedOnboardingStory = false
|
||||
SignalStore.story.userHasViewedOnboardingStory = false
|
||||
Stories.onStorySettingsChanged(Recipient.self().id)
|
||||
refresh()
|
||||
StoryOnboardingDownloadJob.enqueueIfNeeded()
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ class InternalTerminalDonationConfigurationFragment : ComposeFragment() {
|
||||
override fun FragmentContent() {
|
||||
InternalTerminalDonationConfigurationContent(
|
||||
onAddClick = {
|
||||
SignalStore.donationsValues().appendToTerminalDonationQueue(it)
|
||||
SignalStore.donations.appendToTerminalDonationQueue(it)
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
)
|
||||
|
||||
+3
-3
@@ -170,7 +170,7 @@ class InternalBackupPlaygroundFragment : ComposeFragment() {
|
||||
},
|
||||
mediaContent = { snackbarHostState ->
|
||||
MediaList(
|
||||
enabled = SignalStore.backup().backsUpMedia,
|
||||
enabled = SignalStore.backup.backsUpMedia,
|
||||
state = mediaState,
|
||||
snackbarHostState = snackbarHostState,
|
||||
archiveAttachmentMedia = { viewModel.archiveAttachmentMedia(it) },
|
||||
@@ -215,7 +215,7 @@ fun Tabs(
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
if (tabIndex == 1 && SignalStore.backup().backsUpMedia) {
|
||||
if (tabIndex == 1 && SignalStore.backup.backsUpMedia) {
|
||||
TextButton(onClick = onDeleteAllArchivedMedia) {
|
||||
Text(text = "Delete All")
|
||||
}
|
||||
@@ -429,7 +429,7 @@ fun MediaList(
|
||||
) {
|
||||
if (!enabled) {
|
||||
Text(
|
||||
text = "You do not have read/write to archive cdn enabled via SignalStore.backup()",
|
||||
text = "You do not have read/write to archive cdn enabled via SignalStore.backup",
|
||||
modifier = Modifier
|
||||
.padding(16.dp)
|
||||
)
|
||||
|
||||
+2
-2
@@ -306,7 +306,7 @@ class InternalBackupPlaygroundViewModel : ViewModel() {
|
||||
fun restoreArchivedMedia(attachment: BackupAttachment) {
|
||||
disposables += Completable
|
||||
.fromCallable {
|
||||
val recipientId = SignalStore.releaseChannelValues().releaseChannelRecipientId!!
|
||||
val recipientId = SignalStore.releaseChannel.releaseChannelRecipientId!!
|
||||
val threadId = SignalDatabase.threads.getOrCreateThreadIdFor(Recipient.resolved(recipientId))
|
||||
|
||||
val message = IncomingMessage(
|
||||
@@ -388,7 +388,7 @@ class InternalBackupPlaygroundViewModel : ViewModel() {
|
||||
attachments: List<BackupAttachment> = this.attachments,
|
||||
inProgress: Set<AttachmentId> = this.inProgressMediaIds
|
||||
): MediaState {
|
||||
val backupKey = SignalStore.svr().getOrCreateMasterKey().deriveBackupKey()
|
||||
val backupKey = SignalStore.svr.getOrCreateMasterKey().deriveBackupKey()
|
||||
|
||||
val updatedAttachments = attachments.map {
|
||||
val state = if (inProgress.contains(it.dbAttachment.attachmentId)) {
|
||||
|
||||
+13
-13
@@ -117,11 +117,11 @@ class InternalDonorErrorConfigurationViewModel : ViewModel() {
|
||||
fun clearErrorState(): Completable {
|
||||
return Completable.fromAction {
|
||||
synchronized(InAppPaymentSubscriberRecord.Type.DONATION) {
|
||||
SignalStore.donationsValues().setExpiredBadge(null)
|
||||
SignalStore.donationsValues().setExpiredGiftBadge(null)
|
||||
SignalStore.donationsValues().unexpectedSubscriptionCancelationReason = null
|
||||
SignalStore.donationsValues().unexpectedSubscriptionCancelationTimestamp = 0L
|
||||
SignalStore.donationsValues().setUnexpectedSubscriptionCancelationChargeFailure(null)
|
||||
SignalStore.donations.setExpiredBadge(null)
|
||||
SignalStore.donations.setExpiredGiftBadge(null)
|
||||
SignalStore.donations.unexpectedSubscriptionCancelationReason = null
|
||||
SignalStore.donations.unexpectedSubscriptionCancelationTimestamp = 0L
|
||||
SignalStore.donations.setUnexpectedSubscriptionCancelationChargeFailure(null)
|
||||
}
|
||||
|
||||
store.update {
|
||||
@@ -135,24 +135,24 @@ class InternalDonorErrorConfigurationViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
private fun handleBoostExpiration(state: InternalDonorErrorConfigurationState) {
|
||||
SignalStore.donationsValues().setExpiredBadge(state.selectedBadge)
|
||||
SignalStore.donations.setExpiredBadge(state.selectedBadge)
|
||||
}
|
||||
|
||||
private fun handleGiftExpiration(state: InternalDonorErrorConfigurationState) {
|
||||
SignalStore.donationsValues().setExpiredGiftBadge(state.selectedBadge)
|
||||
SignalStore.donations.setExpiredGiftBadge(state.selectedBadge)
|
||||
}
|
||||
|
||||
private fun handleSubscriptionExpiration(state: InternalDonorErrorConfigurationState) {
|
||||
SignalStore.donationsValues().setExpiredBadge(state.selectedBadge)
|
||||
SignalStore.donationsValues().clearUserManuallyCancelled()
|
||||
SignalStore.donations.setExpiredBadge(state.selectedBadge)
|
||||
SignalStore.donations.clearUserManuallyCancelled()
|
||||
handleSubscriptionPaymentFailure(state)
|
||||
}
|
||||
|
||||
private fun handleSubscriptionPaymentFailure(state: InternalDonorErrorConfigurationState) {
|
||||
SignalStore.donationsValues().unexpectedSubscriptionCancelationReason = state.selectedUnexpectedSubscriptionCancellation?.status
|
||||
SignalStore.donationsValues().unexpectedSubscriptionCancelationTimestamp = System.currentTimeMillis()
|
||||
SignalStore.donationsValues().showMonthlyDonationCanceledDialog = true
|
||||
SignalStore.donationsValues().setUnexpectedSubscriptionCancelationChargeFailure(
|
||||
SignalStore.donations.unexpectedSubscriptionCancelationReason = state.selectedUnexpectedSubscriptionCancellation?.status
|
||||
SignalStore.donations.unexpectedSubscriptionCancelationTimestamp = System.currentTimeMillis()
|
||||
SignalStore.donations.showMonthlyDonationCanceledDialog = true
|
||||
SignalStore.donations.setUnexpectedSubscriptionCancelationChargeFailure(
|
||||
state.selectedStripeDeclineCode?.let {
|
||||
ActiveSubscription.ChargeFailure(
|
||||
it.code,
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ class InternalSvrPlaygroundViewModel : ViewModel() {
|
||||
disposables += Single
|
||||
.fromCallable {
|
||||
_state.value.selected.toImplementation()
|
||||
.setPin(_state.value.userPin, SignalStore.svr().getOrCreateMasterKey())
|
||||
.setPin(_state.value.userPin, SignalStore.svr.getOrCreateMasterKey())
|
||||
.execute()
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
+2
-2
@@ -316,7 +316,7 @@ class NotificationsSettingsFragment : DSLSettingsFragment(R.string.preferences__
|
||||
}
|
||||
|
||||
private fun launchMessageSoundSelectionIntent() {
|
||||
val current = SignalStore.settings().messageNotificationSound
|
||||
val current = SignalStore.settings.messageNotificationSound
|
||||
|
||||
val intent = Intent(RingtoneManager.ACTION_RINGTONE_PICKER)
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true)
|
||||
@@ -343,7 +343,7 @@ class NotificationsSettingsFragment : DSLSettingsFragment(R.string.preferences__
|
||||
}
|
||||
|
||||
private fun launchCallRingtoneSelectionIntent() {
|
||||
val current = SignalStore.settings().callRingtone
|
||||
val current = SignalStore.settings.callRingtone
|
||||
|
||||
val intent = Intent(RingtoneManager.ACTION_RINGTONE_PICKER)
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true)
|
||||
|
||||
+26
-26
@@ -22,8 +22,8 @@ class NotificationsSettingsViewModel(private val sharedPreferences: SharedPrefer
|
||||
|
||||
init {
|
||||
if (NotificationChannels.supported()) {
|
||||
SignalStore.settings().messageNotificationSound = NotificationChannels.getInstance().messageRingtone
|
||||
SignalStore.settings().isMessageVibrateEnabled = NotificationChannels.getInstance().messageVibrate
|
||||
SignalStore.settings.messageNotificationSound = NotificationChannels.getInstance().messageRingtone
|
||||
SignalStore.settings.isMessageVibrateEnabled = NotificationChannels.getInstance().messageVibrate
|
||||
}
|
||||
|
||||
store.update { getState(calculateSlowNotifications = true) }
|
||||
@@ -34,46 +34,46 @@ class NotificationsSettingsViewModel(private val sharedPreferences: SharedPrefer
|
||||
}
|
||||
|
||||
fun setMessageNotificationsEnabled(enabled: Boolean) {
|
||||
SignalStore.settings().isMessageNotificationsEnabled = enabled
|
||||
SignalStore.settings.isMessageNotificationsEnabled = enabled
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun setMessageNotificationsSound(sound: Uri?) {
|
||||
val messageSound = sound ?: Uri.EMPTY
|
||||
SignalStore.settings().messageNotificationSound = messageSound
|
||||
SignalStore.settings.messageNotificationSound = messageSound
|
||||
NotificationChannels.getInstance().updateMessageRingtone(messageSound)
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun setMessageNotificationVibration(enabled: Boolean) {
|
||||
SignalStore.settings().isMessageVibrateEnabled = enabled
|
||||
SignalStore.settings.isMessageVibrateEnabled = enabled
|
||||
NotificationChannels.getInstance().updateMessageVibrate(enabled)
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun setMessageNotificationLedColor(color: String) {
|
||||
SignalStore.settings().messageLedColor = color
|
||||
SignalStore.settings.messageLedColor = color
|
||||
NotificationChannels.getInstance().updateMessagesLedColor(color)
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun setMessageNotificationLedBlink(blink: String) {
|
||||
SignalStore.settings().messageLedBlinkPattern = blink
|
||||
SignalStore.settings.messageLedBlinkPattern = blink
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun setMessageNotificationInChatSoundsEnabled(enabled: Boolean) {
|
||||
SignalStore.settings().isMessageNotificationsInChatSoundsEnabled = enabled
|
||||
SignalStore.settings.isMessageNotificationsInChatSoundsEnabled = enabled
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun setMessageRepeatAlerts(repeats: Int) {
|
||||
SignalStore.settings().messageNotificationsRepeatAlerts = repeats
|
||||
SignalStore.settings.messageNotificationsRepeatAlerts = repeats
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun setMessageNotificationPrivacy(preference: String) {
|
||||
SignalStore.settings().messageNotificationsPrivacy = NotificationPrivacyPreference(preference)
|
||||
SignalStore.settings.messageNotificationsPrivacy = NotificationPrivacyPreference(preference)
|
||||
refresh()
|
||||
}
|
||||
|
||||
@@ -83,22 +83,22 @@ class NotificationsSettingsViewModel(private val sharedPreferences: SharedPrefer
|
||||
}
|
||||
|
||||
fun setCallNotificationsEnabled(enabled: Boolean) {
|
||||
SignalStore.settings().isCallNotificationsEnabled = enabled
|
||||
SignalStore.settings.isCallNotificationsEnabled = enabled
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun setCallRingtone(ringtone: Uri?) {
|
||||
SignalStore.settings().callRingtone = ringtone ?: Uri.EMPTY
|
||||
SignalStore.settings.callRingtone = ringtone ?: Uri.EMPTY
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun setCallVibrateEnabled(enabled: Boolean) {
|
||||
SignalStore.settings().isCallVibrateEnabled = enabled
|
||||
SignalStore.settings.isCallVibrateEnabled = enabled
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun setNotifyWhenContactJoinsSignal(enabled: Boolean) {
|
||||
SignalStore.settings().isNotifyWhenContactJoinsSignal = enabled
|
||||
SignalStore.settings.isNotifyWhenContactJoinsSignal = enabled
|
||||
refresh()
|
||||
}
|
||||
|
||||
@@ -109,15 +109,15 @@ class NotificationsSettingsViewModel(private val sharedPreferences: SharedPrefer
|
||||
*/
|
||||
private fun getState(currentState: NotificationsSettingsState? = null, calculateSlowNotifications: Boolean = false): NotificationsSettingsState = NotificationsSettingsState(
|
||||
messageNotificationsState = MessageNotificationsState(
|
||||
notificationsEnabled = SignalStore.settings().isMessageNotificationsEnabled && canEnableNotifications(),
|
||||
notificationsEnabled = SignalStore.settings.isMessageNotificationsEnabled && canEnableNotifications(),
|
||||
canEnableNotifications = canEnableNotifications(),
|
||||
sound = SignalStore.settings().messageNotificationSound,
|
||||
vibrateEnabled = SignalStore.settings().isMessageVibrateEnabled,
|
||||
ledColor = SignalStore.settings().messageLedColor,
|
||||
ledBlink = SignalStore.settings().messageLedBlinkPattern,
|
||||
inChatSoundsEnabled = SignalStore.settings().isMessageNotificationsInChatSoundsEnabled,
|
||||
repeatAlerts = SignalStore.settings().messageNotificationsRepeatAlerts,
|
||||
messagePrivacy = SignalStore.settings().messageNotificationsPrivacy.toString(),
|
||||
sound = SignalStore.settings.messageNotificationSound,
|
||||
vibrateEnabled = SignalStore.settings.isMessageVibrateEnabled,
|
||||
ledColor = SignalStore.settings.messageLedColor,
|
||||
ledBlink = SignalStore.settings.messageLedBlinkPattern,
|
||||
inChatSoundsEnabled = SignalStore.settings.isMessageNotificationsInChatSoundsEnabled,
|
||||
repeatAlerts = SignalStore.settings.messageNotificationsRepeatAlerts,
|
||||
messagePrivacy = SignalStore.settings.messageNotificationsPrivacy.toString(),
|
||||
priority = TextSecurePreferences.getNotificationPriority(AppDependencies.application),
|
||||
troubleshootNotifications = if (calculateSlowNotifications) {
|
||||
SlowNotificationHeuristics.isPotentiallyCausedByBatteryOptimizations() && SlowNotificationHeuristics.isHavingDelayedNotifications()
|
||||
@@ -128,12 +128,12 @@ class NotificationsSettingsViewModel(private val sharedPreferences: SharedPrefer
|
||||
}
|
||||
),
|
||||
callNotificationsState = CallNotificationsState(
|
||||
notificationsEnabled = SignalStore.settings().isCallNotificationsEnabled && canEnableNotifications(),
|
||||
notificationsEnabled = SignalStore.settings.isCallNotificationsEnabled && canEnableNotifications(),
|
||||
canEnableNotifications = canEnableNotifications(),
|
||||
ringtone = SignalStore.settings().callRingtone,
|
||||
vibrateEnabled = SignalStore.settings().isCallVibrateEnabled
|
||||
ringtone = SignalStore.settings.callRingtone,
|
||||
vibrateEnabled = SignalStore.settings.isCallVibrateEnabled
|
||||
),
|
||||
notifyWhenContactJoinsSignal = SignalStore.settings().isNotifyWhenContactJoinsSignal
|
||||
notifyWhenContactJoinsSignal = SignalStore.settings.isNotifyWhenContactJoinsSignal
|
||||
)
|
||||
|
||||
private fun canEnableNotifications(): Boolean {
|
||||
|
||||
+14
-14
@@ -120,16 +120,16 @@ class NotificationProfilesRepository {
|
||||
val activeProfile = NotificationProfiles.getActiveProfile(profiles, now)
|
||||
|
||||
if (profileId == activeProfile?.id) {
|
||||
SignalStore.notificationProfileValues().manuallyEnabledProfile = 0
|
||||
SignalStore.notificationProfileValues().manuallyEnabledUntil = 0
|
||||
SignalStore.notificationProfileValues().manuallyDisabledAt = now
|
||||
SignalStore.notificationProfileValues().lastProfilePopup = 0
|
||||
SignalStore.notificationProfileValues().lastProfilePopupTime = 0
|
||||
SignalStore.notificationProfile.manuallyEnabledProfile = 0
|
||||
SignalStore.notificationProfile.manuallyEnabledUntil = 0
|
||||
SignalStore.notificationProfile.manuallyDisabledAt = now
|
||||
SignalStore.notificationProfile.lastProfilePopup = 0
|
||||
SignalStore.notificationProfile.lastProfilePopupTime = 0
|
||||
} else {
|
||||
val inScheduledWindow = schedule.isCurrentlyActive(now)
|
||||
SignalStore.notificationProfileValues().manuallyEnabledProfile = profileId
|
||||
SignalStore.notificationProfileValues().manuallyEnabledUntil = if (inScheduledWindow) schedule.endDateTime(now.toLocalDateTime()).toMillis() else Long.MAX_VALUE
|
||||
SignalStore.notificationProfileValues().manuallyDisabledAt = now
|
||||
SignalStore.notificationProfile.manuallyEnabledProfile = profileId
|
||||
SignalStore.notificationProfile.manuallyEnabledUntil = if (inScheduledWindow) schedule.endDateTime(now.toLocalDateTime()).toMillis() else Long.MAX_VALUE
|
||||
SignalStore.notificationProfile.manuallyDisabledAt = now
|
||||
}
|
||||
}
|
||||
.doOnComplete { AppDependencies.databaseObserver.notifyNotificationProfileObservers() }
|
||||
@@ -138,9 +138,9 @@ class NotificationProfilesRepository {
|
||||
|
||||
fun manuallyEnableProfileForDuration(profileId: Long, enableUntil: Long, now: Long = System.currentTimeMillis()): Completable {
|
||||
return Completable.fromAction {
|
||||
SignalStore.notificationProfileValues().manuallyEnabledProfile = profileId
|
||||
SignalStore.notificationProfileValues().manuallyEnabledUntil = enableUntil
|
||||
SignalStore.notificationProfileValues().manuallyDisabledAt = now
|
||||
SignalStore.notificationProfile.manuallyEnabledProfile = profileId
|
||||
SignalStore.notificationProfile.manuallyEnabledUntil = enableUntil
|
||||
SignalStore.notificationProfile.manuallyDisabledAt = now
|
||||
}
|
||||
.doOnComplete { AppDependencies.databaseObserver.notifyNotificationProfileObservers() }
|
||||
.subscribeOn(Schedulers.io())
|
||||
@@ -149,9 +149,9 @@ class NotificationProfilesRepository {
|
||||
fun manuallyEnableProfileForSchedule(profileId: Long, schedule: NotificationProfileSchedule, now: Long = System.currentTimeMillis()): Completable {
|
||||
return Completable.fromAction {
|
||||
val inScheduledWindow = schedule.isCurrentlyActive(now)
|
||||
SignalStore.notificationProfileValues().manuallyEnabledProfile = if (inScheduledWindow) profileId else 0
|
||||
SignalStore.notificationProfileValues().manuallyEnabledUntil = if (inScheduledWindow) schedule.endDateTime(now.toLocalDateTime()).toMillis() else Long.MAX_VALUE
|
||||
SignalStore.notificationProfileValues().manuallyDisabledAt = if (inScheduledWindow) now else 0
|
||||
SignalStore.notificationProfile.manuallyEnabledProfile = if (inScheduledWindow) profileId else 0
|
||||
SignalStore.notificationProfile.manuallyEnabledUntil = if (inScheduledWindow) schedule.endDateTime(now.toLocalDateTime()).toMillis() else Long.MAX_VALUE
|
||||
SignalStore.notificationProfile.manuallyDisabledAt = if (inScheduledWindow) now else 0
|
||||
}
|
||||
.doOnComplete { AppDependencies.databaseObserver.notifyNotificationProfileObservers() }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ class PrivacySettingsRepository {
|
||||
TextSecurePreferences.isReadReceiptsEnabled(context),
|
||||
TextSecurePreferences.isTypingIndicatorsEnabled(context),
|
||||
TextSecurePreferences.isShowUnidentifiedDeliveryIndicatorsEnabled(context),
|
||||
SignalStore.settings().isLinkPreviewsEnabled
|
||||
SignalStore.settings.isLinkPreviewsEnabled
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class PrivacySettingsRepository {
|
||||
TextSecurePreferences.isReadReceiptsEnabled(context),
|
||||
enabled,
|
||||
TextSecurePreferences.isShowUnidentifiedDeliveryIndicatorsEnabled(context),
|
||||
SignalStore.settings().isLinkPreviewsEnabled
|
||||
SignalStore.settings.isLinkPreviewsEnabled
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
+3
-3
@@ -58,7 +58,7 @@ class PrivacySettingsViewModel(
|
||||
}
|
||||
|
||||
fun togglePaymentLock(enable: Boolean) {
|
||||
SignalStore.paymentsValues().paymentLock = enable
|
||||
SignalStore.payments.paymentLock = enable
|
||||
refresh()
|
||||
}
|
||||
|
||||
@@ -85,11 +85,11 @@ class PrivacySettingsViewModel(
|
||||
screenLockActivityTimeout = TextSecurePreferences.getScreenLockTimeout(AppDependencies.application),
|
||||
screenSecurity = TextSecurePreferences.isScreenSecurityEnabled(AppDependencies.application),
|
||||
incognitoKeyboard = TextSecurePreferences.isIncognitoKeyboardEnabled(AppDependencies.application),
|
||||
paymentLock = SignalStore.paymentsValues().paymentLock,
|
||||
paymentLock = SignalStore.payments.paymentLock,
|
||||
isObsoletePasswordEnabled = !TextSecurePreferences.isPasswordDisabled(AppDependencies.application),
|
||||
isObsoletePasswordTimeoutEnabled = TextSecurePreferences.isPassphraseTimeoutEnabled(AppDependencies.application),
|
||||
obsoletePasswordTimeout = TextSecurePreferences.getPassphraseTimeoutInterval(AppDependencies.application),
|
||||
universalExpireTimer = SignalStore.settings().universalExpireTimer
|
||||
universalExpireTimer = SignalStore.settings.universalExpireTimer
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -164,7 +164,7 @@ class AdvancedPrivacySettingsFragment : DSLSettingsFragment(R.string.preferences
|
||||
|
||||
private fun getPushToggleSummary(isPushEnabled: Boolean): String {
|
||||
return if (isPushEnabled) {
|
||||
PhoneNumberFormatter.prettyPrint(SignalStore.account().e164!!)
|
||||
PhoneNumberFormatter.prettyPrint(SignalStore.account.e164!!)
|
||||
} else {
|
||||
getString(R.string.preferences__free_private_messages_and_calls)
|
||||
}
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ class AdvancedPrivacySettingsRepository(private val context: Context) {
|
||||
} catch (e: AuthorizationFailedException) {
|
||||
Log.w(TAG, e)
|
||||
}
|
||||
if (SignalStore.account().fcmEnabled) {
|
||||
if (SignalStore.account.fcmEnabled) {
|
||||
Tasks.await(FirebaseInstallations.getInstance().delete())
|
||||
}
|
||||
DisablePushMessagesResult.SUCCESS
|
||||
@@ -58,7 +58,7 @@ class AdvancedPrivacySettingsRepository(private val context: Context) {
|
||||
TextSecurePreferences.isReadReceiptsEnabled(context),
|
||||
TextSecurePreferences.isTypingIndicatorsEnabled(context),
|
||||
TextSecurePreferences.isShowUnidentifiedDeliveryIndicatorsEnabled(context),
|
||||
SignalStore.settings().isLinkPreviewsEnabled
|
||||
SignalStore.settings.isLinkPreviewsEnabled
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
+6
-6
@@ -56,8 +56,8 @@ class AdvancedPrivacySettingsViewModel(
|
||||
}
|
||||
|
||||
fun setCensorshipCircumventionEnabled(enabled: Boolean) {
|
||||
SignalStore.settings().setCensorshipCircumventionEnabled(enabled)
|
||||
SignalStore.misc().isServiceReachableWithoutCircumvention = false
|
||||
SignalStore.settings.setCensorshipCircumventionEnabled(enabled)
|
||||
SignalStore.misc.isServiceReachableWithoutCircumvention = false
|
||||
AppDependencies.resetNetwork()
|
||||
refresh()
|
||||
}
|
||||
@@ -74,7 +74,7 @@ class AdvancedPrivacySettingsViewModel(
|
||||
val censorshipCircumventionState = getCensorshipCircumventionState()
|
||||
|
||||
return AdvancedPrivacySettingsState(
|
||||
isPushEnabled = SignalStore.account().isRegistered,
|
||||
isPushEnabled = SignalStore.account.isRegistered,
|
||||
alwaysRelayCalls = TextSecurePreferences.isTurnOnly(AppDependencies.application),
|
||||
censorshipCircumventionState = censorshipCircumventionState,
|
||||
censorshipCircumventionEnabled = getCensorshipCircumventionEnabled(censorshipCircumventionState),
|
||||
@@ -91,12 +91,12 @@ class AdvancedPrivacySettingsViewModel(
|
||||
private fun getCensorshipCircumventionState(): CensorshipCircumventionState {
|
||||
val countryCode: Int = PhoneNumberFormatter.getLocalCountryCode()
|
||||
val isCountryCodeCensoredByDefault: Boolean = AppDependencies.signalServiceNetworkAccess.isCountryCodeCensoredByDefault(countryCode)
|
||||
val enabledState: SettingsValues.CensorshipCircumventionEnabled = SignalStore.settings().censorshipCircumventionEnabled
|
||||
val enabledState: SettingsValues.CensorshipCircumventionEnabled = SignalStore.settings.censorshipCircumventionEnabled
|
||||
val hasInternet: Boolean = NetworkConstraint.isMet(AppDependencies.application)
|
||||
val websocketConnected: Boolean = AppDependencies.signalWebSocket.webSocketState.firstOrError().blockingGet() == WebSocketConnectionState.CONNECTED
|
||||
|
||||
return when {
|
||||
SignalStore.internalValues().allowChangingCensorshipSetting() -> {
|
||||
SignalStore.internal.allowChangingCensorshipSetting() -> {
|
||||
CensorshipCircumventionState.AVAILABLE
|
||||
}
|
||||
isCountryCodeCensoredByDefault && enabledState == SettingsValues.CensorshipCircumventionEnabled.DISABLED -> {
|
||||
@@ -128,7 +128,7 @@ class AdvancedPrivacySettingsViewModel(
|
||||
true
|
||||
}
|
||||
else -> {
|
||||
SignalStore.settings().censorshipCircumventionEnabled == SettingsValues.CensorshipCircumventionEnabled.ENABLED
|
||||
SignalStore.settings.censorshipCircumventionEnabled == SettingsValues.CensorshipCircumventionEnabled.ENABLED
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ class ExpireTimerSettingsRepository(val context: Context) {
|
||||
|
||||
fun setUniversalExpireTimerSeconds(newExpirationTime: Int, onDone: () -> Unit) {
|
||||
SignalExecutors.BOUNDED.execute {
|
||||
SignalStore.settings().universalExpireTimer = newExpirationTime
|
||||
SignalStore.settings.universalExpireTimer = newExpirationTime
|
||||
SignalDatabase.recipients.markNeedsSync(Recipient.self().id)
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
onDone.invoke()
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ class ExpireTimerSettingsViewModel(val config: Config, private val repository: E
|
||||
if (recipientId != null) {
|
||||
store.update(Recipient.live(recipientId).liveData) { r, s -> s.copy(initialTimer = r.expiresInSeconds, isForRecipient = true) }
|
||||
} else {
|
||||
store.update { it.copy(initialTimer = config.initialValue ?: SignalStore.settings().universalExpireTimer) }
|
||||
store.update { it.copy(initialTimer = config.initialValue ?: SignalStore.settings.universalExpireTimer) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -18,8 +18,8 @@ class PhoneNumberPrivacySettingsViewModel : ViewModel() {
|
||||
|
||||
private val _state = mutableStateOf(
|
||||
PhoneNumberPrivacySettingsState(
|
||||
phoneNumberSharing = SignalStore.phoneNumberPrivacy().isPhoneNumberSharingEnabled,
|
||||
discoverableByPhoneNumber = SignalStore.phoneNumberPrivacy().phoneNumberDiscoverabilityMode != PhoneNumberDiscoverabilityMode.NOT_DISCOVERABLE
|
||||
phoneNumberSharing = SignalStore.phoneNumberPrivacy.isPhoneNumberSharingEnabled,
|
||||
discoverableByPhoneNumber = SignalStore.phoneNumberPrivacy.phoneNumberDiscoverabilityMode != PhoneNumberDiscoverabilityMode.NOT_DISCOVERABLE
|
||||
)
|
||||
)
|
||||
|
||||
@@ -43,7 +43,7 @@ class PhoneNumberPrivacySettingsViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
private fun setPhoneNumberSharingEnabled(phoneNumberSharingEnabled: Boolean) {
|
||||
SignalStore.phoneNumberPrivacy().phoneNumberSharingMode = if (phoneNumberSharingEnabled) PhoneNumberSharingMode.EVERYBODY else PhoneNumberSharingMode.NOBODY
|
||||
SignalStore.phoneNumberPrivacy.phoneNumberSharingMode = if (phoneNumberSharingEnabled) PhoneNumberSharingMode.EVERYBODY else PhoneNumberSharingMode.NOBODY
|
||||
SignalDatabase.recipients.markNeedsSync(Recipient.self().id)
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
AppDependencies.jobManager.add(ProfileUploadJob())
|
||||
@@ -51,7 +51,7 @@ class PhoneNumberPrivacySettingsViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
private fun setDiscoverableByPhoneNumber(discoverable: Boolean) {
|
||||
SignalStore.phoneNumberPrivacy().phoneNumberDiscoverabilityMode = if (discoverable) PhoneNumberDiscoverabilityMode.DISCOVERABLE else PhoneNumberDiscoverabilityMode.NOT_DISCOVERABLE
|
||||
SignalStore.phoneNumberPrivacy.phoneNumberDiscoverabilityMode = if (discoverable) PhoneNumberDiscoverabilityMode.DISCOVERABLE else PhoneNumberDiscoverabilityMode.NOT_DISCOVERABLE
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
AppDependencies.jobManager.startChain(RefreshAttributesJob()).then(RefreshOwnProfileJob()).enqueue()
|
||||
refresh()
|
||||
@@ -59,8 +59,8 @@ class PhoneNumberPrivacySettingsViewModel : ViewModel() {
|
||||
|
||||
fun refresh() {
|
||||
_state.value = PhoneNumberPrivacySettingsState(
|
||||
phoneNumberSharing = SignalStore.phoneNumberPrivacy().isPhoneNumberSharingEnabled,
|
||||
discoverableByPhoneNumber = SignalStore.phoneNumberPrivacy().phoneNumberDiscoverabilityMode != PhoneNumberDiscoverabilityMode.NOT_DISCOVERABLE
|
||||
phoneNumberSharing = SignalStore.phoneNumberPrivacy.isPhoneNumberSharingEnabled,
|
||||
discoverableByPhoneNumber = SignalStore.phoneNumberPrivacy.phoneNumberDiscoverabilityMode != PhoneNumberDiscoverabilityMode.NOT_DISCOVERABLE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -25,9 +25,9 @@ class ManageStorageSettingsViewModel : ViewModel() {
|
||||
|
||||
private val store = MutableStateFlow(
|
||||
ManageStorageState(
|
||||
keepMessagesDuration = SignalStore.settings().keepMessagesDuration,
|
||||
lengthLimit = if (SignalStore.settings().isTrimByLengthEnabled) SignalStore.settings().threadTrimLength else ManageStorageState.NO_LIMIT,
|
||||
syncTrimDeletes = SignalStore.settings().shouldSyncThreadTrimDeletes()
|
||||
keepMessagesDuration = SignalStore.settings.keepMessagesDuration,
|
||||
lengthLimit = if (SignalStore.settings.isTrimByLengthEnabled) SignalStore.settings.threadTrimLength else ManageStorageState.NO_LIMIT,
|
||||
syncTrimDeletes = SignalStore.settings.shouldSyncThreadTrimDeletes()
|
||||
)
|
||||
)
|
||||
val state = store.asStateFlow()
|
||||
@@ -47,7 +47,7 @@ class ManageStorageSettingsViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
fun setKeepMessagesDuration(newDuration: KeepMessagesDuration) {
|
||||
SignalStore.settings().setKeepMessagesForDuration(newDuration)
|
||||
SignalStore.settings.setKeepMessagesForDuration(newDuration)
|
||||
AppDependencies.trimThreadsByDateManager.scheduleIfNecessary()
|
||||
|
||||
store.update { it.copy(keepMessagesDuration = newDuration) }
|
||||
@@ -60,13 +60,13 @@ class ManageStorageSettingsViewModel : ViewModel() {
|
||||
fun setChatLengthLimit(newLimit: Int) {
|
||||
val restrictingChange = isRestrictingLengthLimitChange(newLimit)
|
||||
|
||||
SignalStore.settings().setThreadTrimByLengthEnabled(newLimit != ManageStorageState.NO_LIMIT)
|
||||
SignalStore.settings().threadTrimLength = newLimit
|
||||
SignalStore.settings.setThreadTrimByLengthEnabled(newLimit != ManageStorageState.NO_LIMIT)
|
||||
SignalStore.settings.threadTrimLength = newLimit
|
||||
store.update { it.copy(lengthLimit = newLimit) }
|
||||
|
||||
if (SignalStore.settings().isTrimByLengthEnabled && restrictingChange) {
|
||||
if (SignalStore.settings.isTrimByLengthEnabled && restrictingChange) {
|
||||
SignalExecutors.BOUNDED.execute {
|
||||
val keepMessagesDuration = SignalStore.settings().keepMessagesDuration
|
||||
val keepMessagesDuration = SignalStore.settings.keepMessagesDuration
|
||||
|
||||
val trimBeforeDate = if (keepMessagesDuration != KeepMessagesDuration.FOREVER) {
|
||||
System.currentTimeMillis() - keepMessagesDuration.duration
|
||||
@@ -84,7 +84,7 @@ class ManageStorageSettingsViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
fun setSyncTrimDeletes(syncTrimDeletes: Boolean) {
|
||||
SignalStore.settings().setSyncThreadTrimDeletes(syncTrimDeletes)
|
||||
SignalStore.settings.setSyncThreadTrimDeletes(syncTrimDeletes)
|
||||
store.update { it.copy(syncTrimDeletes = syncTrimDeletes) }
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ object InAppDonations {
|
||||
* Whether the user is using a device that supports GooglePay, based off Wallet API and phone number.
|
||||
*/
|
||||
fun isGooglePayAvailable(): Boolean {
|
||||
return SignalStore.donationsValues().isGooglePayReady && !LocaleRemoteConfig.isGooglePayDisabled()
|
||||
return SignalStore.donations.isGooglePayReady && !LocaleRemoteConfig.isGooglePayDisabled()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+6
-6
@@ -312,7 +312,7 @@ object InAppPaymentsRepository {
|
||||
return if (paymentMethodType != InAppPaymentData.PaymentMethodType.UNKNOWN) {
|
||||
paymentMethodType
|
||||
} else if (subscriberType == InAppPaymentSubscriberRecord.Type.DONATION) {
|
||||
SignalStore.donationsValues().getSubscriptionPaymentSourceType().toPaymentMethodType()
|
||||
SignalStore.donations.getSubscriptionPaymentSourceType().toPaymentMethodType()
|
||||
} else {
|
||||
return InAppPaymentData.PaymentMethodType.UNKNOWN
|
||||
}
|
||||
@@ -328,7 +328,7 @@ object InAppPaymentsRepository {
|
||||
val latestSubscription = SignalDatabase.inAppPayments.getLatestInAppPaymentByType(subscriberType.inAppPaymentType)
|
||||
|
||||
return if (latestSubscription == null) {
|
||||
SignalStore.donationsValues().isUserManuallyCancelled()
|
||||
SignalStore.donations.isUserManuallyCancelled()
|
||||
} else {
|
||||
latestSubscription.data.cancellation?.reason == InAppPaymentData.Cancellation.Reason.MANUAL
|
||||
}
|
||||
@@ -348,7 +348,7 @@ object InAppPaymentsRepository {
|
||||
@WorkerThread
|
||||
fun setShouldCancelSubscriptionBeforeNextSubscribeAttempt(subscriberType: InAppPaymentSubscriberRecord.Type, subscriberId: SubscriberId?, shouldCancel: Boolean) {
|
||||
if (subscriberType == InAppPaymentSubscriberRecord.Type.DONATION) {
|
||||
SignalStore.donationsValues().shouldCancelSubscriptionBeforeNextSubscribeAttempt = shouldCancel
|
||||
SignalStore.donations.shouldCancelSubscriptionBeforeNextSubscribeAttempt = shouldCancel
|
||||
}
|
||||
|
||||
if (subscriberId == null) {
|
||||
@@ -371,7 +371,7 @@ object InAppPaymentsRepository {
|
||||
val latestSubscriber = getSubscriber(subscriberType)
|
||||
|
||||
return latestSubscriber?.requiresCancel ?: if (subscriberType == InAppPaymentSubscriberRecord.Type.DONATION) {
|
||||
SignalStore.donationsValues().shouldCancelSubscriptionBeforeNextSubscribeAttempt
|
||||
SignalStore.donations.shouldCancelSubscriptionBeforeNextSubscribeAttempt
|
||||
} else {
|
||||
false
|
||||
}
|
||||
@@ -388,7 +388,7 @@ object InAppPaymentsRepository {
|
||||
val subscriber = SignalDatabase.inAppPaymentSubscribers.getByCurrencyCode(currency.currencyCode, type)
|
||||
|
||||
return if (subscriber == null && type == InAppPaymentSubscriberRecord.Type.DONATION) {
|
||||
SignalStore.donationsValues().getSubscriber(currency)
|
||||
SignalStore.donations.getSubscriber(currency)
|
||||
} else {
|
||||
subscriber
|
||||
}
|
||||
@@ -400,7 +400,7 @@ object InAppPaymentsRepository {
|
||||
@JvmStatic
|
||||
@WorkerThread
|
||||
fun getSubscriber(type: InAppPaymentSubscriberRecord.Type): InAppPaymentSubscriberRecord? {
|
||||
val currency = SignalStore.donationsValues().getSubscriptionCurrency(type)
|
||||
val currency = SignalStore.donations.getSubscriptionCurrency(type)
|
||||
Log.d(TAG, "Attempting to retrieve subscriber of type $type for ${currency.currencyCode}")
|
||||
|
||||
return getSubscriber(currency, type)
|
||||
|
||||
+9
-9
@@ -52,7 +52,7 @@ object RecurringInAppPaymentRepository {
|
||||
.subscribeOn(Schedulers.io())
|
||||
.flatMap(ServiceResponse<ActiveSubscription>::flattenResult)
|
||||
.doOnSuccess { activeSubscription ->
|
||||
if (activeSubscription.isActive && activeSubscription.activeSubscription.endOfCurrentPeriod > SignalStore.donationsValues().getLastEndOfPeriod()) {
|
||||
if (activeSubscription.isActive && activeSubscription.activeSubscription.endOfCurrentPeriod > SignalStore.donations.getLastEndOfPeriod()) {
|
||||
InAppPaymentKeepAliveJob.enqueueAndTrackTime(System.currentTimeMillis().milliseconds)
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ object RecurringInAppPaymentRepository {
|
||||
InAppPaymentsRepository.setSubscriber(
|
||||
InAppPaymentSubscriberRecord(
|
||||
subscriberId = subscriberId,
|
||||
currency = SignalStore.donationsValues().getSubscriptionCurrency(subscriberType),
|
||||
currency = SignalStore.donations.getSubscriptionCurrency(subscriberType),
|
||||
type = subscriberType,
|
||||
requiresCancel = false,
|
||||
paymentMethodType = InAppPaymentData.PaymentMethodType.UNKNOWN
|
||||
@@ -141,7 +141,7 @@ object RecurringInAppPaymentRepository {
|
||||
serviceResponse.resultOrThrow
|
||||
|
||||
Log.d(TAG, "Cancelled active subscription.", true)
|
||||
SignalStore.donationsValues().updateLocalStateForManualCancellation(subscriberType)
|
||||
SignalStore.donations.updateLocalStateForManualCancellation(subscriberType)
|
||||
MultiDeviceSubscriptionSyncRequestJob.enqueue()
|
||||
InAppPaymentsRepository.scheduleSyncForAccountRecordChange()
|
||||
}
|
||||
@@ -157,7 +157,7 @@ object RecurringInAppPaymentRepository {
|
||||
return Single.fromCallable { InAppPaymentsRepository.getShouldCancelSubscriptionBeforeNextSubscribeAttempt(subscriberType) }.flatMapCompletable {
|
||||
if (it) {
|
||||
cancelActiveSubscription(subscriberType).doOnComplete {
|
||||
SignalStore.donationsValues().updateLocalStateForManualCancellation(subscriberType)
|
||||
SignalStore.donations.updateLocalStateForManualCancellation(subscriberType)
|
||||
MultiDeviceSubscriptionSyncRequestJob.enqueue()
|
||||
}
|
||||
} else {
|
||||
@@ -212,14 +212,14 @@ object RecurringInAppPaymentRepository {
|
||||
.flatMapCompletable {
|
||||
if (it.status == 200 || it.status == 204) {
|
||||
Log.d(TAG, "Successfully set user subscription to level $subscriptionLevel with response code ${it.status}", true)
|
||||
SignalStore.donationsValues().updateLocalStateForLocalSubscribe(subscriberType)
|
||||
SignalStore.donations.updateLocalStateForLocalSubscribe(subscriberType)
|
||||
syncAccountRecord().subscribe()
|
||||
LevelUpdate.updateProcessingState(false)
|
||||
Completable.complete()
|
||||
} else {
|
||||
if (it.applicationError.isPresent) {
|
||||
Log.w(TAG, "Failed to set user subscription to level $subscriptionLevel with response code ${it.status}", it.applicationError.get(), true)
|
||||
SignalStore.donationsValues().clearLevelOperations()
|
||||
SignalStore.donations.clearLevelOperations()
|
||||
} else {
|
||||
Log.w(TAG, "Failed to set user subscription to level $subscriptionLevel", it.executionError.orElse(null), true)
|
||||
}
|
||||
@@ -256,14 +256,14 @@ object RecurringInAppPaymentRepository {
|
||||
|
||||
fun getOrCreateLevelUpdateOperation(tag: String, subscriptionLevel: String): LevelUpdateOperation {
|
||||
Log.d(tag, "Retrieving level update operation for $subscriptionLevel")
|
||||
val levelUpdateOperation = SignalStore.donationsValues().getLevelOperation(subscriptionLevel)
|
||||
val levelUpdateOperation = SignalStore.donations.getLevelOperation(subscriptionLevel)
|
||||
return if (levelUpdateOperation == null) {
|
||||
val newOperation = LevelUpdateOperation(
|
||||
idempotencyKey = IdempotencyKey.generate(),
|
||||
level = subscriptionLevel
|
||||
)
|
||||
|
||||
SignalStore.donationsValues().setLevelOperation(newOperation)
|
||||
SignalStore.donations.setLevelOperation(newOperation)
|
||||
LevelUpdate.updateProcessingState(true)
|
||||
Log.d(tag, "Created a new operation for $subscriptionLevel")
|
||||
newOperation
|
||||
@@ -281,7 +281,7 @@ object RecurringInAppPaymentRepository {
|
||||
private fun updateLocalSubscriptionStateAndScheduleDataSync(subscriberType: InAppPaymentSubscriberRecord.Type): Completable {
|
||||
return Completable.fromAction {
|
||||
Log.d(TAG, "Marking subscription cancelled...", true)
|
||||
SignalStore.donationsValues().updateLocalStateForManualCancellation(subscriberType)
|
||||
SignalStore.donations.updateLocalStateForManualCancellation(subscriberType)
|
||||
MultiDeviceSubscriptionSyncRequestJob.enqueue()
|
||||
SignalDatabase.recipients.markNeedsSync(Recipient.self().id)
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
|
||||
+3
-3
@@ -42,7 +42,7 @@ class TerminalDonationDelegate(
|
||||
private val badgeRepository = TerminalDonationRepository()
|
||||
|
||||
override fun onResume(owner: LifecycleOwner) {
|
||||
val donations = SignalStore.donationsValues().consumeTerminalDonations()
|
||||
val donations = SignalStore.donations.consumeTerminalDonations()
|
||||
for (donation in donations) {
|
||||
if (donation.isLongRunningPaymentMethod && (donation.error == null || donation.error.type != DonationErrorValue.Type.REDEMPTION)) {
|
||||
TerminalDonationBottomSheet.show(fragmentManager, donation)
|
||||
@@ -57,7 +57,7 @@ class TerminalDonationDelegate(
|
||||
}
|
||||
}
|
||||
|
||||
val verifiedMonthlyDonation: Stripe3DSData? = SignalStore.donationsValues().consumeVerifiedSubscription3DSData()
|
||||
val verifiedMonthlyDonation: Stripe3DSData? = SignalStore.donations.consumeVerifiedSubscription3DSData()
|
||||
if (verifiedMonthlyDonation != null) {
|
||||
DonationPendingBottomSheet().apply {
|
||||
arguments = DonationPendingBottomSheetArgs.Builder(verifiedMonthlyDonation.inAppPayment).build().toBundle()
|
||||
@@ -80,7 +80,7 @@ class TerminalDonationDelegate(
|
||||
DonationPendingBottomSheet().apply {
|
||||
arguments = DonationPendingBottomSheetArgs.Builder(payment).build().toBundle()
|
||||
}.show(fragmentManager, null)
|
||||
} else if (payment.data.error != null && payment.data.cancellation != null && payment.data.cancellation.reason != InAppPaymentData.Cancellation.Reason.MANUAL && SignalStore.donationsValues().showMonthlyDonationCanceledDialog) {
|
||||
} else if (payment.data.error != null && payment.data.cancellation != null && payment.data.cancellation.reason != InAppPaymentData.Cancellation.Reason.MANUAL && SignalStore.donations.showMonthlyDonationCanceledDialog) {
|
||||
MonthlyDonationCanceledBottomSheetDialogFragment.show(fragmentManager)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ class TerminalDonationViewModel(
|
||||
disposables += repository.getBadge(donationCompleted)
|
||||
.map { badge ->
|
||||
val hasOtherBadges = Recipient.self().badges.filterNot { it.id == badge.id }.isNotEmpty()
|
||||
val isDisplayingBadges = SignalStore.donationsValues().getDisplayBadgesOnProfile()
|
||||
val isDisplayingBadges = SignalStore.donations.getDisplayBadgesOnProfile()
|
||||
|
||||
val toggleType = when {
|
||||
hasOtherBadges && isDisplayingBadges -> ToggleType.MAKE_FEATURED_BADGE
|
||||
|
||||
+3
-3
@@ -24,9 +24,9 @@ class SetCurrencyViewModel(
|
||||
private val store = Store(
|
||||
SetCurrencyState(
|
||||
selectedCurrencyCode = if (inAppPaymentType.recurring) {
|
||||
SignalStore.donationsValues().getSubscriptionCurrency(inAppPaymentType.requireSubscriberType()).currencyCode
|
||||
SignalStore.donations.getSubscriptionCurrency(inAppPaymentType.requireSubscriberType()).currencyCode
|
||||
} else {
|
||||
SignalStore.donationsValues().getOneTimeCurrency().currencyCode
|
||||
SignalStore.donations.getOneTimeCurrency().currencyCode
|
||||
},
|
||||
currencies = supportedCurrencyCodes
|
||||
.map(Currency::getInstance)
|
||||
@@ -40,7 +40,7 @@ class SetCurrencyViewModel(
|
||||
store.update { it.copy(selectedCurrencyCode = selectedCurrencyCode) }
|
||||
|
||||
if (!inAppPaymentType.recurring) {
|
||||
SignalStore.donationsValues().setOneTimeCurrency(Currency.getInstance(selectedCurrencyCode))
|
||||
SignalStore.donations.setOneTimeCurrency(Currency.getInstance(selectedCurrencyCode))
|
||||
} else {
|
||||
val currency = Currency.getInstance(selectedCurrencyCode)
|
||||
val subscriber = InAppPaymentsRepository.getSubscriber(currency, inAppPaymentType.requireSubscriberType())
|
||||
|
||||
+2
-2
@@ -91,7 +91,7 @@ data class DonateToSignalState(
|
||||
|
||||
data class OneTimeDonationState(
|
||||
val badge: Badge? = null,
|
||||
val selectedCurrency: Currency = SignalStore.donationsValues().getOneTimeCurrency(),
|
||||
val selectedCurrency: Currency = SignalStore.donations.getOneTimeCurrency(),
|
||||
val boosts: List<Boost> = emptyList(),
|
||||
val selectedBoost: Boost? = null,
|
||||
val customAmount: FiatMoney = FiatMoney(BigDecimal.ZERO, selectedCurrency),
|
||||
@@ -114,7 +114,7 @@ data class DonateToSignalState(
|
||||
}
|
||||
|
||||
data class MonthlyDonationState(
|
||||
val selectedCurrency: Currency = SignalStore.donationsValues().getSubscriptionCurrency(InAppPaymentSubscriberRecord.Type.DONATION),
|
||||
val selectedCurrency: Currency = SignalStore.donations.getSubscriptionCurrency(InAppPaymentSubscriberRecord.Type.DONATION),
|
||||
val subscriptions: List<Subscription> = emptyList(),
|
||||
private val _activeSubscription: ActiveSubscription? = null,
|
||||
val selectedSubscription: Subscription? = null,
|
||||
|
||||
+5
-5
@@ -248,7 +248,7 @@ class DonateToSignalViewModel(
|
||||
}
|
||||
}.distinctUntilChanged()
|
||||
|
||||
val oneTimeDonationFromStore: Observable<Optional<PendingOneTimeDonation>> = SignalStore.donationsValues().observablePendingOneTimeDonation
|
||||
val oneTimeDonationFromStore: Observable<Optional<PendingOneTimeDonation>> = SignalStore.donations.observablePendingOneTimeDonation
|
||||
.map { pending -> pending.filter { !it.isExpired } }
|
||||
.distinctUntilChanged()
|
||||
|
||||
@@ -283,13 +283,13 @@ class DonateToSignalViewModel(
|
||||
)
|
||||
|
||||
val boosts: Observable<Map<Currency, List<Boost>>> = oneTimeInAppPaymentRepository.getBoosts().toObservable()
|
||||
val oneTimeCurrency: Observable<Currency> = SignalStore.donationsValues().observableOneTimeCurrency
|
||||
val oneTimeCurrency: Observable<Currency> = SignalStore.donations.observableOneTimeCurrency
|
||||
|
||||
oneTimeDonationDisposables += Observable.combineLatest(boosts, oneTimeCurrency) { boostMap, currency ->
|
||||
val boostList = if (currency in boostMap) {
|
||||
boostMap[currency]!!
|
||||
} else {
|
||||
SignalStore.donationsValues().setOneTimeCurrency(PlatformCurrencyUtil.USD)
|
||||
SignalStore.donations.setOneTimeCurrency(PlatformCurrencyUtil.USD)
|
||||
listOf()
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ class DonateToSignalViewModel(
|
||||
onSuccess = { subscriptions ->
|
||||
if (subscriptions.isNotEmpty()) {
|
||||
val priceCurrencies = subscriptions[0].prices.map { it.currency }
|
||||
val selectedCurrency = SignalStore.donationsValues().getSubscriptionCurrency(InAppPaymentSubscriberRecord.Type.DONATION)
|
||||
val selectedCurrency = SignalStore.donations.getSubscriptionCurrency(InAppPaymentSubscriberRecord.Type.DONATION)
|
||||
|
||||
if (selectedCurrency !in priceCurrencies) {
|
||||
Log.w(TAG, "Unsupported currency selection. Defaulting to USD. $selectedCurrency isn't supported.")
|
||||
@@ -403,7 +403,7 @@ class DonateToSignalViewModel(
|
||||
}
|
||||
|
||||
private fun monitorSubscriptionCurrency() {
|
||||
monthlyDonationDisposables += SignalStore.donationsValues().observableRecurringDonationCurrency.subscribe {
|
||||
monthlyDonationDisposables += SignalStore.donations.observableRecurringDonationCurrency.subscribe {
|
||||
store.update { state ->
|
||||
state.copy(monthlyDonationState = state.monthlyDonationState.copy(selectedCurrency = it))
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user