Periodically fetch release notes.

This commit is contained in:
Cody Henthorne
2022-02-02 10:45:04 -05:00
parent 9114dc83d7
commit 8348badcd6
25 changed files with 789 additions and 34 deletions

View File

@@ -0,0 +1,37 @@
package org.thoughtcrime.securesms.keyvalue
import org.thoughtcrime.securesms.recipients.RecipientId
internal class ReleaseChannelValues(store: KeyValueStore) : SignalStoreValues(store) {
companion object {
private const val KEY_RELEASE_CHANNEL_RECIPIENT_ID = "releasechannel.recipient_id"
private const val KEY_NEXT_SCHEDULED_CHECK = "releasechannel.next_scheduled_check"
private const val KEY_PREVIOUS_MANIFEST_MD5 = "releasechannel.previous_manifest_md5"
private const val KEY_HIGHEST_VERSION_NOTE_RECEIVED = "releasechannel.highest_version_note_received"
}
override fun onFirstEverAppLaunch() = Unit
override fun getKeysToIncludeInBackup(): List<String> = listOf(
KEY_RELEASE_CHANNEL_RECIPIENT_ID
)
val releaseChannelRecipientId: RecipientId?
get() {
val id = getString(KEY_RELEASE_CHANNEL_RECIPIENT_ID, "")
return if (id.isEmpty()) {
null
} else {
RecipientId.from(id)
}
}
fun setReleaseChannelRecipientId(id: RecipientId) {
putString(KEY_RELEASE_CHANNEL_RECIPIENT_ID, id.serialize())
}
var nextScheduledCheck by longValue(KEY_NEXT_SCHEDULED_CHECK, 0)
var previousManifestMd5 by blobValue(KEY_PREVIOUS_MANIFEST_MD5, ByteArray(0))
var highestVersionNoteReceived by integerValue(KEY_HIGHEST_VERSION_NOTE_RECEIVED, 0)
}

View File

@@ -41,6 +41,7 @@ public final class SignalStore {
private final ChatColorsValues chatColorsValues;
private final ImageEditorValues imageEditorValues;
private final NotificationProfileValues notificationProfileValues;
private final ReleaseChannelValues releaseChannelValues;
private static volatile SignalStore instance;
@@ -81,6 +82,7 @@ public final class SignalStore {
this.chatColorsValues = new ChatColorsValues(store);
this.imageEditorValues = new ImageEditorValues(store);
this.notificationProfileValues = new NotificationProfileValues(store);
this.releaseChannelValues = new ReleaseChannelValues(store);
}
public static void onFirstEverAppLaunch() {
@@ -107,6 +109,7 @@ public final class SignalStore {
chatColorsValues().onFirstEverAppLaunch();
imageEditorValues().onFirstEverAppLaunch();
notificationProfileValues().onFirstEverAppLaunch();
releaseChannelValues().onFirstEverAppLaunch();
}
public static List<String> getKeysToIncludeInBackup() {
@@ -134,6 +137,7 @@ public final class SignalStore {
keys.addAll(chatColorsValues().getKeysToIncludeInBackup());
keys.addAll(imageEditorValues().getKeysToIncludeInBackup());
keys.addAll(notificationProfileValues().getKeysToIncludeInBackup());
keys.addAll(releaseChannelValues().getKeysToIncludeInBackup());
return keys;
}
@@ -238,6 +242,10 @@ public final class SignalStore {
return getInstance().notificationProfileValues;
}
public static @NonNull ReleaseChannelValues releaseChannelValues() {
return getInstance().releaseChannelValues;
}
public static @NonNull GroupsV2AuthorizationSignalStoreCache groupsV2AuthorizationCache() {
return new GroupsV2AuthorizationSignalStoreCache(getStore());
}