mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-25 06:47:46 +00:00
Add emdash instead of 0 if no callers are present and we haven't connected / loaded the group state.
This commit is contained in:
@@ -6,6 +6,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.annimon.stream.ComparatorCompat;
|
||||
import com.annimon.stream.OptionalLong;
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
@@ -35,7 +36,7 @@ public final class CallParticipantsState {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
0);
|
||||
OptionalLong.empty());
|
||||
|
||||
private final WebRtcViewModel.State callState;
|
||||
private final WebRtcViewModel.GroupCallState groupCallState;
|
||||
@@ -46,7 +47,7 @@ public final class CallParticipantsState {
|
||||
private final boolean isInPipMode;
|
||||
private final boolean showVideoForOutgoing;
|
||||
private final boolean isViewingFocusedParticipant;
|
||||
private final long remoteDevicesCount;
|
||||
private final OptionalLong remoteDevicesCount;
|
||||
|
||||
public CallParticipantsState(@NonNull WebRtcViewModel.State callState,
|
||||
@NonNull WebRtcViewModel.GroupCallState groupCallState,
|
||||
@@ -57,7 +58,7 @@ public final class CallParticipantsState {
|
||||
boolean isInPipMode,
|
||||
boolean showVideoForOutgoing,
|
||||
boolean isViewingFocusedParticipant,
|
||||
long remoteDevicesCount)
|
||||
OptionalLong remoteDevicesCount)
|
||||
{
|
||||
this.callState = callState;
|
||||
this.groupCallState = groupCallState;
|
||||
@@ -158,10 +159,17 @@ public final class CallParticipantsState {
|
||||
return Stream.of(getAllRemoteParticipants()).anyMatch(p -> p.getVideoSink().needsNewRequestingSize());
|
||||
}
|
||||
|
||||
public long getRemoteDevicesCount() {
|
||||
public @NonNull OptionalLong getRemoteDevicesCount() {
|
||||
return remoteDevicesCount;
|
||||
}
|
||||
|
||||
public @NonNull OptionalLong getParticipantCount() {
|
||||
boolean includeSelf = groupCallState == WebRtcViewModel.GroupCallState.CONNECTED_AND_JOINED;
|
||||
|
||||
return remoteDevicesCount.map(l -> l + (includeSelf ? 1L : 0L))
|
||||
.or(() -> includeSelf ? OptionalLong.of(1L) : OptionalLong.empty());
|
||||
}
|
||||
|
||||
public static @NonNull CallParticipantsState update(@NonNull CallParticipantsState oldState,
|
||||
@NonNull WebRtcViewModel webRtcViewModel,
|
||||
boolean enableVideo)
|
||||
|
@@ -28,6 +28,7 @@ import androidx.transition.TransitionSet;
|
||||
import androidx.viewpager2.widget.MarginPageTransformer;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.annimon.stream.OptionalLong;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
@@ -262,16 +263,16 @@ public class WebRtcCallView extends FrameLayout {
|
||||
pages.add(WebRtcCallParticipantsPage.forSingleParticipant(state.getFocusedParticipant(), state.isInPipMode()));
|
||||
}
|
||||
|
||||
if ((state.getGroupCallState().isNotIdle() && state.getRemoteDevicesCount() > 0) || state.getGroupCallState().isConnected()) {
|
||||
if ((state.getGroupCallState().isNotIdle() && state.getRemoteDevicesCount().orElse(0) > 0) || state.getGroupCallState().isConnected()) {
|
||||
recipientName.setText(state.getRemoteParticipantsDescription(getContext()));
|
||||
} else if (state.getGroupCallState().isNotIdle()) {
|
||||
recipientName.setText(getContext().getString(R.string.WebRtcCallView__s_group_call, Recipient.resolved(recipientId).getDisplayName(getContext())));
|
||||
}
|
||||
|
||||
if (state.getGroupCallState().isNotIdle() && participantCount != null) {
|
||||
boolean includeSelf = state.getGroupCallState() == WebRtcViewModel.GroupCallState.CONNECTED_AND_JOINED;
|
||||
|
||||
participantCount.setText(String.valueOf(state.getRemoteDevicesCount() + (includeSelf ? 1 : 0)));
|
||||
participantCount.setText(state.getParticipantCount()
|
||||
.mapToObj(String::valueOf).orElse("\u2014"));
|
||||
participantCount.setEnabled(state.getParticipantCount().isPresent());
|
||||
}
|
||||
|
||||
pagerAdapter.submitList(pages);
|
||||
|
@@ -170,7 +170,7 @@ public class WebRtcCallViewModel extends ViewModel {
|
||||
webRtcViewModel.isBluetoothAvailable(),
|
||||
Util.hasItems(webRtcViewModel.getRemoteParticipants()),
|
||||
repository.getAudioOutput(),
|
||||
webRtcViewModel.getRemoteDevicesCount(),
|
||||
webRtcViewModel.getRemoteDevicesCount().orElse(0),
|
||||
webRtcViewModel.getParticipantLimit());
|
||||
|
||||
if (webRtcViewModel.getState() == WebRtcViewModel.State.CALL_CONNECTED && callConnectedTime == -1) {
|
||||
@@ -274,9 +274,9 @@ public class WebRtcCallViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
private boolean shouldShowSpeakerHint(@NonNull CallParticipantsState state) {
|
||||
return !state.isInPipMode() &&
|
||||
state.getRemoteDevicesCount() > 1 &&
|
||||
state.getGroupCallState().isConnected() &&
|
||||
return !state.isInPipMode() &&
|
||||
state.getRemoteDevicesCount().orElse(0) > 1 &&
|
||||
state.getGroupCallState().isConnected() &&
|
||||
!SignalStore.tooltips().hasSeenGroupCallSpeakerView();
|
||||
}
|
||||
|
||||
|
@@ -15,6 +15,7 @@ import androidx.lifecycle.ViewModelProviders;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.annimon.stream.OptionalLong;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
@@ -88,19 +89,21 @@ public class CallParticipantsListDialog extends BottomSheetDialogFragment {
|
||||
private void updateList(@NonNull CallParticipantsState callParticipantsState) {
|
||||
List<MappingModel<?>> items = new ArrayList<>();
|
||||
|
||||
boolean includeSelf = callParticipantsState.getGroupCallState() == WebRtcViewModel.GroupCallState.CONNECTED_AND_JOINED;
|
||||
boolean includeSelf = callParticipantsState.getGroupCallState() == WebRtcViewModel.GroupCallState.CONNECTED_AND_JOINED;
|
||||
OptionalLong headerCount = callParticipantsState.getParticipantCount();
|
||||
|
||||
items.add(new CallParticipantsListHeader((int) callParticipantsState.getRemoteDevicesCount() + (includeSelf ? 1 : 0)));
|
||||
headerCount.executeIfPresent(count -> {
|
||||
items.add(new CallParticipantsListHeader((int) count));
|
||||
|
||||
if (includeSelf) {
|
||||
items.add(new CallParticipantViewState(callParticipantsState.getLocalParticipant()));
|
||||
}
|
||||
if (includeSelf) {
|
||||
items.add(new CallParticipantViewState(callParticipantsState.getLocalParticipant()));
|
||||
}
|
||||
|
||||
for (CallParticipant callParticipant : callParticipantsState.getAllRemoteParticipants()) {
|
||||
items.add(new CallParticipantViewState(callParticipant));
|
||||
}
|
||||
for (CallParticipant callParticipant : callParticipantsState.getAllRemoteParticipants()) {
|
||||
items.add(new CallParticipantViewState(callParticipant));
|
||||
}
|
||||
});
|
||||
|
||||
adapter.submitList(items);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.events;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.annimon.stream.OptionalLong;
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink;
|
||||
@@ -94,7 +95,7 @@ public class WebRtcViewModel {
|
||||
private final CallParticipant localParticipant;
|
||||
private final List<CallParticipant> remoteParticipants;
|
||||
private final Set<RecipientId> identityChangedRecipients;
|
||||
private final long remoteDevicesCount;
|
||||
private final OptionalLong remoteDevicesCount;
|
||||
private final Long participantLimit;
|
||||
|
||||
public WebRtcViewModel(@NonNull WebRtcServiceState state) {
|
||||
@@ -154,7 +155,7 @@ public class WebRtcViewModel {
|
||||
return identityChangedRecipients;
|
||||
}
|
||||
|
||||
public long getRemoteDevicesCount() {
|
||||
public OptionalLong getRemoteDevicesCount() {
|
||||
return remoteDevicesCount;
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,8 @@ package org.thoughtcrime.securesms.service.webrtc.state;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.annimon.stream.OptionalLong;
|
||||
|
||||
import org.signal.ringrtc.GroupCall;
|
||||
import org.thoughtcrime.securesms.events.CallParticipant;
|
||||
import org.thoughtcrime.securesms.events.CallParticipantId;
|
||||
@@ -35,7 +37,7 @@ public class CallInfoState {
|
||||
GroupCall groupCall;
|
||||
WebRtcViewModel.GroupCallState groupState;
|
||||
Set<RecipientId> identityChangedRecipients;
|
||||
long remoteDevicesCount;
|
||||
OptionalLong remoteDevicesCount;
|
||||
Long participantLimit;
|
||||
|
||||
public CallInfoState() {
|
||||
@@ -48,7 +50,7 @@ public class CallInfoState {
|
||||
null,
|
||||
WebRtcViewModel.GroupCallState.IDLE,
|
||||
Collections.emptySet(),
|
||||
0L,
|
||||
OptionalLong.empty(),
|
||||
null);
|
||||
}
|
||||
|
||||
@@ -75,7 +77,7 @@ public class CallInfoState {
|
||||
@Nullable GroupCall groupCall,
|
||||
@NonNull WebRtcViewModel.GroupCallState groupState,
|
||||
@NonNull Set<RecipientId> identityChangedRecipients,
|
||||
long remoteDevicesCount,
|
||||
@NonNull OptionalLong remoteDevicesCount,
|
||||
@Nullable Long participantLimit)
|
||||
{
|
||||
this.callState = callState;
|
||||
@@ -147,7 +149,7 @@ public class CallInfoState {
|
||||
return identityChangedRecipients;
|
||||
}
|
||||
|
||||
public long getRemoteDevicesCount() {
|
||||
public OptionalLong getRemoteDevicesCount() {
|
||||
return remoteDevicesCount;
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,8 @@ package org.thoughtcrime.securesms.service.webrtc.state;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.annimon.stream.OptionalLong;
|
||||
|
||||
import org.signal.ringrtc.GroupCall;
|
||||
import org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink;
|
||||
import org.thoughtcrime.securesms.events.CallParticipant;
|
||||
@@ -258,7 +260,7 @@ public class WebRtcServiceStateBuilder {
|
||||
}
|
||||
|
||||
public @NonNull CallInfoStateBuilder remoteDevicesCount(long remoteDevicesCount) {
|
||||
toBuild.remoteDevicesCount = remoteDevicesCount;
|
||||
toBuild.remoteDevicesCount = OptionalLong.of(remoteDevicesCount);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user