Rewrite the AppDependencies system.

This commit is contained in:
Greyson Parrelli
2024-05-22 15:44:24 -04:00
committed by Cody Henthorne
parent a0131bf39b
commit b6a4e1f145
560 changed files with 2909 additions and 3036 deletions

View File

@@ -16,7 +16,7 @@ import org.thoughtcrime.securesms.crypto.MasterCipher
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil
import org.thoughtcrime.securesms.crypto.storage.PreKeyMetadataStore
import org.thoughtcrime.securesms.database.SignalDatabase
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.jobs.PreKeysSyncJob
import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.service.KeyCachingService
@@ -88,11 +88,11 @@ internal class AccountValues internal constructor(store: KeyValueStore) : Signal
init {
if (!store.containsKey(KEY_ACI)) {
migrateFromSharedPrefsV1(ApplicationDependencies.getApplication())
migrateFromSharedPrefsV1(AppDependencies.application)
}
if (!store.containsKey(KEY_ACI_IDENTITY_PUBLIC_KEY)) {
migrateFromSharedPrefsV2(ApplicationDependencies.getApplication())
migrateFromSharedPrefsV2(AppDependencies.application)
}
store.getString(KEY_PNI, null)?.let { pni ->
@@ -360,7 +360,7 @@ internal class AccountValues internal constructor(store: KeyValueStore) : Signal
putBoolean(KEY_IS_REGISTERED, registered)
ApplicationDependencies.getIncomingMessageObserver().notifyRegistrationChanged()
AppDependencies.incomingMessageObserver.notifyRegistrationChanged()
if (previous != registered) {
Recipient.self().live().refresh()
@@ -378,7 +378,7 @@ internal class AccountValues internal constructor(store: KeyValueStore) : Signal
fun clearRegistrationButKeepCredentials() {
putBoolean(KEY_IS_REGISTERED, false)
ApplicationDependencies.getIncomingMessageObserver().notifyRegistrationChanged()
AppDependencies.incomingMessageObserver.notifyRegistrationChanged()
Recipient.self().live().refresh()
}
@@ -449,7 +449,7 @@ internal class AccountValues internal constructor(store: KeyValueStore) : Signal
val self = Recipient.self()
SignalDatabase.recipients.setProfileKey(self.id, newProfileKey)
ApplicationDependencies.getGroupsV2Authorization().clear()
AppDependencies.groupsV2Authorization.clear()
}
/** Do not alter. If you need to migrate more stuff, create a new method. */

View File

@@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.keyvalue;
import androidx.annotation.NonNull;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.lock.SignalPinReminders;
import org.thoughtcrime.securesms.lock.v2.PinKeyboardType;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
@@ -78,11 +78,11 @@ public final class PinValues extends SignalStoreValues {
}
public long getCurrentInterval() {
return getLong(NEXT_INTERVAL, TextSecurePreferences.getRegistrationLockNextReminderInterval(ApplicationDependencies.getApplication()));
return getLong(NEXT_INTERVAL, TextSecurePreferences.getRegistrationLockNextReminderInterval(AppDependencies.getApplication()));
}
public long getLastSuccessfulEntryTime() {
return getLong(LAST_SUCCESSFUL_ENTRY, TextSecurePreferences.getRegistrationLockLastReminderTime(ApplicationDependencies.getApplication()));
return getLong(LAST_SUCCESSFUL_ENTRY, TextSecurePreferences.getRegistrationLockLastReminderTime(AppDependencies.getApplication()));
}
public void setKeyboardType(@NonNull PinKeyboardType keyboardType) {

View File

@@ -9,15 +9,11 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.LiveData;
import org.signal.core.util.concurrent.SignalExecutors;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.database.SignalDatabase;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.mms.SentMediaQuality;
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.storage.StorageSyncHelper;
import org.thoughtcrime.securesms.util.SingleLiveEvent;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.webrtc.CallDataMode;
@@ -210,7 +206,7 @@ public final class SettingsValues extends SignalStoreValues {
}
public @NonNull Theme getTheme() {
return Theme.deserialize(getString(THEME, TextSecurePreferences.getTheme(ApplicationDependencies.getApplication())));
return Theme.deserialize(getString(THEME, TextSecurePreferences.getTheme(AppDependencies.getApplication())));
}
public void setTheme(@NonNull Theme theme) {
@@ -219,7 +215,7 @@ public final class SettingsValues extends SignalStoreValues {
}
public int getMessageFontSize() {
return getInteger(MESSAGE_FONT_SIZE, TextSecurePreferences.getMessageBodyTextSize(ApplicationDependencies.getApplication()));
return getInteger(MESSAGE_FONT_SIZE, TextSecurePreferences.getMessageBodyTextSize(AppDependencies.getApplication()));
}
public int getMessageQuoteFontSize(@NonNull Context context) {
@@ -255,16 +251,16 @@ public final class SettingsValues extends SignalStoreValues {
}
public @NonNull String getLanguage() {
return TextSecurePreferences.getLanguage(ApplicationDependencies.getApplication());
return TextSecurePreferences.getLanguage(AppDependencies.getApplication());
}
public void setLanguage(@NonNull String language) {
TextSecurePreferences.setLanguage(ApplicationDependencies.getApplication(), language);
TextSecurePreferences.setLanguage(AppDependencies.getApplication(), language);
onConfigurationSettingChanged.postValue(LANGUAGE);
}
public boolean isPreferSystemEmoji() {
return getBoolean(PREFER_SYSTEM_EMOJI, TextSecurePreferences.isSystemEmojiPreferred(ApplicationDependencies.getApplication()));
return getBoolean(PREFER_SYSTEM_EMOJI, TextSecurePreferences.isSystemEmojiPreferred(AppDependencies.getApplication()));
}
public void setPreferSystemEmoji(boolean useSystemEmoji) {
@@ -272,7 +268,7 @@ public final class SettingsValues extends SignalStoreValues {
}
public boolean isEnterKeySends() {
return getBoolean(ENTER_KEY_SENDS, TextSecurePreferences.isEnterSendsEnabled(ApplicationDependencies.getApplication()));
return getBoolean(ENTER_KEY_SENDS, TextSecurePreferences.isEnterSendsEnabled(AppDependencies.getApplication()));
}
public void setEnterKeySends(boolean enterKeySends) {
@@ -280,7 +276,7 @@ public final class SettingsValues extends SignalStoreValues {
}
public boolean isBackupEnabled() {
return getBoolean(BACKUPS_ENABLED, TextSecurePreferences.isBackupEnabled(ApplicationDependencies.getApplication()));
return getBoolean(BACKUPS_ENABLED, TextSecurePreferences.isBackupEnabled(AppDependencies.getApplication()));
}
public void setBackupEnabled(boolean backupEnabled) {
@@ -301,7 +297,7 @@ public final class SettingsValues extends SignalStoreValues {
}
public boolean isSmsDeliveryReportsEnabled() {
return getBoolean(SMS_DELIVERY_REPORTS_ENABLED, TextSecurePreferences.isSmsDeliveryReportsEnabled(ApplicationDependencies.getApplication()));
return getBoolean(SMS_DELIVERY_REPORTS_ENABLED, TextSecurePreferences.isSmsDeliveryReportsEnabled(AppDependencies.getApplication()));
}
public void setSmsDeliveryReportsEnabled(boolean smsDeliveryReportsEnabled) {
@@ -309,7 +305,7 @@ public final class SettingsValues extends SignalStoreValues {
}
public boolean isWifiCallingCompatibilityModeEnabled() {
return getBoolean(WIFI_CALLING_COMPATIBILITY_MODE_ENABLED, TextSecurePreferences.isWifiSmsEnabled(ApplicationDependencies.getApplication()));
return getBoolean(WIFI_CALLING_COMPATIBILITY_MODE_ENABLED, TextSecurePreferences.isWifiSmsEnabled(AppDependencies.getApplication()));
}
public void setWifiCallingCompatibilityModeEnabled(boolean wifiCallingCompatibilityModeEnabled) {
@@ -321,7 +317,7 @@ public final class SettingsValues extends SignalStoreValues {
}
public boolean isMessageNotificationsEnabled() {
return getBoolean(MESSAGE_NOTIFICATIONS_ENABLED, TextSecurePreferences.isNotificationsEnabled(ApplicationDependencies.getApplication()));
return getBoolean(MESSAGE_NOTIFICATIONS_ENABLED, TextSecurePreferences.isNotificationsEnabled(AppDependencies.getApplication()));
}
public void setMessageNotificationSound(@NonNull Uri sound) {
@@ -329,7 +325,7 @@ public final class SettingsValues extends SignalStoreValues {
}
public @NonNull Uri getMessageNotificationSound() {
String result = getString(MESSAGE_NOTIFICATION_SOUND, TextSecurePreferences.getNotificationRingtone(ApplicationDependencies.getApplication()).toString());
String result = getString(MESSAGE_NOTIFICATION_SOUND, TextSecurePreferences.getNotificationRingtone(AppDependencies.getApplication()).toString());
if (result.startsWith("file:")) {
result = Settings.System.DEFAULT_NOTIFICATION_URI.toString();
@@ -339,7 +335,7 @@ public final class SettingsValues extends SignalStoreValues {
}
public boolean isMessageVibrateEnabled() {
return getBoolean(MESSAGE_VIBRATE_ENABLED, TextSecurePreferences.isNotificationVibrateEnabled(ApplicationDependencies.getApplication()));
return getBoolean(MESSAGE_VIBRATE_ENABLED, TextSecurePreferences.isNotificationVibrateEnabled(AppDependencies.getApplication()));
}
public void setMessageVibrateEnabled(boolean messageVibrateEnabled) {
@@ -347,7 +343,7 @@ public final class SettingsValues extends SignalStoreValues {
}
public @NonNull String getMessageLedColor() {
return getString(MESSAGE_LED_COLOR, TextSecurePreferences.getNotificationLedColor(ApplicationDependencies.getApplication()));
return getString(MESSAGE_LED_COLOR, TextSecurePreferences.getNotificationLedColor(AppDependencies.getApplication()));
}
public void setMessageLedColor(@NonNull String ledColor) {
@@ -355,7 +351,7 @@ public final class SettingsValues extends SignalStoreValues {
}
public @NonNull String getMessageLedBlinkPattern() {
return getString(MESSAGE_LED_BLINK_PATTERN, TextSecurePreferences.getNotificationLedPattern(ApplicationDependencies.getApplication()));
return getString(MESSAGE_LED_BLINK_PATTERN, TextSecurePreferences.getNotificationLedPattern(AppDependencies.getApplication()));
}
public void setMessageLedBlinkPattern(@NonNull String blinkPattern) {
@@ -363,7 +359,7 @@ public final class SettingsValues extends SignalStoreValues {
}
public boolean isMessageNotificationsInChatSoundsEnabled() {
return getBoolean(MESSAGE_IN_CHAT_SOUNDS_ENABLED, TextSecurePreferences.isInThreadNotifications(ApplicationDependencies.getApplication()));
return getBoolean(MESSAGE_IN_CHAT_SOUNDS_ENABLED, TextSecurePreferences.isInThreadNotifications(AppDependencies.getApplication()));
}
public void setMessageNotificationsInChatSoundsEnabled(boolean inChatSoundsEnabled) {
@@ -371,7 +367,7 @@ public final class SettingsValues extends SignalStoreValues {
}
public int getMessageNotificationsRepeatAlerts() {
return getInteger(MESSAGE_REPEAT_ALERTS, TextSecurePreferences.getRepeatAlertsCount(ApplicationDependencies.getApplication()));
return getInteger(MESSAGE_REPEAT_ALERTS, TextSecurePreferences.getRepeatAlertsCount(AppDependencies.getApplication()));
}
public void setMessageNotificationsRepeatAlerts(int count) {
@@ -379,7 +375,7 @@ public final class SettingsValues extends SignalStoreValues {
}
public @NonNull NotificationPrivacyPreference getMessageNotificationsPrivacy() {
return new NotificationPrivacyPreference(getString(MESSAGE_NOTIFICATION_PRIVACY, TextSecurePreferences.getNotificationPrivacy(ApplicationDependencies.getApplication()).toString()));
return new NotificationPrivacyPreference(getString(MESSAGE_NOTIFICATION_PRIVACY, TextSecurePreferences.getNotificationPrivacy(AppDependencies.getApplication()).toString()));
}
public void setMessageNotificationsPrivacy(@NonNull NotificationPrivacyPreference messageNotificationsPrivacy) {
@@ -387,7 +383,7 @@ public final class SettingsValues extends SignalStoreValues {
}
public boolean isCallNotificationsEnabled() {
return getBoolean(CALL_NOTIFICATIONS_ENABLED, TextSecurePreferences.isCallNotificationsEnabled(ApplicationDependencies.getApplication()));
return getBoolean(CALL_NOTIFICATIONS_ENABLED, TextSecurePreferences.isCallNotificationsEnabled(AppDependencies.getApplication()));
}
public void setCallNotificationsEnabled(boolean callNotificationsEnabled) {
@@ -395,7 +391,7 @@ public final class SettingsValues extends SignalStoreValues {
}
public @NonNull Uri getCallRingtone() {
String result = getString(CALL_RINGTONE, TextSecurePreferences.getCallNotificationRingtone(ApplicationDependencies.getApplication()).toString());
String result = getString(CALL_RINGTONE, TextSecurePreferences.getCallNotificationRingtone(AppDependencies.getApplication()).toString());
if (result != null && result.startsWith("file:")) {
result = Settings.System.DEFAULT_RINGTONE_URI.toString();
@@ -409,7 +405,7 @@ public final class SettingsValues extends SignalStoreValues {
}
public boolean isCallVibrateEnabled() {
return getBoolean(CALL_VIBRATE_ENABLED, TextSecurePreferences.isCallNotificationVibrateEnabled(ApplicationDependencies.getApplication()));
return getBoolean(CALL_VIBRATE_ENABLED, TextSecurePreferences.isCallNotificationVibrateEnabled(AppDependencies.getApplication()));
}
public void setCallVibrateEnabled(boolean callVibrateEnabled) {
@@ -417,7 +413,7 @@ public final class SettingsValues extends SignalStoreValues {
}
public boolean isNotifyWhenContactJoinsSignal() {
return getBoolean(NOTIFY_WHEN_CONTACT_JOINS_SIGNAL, TextSecurePreferences.isNewContactsNotificationEnabled(ApplicationDependencies.getApplication()));
return getBoolean(NOTIFY_WHEN_CONTACT_JOINS_SIGNAL, TextSecurePreferences.isNewContactsNotificationEnabled(AppDependencies.getApplication()));
}
public void setNotifyWhenContactJoinsSignal(boolean notifyWhenContactJoinsSignal) {

View File

@@ -5,7 +5,7 @@ import androidx.annotation.VisibleForTesting;
import androidx.preference.PreferenceDataStore;
import org.thoughtcrime.securesms.database.KeyValueDatabase;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.util.SignalUncaughtExceptionHandler;
import java.util.ArrayList;
@@ -54,7 +54,7 @@ public final class SignalStore {
if (instance == null) {
synchronized (SignalStore.class) {
if (instance == null) {
instance = new SignalStore(new KeyValueStore(KeyValueDatabase.getInstance(ApplicationDependencies.getApplication())));
instance = new SignalStore(new KeyValueStore(KeyValueDatabase.getInstance(AppDependencies.getApplication())));
}
}
}
@@ -91,7 +91,7 @@ public final class SignalStore {
this.storyValues = new StoryValues(store);
this.apkUpdate = new ApkUpdateValues(store);
this.backupValues = new BackupValues(store);
this.plainTextValues = new PlainTextSharedPrefsDataStore(ApplicationDependencies.getApplication());
this.plainTextValues = new PlainTextSharedPrefsDataStore(AppDependencies.getApplication());
}
public static void onFirstEverAppLaunch() {