Remove unused context arguments in RecipientUtil.

This commit is contained in:
Cody Henthorne
2022-10-06 08:57:30 -04:00
committed by Greyson Parrelli
parent db0bca00ec
commit bef83e4c0c
14 changed files with 50 additions and 50 deletions

View File

@@ -172,7 +172,7 @@ public class RecipientUtil {
SignalDatabase.recipients().setBlocked(recipient.getId(), true);
if (recipient.isSystemContact() || recipient.isProfileSharing() || isProfileSharedViaGroup(context, recipient)) {
if (recipient.isSystemContact() || recipient.isProfileSharing() || isProfileSharedViaGroup(recipient)) {
SignalDatabase.recipients().setProfileSharing(recipient.getId(), false);
ApplicationDependencies.getJobManager().startChain(new RefreshOwnProfileJob())
@@ -185,7 +185,7 @@ public class RecipientUtil {
}
@WorkerThread
public static void unblock(@NonNull Context context, @NonNull Recipient recipient) {
public static void unblock(@NonNull Recipient recipient) {
if (!isBlockable(recipient)) {
throw new AssertionError("Recipient is not blockable!");
}
@@ -221,7 +221,7 @@ public class RecipientUtil {
return true;
}
return isMessageRequestAccepted(context, threadId, threadRecipient);
return isMessageRequestAccepted(threadId, threadRecipient);
}
/**
@@ -234,7 +234,7 @@ public class RecipientUtil {
}
Long threadId = SignalDatabase.threads().getThreadIdFor(threadRecipient.getId());
return isMessageRequestAccepted(context, threadId, threadRecipient);
return isMessageRequestAccepted(threadId, threadRecipient);
}
/**
@@ -242,33 +242,33 @@ public class RecipientUtil {
* is more likely to return false.
*/
@WorkerThread
public static boolean isCallRequestAccepted(@NonNull Context context, @Nullable Recipient threadRecipient) {
public static boolean isCallRequestAccepted(@Nullable Recipient threadRecipient) {
if (threadRecipient == null) {
return true;
}
Long threadId = SignalDatabase.threads().getThreadIdFor(threadRecipient.getId());
return isCallRequestAccepted(context, threadId, threadRecipient);
return isCallRequestAccepted(threadId, threadRecipient);
}
/**
* @return True if a conversation existed before we enabled message requests, otherwise false.
*/
@WorkerThread
public static boolean isPreMessageRequestThread(@NonNull Context context, @Nullable Long threadId) {
public static boolean isPreMessageRequestThread(@Nullable Long threadId) {
long beforeTime = SignalStore.misc().getMessageRequestEnableTime();
return threadId != null && SignalDatabase.mmsSms().getConversationCount(threadId, beforeTime) > 0;
}
@WorkerThread
public static void shareProfileIfFirstSecureMessage(@NonNull Context context, @NonNull Recipient recipient) {
public static void shareProfileIfFirstSecureMessage(@NonNull Recipient recipient) {
if (recipient.isProfileSharing()) {
return;
}
long threadId = SignalDatabase.threads().getThreadIdIfExistsFor(recipient.getId());
if (isPreMessageRequestThread(context, threadId)) {
if (isPreMessageRequestThread(threadId)) {
return;
}
@@ -290,7 +290,7 @@ public class RecipientUtil {
/**
* @return True if this recipient should already have your profile key, otherwise false.
*/
public static boolean shouldHaveProfileKey(@NonNull Context context, @NonNull Recipient recipient) {
public static boolean shouldHaveProfileKey(@NonNull Recipient recipient) {
if (recipient.isBlocked()) {
return false;
}
@@ -327,33 +327,33 @@ public class RecipientUtil {
}
@WorkerThread
public static boolean isMessageRequestAccepted(@NonNull Context context, @Nullable Long threadId, @Nullable Recipient threadRecipient) {
return threadRecipient == null ||
threadRecipient.isSelf() ||
threadRecipient.isProfileSharing() ||
threadRecipient.isSystemContact() ||
threadRecipient.isForceSmsSelection() ||
!threadRecipient.isRegistered() ||
hasSentMessageInThread(context, threadId) ||
noSecureMessagesAndNoCallsInThread(context, threadId) ||
isPreMessageRequestThread(context, threadId);
public static boolean isMessageRequestAccepted(@Nullable Long threadId, @Nullable Recipient threadRecipient) {
return threadRecipient == null ||
threadRecipient.isSelf() ||
threadRecipient.isProfileSharing() ||
threadRecipient.isSystemContact() ||
threadRecipient.isForceSmsSelection() ||
!threadRecipient.isRegistered() ||
hasSentMessageInThread(threadId) ||
noSecureMessagesAndNoCallsInThread(threadId) ||
isPreMessageRequestThread(threadId);
}
@WorkerThread
private static boolean isCallRequestAccepted(@NonNull Context context, @Nullable Long threadId, @NonNull Recipient threadRecipient) {
return threadRecipient.isProfileSharing() ||
threadRecipient.isSystemContact() ||
hasSentMessageInThread(context, threadId) ||
isPreMessageRequestThread(context, threadId);
private static boolean isCallRequestAccepted(@Nullable Long threadId, @NonNull Recipient threadRecipient) {
return threadRecipient.isProfileSharing() ||
threadRecipient.isSystemContact() ||
hasSentMessageInThread(threadId) ||
isPreMessageRequestThread(threadId);
}
@WorkerThread
public static boolean hasSentMessageInThread(@NonNull Context context, @Nullable Long threadId) {
public static boolean hasSentMessageInThread(@Nullable Long threadId) {
return threadId != null && SignalDatabase.mmsSms().getOutgoingSecureConversationCount(threadId) != 0;
}
@WorkerThread
private static boolean noSecureMessagesAndNoCallsInThread(@NonNull Context context, @Nullable Long threadId) {
private static boolean noSecureMessagesAndNoCallsInThread(@Nullable Long threadId) {
if (threadId == null) {
return true;
}
@@ -363,7 +363,7 @@ public class RecipientUtil {
}
@WorkerThread
private static boolean isProfileSharedViaGroup(@NonNull Context context, @NonNull Recipient recipient) {
private static boolean isProfileSharedViaGroup(@NonNull Recipient recipient) {
return Stream.of(SignalDatabase.groups().getPushGroupsContainingMember(recipient.getId()))
.anyMatch(group -> Recipient.resolved(group.getRecipientId()).isProfileSharing());
}

View File

@@ -170,7 +170,7 @@ final class RecipientDialogViewModel extends ViewModel {
}
void onUnblockClicked(@NonNull FragmentActivity activity) {
recipientDialogRepository.getRecipient(recipient -> BlockUnblockDialog.showUnblockFor(activity, activity.getLifecycle(), recipient, () -> RecipientUtil.unblock(context, recipient)));
recipientDialogRepository.getRecipient(recipient -> BlockUnblockDialog.showUnblockFor(activity, activity.getLifecycle(), recipient, () -> RecipientUtil.unblock(recipient)));
}
void onViewSafetyNumberClicked(@NonNull Activity activity, @NonNull IdentityRecord identityRecord) {