Block GV1 creation if forced migrations are enabled.
This commit is contained in:
parent
28511de23c
commit
f7befd1593
5 changed files with 28 additions and 6 deletions
|
@ -40,6 +40,7 @@ import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
|||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.util.BitmapUtil;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
import org.thoughtcrime.securesms.util.text.AfterTextChanged;
|
||||
import org.thoughtcrime.securesms.util.views.LearnMoreTextView;
|
||||
|
@ -120,10 +121,15 @@ public class AddGroupDetailsFragment extends LoggingFragment {
|
|||
toolbar.setTitle(isMms ? R.string.AddGroupDetailsFragment__create_group : R.string.AddGroupDetailsFragment__name_this_group);
|
||||
});
|
||||
viewModel.getNonGv2CapableMembers().observe(getViewLifecycleOwner(), nonGv2CapableMembers -> {
|
||||
boolean forcedMigration = FeatureFlags.groupsV1ForcedMigration();
|
||||
|
||||
int stringRes = forcedMigration ? R.plurals.AddGroupDetailsFragment__d_members_do_not_support_new_groups_so_this_group_cannot_be_created
|
||||
: R.plurals.AddGroupDetailsFragment__d_members_do_not_support_new_groups;
|
||||
|
||||
gv2Warning.setVisibility(nonGv2CapableMembers.isEmpty() ? View.GONE : View.VISIBLE);
|
||||
gv2Warning.setText(requireContext().getResources().getQuantityString(R.plurals.AddGroupDetailsFragment__d_members_do_not_support_new_groups, nonGv2CapableMembers.size(), nonGv2CapableMembers.size()));
|
||||
gv2Warning.setText(requireContext().getResources().getQuantityString(stringRes, nonGv2CapableMembers.size(), nonGv2CapableMembers.size()));
|
||||
gv2Warning.setLearnMoreVisible(true);
|
||||
gv2Warning.setOnLinkClickListener(v -> NonGv2MemberDialog.showNonGv2Members(requireContext(), nonGv2CapableMembers));
|
||||
gv2Warning.setOnLinkClickListener(v -> NonGv2MemberDialog.showNonGv2Members(requireContext(), nonGv2CapableMembers, forcedMigration));
|
||||
});
|
||||
viewModel.getAvatar().observe(getViewLifecycleOwner(), avatarBytes -> {
|
||||
if (avatarBytes == null) {
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
|||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.util.DefaultValueLiveData;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.thoughtcrime.securesms.util.SingleLiveEvent;
|
||||
import org.thoughtcrime.securesms.util.livedata.LiveDataUtil;
|
||||
|
||||
|
@ -62,7 +63,8 @@ public final class AddGroupDetailsViewModel extends ViewModel {
|
|||
});
|
||||
|
||||
nonGv2CapableMembers = LiveDataUtil.mapAsync(membersToCheckGv2CapabilityOf, memberList -> repository.checkCapabilities(Stream.of(memberList).map(newGroupCandidate -> newGroupCandidate.getMember().getId()).toList()));
|
||||
canSubmitForm = LiveDataUtil.combineLatest(isMms, isValidName, (mms, validName) -> mms || validName);
|
||||
canSubmitForm = FeatureFlags.groupsV1ForcedMigration() ? LiveDataUtil.just(false)
|
||||
: LiveDataUtil.combineLatest(isMms, isValidName, (mms, validName) -> mms || validName);
|
||||
|
||||
repository.resolveMembers(recipientIds, initialMembers::postValue);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public final class NonGv2MemberDialog {
|
|||
private NonGv2MemberDialog() {
|
||||
}
|
||||
|
||||
public static @Nullable Dialog showNonGv2Members(@NonNull Context context, @NonNull List<Recipient> recipients) {
|
||||
public static @Nullable Dialog showNonGv2Members(@NonNull Context context, @NonNull List<Recipient> recipients, boolean forcedMigration) {
|
||||
int size = recipients.size();
|
||||
if (size == 0) {
|
||||
return null;
|
||||
|
@ -32,9 +32,13 @@ public final class NonGv2MemberDialog {
|
|||
// })
|
||||
.setPositiveButton(android.R.string.ok, null);
|
||||
if (size == 1) {
|
||||
builder.setMessage(context.getString(R.string.NonGv2MemberDialog_single_users_are_non_gv2_capable, recipients.get(0).getDisplayName(context)));
|
||||
int stringRes = forcedMigration ? R.string.NonGv2MemberDialog_single_users_are_non_gv2_capable_forced_migration
|
||||
: R.string.NonGv2MemberDialog_single_users_are_non_gv2_capable;
|
||||
builder.setMessage(context.getString(stringRes, recipients.get(0).getDisplayName(context)));
|
||||
} else {
|
||||
builder.setMessage(context.getResources().getQuantityString(R.plurals.NonGv2MemberDialog_d_users_are_non_gv2_capable, size, size))
|
||||
int pluralRes = forcedMigration ? R.plurals.NonGv2MemberDialog_d_users_are_non_gv2_capable_forced_migration
|
||||
: R.plurals.NonGv2MemberDialog_d_users_are_non_gv2_capable;
|
||||
builder.setMessage(context.getResources().getQuantityString(pluralRes, size, size))
|
||||
.setView(R.layout.dialog_multiple_members_non_gv2_capable);
|
||||
}
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ public final class FeatureFlags {
|
|||
MAX_ENVELOPE_SIZE,
|
||||
GV1_AUTO_MIGRATE_VERSION,
|
||||
GV1_MANUAL_MIGRATE_VERSION,
|
||||
GV1_FORCED_MIGRATE_VERSION,
|
||||
GROUP_CALLING_VERSION
|
||||
);
|
||||
|
||||
|
|
|
@ -702,6 +702,10 @@
|
|||
<item quantity="one">%d member does not support New Groups, so this will be a Legacy Group.</item>
|
||||
<item quantity="other">%d members do not support New Groups, so this group will be a Legacy Group.</item>
|
||||
</plurals>
|
||||
<plurals name="AddGroupDetailsFragment__d_members_do_not_support_new_groups_so_this_group_cannot_be_created">
|
||||
<item quantity="one">%d member does not support New Groups, so this group cannot be created.</item>
|
||||
<item quantity="other">%d members do not support New Groups, so this group cannot be created.</item>
|
||||
</plurals>
|
||||
|
||||
<!-- NonGv2MemberDialog -->
|
||||
<string name="NonGv2MemberDialog_single_users_are_non_gv2_capable">A Legacy Group will be created because “%1$s” is using an old version of Signal. You can create a New Style Group with them after they update Signal, or remove them before creating the group.</string>
|
||||
|
@ -709,6 +713,11 @@
|
|||
<item quantity="one">A Legacy Group will be created because %1$d member is using an old version of Signal. You can create a New Style Group with them after they update Signal, or remove them before creating the group.</item>
|
||||
<item quantity="other">A Legacy Group will be created because %1$d members are using an old version of Signal. You can create a New Style Group with them after they update Signal, or remove them before creating the group.</item>
|
||||
</plurals>
|
||||
<string name="NonGv2MemberDialog_single_users_are_non_gv2_capable_forced_migration">This group cannot be created because “%1$s” is using an old version of Signal. You must remove them before creating the group.</string>
|
||||
<plurals name="NonGv2MemberDialog_d_users_are_non_gv2_capable_forced_migration">
|
||||
<item quantity="one">This group cannot be created because %1$d member is using an old version of Signal. You must remove them before creating the group.</item>
|
||||
<item quantity="other">This group cannot be created because %1$d members are using an old version of Signal. You must remove them before creating the group.</item>
|
||||
</plurals>
|
||||
|
||||
<!-- ManageGroupActivity -->
|
||||
<string name="ManageGroupActivity_disappearing_messages">Disappearing messages</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue