Display speaker in PiP.

fork-5.53.8
Alex Hart 2020-12-07 13:16:02 -04:00 zatwierdzone przez GitHub
rodzic ea94f6bc91
commit 61886ea10a
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
4 zmienionych plików z 23 dodań i 12 usunięć

Wyświetl plik

@ -30,6 +30,7 @@ public class CallParticipantsLayout extends FlexboxLayout {
private static final int CORNER_RADIUS = ViewUtil.dpToPx(10); private static final int CORNER_RADIUS = ViewUtil.dpToPx(10);
private List<CallParticipant> callParticipants = Collections.emptyList(); private List<CallParticipant> callParticipants = Collections.emptyList();
private CallParticipant focusedParticipant = null;
private boolean shouldRenderInPip; private boolean shouldRenderInPip;
public CallParticipantsLayout(@NonNull Context context) { public CallParticipantsLayout(@NonNull Context context) {
@ -44,9 +45,10 @@ public class CallParticipantsLayout extends FlexboxLayout {
super(context, attrs, defStyleAttr); super(context, attrs, defStyleAttr);
} }
void update(@NonNull List<CallParticipant> callParticipants, boolean shouldRenderInPip) { void update(@NonNull List<CallParticipant> callParticipants, @NonNull CallParticipant focusedParticipant, boolean shouldRenderInPip) {
this.callParticipants = callParticipants; this.callParticipants = callParticipants;
this.shouldRenderInPip = shouldRenderInPip; this.focusedParticipant = focusedParticipant;
this.shouldRenderInPip = shouldRenderInPip;
updateLayout(); updateLayout();
} }
@ -55,7 +57,7 @@ public class CallParticipantsLayout extends FlexboxLayout {
if (shouldRenderInPip && Util.hasItems(callParticipants)) { if (shouldRenderInPip && Util.hasItems(callParticipants)) {
updateChildrenCount(1); updateChildrenCount(1);
update(0, 1, callParticipants.get(0)); update(0, 1, focusedParticipant);
} else { } else {
int count = callParticipants.size(); int count = callParticipants.size();
updateChildrenCount(count); updateChildrenCount(count);

Wyświetl plik

@ -11,34 +11,42 @@ import java.util.Objects;
class WebRtcCallParticipantsPage { class WebRtcCallParticipantsPage {
private final List<CallParticipant> callParticipants; private final List<CallParticipant> callParticipants;
private final CallParticipant focusedParticipant;
private final boolean isSpeaker; private final boolean isSpeaker;
private final boolean isRenderInPip; private final boolean isRenderInPip;
static WebRtcCallParticipantsPage forMultipleParticipants(@NonNull List<CallParticipant> callParticipants, static WebRtcCallParticipantsPage forMultipleParticipants(@NonNull List<CallParticipant> callParticipants,
@NonNull CallParticipant focusedParticipant,
boolean isRenderInPip) boolean isRenderInPip)
{ {
return new WebRtcCallParticipantsPage(callParticipants, false, isRenderInPip); return new WebRtcCallParticipantsPage(callParticipants, focusedParticipant, false, isRenderInPip);
} }
static WebRtcCallParticipantsPage forSingleParticipant(@NonNull CallParticipant singleParticipant, static WebRtcCallParticipantsPage forSingleParticipant(@NonNull CallParticipant singleParticipant,
boolean isRenderInPip) boolean isRenderInPip)
{ {
return new WebRtcCallParticipantsPage(Collections.singletonList(singleParticipant), true, isRenderInPip); return new WebRtcCallParticipantsPage(Collections.singletonList(singleParticipant), singleParticipant, true, isRenderInPip);
} }
private WebRtcCallParticipantsPage(@NonNull List<CallParticipant> callParticipants, private WebRtcCallParticipantsPage(@NonNull List<CallParticipant> callParticipants,
@NonNull CallParticipant focusedParticipant,
boolean isSpeaker, boolean isSpeaker,
boolean isRenderInPip) boolean isRenderInPip)
{ {
this.callParticipants = callParticipants; this.callParticipants = callParticipants;
this.isSpeaker = isSpeaker; this.focusedParticipant = focusedParticipant;
this.isRenderInPip = isRenderInPip; this.isSpeaker = isSpeaker;
this.isRenderInPip = isRenderInPip;
} }
public @NonNull List<CallParticipant> getCallParticipants() { public @NonNull List<CallParticipant> getCallParticipants() {
return callParticipants; return callParticipants;
} }
public @NonNull CallParticipant getFocusedParticipant() {
return focusedParticipant;
}
public boolean isRenderInPip() { public boolean isRenderInPip() {
return isRenderInPip; return isRenderInPip;
} }
@ -54,11 +62,12 @@ class WebRtcCallParticipantsPage {
WebRtcCallParticipantsPage that = (WebRtcCallParticipantsPage) o; WebRtcCallParticipantsPage that = (WebRtcCallParticipantsPage) o;
return isSpeaker == that.isSpeaker && return isSpeaker == that.isSpeaker &&
isRenderInPip == that.isRenderInPip && isRenderInPip == that.isRenderInPip &&
focusedParticipant.equals(that.focusedParticipant) &&
callParticipants.equals(that.callParticipants); callParticipants.equals(that.callParticipants);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(callParticipants, isSpeaker); return Objects.hash(callParticipants, isSpeaker, focusedParticipant, isRenderInPip);
} }
} }

Wyświetl plik

@ -84,7 +84,7 @@ class WebRtcCallParticipantsPagerAdapter extends ListAdapter<WebRtcCallParticipa
@Override @Override
void bind(WebRtcCallParticipantsPage page) { void bind(WebRtcCallParticipantsPage page) {
callParticipantsLayout.update(page.getCallParticipants(), page.isRenderInPip()); callParticipantsLayout.update(page.getCallParticipants(), page.getFocusedParticipant(), page.isRenderInPip());
} }
} }

Wyświetl plik

@ -255,7 +255,7 @@ public class WebRtcCallView extends FrameLayout {
List<WebRtcCallParticipantsPage> pages = new ArrayList<>(2); List<WebRtcCallParticipantsPage> pages = new ArrayList<>(2);
if (!state.getGridParticipants().isEmpty()) { if (!state.getGridParticipants().isEmpty()) {
pages.add(WebRtcCallParticipantsPage.forMultipleParticipants(state.getGridParticipants(), state.isInPipMode())); pages.add(WebRtcCallParticipantsPage.forMultipleParticipants(state.getGridParticipants(), state.getFocusedParticipant(), state.isInPipMode()));
} }
if (state.getFocusedParticipant() != null && state.getAllRemoteParticipants().size() > 1) { if (state.getFocusedParticipant() != null && state.getAllRemoteParticipants().size() > 1) {