From 355c3ff1555cdaee7b5a52d9618fd2fc4fce2d23 Mon Sep 17 00:00:00 2001 From: Alex Hart Date: Thu, 6 Feb 2025 16:00:34 -0400 Subject: [PATCH] Remove old call participant dialog. --- .../CallParticipantViewHolder.java | 32 ----- .../CallParticipantViewState.java | 53 --------- .../CallParticipantsListAdapter.java | 14 --- .../CallParticipantsListDialog.java | 111 ------------------ .../CallParticipantsListHeader.java | 31 ----- .../CallParticipantsListHeaderViewHolder.java | 24 ---- .../webrtc/v2/WebRtcCallActivity.kt | 2 - 7 files changed, 267 deletions(-) delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantViewHolder.java delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantViewState.java delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantsListAdapter.java delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantsListDialog.java delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantsListHeader.java delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantsListHeaderViewHolder.java diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantViewHolder.java b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantViewHolder.java deleted file mode 100644 index 673967eb11..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantViewHolder.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.thoughtcrime.securesms.components.webrtc.participantslist; - -import android.view.View; - -import androidx.annotation.NonNull; - -import org.thoughtcrime.securesms.R; -import org.thoughtcrime.securesms.util.viewholders.RecipientViewHolder; - -public class CallParticipantViewHolder extends RecipientViewHolder { - - private final View videoMuted; - private final View audioMuted; - private final View screenSharing; - - public CallParticipantViewHolder(@NonNull View itemView) { - super(itemView, null); - - videoMuted = findViewById(R.id.call_participant_video_muted); - audioMuted = findViewById(R.id.call_participant_audio_muted); - screenSharing = findViewById(R.id.call_participant_screen_sharing); - } - - @Override - public void bind(@NonNull CallParticipantViewState model) { - super.bind(model); - - videoMuted.setVisibility(model.getVideoMutedVisibility()); - audioMuted.setVisibility(model.getAudioMutedVisibility()); - screenSharing.setVisibility(model.getScreenSharingVisibility()); - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantViewState.java b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantViewState.java deleted file mode 100644 index d35f3e6c88..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantViewState.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.thoughtcrime.securesms.components.webrtc.participantslist; - -import android.content.Context; -import android.view.View; - -import androidx.annotation.NonNull; - -import org.thoughtcrime.securesms.events.CallParticipant; -import org.thoughtcrime.securesms.recipients.Recipient; -import org.thoughtcrime.securesms.util.viewholders.RecipientMappingModel; - -public final class CallParticipantViewState extends RecipientMappingModel { - - private final CallParticipant callParticipant; - - CallParticipantViewState(@NonNull CallParticipant callParticipant) { - this.callParticipant = callParticipant; - } - - @Override - public @NonNull Recipient getRecipient() { - return callParticipant.getRecipient(); - } - - @Override - public @NonNull String getName(@NonNull Context context) { - return callParticipant.getRecipientDisplayName(context); - } - - public int getVideoMutedVisibility() { - return callParticipant.isVideoEnabled() ? View.GONE : View.VISIBLE; - } - - public int getAudioMutedVisibility() { - return callParticipant.isMicrophoneEnabled() ? View.GONE : View.VISIBLE; - } - - public int getScreenSharingVisibility() { - return callParticipant.isScreenSharing() ? View.VISIBLE : View.GONE; - } - - @Override - public boolean areItemsTheSame(@NonNull CallParticipantViewState newItem) { - return callParticipant.getCallParticipantId().equals(newItem.callParticipant.getCallParticipantId()); - } - - @Override - public boolean areContentsTheSame(@NonNull CallParticipantViewState newItem) { - return super.areContentsTheSame(newItem) && - callParticipant.isVideoEnabled() == newItem.callParticipant.isVideoEnabled() && - callParticipant.isMicrophoneEnabled() == newItem.callParticipant.isMicrophoneEnabled(); - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantsListAdapter.java b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantsListAdapter.java deleted file mode 100644 index 16d3046183..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantsListAdapter.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.thoughtcrime.securesms.components.webrtc.participantslist; - -import org.thoughtcrime.securesms.R; -import org.thoughtcrime.securesms.util.adapter.mapping.LayoutFactory; -import org.thoughtcrime.securesms.util.adapter.mapping.MappingAdapter; - -public class CallParticipantsListAdapter extends MappingAdapter { - - CallParticipantsListAdapter() { - registerFactory(CallParticipantsListHeader.class, new LayoutFactory<>(CallParticipantsListHeaderViewHolder::new, R.layout.call_participants_list_header)); - registerFactory(CallParticipantViewState.class, new LayoutFactory<>(CallParticipantViewHolder::new, R.layout.call_participants_list_item)); - } - -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantsListDialog.java b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantsListDialog.java deleted file mode 100644 index 00a86f9848..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantsListDialog.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.thoughtcrime.securesms.components.webrtc.participantslist; - -import android.os.Bundle; -import android.view.ContextThemeWrapper; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.fragment.app.DialogFragment; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentManager; -import androidx.lifecycle.ViewModelProvider; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.annimon.stream.OptionalLong; -import com.google.android.material.bottomsheet.BottomSheetDialogFragment; - -import org.signal.core.util.concurrent.LifecycleDisposable; -import org.thoughtcrime.securesms.R; -import org.thoughtcrime.securesms.components.webrtc.CallParticipantsState; -import org.thoughtcrime.securesms.components.webrtc.v2.WebRtcCallViewModel; -import org.thoughtcrime.securesms.events.CallParticipant; -import org.thoughtcrime.securesms.events.WebRtcViewModel; -import org.thoughtcrime.securesms.util.BottomSheetUtil; -import org.thoughtcrime.securesms.util.adapter.mapping.MappingModel; - -import java.util.ArrayList; -import java.util.List; - -public class CallParticipantsListDialog extends BottomSheetDialogFragment { - - private RecyclerView participantList; - private CallParticipantsListAdapter adapter; - - private final LifecycleDisposable lifecycleDisposable = new LifecycleDisposable(); - - public static void show(@NonNull FragmentManager manager) { - CallParticipantsListDialog fragment = new CallParticipantsListDialog(); - - fragment.show(manager, BottomSheetUtil.STANDARD_BOTTOM_SHEET_FRAGMENT_TAG); - } - - public static void dismiss(@NonNull FragmentManager manager) { - Fragment fragment = manager.findFragmentByTag(BottomSheetUtil.STANDARD_BOTTOM_SHEET_FRAGMENT_TAG); - if (fragment instanceof CallParticipantsListDialog) { - ((CallParticipantsListDialog) fragment).dismissAllowingStateLoss(); - } - } - - @Override - public void show(@NonNull FragmentManager manager, @Nullable String tag) { - BottomSheetUtil.show(manager, tag, this); - } - - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - setStyle(DialogFragment.STYLE_NORMAL, R.style.Theme_Signal_RoundedBottomSheet); - super.onCreate(savedInstanceState); - } - - @Override - public @NonNull View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(inflater.getContext(), R.style.TextSecure_DarkTheme); - LayoutInflater themedInflater = LayoutInflater.from(contextThemeWrapper); - - participantList = (RecyclerView) themedInflater.inflate(R.layout.call_participants_list_dialog, container, false); - - return participantList; - } - - @Override - public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { - final WebRtcCallViewModel viewModel = new ViewModelProvider(requireActivity()).get(WebRtcCallViewModel.class); - - initializeList(); - - lifecycleDisposable.bindTo(getViewLifecycleOwner()); - lifecycleDisposable.add(viewModel.getCallParticipantsState().subscribe(this::updateList)); - } - - private void initializeList() { - adapter = new CallParticipantsListAdapter(); - - participantList.setLayoutManager(new LinearLayoutManager(requireContext())); - participantList.setAdapter(adapter); - } - - private void updateList(@NonNull CallParticipantsState callParticipantsState) { - List> items = new ArrayList<>(); - - boolean includeSelf = callParticipantsState.getGroupCallState() == WebRtcViewModel.GroupCallState.CONNECTED_AND_JOINED; - OptionalLong headerCount = callParticipantsState.getParticipantCount(); - - headerCount.executeIfPresent(count -> { - items.add(new CallParticipantsListHeader((int) count)); - - if (includeSelf) { - items.add(new CallParticipantViewState(callParticipantsState.getLocalParticipant())); - } - - for (CallParticipant callParticipant : callParticipantsState.getAllRemoteParticipants()) { - items.add(new CallParticipantViewState(callParticipant)); - } - }); - - adapter.submitList(items); - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantsListHeader.java b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantsListHeader.java deleted file mode 100644 index 1405f173a3..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantsListHeader.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.thoughtcrime.securesms.components.webrtc.participantslist; - -import android.content.Context; - -import androidx.annotation.NonNull; - -import org.thoughtcrime.securesms.R; -import org.thoughtcrime.securesms.util.adapter.mapping.MappingModel; - -public class CallParticipantsListHeader implements MappingModel { - - private int participantCount; - - public CallParticipantsListHeader(int participantCount) { - this.participantCount = participantCount; - } - - @NonNull String getHeader(@NonNull Context context) { - return context.getResources().getQuantityString(R.plurals.CallParticipantsListDialog_in_this_call, participantCount, participantCount); - } - - @Override - public boolean areItemsTheSame(@NonNull CallParticipantsListHeader newItem) { - return true; - } - - @Override - public boolean areContentsTheSame(@NonNull CallParticipantsListHeader newItem) { - return participantCount == newItem.participantCount; - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantsListHeaderViewHolder.java b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantsListHeaderViewHolder.java deleted file mode 100644 index e854af2803..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/participantslist/CallParticipantsListHeaderViewHolder.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.thoughtcrime.securesms.components.webrtc.participantslist; - -import android.view.View; -import android.widget.TextView; - -import androidx.annotation.NonNull; - -import org.thoughtcrime.securesms.R; -import org.thoughtcrime.securesms.util.adapter.mapping.MappingViewHolder; - -public class CallParticipantsListHeaderViewHolder extends MappingViewHolder { - - private final TextView headerText; - - public CallParticipantsListHeaderViewHolder(@NonNull View itemView) { - super(itemView); - headerText = findViewById(R.id.call_participants_list_header); - } - - @Override - public void bind(@NonNull CallParticipantsListHeader model) { - headerText.setText(model.getHeader(getContext())); - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/v2/WebRtcCallActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/v2/WebRtcCallActivity.kt index b3f4727c0b..848a67e136 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/v2/WebRtcCallActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/v2/WebRtcCallActivity.kt @@ -64,7 +64,6 @@ import org.thoughtcrime.securesms.components.webrtc.WebRtcControls import org.thoughtcrime.securesms.components.webrtc.WifiToCellularPopupWindow import org.thoughtcrime.securesms.components.webrtc.controls.ControlsAndInfoController import org.thoughtcrime.securesms.components.webrtc.controls.ControlsAndInfoViewModel -import org.thoughtcrime.securesms.components.webrtc.participantslist.CallParticipantsListDialog import org.thoughtcrime.securesms.components.webrtc.requests.CallLinkIncomingRequestSheet import org.thoughtcrime.securesms.conversation.ui.error.SafetyNumberChangeDialog import org.thoughtcrime.securesms.dependencies.AppDependencies @@ -591,7 +590,6 @@ class WebRtcCallActivity : BaseActivity(), SafetyNumberChangeDialog.Callback, Re private fun registerSystemPipChangeListeners() { addOnPictureInPictureModeChangedListener { - CallParticipantsListDialog.dismiss(supportFragmentManager) CallReactionScrubber.dismissCustomEmojiBottomSheet(supportFragmentManager) } }