Allow block of any recipient except MMS groups still.

fork-5.53.8
Alan Evans 2021-01-28 11:45:11 -04:00 zatwierdzone przez Greyson Parrelli
rodzic f312757daf
commit d1f6a924fb
6 zmienionych plików z 30 dodań i 13 usunięć

Wyświetl plik

@ -352,10 +352,8 @@ public class ManageGroupFragment extends LoggingFragment {
viewModel.getMentionSetting().observe(getViewLifecycleOwner(), value -> mentionsValue.setText(value));
viewModel.getCanLeaveGroup().observe(getViewLifecycleOwner(), canLeave -> leaveGroup.setVisibility(canLeave ? View.VISIBLE : View.GONE));
viewModel.getCanBlockGroup().observe(getViewLifecycleOwner(), canBlock -> {
blockGroup.setVisibility(canBlock ? View.VISIBLE : View.GONE);
unblockGroup.setVisibility(canBlock ? View.GONE : View.VISIBLE);
});
viewModel.getCanBlockGroup().observe(getViewLifecycleOwner(), canBlock -> blockGroup.setVisibility(canBlock ? View.VISIBLE : View.GONE));
viewModel.getCanUnblockGroup().observe(getViewLifecycleOwner(), canUnblock -> unblockGroup.setVisibility(canUnblock ? View.VISIBLE : View.GONE));
viewModel.getGroupInfoMessage().observe(getViewLifecycleOwner(), message -> {
switch (message) {

Wyświetl plik

@ -77,6 +77,7 @@ public class ManageGroupViewModel extends ViewModel {
private final DefaultValueLiveData<CollapseState> memberListCollapseState = new DefaultValueLiveData<>(CollapseState.COLLAPSED);
private final LiveData<Boolean> canLeaveGroup;
private final LiveData<Boolean> canBlockGroup;
private final LiveData<Boolean> canUnblockGroup;
private final LiveData<Boolean> showLegacyIndicator;
private final LiveData<String> mentionSetting;
private final LiveData<Boolean> groupLinkOn;
@ -119,7 +120,8 @@ public class ManageGroupViewModel extends ViewModel {
this.hasCustomNotifications = Transformations.map(this.groupRecipient,
recipient -> recipient.getNotificationChannel() != null || !NotificationChannels.supported());
this.canLeaveGroup = liveGroup.isActive();
this.canBlockGroup = Transformations.map(this.groupRecipient, recipient -> !recipient.isBlocked());
this.canBlockGroup = Transformations.map(this.groupRecipient, recipient -> RecipientUtil.isBlockable(recipient) && !recipient.isBlocked());
this.canUnblockGroup = Transformations.map(this.groupRecipient, Recipient::isBlocked);
this.mentionSetting = Transformations.distinctUntilChanged(Transformations.map(this.groupRecipient,
recipient -> MentionUtil.getMentionSettingDisplayValue(context, recipient.getMentionSetting())));
this.groupLinkOn = Transformations.map(liveGroup.getGroupLink(), GroupLinkUrlAndStatus::isEnabled);
@ -220,6 +222,10 @@ public class ManageGroupViewModel extends ViewModel {
return canBlockGroup;
}
LiveData<Boolean> getCanUnblockGroup() {
return canUnblockGroup;
}
LiveData<Boolean> getCanLeaveGroup() {
return canLeaveGroup;
}

Wyświetl plik

@ -91,6 +91,10 @@ public class MultiDeviceMessageRequestResponseJob extends BaseJob {
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
Recipient recipient = Recipient.resolved(threadRecipient);
if (!recipient.hasServiceIdentifier()) {
Log.i(TAG, "Queued for recipient without service identifier");
return;
}
MessageRequestResponseMessage response;

Wyświetl plik

@ -111,7 +111,7 @@ public class RecipientUtil {
public static boolean isBlockable(@NonNull Recipient recipient) {
Recipient resolved = recipient.resolve();
return resolved.isPushGroup() || resolved.hasServiceIdentifier();
return !resolved.isMmsGroup();
}
public static List<Recipient> getEligibleForSending(@NonNull List<Recipient> recipients) {
@ -177,7 +177,10 @@ public class RecipientUtil {
DatabaseFactory.getRecipientDatabase(context).setProfileSharing(recipient.getId(), true);
ApplicationDependencies.getJobManager().add(new MultiDeviceBlockedUpdateJob());
StorageSyncHelper.scheduleSyncForDataChange();
ApplicationDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forAccept(recipient.getId()));
if (recipient.hasServiceIdentifier()) {
ApplicationDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forAccept(recipient.getId()));
}
}
/**

Wyświetl plik

@ -51,7 +51,6 @@ import org.thoughtcrime.securesms.recipients.RecipientExporter;
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.thoughtcrime.securesms.recipients.ui.notifications.CustomNotificationsDialogFragment;
import org.thoughtcrime.securesms.util.DateUtils;
import org.thoughtcrime.securesms.util.FeatureFlags;
import org.thoughtcrime.securesms.util.LifecycleCursorWrapper;
import org.thoughtcrime.securesms.util.ServiceUtil;
import org.thoughtcrime.securesms.util.Util;
@ -261,10 +260,11 @@ public class ManageRecipientFragment extends LoggingFragment {
});
}
viewModel.getCanBlock().observe(getViewLifecycleOwner(), canBlock -> {
block.setVisibility(canBlock ? View.VISIBLE : View.GONE);
unblock.setVisibility(canBlock ? View.GONE : View.VISIBLE);
});
viewModel.getCanBlock().observe(getViewLifecycleOwner(),
canBlock -> block.setVisibility(canBlock ? View.VISIBLE : View.GONE));
viewModel.getCanUnblock().observe(getViewLifecycleOwner(),
canUnblock -> unblock.setVisibility(canUnblock ? View.VISIBLE : View.GONE));
messageButton.setOnClickListener(v -> {
if (fromConversation) {

Wyświetl plik

@ -63,6 +63,7 @@ public final class ManageRecipientViewModel extends ViewModel {
private final LiveData<Boolean> canCollapseMemberList;
private final DefaultValueLiveData<CollapseState> groupListCollapseState;
private final LiveData<Boolean> canBlock;
private final LiveData<Boolean> canUnblock;
private final LiveData<List<GroupMemberEntry.FullMember>> visibleSharedGroups;
private final LiveData<String> sharedGroupsCountSummary;
private final LiveData<Boolean> canAddToAGroup;
@ -79,7 +80,8 @@ public final class ManageRecipientViewModel extends ViewModel {
this.disappearingMessageTimer = Transformations.map(this.recipient, r -> ExpirationUtil.getExpirationDisplayValue(context, r.getExpireMessages()));
this.muteState = Transformations.map(this.recipient, r -> new MuteState(r.getMuteUntil(), r.isMuted()));
this.hasCustomNotifications = Transformations.map(this.recipient, r -> r.getNotificationChannel() != null || !NotificationChannels.supported());
this.canBlock = Transformations.map(this.recipient, r -> !r.isBlocked());
this.canBlock = Transformations.map(this.recipient, r -> RecipientUtil.isBlockable(r) && !r.isBlocked());
this.canUnblock = Transformations.map(this.recipient, Recipient::isBlocked);
this.internalDetails = Transformations.map(this.recipient, this::populateInternalDetails);
manageRecipientRepository.getThreadId(this::onThreadIdLoaded);
@ -181,6 +183,10 @@ public final class ManageRecipientViewModel extends ViewModel {
return canBlock;
}
LiveData<Boolean> getCanUnblock() {
return canUnblock;
}
void handleExpirationSelection(@NonNull Context context) {
withRecipient(recipient ->
ExpirationDialog.show(context,