mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-30 05:31:34 +01:00
Convert SignalStore to kotlin.
This commit is contained in:
@@ -78,13 +78,13 @@ object DeleteDialog {
|
||||
}
|
||||
|
||||
private fun handleDeleteForEveryone(context: Context, messageRecords: Set<MessageRecord>, emitter: SingleEmitter<Pair<Boolean, Boolean>>) {
|
||||
if (SignalStore.uiHints().hasConfirmedDeleteForEveryoneOnce()) {
|
||||
if (SignalStore.uiHints.hasConfirmedDeleteForEveryoneOnce()) {
|
||||
deleteForEveryone(messageRecords, emitter)
|
||||
} else {
|
||||
MaterialAlertDialogBuilder(context)
|
||||
.setMessage(R.string.ConversationFragment_this_message_will_be_deleted_for_everyone_in_the_conversation)
|
||||
.setPositiveButton(R.string.ConversationFragment_delete_for_everyone) { _, _ ->
|
||||
SignalStore.uiHints().markHasConfirmedDeleteForEveryoneOnce()
|
||||
SignalStore.uiHints.markHasConfirmedDeleteForEveryoneOnce()
|
||||
deleteForEveryone(messageRecords, emitter)
|
||||
}
|
||||
.setNegativeButton(android.R.string.cancel) { _, _ -> emitter.onSuccess(Pair(false, false)) }
|
||||
|
||||
@@ -17,7 +17,7 @@ object LocaleUtil {
|
||||
*/
|
||||
fun getLocaleDefaults(): List<Locale> {
|
||||
val locales: MutableList<Locale> = mutableListOf()
|
||||
val signalLocale: Locale? = LanguageString.parseLocale(SignalStore.settings().language)
|
||||
val signalLocale: Locale? = LanguageString.parseLocale(SignalStore.settings.language)
|
||||
val localeList: LocaleListCompat = LocaleListCompat.getDefault()
|
||||
|
||||
if (signalLocale != null) {
|
||||
|
||||
@@ -43,8 +43,8 @@ public final class NetworkUtil {
|
||||
}
|
||||
|
||||
public static @NonNull CallManager.DataMode getCallingDataMode(@NonNull Context context, @NonNull PeerConnection.AdapterType networkAdapter) {
|
||||
if (SignalStore.internalValues().callingDataMode() != CallManager.DataMode.NORMAL) {
|
||||
return SignalStore.internalValues().callingDataMode();
|
||||
if (SignalStore.internal().callingDataMode() != CallManager.DataMode.NORMAL) {
|
||||
return SignalStore.internal().callingDataMode();
|
||||
}
|
||||
|
||||
return useLowDataCalling(context, networkAdapter) ? CallManager.DataMode.LOW : CallManager.DataMode.NORMAL;
|
||||
|
||||
@@ -377,7 +377,7 @@ public final class ProfileUtil {
|
||||
avatar,
|
||||
badgeIds,
|
||||
SignalStore.phoneNumberPrivacy().isPhoneNumberSharingEnabled()).orElse(null);
|
||||
SignalStore.registrationValues().markHasUploadedProfile();
|
||||
SignalStore.registration().markHasUploadedProfile();
|
||||
if (!avatar.keepTheSame) {
|
||||
SignalDatabase.recipients().setProfileAvatar(Recipient.self().getId(), avatarPath);
|
||||
}
|
||||
@@ -385,7 +385,7 @@ public final class ProfileUtil {
|
||||
}
|
||||
|
||||
private static @Nullable PaymentAddress getSelfPaymentsAddressProtobuf() {
|
||||
if (!SignalStore.paymentsValues().mobileCoinPaymentsEnabled()) {
|
||||
if (!SignalStore.payments().mobileCoinPaymentsEnabled()) {
|
||||
return null;
|
||||
} else {
|
||||
IdentityKeyPair identityKeyPair = SignalStore.account().getAciIdentityKey();
|
||||
|
||||
@@ -50,11 +50,11 @@ object RemoteConfig {
|
||||
@JvmStatic
|
||||
@Synchronized
|
||||
fun init() {
|
||||
val current = parseStoredConfig(SignalStore.remoteConfigValues().currentConfig)
|
||||
val pending = parseStoredConfig(SignalStore.remoteConfigValues().pendingConfig)
|
||||
val current = parseStoredConfig(SignalStore.remoteConfig.currentConfig)
|
||||
val pending = parseStoredConfig(SignalStore.remoteConfig.pendingConfig)
|
||||
val changes = computeChanges(current, pending)
|
||||
|
||||
SignalStore.remoteConfigValues().currentConfig = mapToJson(pending)
|
||||
SignalStore.remoteConfig.currentConfig = mapToJson(pending)
|
||||
REMOTE_VALUES.putAll(pending)
|
||||
triggerFlagChangeListeners(changes)
|
||||
|
||||
@@ -63,7 +63,7 @@ object RemoteConfig {
|
||||
|
||||
@JvmStatic
|
||||
fun refreshIfNecessary() {
|
||||
val timeSinceLastFetch = System.currentTimeMillis() - SignalStore.remoteConfigValues().lastFetchTime
|
||||
val timeSinceLastFetch = System.currentTimeMillis() - SignalStore.remoteConfig.lastFetchTime
|
||||
|
||||
if (timeSinceLastFetch < 0 || timeSinceLastFetch > FETCH_INTERVAL.inWholeMilliseconds) {
|
||||
Log.i(TAG, "Scheduling remote config refresh.")
|
||||
@@ -85,7 +85,7 @@ object RemoteConfig {
|
||||
@Synchronized
|
||||
fun update(config: Map<String, Any?>) {
|
||||
val memory: Map<String, Any> = REMOTE_VALUES
|
||||
val disk = parseStoredConfig(SignalStore.remoteConfigValues().pendingConfig)
|
||||
val disk = parseStoredConfig(SignalStore.remoteConfig.pendingConfig)
|
||||
|
||||
val remoteCapable: Set<String> = configsByKey.filterValues { it.active }.keys
|
||||
val hotSwap: Set<String> = configsByKey.filterValues { it.hotSwappable }.keys
|
||||
@@ -93,12 +93,12 @@ object RemoteConfig {
|
||||
|
||||
val result = updateInternal(config, memory, disk, remoteCapable, hotSwap, sticky)
|
||||
|
||||
SignalStore.remoteConfigValues().pendingConfig = mapToJson(result.disk)
|
||||
SignalStore.remoteConfig.pendingConfig = mapToJson(result.disk)
|
||||
REMOTE_VALUES.clear()
|
||||
REMOTE_VALUES.putAll(result.memory)
|
||||
triggerFlagChangeListeners(result.memoryChanges)
|
||||
|
||||
SignalStore.remoteConfigValues().lastFetchTime = System.currentTimeMillis()
|
||||
SignalStore.remoteConfig.lastFetchTime = System.currentTimeMillis()
|
||||
|
||||
Log.i(TAG, "[Memory] Before: $memory")
|
||||
Log.i(TAG, "[Memory] After : ${result.memory}")
|
||||
@@ -116,13 +116,13 @@ object RemoteConfig {
|
||||
@JvmStatic
|
||||
@get:Synchronized
|
||||
val debugDiskValues: Map<String, Any>
|
||||
get() = TreeMap(parseStoredConfig(SignalStore.remoteConfigValues().currentConfig))
|
||||
get() = TreeMap(parseStoredConfig(SignalStore.remoteConfig.currentConfig))
|
||||
|
||||
/** Only for rendering debug info. */
|
||||
@JvmStatic
|
||||
@get:Synchronized
|
||||
val debugPendingDiskValues: Map<String, Any>
|
||||
get() = TreeMap(parseStoredConfig(SignalStore.remoteConfigValues().pendingConfig))
|
||||
get() = TreeMap(parseStoredConfig(SignalStore.remoteConfig.pendingConfig))
|
||||
|
||||
@JvmStatic
|
||||
@VisibleForTesting
|
||||
|
||||
@@ -25,7 +25,7 @@ object VersionTracker {
|
||||
|
||||
if (currentVersionCode != lastVersionCode) {
|
||||
Log.i(TAG, "Upgraded from $lastVersionCode to $currentVersionCode. Clearing client deprecation.", true)
|
||||
SignalStore.misc().isClientDeprecated = false
|
||||
SignalStore.misc.isClientDeprecated = false
|
||||
val jobChain = listOf(RemoteConfigRefreshJob(), RefreshAttributesJob())
|
||||
AppDependencies.jobManager.startChain(jobChain).enqueue()
|
||||
RetrieveRemoteAnnouncementsJob.enqueue(true)
|
||||
|
||||
Reference in New Issue
Block a user