From 4a102d44cbcfe8312cbcea74b8cedf59bc402d0c Mon Sep 17 00:00:00 2001 From: Nicholas Tinsley Date: Fri, 22 Dec 2023 12:23:15 -0500 Subject: [PATCH] Show raise hand on each particpiant. --- .../webrtc/CallParticipantView.java | 20 +++++++++++++ .../webrtc/CallParticipantsLayout.java | 3 ++ .../WebRtcCallParticipantsPagerAdapter.java | 1 + .../main/res/layout/call_participant_item.xml | 30 +++++++++++++++++++ 4 files changed, 54 insertions(+) diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantView.java b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantView.java index af063c6d99..71246b9ecd 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantView.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantView.java @@ -6,6 +6,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageView; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -36,6 +37,7 @@ import org.thoughtcrime.securesms.mms.GlideApp; import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.RecipientId; import org.thoughtcrime.securesms.util.AvatarUtil; +import org.thoughtcrime.securesms.util.FeatureFlags; import org.thoughtcrime.securesms.util.ViewUtil; import org.webrtc.RendererCommon; import org.whispersystems.signalservice.api.util.Preconditions; @@ -57,6 +59,7 @@ public class CallParticipantView extends ConstraintLayout { private RecipientId recipientId; private boolean infoMode; + private boolean raiseHandAllowed; private Runnable missingMediaKeysUpdater; private SelfPipMode selfPipMode = SelfPipMode.NOT_SELF_PIP; @@ -76,6 +79,8 @@ public class CallParticipantView extends ConstraintLayout { private AppCompatImageView infoIcon; private View switchCameraIconFrame; private View switchCameraIcon; + private ImageView raiseHandIcon; + private TextView nameLabel; public CallParticipantView(@NonNull Context context) { super(context); @@ -108,6 +113,8 @@ public class CallParticipantView extends ConstraintLayout { pipBadge = findViewById(R.id.call_participant_item_pip_badge); switchCameraIconFrame = findViewById(R.id.call_participant_switch_camera); switchCameraIcon = findViewById(R.id.call_participant_switch_camera_icon); + raiseHandIcon = findViewById(R.id.call_participant_raise_hand_icon); + nameLabel = findViewById(R.id.call_participant_name_label); avatar.setFallbackPhotoProvider(FALLBACK_PHOTO_PROVIDER); useLargeAvatar(); @@ -172,6 +179,15 @@ public class CallParticipantView extends ConstraintLayout { audioIndicator.setVisibility(View.VISIBLE); audioIndicator.bind(participant.isMicrophoneEnabled(), participant.getAudioLevel()); + final String shortRecipientDisplayName = participant.getShortRecipientDisplayName(getContext()); + if (FeatureFlags.groupCallRaiseHand() && raiseHandAllowed && participant.isHandRaised()) { + raiseHandIcon.setVisibility(View.VISIBLE); + nameLabel.setVisibility(View.VISIBLE); + nameLabel.setText(shortRecipientDisplayName); + } else { + raiseHandIcon.setVisibility(View.GONE); + nameLabel.setVisibility(View.GONE); + } } if (participantChanged || !Objects.equals(contactPhoto, participant.getRecipient().getContactPhoto())) { @@ -219,6 +235,10 @@ public class CallParticipantView extends ConstraintLayout { pipBadge.setVisibility(shouldRenderInPip ? View.VISIBLE : View.GONE); } + public void setRaiseHandAllowed(boolean raiseHandAllowed) { + this.raiseHandAllowed = raiseHandAllowed; + } + /** * Adjust UI elements for the various self PIP positions. If called after a {@link TransitionManager#beginDelayedTransition(ViewGroup, Transition)}, * the changes to the UI elements will animate. diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantsLayout.java b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantsLayout.java index a6d2835e14..dfeb82d538 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantsLayout.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantsLayout.java @@ -28,6 +28,7 @@ public class CallParticipantsLayout extends FlexboxLayout { private static final int MULTIPLE_PARTICIPANT_SPACING = ViewUtil.dpToPx(3); private static final int CORNER_RADIUS = ViewUtil.dpToPx(10); + private static final int RAISE_HAND_MINIMUM_COUNT = 2; private List callParticipants = Collections.emptyList(); private CallParticipant focusedParticipant = null; @@ -145,6 +146,8 @@ public class CallParticipantsLayout extends FlexboxLayout { callParticipantView.useLargeAvatar(); } + callParticipantView.setRaiseHandAllowed(count >= RAISE_HAND_MINIMUM_COUNT); + layoutStrategy.setChildLayoutParams(view, index, getChildCount()); } diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallParticipantsPagerAdapter.java b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallParticipantsPagerAdapter.java index 93b941af24..7412511261 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallParticipantsPagerAdapter.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallParticipantsPagerAdapter.java @@ -112,6 +112,7 @@ class WebRtcCallParticipantsPagerAdapter extends ListAdapter + + + +