Improve experience of populating migration dialog.

This commit is contained in:
Greyson Parrelli 2021-02-12 11:42:20 -05:00
parent 1935b0ebdd
commit 527fbee41e
3 changed files with 23 additions and 2 deletions

View file

@ -21,6 +21,7 @@ import org.thoughtcrime.securesms.groups.ui.GroupMemberListView;
import org.thoughtcrime.securesms.recipients.RecipientId; import org.thoughtcrime.securesms.recipients.RecipientId;
import org.thoughtcrime.securesms.util.BottomSheetUtil; import org.thoughtcrime.securesms.util.BottomSheetUtil;
import org.thoughtcrime.securesms.util.ThemeUtil; import org.thoughtcrime.securesms.util.ThemeUtil;
import org.thoughtcrime.securesms.util.ViewUtil;
import org.thoughtcrime.securesms.util.views.SimpleProgressDialog; import org.thoughtcrime.securesms.util.views.SimpleProgressDialog;
/** /**
@ -38,6 +39,8 @@ public final class GroupsV1MigrationInitiationBottomSheetDialogFragment extends
private GroupMemberListView ineligibleList; private GroupMemberListView ineligibleList;
private TextView ineligibleTitle; private TextView ineligibleTitle;
private View ineligibleContainer; private View ineligibleContainer;
private View upgradeButton;
private View spinner;
public static void showForInitiation(@NonNull FragmentManager manager, @NonNull RecipientId groupRecipientId) { public static void showForInitiation(@NonNull FragmentManager manager, @NonNull RecipientId groupRecipientId) {
Bundle args = new Bundle(); Bundle args = new Bundle();
@ -71,6 +74,8 @@ public final class GroupsV1MigrationInitiationBottomSheetDialogFragment extends
this.ineligibleContainer = view.findViewById(R.id.gv1_migrate_ineligible_container); this.ineligibleContainer = view.findViewById(R.id.gv1_migrate_ineligible_container);
this.ineligibleTitle = view.findViewById(R.id.gv1_migrate_ineligible_title); this.ineligibleTitle = view.findViewById(R.id.gv1_migrate_ineligible_title);
this.ineligibleList = view.findViewById(R.id.gv1_migrate_ineligible_list); this.ineligibleList = view.findViewById(R.id.gv1_migrate_ineligible_list);
this.upgradeButton = view.findViewById(R.id.gv1_migrate_upgrade_button);
this.spinner = view.findViewById(R.id.gv1_migrate_spinner);
inviteList.setNestedScrollingEnabled(false); inviteList.setNestedScrollingEnabled(false);
ineligibleList.setNestedScrollingEnabled(false); ineligibleList.setNestedScrollingEnabled(false);
@ -82,8 +87,9 @@ public final class GroupsV1MigrationInitiationBottomSheetDialogFragment extends
viewModel = ViewModelProviders.of(this, new GroupsV1MigrationInitiationViewModel.Factory(groupRecipientId)).get(GroupsV1MigrationInitiationViewModel.class); viewModel = ViewModelProviders.of(this, new GroupsV1MigrationInitiationViewModel.Factory(groupRecipientId)).get(GroupsV1MigrationInitiationViewModel.class);
viewModel.getMigrationState().observe(getViewLifecycleOwner(), this::onMigrationStateChanged); viewModel.getMigrationState().observe(getViewLifecycleOwner(), this::onMigrationStateChanged);
upgradeButton.setEnabled(false);
upgradeButton.setOnClickListener(v -> onUpgradeClicked());
view.findViewById(R.id.gv1_migrate_cancel_button).setOnClickListener(v -> dismiss()); view.findViewById(R.id.gv1_migrate_cancel_button).setOnClickListener(v -> dismiss());
view.findViewById(R.id.gv1_migrate_upgrade_button).setOnClickListener(v -> onUpgradeClicked());
} }
@Override @Override
@ -107,6 +113,9 @@ public final class GroupsV1MigrationInitiationBottomSheetDialogFragment extends
} else { } else {
ineligibleContainer.setVisibility(View.GONE); ineligibleContainer.setVisibility(View.GONE);
} }
upgradeButton.setEnabled(true);
spinner.setVisibility(View.GONE);
} }
private void onUpgradeClicked() { private void onUpgradeClicked() {

View file

@ -20,6 +20,7 @@ import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId; import org.thoughtcrime.securesms.recipients.RecipientId;
import org.thoughtcrime.securesms.recipients.RecipientUtil; import org.thoughtcrime.securesms.recipients.RecipientUtil;
import org.thoughtcrime.securesms.transport.RetryLaterException; import org.thoughtcrime.securesms.transport.RetryLaterException;
import org.thoughtcrime.securesms.util.Util;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.Collections;
@ -83,7 +84,11 @@ final class GroupsV1MigrationRepository {
} }
try { try {
RecipientUtil.ensureUuidsAreAvailable(ApplicationDependencies.getApplication(), group.getParticipants()); List<Recipient> registered = Stream.of(group.getParticipants())
.filter(Recipient::isRegistered)
.toList();
RecipientUtil.ensureUuidsAreAvailable(ApplicationDependencies.getApplication(), registered);
} catch (IOException e) { } catch (IOException e) {
Log.w(TAG, "Failed to refresh UUIDs!", e); Log.w(TAG, "Failed to refresh UUIDs!", e);
} }

View file

@ -76,6 +76,13 @@
</LinearLayout> </LinearLayout>
<ProgressBar
android:id="@+id/gv1_migrate_spinner"
android:layout_width="match_parent"
android:layout_height="75dp"
android:layout_marginTop="23dp"
android:indeterminate="true" />
<LinearLayout <LinearLayout
android:id="@+id/gv1_migrate_invite_container" android:id="@+id/gv1_migrate_invite_container"
android:layout_width="match_parent" android:layout_width="match_parent"