mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Rewrite the AppDependencies system.
This commit is contained in:
committed by
Cody Henthorne
parent
a0131bf39b
commit
b6a4e1f145
@@ -13,7 +13,7 @@ import org.signal.core.util.concurrent.SimpleTask;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.conversation.colors.AvatarColor;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceProfileContentUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceProfileKeyUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.ProfileUploadJob;
|
||||
@@ -140,10 +140,10 @@ public class EditSelfProfileRepository implements EditProfileRepository {
|
||||
}
|
||||
}
|
||||
|
||||
ApplicationDependencies.getJobManager()
|
||||
.startChain(new ProfileUploadJob())
|
||||
.then(Arrays.asList(new MultiDeviceProfileKeyUpdateJob(), new MultiDeviceProfileContentUpdateJob()))
|
||||
.enqueue();
|
||||
AppDependencies.getJobManager()
|
||||
.startChain(new ProfileUploadJob())
|
||||
.then(Arrays.asList(new MultiDeviceProfileKeyUpdateJob(), new MultiDeviceProfileContentUpdateJob()))
|
||||
.enqueue();
|
||||
|
||||
RegistrationUtil.maybeMarkRegistrationComplete();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.thoughtcrime.securesms.profiles.edit.pnp
|
||||
|
||||
import io.reactivex.rxjava3.core.Completable
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobs.ProfileUploadJob
|
||||
import org.thoughtcrime.securesms.jobs.RefreshAttributesJob
|
||||
import org.thoughtcrime.securesms.keyvalue.PhoneNumberPrivacyValues
|
||||
@@ -33,9 +33,9 @@ class WhoCanFindMeByPhoneNumberRepository {
|
||||
}
|
||||
}
|
||||
|
||||
ApplicationDependencies.getJobManager().add(RefreshAttributesJob())
|
||||
AppDependencies.jobManager.add(RefreshAttributesJob())
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
ApplicationDependencies.getJobManager().add(ProfileUploadJob())
|
||||
AppDependencies.jobManager.add(ProfileUploadJob())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import androidx.core.util.Consumer;
|
||||
import org.signal.core.util.concurrent.SignalExecutors;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceProfileContentUpdateJob;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||
@@ -29,7 +29,7 @@ final class EditProfileRepository {
|
||||
try {
|
||||
ProfileUtil.uploadProfileWithName(context, profileName);
|
||||
SignalDatabase.recipients().setProfileName(Recipient.self().getId(), profileName);
|
||||
ApplicationDependencies.getJobManager().add(new MultiDeviceProfileContentUpdateJob());
|
||||
AppDependencies.getJobManager().add(new MultiDeviceProfileContentUpdateJob());
|
||||
|
||||
callback.accept(Result.SUCCESS);
|
||||
} catch (IOException e) {
|
||||
@@ -44,7 +44,7 @@ final class EditProfileRepository {
|
||||
try {
|
||||
ProfileUtil.uploadProfileWithAbout(context, about, emoji);
|
||||
SignalDatabase.recipients().setAbout(Recipient.self().getId(), about, emoji);
|
||||
ApplicationDependencies.getJobManager().add(new MultiDeviceProfileContentUpdateJob());
|
||||
AppDependencies.getJobManager().add(new MultiDeviceProfileContentUpdateJob());
|
||||
|
||||
callback.accept(Result.SUCCESS);
|
||||
} catch (IOException e) {
|
||||
@@ -60,7 +60,7 @@ final class EditProfileRepository {
|
||||
ProfileUtil.uploadProfileWithAvatar(new StreamDetails(new ByteArrayInputStream(data), contentType, data.length));
|
||||
AvatarHelper.setAvatar(context, Recipient.self().getId(), new ByteArrayInputStream(data));
|
||||
SignalStore.misc().setHasEverHadAnAvatar(true);
|
||||
ApplicationDependencies.getJobManager().add(new MultiDeviceProfileContentUpdateJob());
|
||||
AppDependencies.getJobManager().add(new MultiDeviceProfileContentUpdateJob());
|
||||
|
||||
callback.accept(Result.SUCCESS);
|
||||
} catch (IOException e) {
|
||||
@@ -75,7 +75,7 @@ final class EditProfileRepository {
|
||||
try {
|
||||
ProfileUtil.uploadProfileWithAvatar(null);
|
||||
AvatarHelper.delete(context, Recipient.self().getId());
|
||||
ApplicationDependencies.getJobManager().add(new MultiDeviceProfileContentUpdateJob());
|
||||
AppDependencies.getJobManager().add(new MultiDeviceProfileContentUpdateJob());
|
||||
|
||||
callback.accept(Result.SUCCESS);
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.signal.core.util.StreamUtil;
|
||||
import org.signal.core.util.concurrent.SignalExecutors;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.badges.models.Badge;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies;
|
||||
import org.thoughtcrime.securesms.jobs.RetrieveProfileJob;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.mediasend.Media;
|
||||
@@ -108,7 +108,7 @@ class EditProfileViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
public boolean isRegisteredAndUpToDate() {
|
||||
return !TextSecurePreferences.isUnauthorizedReceived(ApplicationDependencies.getApplication()) && SignalStore.account().isRegistered() && !SignalStore.misc().isClientDeprecated();
|
||||
return !TextSecurePreferences.isUnauthorizedReceived(AppDependencies.getApplication()) && SignalStore.account().isRegistered() && !SignalStore.misc().isClientDeprecated();
|
||||
}
|
||||
|
||||
public boolean isDeprecated() {
|
||||
@@ -170,7 +170,7 @@ class EditProfileViewModel extends ViewModel {
|
||||
about.postValue(recipient.getAbout());
|
||||
aboutEmoji.postValue(recipient.getAboutEmoji());
|
||||
badge.postValue(Optional.ofNullable(recipient.getFeaturedBadge()));
|
||||
renderAvatar(AvatarHelper.getSelfProfileAvatarStream(ApplicationDependencies.getApplication()));
|
||||
renderAvatar(AvatarHelper.getSelfProfileAvatarStream(AppDependencies.getApplication()));
|
||||
}
|
||||
|
||||
private void renderAvatar(@Nullable StreamDetails details) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.signal.core.util.Result
|
||||
import org.signal.core.util.isNotNullOrBlank
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.libsignal.usernames.Username
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.profiles.manage.UsernameRepository.UsernameDeleteResult
|
||||
import org.thoughtcrime.securesms.profiles.manage.UsernameRepository.UsernameSetResult
|
||||
@@ -139,7 +139,7 @@ internal class UsernameEditViewModel private constructor(private val mode: Usern
|
||||
* @param userConfirmedResetOk True if the user is submitting this after confirming that they're ok with resetting their username via [Event.NEEDS_CONFIRM_RESET].
|
||||
*/
|
||||
fun onUsernameSubmitted(userConfirmedResetOk: Boolean) {
|
||||
if (!NetworkUtil.isConnected(ApplicationDependencies.getApplication())) {
|
||||
if (!NetworkUtil.isConnected(AppDependencies.application)) {
|
||||
events.onNext(Event.NETWORK_FAILURE)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.signal.libsignal.usernames.BaseUsernameException
|
||||
import org.signal.libsignal.usernames.Username
|
||||
import org.thoughtcrime.securesms.components.settings.app.usernamelinks.main.UsernameLinkResetResult
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.keyvalue.AccountValues
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
@@ -88,7 +88,7 @@ object UsernameRepository {
|
||||
private const val BASE_URL = "https://signal.me/#eu/"
|
||||
private const val USERNAME_SYNC_ERROR_THRESHOLD = 3
|
||||
|
||||
private val accountManager: SignalServiceAccountManager get() = ApplicationDependencies.getSignalServiceAccountManager()
|
||||
private val accountManager: SignalServiceAccountManager get() = AppDependencies.signalServiceAccountManager
|
||||
|
||||
/**
|
||||
* Given a nickname, this will temporarily reserve a matching discriminator that can later be confirmed via [confirmUsernameAndCreateNewLink].
|
||||
@@ -180,7 +180,7 @@ object UsernameRepository {
|
||||
* Creates or rotates the username link for the local user.
|
||||
*/
|
||||
fun createOrResetUsernameLink(): Single<UsernameLinkResetResult> {
|
||||
if (!NetworkUtil.isConnected(ApplicationDependencies.getApplication())) {
|
||||
if (!NetworkUtil.isConnected(AppDependencies.application)) {
|
||||
Log.w(TAG, "[createOrResetUsernameLink] No network! Not making any changes.")
|
||||
return Single.just(UsernameLinkResetResult.NetworkUnavailable)
|
||||
}
|
||||
@@ -269,7 +269,7 @@ object UsernameRepository {
|
||||
fun fetchAciForUsername(username: String): Single<UsernameAciFetchResult> {
|
||||
return Single.fromCallable {
|
||||
try {
|
||||
val aci: ACI = ApplicationDependencies.getSignalServiceAccountManager().getAciByUsername(Username(username))
|
||||
val aci: ACI = AppDependencies.signalServiceAccountManager.getAciByUsername(Username(username))
|
||||
UsernameAciFetchResult.Success(aci)
|
||||
} catch (e: UsernameIsNotAssociatedWithAnAccountException) {
|
||||
Log.w(TAG, "[fetchAciFromUsername] Failed to get ACI for username hash", e)
|
||||
@@ -397,7 +397,7 @@ object UsernameRepository {
|
||||
private fun updateUsernameDisplayForCurrentLinkInternal(updatedUsername: Username): UsernameSetResult {
|
||||
Log.i(TAG, "[updateUsernameDisplayForCurrentLink] Beginning username update...")
|
||||
|
||||
if (!NetworkUtil.isConnected(ApplicationDependencies.getApplication())) {
|
||||
if (!NetworkUtil.isConnected(AppDependencies.application)) {
|
||||
Log.w(TAG, "[deleteUsernameInternal] No network connection! Not attempting the request.")
|
||||
return UsernameSetResult.NETWORK_ERROR
|
||||
}
|
||||
@@ -428,7 +428,7 @@ object UsernameRepository {
|
||||
private fun confirmUsernameAndCreateNewLinkInternal(username: Username): UsernameSetResult {
|
||||
Log.i(TAG, "[confirmUsernameAndCreateNewLink] Beginning username confirmation...")
|
||||
|
||||
if (!NetworkUtil.isConnected(ApplicationDependencies.getApplication())) {
|
||||
if (!NetworkUtil.isConnected(AppDependencies.application)) {
|
||||
Log.w(TAG, "[confirmUsernameAndCreateNewLink] No network connection! Not attempting the request.")
|
||||
return UsernameSetResult.NETWORK_ERROR
|
||||
}
|
||||
@@ -464,7 +464,7 @@ object UsernameRepository {
|
||||
|
||||
@WorkerThread
|
||||
private fun deleteUsernameInternal(): UsernameDeleteResult {
|
||||
if (!NetworkUtil.isConnected(ApplicationDependencies.getApplication())) {
|
||||
if (!NetworkUtil.isConnected(AppDependencies.application)) {
|
||||
Log.w(TAG, "[deleteUsernameInternal] No network connection! Not attempting the request.")
|
||||
return UsernameDeleteResult.NETWORK_ERROR
|
||||
}
|
||||
|
||||
@@ -5,12 +5,10 @@ import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import org.signal.core.util.concurrent.SignalExecutors;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadTable;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies;
|
||||
import org.thoughtcrime.securesms.groups.GroupChangeException;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.groups.GroupManager;
|
||||
@@ -21,7 +19,6 @@ import org.thoughtcrime.securesms.recipients.RecipientUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -84,7 +81,7 @@ class ReviewCardRepository {
|
||||
if (resolved.isGroup()) throw new AssertionError();
|
||||
|
||||
if (TextSecurePreferences.isMultiDevice(context)) {
|
||||
ApplicationDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forDelete(recipientId));
|
||||
AppDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forDelete(recipientId));
|
||||
}
|
||||
|
||||
ThreadTable threadTable = SignalDatabase.threads();
|
||||
|
||||
Reference in New Issue
Block a user