Do not show speaker hint in pip.

fork-5.53.8
Cody Henthorne 2020-12-08 17:18:22 -05:00 zatwierdzone przez Greyson Parrelli
rodzic 9f8e31db78
commit a564aae80a
3 zmienionych plików z 25 dodań i 22 usunięć

Wyświetl plik

@ -245,6 +245,7 @@ public class WebRtcCallActivity extends AppCompatActivity implements SafetyNumbe
viewModel.getCallParticipantListUpdate().observe(this, participantUpdateWindow::addCallParticipantListUpdate); viewModel.getCallParticipantListUpdate().observe(this, participantUpdateWindow::addCallParticipantListUpdate);
viewModel.getSafetyNumberChangeEvent().observe(this, this::handleSafetyNumberChangeEvent); viewModel.getSafetyNumberChangeEvent().observe(this, this::handleSafetyNumberChangeEvent);
viewModel.getGroupMembers().observe(this, unused -> updateGroupMembersForGroupCall()); viewModel.getGroupMembers().observe(this, unused -> updateGroupMembersForGroupCall());
viewModel.shouldShowSpeakerHint().observe(this, this::updateSpeakerHint);
callScreen.getViewTreeObserver().addOnGlobalLayoutListener(() -> { callScreen.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
CallParticipantsState state = viewModel.getCallParticipantsState().getValue(); CallParticipantsState state = viewModel.getCallParticipantsState().getValue();
@ -286,10 +287,6 @@ public class WebRtcCallActivity extends AppCompatActivity implements SafetyNumbe
videoTooltip.dismiss(); videoTooltip.dismiss();
videoTooltip = null; videoTooltip = null;
} }
} else if (event instanceof WebRtcCallViewModel.Event.ShowSpeakerViewHint) {
callScreen.showSpeakerViewHint();
} else if (event instanceof WebRtcCallViewModel.Event.HideSpeakerViewHint) {
callScreen.hideSpeakerViewHint();
} else { } else {
throw new IllegalArgumentException("Unknown event: " + event); throw new IllegalArgumentException("Unknown event: " + event);
} }
@ -517,6 +514,14 @@ public class WebRtcCallActivity extends AppCompatActivity implements SafetyNumbe
startService(new Intent(this, WebRtcCallService.class).setAction(WebRtcCallService.ACTION_GROUP_REQUEST_UPDATE_MEMBERS)); startService(new Intent(this, WebRtcCallService.class).setAction(WebRtcCallService.ACTION_GROUP_REQUEST_UPDATE_MEMBERS));
} }
private void updateSpeakerHint(boolean showSpeakerHint) {
if (showSpeakerHint) {
callScreen.showSpeakerViewHint();
} else {
callScreen.hideSpeakerViewHint();
}
}
@Override @Override
public void onSendAnywayAfterSafetyNumberChange(@NonNull List<RecipientId> changedRecipients) { public void onSendAnywayAfterSafetyNumberChange(@NonNull List<RecipientId> changedRecipients) {
CallParticipantsState state = viewModel.getCallParticipantsState().getValue(); CallParticipantsState state = viewModel.getCallParticipantsState().getValue();

Wyświetl plik

@ -517,7 +517,7 @@ public class WebRtcCallView extends FrameLayout {
} }
public void showSpeakerViewHint() { public void showSpeakerViewHint() {
groupCallSpeakerHint.get(); groupCallSpeakerHint.get().setVisibility(View.VISIBLE);
} }
public void hideSpeakerViewHint() { public void hideSpeakerViewHint() {

Wyświetl plik

@ -47,6 +47,7 @@ public class WebRtcCallViewModel extends ViewModel {
private final LiveData<SafetyNumberChangeEvent> safetyNumberChangeEvent = LiveDataUtil.combineLatest(isInPipMode, identityChangedRecipients, SafetyNumberChangeEvent::new); private final LiveData<SafetyNumberChangeEvent> safetyNumberChangeEvent = LiveDataUtil.combineLatest(isInPipMode, identityChangedRecipients, SafetyNumberChangeEvent::new);
private final LiveData<Recipient> groupRecipient = LiveDataUtil.filter(Transformations.switchMap(liveRecipient, LiveRecipient::getLiveData), Recipient::isActiveGroup); private final LiveData<Recipient> groupRecipient = LiveDataUtil.filter(Transformations.switchMap(liveRecipient, LiveRecipient::getLiveData), Recipient::isActiveGroup);
private final LiveData<List<GroupMemberEntry.FullMember>> groupMembers = LiveDataUtil.skip(Transformations.switchMap(groupRecipient, r -> Transformations.distinctUntilChanged(new LiveGroup(r.requireGroupId()).getFullMembers())), 1); private final LiveData<List<GroupMemberEntry.FullMember>> groupMembers = LiveDataUtil.skip(Transformations.switchMap(groupRecipient, r -> Transformations.distinctUntilChanged(new LiveGroup(r.requireGroupId()).getFullMembers())), 1);
private final LiveData<Boolean> shouldShowSpeakerHint = Transformations.map(participantsState, this::shouldShowSpeakerHint);
private boolean canDisplayTooltipIfNeeded = true; private boolean canDisplayTooltipIfNeeded = true;
private boolean hasEnabledLocalVideo = false; private boolean hasEnabledLocalVideo = false;
@ -100,6 +101,10 @@ public class WebRtcCallViewModel extends ViewModel {
return groupMembers; return groupMembers;
} }
public LiveData<Boolean> shouldShowSpeakerHint() {
return shouldShowSpeakerHint;
}
public boolean canEnterPipMode() { public boolean canEnterPipMode() {
return canEnterPipMode; return canEnterPipMode;
} }
@ -122,12 +127,12 @@ public class WebRtcCallViewModel extends ViewModel {
@MainThread @MainThread
public void setIsViewingFocusedParticipant(@NonNull CallParticipantsState.SelectedPage page) { public void setIsViewingFocusedParticipant(@NonNull CallParticipantsState.SelectedPage page) {
//noinspection ConstantConditions
participantsState.setValue(CallParticipantsState.update(participantsState.getValue(), page));
if (page == CallParticipantsState.SelectedPage.FOCUSED) { if (page == CallParticipantsState.SelectedPage.FOCUSED) {
SignalStore.tooltips().markGroupCallSpeakerViewSeen(); SignalStore.tooltips().markGroupCallSpeakerViewSeen();
events.setValue(new Event.HideSpeakerViewHint());
} }
//noinspection ConstantConditions
participantsState.setValue(CallParticipantsState.update(participantsState.getValue(), page));
} }
public void onDismissedVideoTooltip() { public void onDismissedVideoTooltip() {
@ -187,14 +192,6 @@ public class WebRtcCallViewModel extends ViewModel {
canDisplayTooltipIfNeeded = false; canDisplayTooltipIfNeeded = false;
events.setValue(new Event.ShowVideoTooltip()); events.setValue(new Event.ShowVideoTooltip());
} }
//noinspection ConstantConditions
if (!isInPipMode.getValue() &&
webRtcViewModel.getRemoteParticipants().size() > 1 &&
webRtcViewModel.getGroupState().isConnected() &&
!SignalStore.tooltips().hasSeenGroupCallSpeakerView()) {
events.setValue(new Event.ShowSpeakerViewHint());
}
} }
private boolean containsPlaceholders(@NonNull List<CallParticipant> callParticipants) { private boolean containsPlaceholders(@NonNull List<CallParticipant> callParticipants) {
@ -276,6 +273,13 @@ public class WebRtcCallViewModel extends ViewModel {
return isInPipMode ? WebRtcControls.PIP : controls; return isInPipMode ? WebRtcControls.PIP : controls;
} }
private boolean shouldShowSpeakerHint(@NonNull CallParticipantsState state) {
return !state.isInPipMode() &&
state.getRemoteDevicesCount() > 1 &&
state.getGroupCallState().isConnected() &&
!SignalStore.tooltips().hasSeenGroupCallSpeakerView();
}
private void startTimer() { private void startTimer() {
cancelTimer(); cancelTimer();
@ -332,12 +336,6 @@ public class WebRtcCallViewModel extends ViewModel {
public static class DismissVideoTooltip extends Event { public static class DismissVideoTooltip extends Event {
} }
public static class ShowSpeakerViewHint extends Event {
}
public static class HideSpeakerViewHint extends Event {
}
public static class StartCall extends Event { public static class StartCall extends Event {
private final boolean isVideoCall; private final boolean isVideoCall;