Inline the GV1 forced migration flag.

fork-5.53.8
Greyson Parrelli 2021-06-08 12:42:51 -04:00 zatwierdzone przez GitHub
rodzic cf361334c4
commit 0972d8f1e1
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
16 zmienionych plików z 15 dodań i 146 usunięć

Wyświetl plik

@ -1,24 +0,0 @@
package org.thoughtcrime.securesms.components.reminder;
import android.content.Context;
import androidx.annotation.NonNull;
import org.thoughtcrime.securesms.R;
/**
* Shows a reminder to upgrade a group to GV2.
*/
public class GroupsV1MigrationInitiationReminder extends Reminder {
public GroupsV1MigrationInitiationReminder(@NonNull Context context) {
super(null, context.getString(R.string.GroupsV1MigrationInitiationReminder_to_access_new_features_like_mentions));
addAction(new Action(context.getString(R.string.GroupsV1MigrationInitiationReminder_upgrade_group), R.id.reminder_action_gv1_initiation_update_group));
addAction(new Action(context.getResources().getString(R.string.GroupsV1MigrationInitiationReminder_not_now), R.id.reminder_action_gv1_initiation_not_now));
}
@Override
public boolean isDismissable() {
return false;
}
}

Wyświetl plik

@ -123,7 +123,6 @@ import org.thoughtcrime.securesms.components.identity.UnverifiedBannerView;
import org.thoughtcrime.securesms.components.location.SignalPlace;
import org.thoughtcrime.securesms.components.mention.MentionAnnotation;
import org.thoughtcrime.securesms.components.reminder.ExpiredBuildReminder;
import org.thoughtcrime.securesms.components.reminder.GroupsV1MigrationInitiationReminder;
import org.thoughtcrime.securesms.components.reminder.GroupsV1MigrationSuggestionsReminder;
import org.thoughtcrime.securesms.components.reminder.PendingGroupJoinRequestsReminder;
import org.thoughtcrime.securesms.components.reminder.Reminder;
@ -1652,8 +1651,6 @@ public class ConversationActivity extends PassphraseRequiredActivity
private void initializeGroupV1MigrationsBanners() {
groupViewModel.getGroupV1MigrationSuggestions()
.observe(this, s -> updateReminders());
groupViewModel.getShowGroupsV1MigrationBanner()
.observe(this, b -> updateReminders());
}
private ListenableFuture<Boolean> initializeDraftFromDatabase() {
@ -1812,7 +1809,6 @@ public class ConversationActivity extends PassphraseRequiredActivity
Optional<Reminder> inviteReminder = inviteReminderModel.getReminder();
Integer actionableRequestingMembers = groupViewModel.getActionableRequestingMembers().getValue();
List<RecipientId> gv1MigrationSuggestions = groupViewModel.getGroupV1MigrationSuggestions().getValue();
Boolean gv1MigrationBanner = groupViewModel.getShowGroupsV1MigrationBanner().getValue();
if (UnauthorizedReminder.isEligible(this)) {
reminderView.get().showReminder(new UnauthorizedReminder(this));
@ -1837,15 +1833,6 @@ public class ConversationActivity extends PassphraseRequiredActivity
startActivity(ManagePendingAndRequestingMembersActivity.newIntent(this, getRecipient().getGroupId().get().requireV2()));
}
});
} else if (gv1MigrationBanner == Boolean.TRUE && recipient.get().isPushV1Group()) {
reminderView.get().showReminder(new GroupsV1MigrationInitiationReminder(this));
reminderView.get().setOnActionClickListener(actionId -> {
if (actionId == R.id.reminder_action_gv1_initiation_update_group) {
GroupsV1MigrationInitiationBottomSheetDialogFragment.showForInitiation(getSupportFragmentManager(), recipient.getId());
} else if (actionId == R.id.reminder_action_gv1_initiation_not_now) {
groupViewModel.onMigrationInitiationReminderBannerDismissed(recipient.getId());
}
});
} else if (gv1MigrationSuggestions != null && gv1MigrationSuggestions.size() > 0 && recipient.get().isPushV2Group()) {
reminderView.get().showReminder(new GroupsV1MigrationSuggestionsReminder(this, gv1MigrationSuggestions));
reminderView.get().setOnActionClickListener(actionId -> {

Wyświetl plik

@ -43,15 +43,12 @@ import java.util.concurrent.TimeUnit;
final class ConversationGroupViewModel extends ViewModel {
private static final long GV1_MIGRATION_REMINDER_INTERVAL = TimeUnit.DAYS.toMillis(1);
private final MutableLiveData<Recipient> liveRecipient;
private final LiveData<GroupActiveState> groupActiveState;
private final LiveData<GroupDatabase.MemberLevel> selfMembershipLevel;
private final LiveData<Integer> actionableRequestingMembers;
private final LiveData<ReviewState> reviewState;
private final LiveData<List<RecipientId>> gv1MigrationSuggestions;
private final LiveData<Boolean> gv1MigrationReminder;
private boolean firstTimeInviteFriendsTriggered;
@ -73,7 +70,6 @@ final class ConversationGroupViewModel extends ViewModel {
this.selfMembershipLevel = Transformations.distinctUntilChanged(Transformations.map(groupRecord, ConversationGroupViewModel::mapToSelfMembershipLevel));
this.actionableRequestingMembers = Transformations.distinctUntilChanged(Transformations.map(groupRecord, ConversationGroupViewModel::mapToActionableRequestingMemberCount));
this.gv1MigrationSuggestions = Transformations.distinctUntilChanged(LiveDataUtil.mapAsync(groupRecord, ConversationGroupViewModel::mapToGroupV1MigrationSuggestions));
this.gv1MigrationReminder = Transformations.distinctUntilChanged(LiveDataUtil.mapAsync(groupRecord, ConversationGroupViewModel::mapToGroupV1MigrationReminder));
this.reviewState = LiveDataUtil.combineLatest(groupRecord,
duplicates,
(record, dups) -> dups.isEmpty()
@ -95,13 +91,6 @@ final class ConversationGroupViewModel extends ViewModel {
});
}
void onMigrationInitiationReminderBannerDismissed(@NonNull RecipientId recipientId) {
SignalExecutors.BOUNDED.execute(() -> {
DatabaseFactory.getRecipientDatabase(ApplicationDependencies.getApplication()).markGroupsV1MigrationReminderSeen(recipientId, System.currentTimeMillis());
liveRecipient.postValue(liveRecipient.getValue());
});
}
/**
* The number of pending group join requests that can be actioned by this client.
*/
@ -125,10 +114,6 @@ final class ConversationGroupViewModel extends ViewModel {
return gv1MigrationSuggestions;
}
@NonNull LiveData<Boolean> getShowGroupsV1MigrationBanner() {
return gv1MigrationReminder;
}
private static @Nullable GroupRecord getGroupRecordForRecipient(@Nullable Recipient recipient) {
if (recipient != null && recipient.isGroup()) {
Application context = ApplicationDependencies.getApplication();
@ -188,31 +173,6 @@ final class ConversationGroupViewModel extends ViewModel {
.toList();
}
@WorkerThread
private static boolean mapToGroupV1MigrationReminder(@Nullable GroupRecord record) {
if (record == null ||
!record.isV1Group() ||
!record.isActive() ||
FeatureFlags.groupsV1ForcedMigration() ||
Recipient.self().getGroupsV1MigrationCapability() != Recipient.Capability.SUPPORTED ||
!Recipient.resolved(record.getRecipientId()).isProfileSharing())
{
return false;
}
boolean canAutoMigrate = Stream.of(Recipient.resolvedList(record.getMembers()))
.allMatch(GroupsV1MigrationUtil::isAutoMigratable);
if (canAutoMigrate) {
return false;
}
Context context = ApplicationDependencies.getApplication();
long lastReminderTime = DatabaseFactory.getRecipientDatabase(context).getGroupsV1MigrationReminderLastSeen(record.getRecipientId());
return System.currentTimeMillis() - lastReminderTime > GV1_MIGRATION_REMINDER_INTERVAL;
}
public static void onCancelJoinRequest(@NonNull Recipient recipient,
@NonNull AsynchronousCallback.WorkerThread<Void, GroupChangeFailureReason> callback)
{

Wyświetl plik

@ -1067,7 +1067,7 @@ private static final String[] GROUP_PROJECTION = {
return GroupAccessControl.ALL_MEMBERS;
}
return GroupAccessControl.ONLY_ADMINS;
} else if (isV1Group() && FeatureFlags.groupsV1ForcedMigration()) {
} else if (isV1Group()) {
return GroupAccessControl.NO_ONE;
} else {
return id.isV1() ? GroupAccessControl.ALL_MEMBERS : GroupAccessControl.ONLY_ADMINS;
@ -1083,7 +1083,7 @@ private static final String[] GROUP_PROJECTION = {
return GroupAccessControl.ALL_MEMBERS;
}
return GroupAccessControl.ONLY_ADMINS;
} else if (isV1Group() && FeatureFlags.groupsV1ForcedMigration()) {
} else if (isV1Group()) {
return GroupAccessControl.NO_ONE;
} else {
return GroupAccessControl.ALL_MEMBERS;

Wyświetl plik

@ -140,7 +140,6 @@ public class RecipientDatabase extends Database {
private static final String PROFILE_JOINED_NAME = "profile_joined_name";
private static final String MENTION_SETTING = "mention_setting";
private static final String STORAGE_PROTO = "storage_proto";
private static final String LAST_GV1_MIGRATE_REMINDER = "last_gv1_migrate_reminder";
private static final String LAST_SESSION_RESET = "last_session_reset";
private static final String WALLPAPER = "wallpaper";
private static final String WALLPAPER_URI = "wallpaper_file";
@ -359,7 +358,6 @@ public class RecipientDatabase extends Database {
MENTION_SETTING + " INTEGER DEFAULT " + MentionSetting.ALWAYS_NOTIFY.getId() + ", " +
STORAGE_PROTO + " TEXT DEFAULT NULL, " +
CAPABILITIES + " INTEGER DEFAULT 0, " +
LAST_GV1_MIGRATE_REMINDER + " INTEGER DEFAULT 0, " +
LAST_SESSION_RESET + " BLOB DEFAULT NULL, " +
WALLPAPER + " BLOB DEFAULT NULL, " +
WALLPAPER_URI + " TEXT DEFAULT NULL, " +
@ -1583,27 +1581,6 @@ public class RecipientDatabase extends Database {
}
}
public void markGroupsV1MigrationReminderSeen(@NonNull RecipientId id, long time) {
ContentValues values = new ContentValues(1);
values.put(LAST_GV1_MIGRATE_REMINDER, time);
if (update(id, values)) {
Recipient.live(id).refresh();
}
}
public long getGroupsV1MigrationReminderLastSeen(@NonNull RecipientId id) {
SQLiteDatabase db = databaseHelper.getReadableDatabase();
try (Cursor cursor = db.query(TABLE_NAME, new String[] { LAST_GV1_MIGRATE_REMINDER }, ID_WHERE, SqlUtil.buildArgs(id), null, null, null)) {
if (cursor.moveToFirst()) {
return CursorUtil.requireLong(cursor, LAST_GV1_MIGRATE_REMINDER);
}
}
return 0;
}
public void setLastSessionResetTime(@NonNull RecipientId id, DeviceLastResetTime lastResetTime) {
ContentValues values = new ContentValues(1);
values.put(LAST_SESSION_RESET, lastResetTime.toByteArray());

Wyświetl plik

@ -130,15 +130,10 @@ 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(stringRes, nonGv2CapableMembers.size(), nonGv2CapableMembers.size()));
gv2Warning.setText(requireContext().getResources().getQuantityString(R.plurals.AddGroupDetailsFragment__d_members_do_not_support_new_groups_so_this_group_cannot_be_created, nonGv2CapableMembers.size(), nonGv2CapableMembers.size()));
gv2Warning.setLearnMoreVisible(true);
gv2Warning.setOnLinkClickListener(v -> NonGv2MemberDialog.showNonGv2Members(requireContext(), nonGv2CapableMembers, forcedMigration));
gv2Warning.setOnLinkClickListener(v -> NonGv2MemberDialog.showNonGv2Members(requireContext(), nonGv2CapableMembers));
});
viewModel.getAvatar().observe(getViewLifecycleOwner(), avatarBytes -> {
if (avatarBytes == null) {

Wyświetl plik

@ -64,7 +64,7 @@ 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(LiveDataUtil.combineLatest(isMms, isValidName, (mms, validName) -> mms || validName),
nonGv2CapableMembers,
(canSubmit, nonGv2) -> canSubmit && !(FeatureFlags.groupsV1ForcedMigration() && nonGv2.size() > 0));
(canSubmit, nonGv2) -> canSubmit && nonGv2.isEmpty());
repository.resolveMembers(recipientIds, initialMembers::postValue);
}

Wyświetl plik

@ -20,7 +20,7 @@ public final class NonGv2MemberDialog {
private NonGv2MemberDialog() {
}
public static @Nullable Dialog showNonGv2Members(@NonNull Context context, @NonNull List<Recipient> recipients, boolean forcedMigration) {
public static @Nullable Dialog showNonGv2Members(@NonNull Context context, @NonNull List<Recipient> recipients) {
int size = recipients.size();
if (size == 0) {
return null;
@ -32,13 +32,9 @@ public final class NonGv2MemberDialog {
// })
.setPositiveButton(android.R.string.ok, null);
if (size == 1) {
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)));
builder.setMessage(context.getString(R.string.NonGv2MemberDialog_single_users_are_non_gv2_capable_forced_migration, recipients.get(0).getDisplayName(context)));
} else {
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))
builder.setMessage(context.getResources().getQuantityString(R.plurals.NonGv2MemberDialog_d_users_are_non_gv2_capable_forced_migration, size, size))
.setView(R.layout.dialog_multiple_members_non_gv2_capable);
}

Wyświetl plik

@ -174,7 +174,7 @@ public final class PushGroupSendJob extends PushSendJob {
throw new MmsException("Message recipient isn't a group!");
}
if (groupRecipient.isPushV1Group() && FeatureFlags.groupsV1ForcedMigration()) {
if (groupRecipient.isPushV1Group()) {
throw new MmsException("No GV1 messages can be sent anymore!");
}

Wyświetl plik

@ -120,7 +120,7 @@ class CameraContactsRepository {
List<Recipient> recipients = new ArrayList<>();
try (GroupDatabase.Reader reader = groupDatabase.getGroupsFilteredByTitle(query, false, FeatureFlags.groupsV1ForcedMigration())) {
try (GroupDatabase.Reader reader = groupDatabase.getGroupsFilteredByTitle(query, false, true)) {
GroupDatabase.GroupRecord groupRecord;
while ((groupRecord = reader.getNext()) != null) {
RecipientId recipientId = recipientDatabase.getOrInsertFromGroupId(groupRecord.getId());

Wyświetl plik

@ -103,14 +103,10 @@ final class MessageRequestRepository {
}
} else if (recipient.isPushV1Group()) {
if (RecipientUtil.isMessageRequestAccepted(context, threadId)) {
if (FeatureFlags.groupsV1ForcedMigration()) {
if (recipient.getParticipants().size() > FeatureFlags.groupLimits().getHardLimit()) {
return MessageRequestState.DEPRECATED_GROUP_V1_TOO_LARGE;
} else {
return MessageRequestState.DEPRECATED_GROUP_V1;
}
if (recipient.getParticipants().size() > FeatureFlags.groupLimits().getHardLimit()) {
return MessageRequestState.DEPRECATED_GROUP_V1_TOO_LARGE;
} else {
return MessageRequestState.NONE;
return MessageRequestState.DEPRECATED_GROUP_V1;
}
} else if (!recipient.isActiveGroup()) {
return MessageRequestState.NONE;

Wyświetl plik

@ -67,7 +67,7 @@ public class DirectShareService extends ChooserTargetService {
ComponentName componentName = new ComponentName(this, ShareActivity.class);
ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(this);
try (ThreadDatabase.Reader reader = threadDatabase.readerFor(threadDatabase.getRecentConversationList(MAX_TARGETS, false, FeatureFlags.groupsV1ForcedMigration()))) {
try (ThreadDatabase.Reader reader = threadDatabase.readerFor(threadDatabase.getRecentConversationList(MAX_TARGETS, false, true))) {
ThreadRecord record;
while ((record = reader.getNext()) != null) {

Wyświetl plik

@ -217,9 +217,7 @@ public class ShareActivity extends PassphraseRequiredActivity
mode |= DisplayMode.FLAG_SMS;
}
if (FeatureFlags.groupsV1ForcedMigration()) {
mode |= DisplayMode.FLAG_HIDE_GROUPS_V1;
}
mode |= DisplayMode.FLAG_HIDE_GROUPS_V1;
getIntent().putExtra(ContactSelectionListFragment.DISPLAY_MODE, mode);
}

Wyświetl plik

@ -61,7 +61,6 @@ public final class FeatureFlags {
private static final String CLIENT_EXPIRATION = "android.clientExpiration";
public static final String DONATE_MEGAPHONE = "android.donate";
private static final String VIEWED_RECEIPTS = "android.viewed.receipts";
private static final String GV1_FORCED_MIGRATE = "android.groupsV1Migration.forced.2";
private static final String SEND_VIEWED_RECEIPTS = "android.sendViewedReceipts";
private static final String CUSTOM_VIDEO_MUXER = "android.customVideoMuxer";
private static final String CDS_REFRESH_INTERVAL = "cds.syncInterval.seconds";
@ -96,7 +95,6 @@ public final class FeatureFlags {
CLIENT_EXPIRATION,
DONATE_MEGAPHONE,
VIEWED_RECEIPTS,
GV1_FORCED_MIGRATE,
SEND_VIEWED_RECEIPTS,
CUSTOM_VIDEO_MUXER,
CDS_REFRESH_INTERVAL,
@ -158,7 +156,6 @@ public final class FeatureFlags {
ANIMATED_STICKER_MIN_TOTAL_MEMORY,
MESSAGE_PROCESSOR_ALARM_INTERVAL,
MESSAGE_PROCESSOR_DELAY,
GV1_FORCED_MIGRATE,
MP4_GIF_SEND_SUPPORT,
MEDIA_QUALITY_LEVELS,
RETRY_RECEIPT_LIFESPAN,
@ -284,11 +281,6 @@ public final class FeatureFlags {
return getBoolean(VIEWED_RECEIPTS, false);
}
/** Whether or not forced migration from GV1->GV2 is enabled. */
public static boolean groupsV1ForcedMigration() {
return getBoolean(GV1_FORCED_MIGRATE, false);
}
/** Whether or not to send viewed receipts. */
public static boolean sendViewedReceipts() {
return getBoolean(SEND_VIEWED_RECEIPTS, false);

Wyświetl plik

@ -12,9 +12,6 @@
<item name="reminder_action_gv1_suggestion_no_thanks" type="id" />
<item name="reminder_action_gv1_suggestion_add_members" type="id" />
<item name="reminder_action_gv1_initiation_not_now" type="id" />
<item name="reminder_action_gv1_initiation_update_group" type="id" />
<item name="status_bar_guideline" type="id" />
<item name="navigation_bar_guideline" type="id" />
</resources>

Wyświetl plik

@ -574,11 +574,6 @@
<item quantity="other">These members are not capable of joining New Groups, and will be removed from the group:</item>
</plurals>
<!-- GroupsV1MigrationInitiationReminder -->
<string name="GroupsV1MigrationInitiationReminder_to_access_new_features_like_mentions">To access new features like @mentions and admins, upgrade this group.</string>
<string name="GroupsV1MigrationInitiationReminder_not_now">Not now</string>
<string name="GroupsV1MigrationInitiationReminder_upgrade_group">Upgrade group</string>
<!-- GroupsV1MigrationSuggestionsReminder -->
<plurals name="GroupsV1MigrationSuggestionsReminder_members_couldnt_be_added_to_the_new_group">
<item quantity="one">%1$d member couldn\'t be re-added to the New Group. Do you want to add them now?</item>