Skip to content

Commit

Permalink
Show linked device update message if we don't have the capability to …
Browse files Browse the repository at this point in the history
…join a group by link.
  • Loading branch information
alan-signal authored and greyson-signal committed Sep 23, 2020
1 parent 34ef8b5 commit d459c75
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto;
import org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto;
import org.thoughtcrime.securesms.conversation.ConversationActivity;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.groups.v2.GroupInviteLinkUrl;
import org.thoughtcrime.securesms.jobs.RetrieveProfileJob;
import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.BottomSheetUtil;
Expand Down Expand Up @@ -113,6 +115,13 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
});
groupJoinButton.setVisibility(View.VISIBLE);
break;
case UPDATE_LINKED_DEVICE_TO_JOIN:
groupJoinExplain.setText(R.string.GroupJoinUpdateRequiredBottomSheetDialogFragment_update_linked_device_message);
groupCancelButton.setText(android.R.string.ok);
groupJoinButton.setVisibility(View.GONE);
ApplicationDependencies.getJobManager()
.add(RetrieveProfileJob.forRecipient(Recipient.self().getId()));
break;
case LOCAL_CAN_JOIN:
groupJoinExplain.setText(details.joinRequiresAdminApproval() ? R.string.GroupJoinBottomSheetDialogFragment_admin_approval_needed
: R.string.GroupJoinBottomSheetDialogFragment_direct_join);
Expand Down Expand Up @@ -151,19 +160,21 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
);
}

private static FeatureFlags.GroupJoinStatus getGroupJoinStatus() {
private static ExtendedGroupJoinStatus getGroupJoinStatus() {
FeatureFlags.GroupJoinStatus groupJoinStatus = FeatureFlags.clientLocalGroupJoinStatus();

if (groupJoinStatus == FeatureFlags.GroupJoinStatus.LOCAL_CAN_JOIN) {
if (Recipient.self().getGroupsV2Capability() == Recipient.Capability.NOT_SUPPORTED) {
// TODO [Alan] GV2 additional copy could be presented in these cases
return FeatureFlags.GroupJoinStatus.UPDATE_TO_JOIN;
switch (groupJoinStatus) {
case COMING_SOON : return ExtendedGroupJoinStatus.COMING_SOON;
case UPDATE_TO_JOIN: return ExtendedGroupJoinStatus.UPDATE_TO_JOIN;
case LOCAL_CAN_JOIN: {
if (Recipient.self().getGroupsV2Capability() != Recipient.Capability.SUPPORTED) {
return ExtendedGroupJoinStatus.UPDATE_LINKED_DEVICE_TO_JOIN;
}

return ExtendedGroupJoinStatus.LOCAL_CAN_JOIN;
}

return groupJoinStatus;
default: throw new AssertionError();
}

return groupJoinStatus;
}

private @NonNull String errorToMessage(@NonNull FetchGroupDetailsError error) {
Expand Down Expand Up @@ -201,4 +212,18 @@ private static final class FallbackPhotoProvider extends Recipient.FallbackPhoto
return new ResourceContactPhoto(R.drawable.ic_group_outline_48);
}
}

public enum ExtendedGroupJoinStatus {
/** No version of the client that can join V2 groups by link is in production. */
COMING_SOON,

/** A newer version of the client is in production that will allow joining via GV2 group links. */
UPDATE_TO_JOIN,

/** Locally we're using a version that can use group links, but one or more linked devices needs updating for GV2. */
UPDATE_LINKED_DEVICE_TO_JOIN,

/** This version of the client allows joining via GV2 group links. */
LOCAL_CAN_JOIN
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@
<string name="GroupJoinUpdateRequiredBottomSheetDialogFragment_coming_soon">Joining a group via a link is not yet supported by Signal. This feature will be released in an upcoming update.</string>
<string name="GroupJoinUpdateRequiredBottomSheetDialogFragment_update_message">The version of Signal you’re using does not support group links. Update to the latest version to join this group via link.</string>
<string name="GroupJoinUpdateRequiredBottomSheetDialogFragment_update_signal">Update Signal</string>
<string name="GroupJoinUpdateRequiredBottomSheetDialogFragment_update_linked_device_message">One or more of your linked devices are running a version of Signal that doesn\'t support group links. Update Signal on your linked device(s) to join this group.</string>
<string name="GroupJoinUpdateRequiredBottomSheetDialogFragment_group_link_is_not_valid">Group link is not valid</string>

<!-- GV2 Request confirmation dialog -->
Expand Down

0 comments on commit d459c75

Please sign in to comment.