Convert WebRtcCallingActivity to Kotlin.

This commit is contained in:
Alex Hart
2025-01-31 12:52:45 -04:00
committed by Greyson Parrelli
parent 386ebaa6df
commit fee7d20cc6
10 changed files with 1219 additions and 1357 deletions

View File

@@ -128,7 +128,7 @@
<meta-data android:name="firebase_messaging_auto_init_enabled" android:value="false" /> <meta-data android:name="firebase_messaging_auto_init_enabled" android:value="false" />
<meta-data android:name="android.webkit.WebView.MetricsOptOut" android:value="true" /> <meta-data android:name="android.webkit.WebView.MetricsOptOut" android:value="true" />
<activity android:name=".WebRtcCallActivity" <activity android:name=".components.webrtc.v2.WebRtcCallActivity"
android:theme="@style/TextSecure.DarkTheme.WebRTCCall" android:theme="@style/TextSecure.DarkTheme.WebRTCCall"
android:excludeFromRecents="true" android:excludeFromRecents="true"
android:supportsPictureInPicture="true" android:supportsPictureInPicture="true"

View File

@@ -68,7 +68,7 @@ class CallOverflowPopupWindow(private val activity: FragmentActivity, parentView
PopupWindowCompat.showAsDropDown(this, anchor, xOffset, yOffset, Gravity.NO_GRAVITY) PopupWindowCompat.showAsDropDown(this, anchor, xOffset, yOffset, Gravity.NO_GRAVITY)
} }
interface RaisedHandDelegate { fun interface RaisedHandDelegate {
fun isSelfHandRaised(): Boolean fun isSelfHandRaised(): Boolean
} }
} }

View File

@@ -11,7 +11,7 @@ import androidx.core.app.NotificationManagerCompat;
import org.signal.core.util.PendingIntentFlags; import org.signal.core.util.PendingIntentFlags;
import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.WebRtcCallActivity; import org.thoughtcrime.securesms.components.webrtc.v2.CallIntent;
import org.thoughtcrime.securesms.notifications.NotificationChannels; import org.thoughtcrime.securesms.notifications.NotificationChannels;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
@@ -26,7 +26,7 @@ public final class GroupCallSafetyNumberChangeNotificationUtil {
} }
public static void showNotification(@NonNull Context context, @NonNull Recipient recipient) { public static void showNotification(@NonNull Context context, @NonNull Recipient recipient) {
Intent contentIntent = new Intent(context, WebRtcCallActivity.class); Intent contentIntent = new Intent(context, CallIntent.getActivityClass());
contentIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); contentIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, contentIntent, PendingIntentFlags.mutable()); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, contentIntent, PendingIntentFlags.mutable());

View File

@@ -46,8 +46,8 @@ import io.reactivex.rxjava3.kotlin.subscribeBy
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
import org.signal.core.util.dp import org.signal.core.util.dp
import org.signal.core.util.logging.Log import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.BaseActivity
import org.thoughtcrime.securesms.R import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.WebRtcCallActivity
import org.thoughtcrime.securesms.calls.links.EditCallLinkNameDialogFragment import org.thoughtcrime.securesms.calls.links.EditCallLinkNameDialogFragment
import org.thoughtcrime.securesms.components.InsetAwareConstraintLayout import org.thoughtcrime.securesms.components.InsetAwareConstraintLayout
import org.thoughtcrime.securesms.components.webrtc.CallOverflowPopupWindow import org.thoughtcrime.securesms.components.webrtc.CallOverflowPopupWindow
@@ -65,7 +65,7 @@ import kotlin.time.Duration.Companion.seconds
* Brain for rendering the call controls and info within a bottom sheet when we display the activity in portrait mode. * Brain for rendering the call controls and info within a bottom sheet when we display the activity in portrait mode.
*/ */
class ControlsAndInfoController private constructor( class ControlsAndInfoController private constructor(
private val webRtcCallActivity: WebRtcCallActivity, private val activity: BaseActivity,
private val webRtcCallView: WebRtcCallView, private val webRtcCallView: WebRtcCallView,
private val overflowPopupWindow: CallOverflowPopupWindow, private val overflowPopupWindow: CallOverflowPopupWindow,
private val viewModel: WebRtcCallViewModel, private val viewModel: WebRtcCallViewModel,
@@ -74,13 +74,13 @@ class ControlsAndInfoController private constructor(
) : Disposable by disposables { ) : Disposable by disposables {
constructor( constructor(
webRtcCallActivity: WebRtcCallActivity, activity: BaseActivity,
webRtcCallView: WebRtcCallView, webRtcCallView: WebRtcCallView,
overflowPopupWindow: CallOverflowPopupWindow, overflowPopupWindow: CallOverflowPopupWindow,
viewModel: WebRtcCallViewModel, viewModel: WebRtcCallViewModel,
controlsAndInfoViewModel: ControlsAndInfoViewModel controlsAndInfoViewModel: ControlsAndInfoViewModel
) : this( ) : this(
webRtcCallActivity, activity,
webRtcCallView, webRtcCallView,
overflowPopupWindow, overflowPopupWindow,
viewModel, viewModel,
@@ -108,15 +108,15 @@ class ControlsAndInfoController private constructor(
private val aboveControlsGuideline: Guideline = webRtcCallView.findViewById(R.id.call_screen_above_controls_guideline) private val aboveControlsGuideline: Guideline = webRtcCallView.findViewById(R.id.call_screen_above_controls_guideline)
private val toggleCameraDirectionView: View = webRtcCallView.findViewById(R.id.call_screen_camera_direction_toggle) private val toggleCameraDirectionView: View = webRtcCallView.findViewById(R.id.call_screen_camera_direction_toggle)
private val callControls: ConstraintLayout = webRtcCallView.findViewById(R.id.call_controls_constraint_layout) private val callControls: ConstraintLayout = webRtcCallView.findViewById(R.id.call_controls_constraint_layout)
private val isLandscape = webRtcCallActivity.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE private val isLandscape = activity.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
private val waitingToBeLetInProgressDrawable = IndeterminateDrawable.createCircularDrawable( private val waitingToBeLetInProgressDrawable = IndeterminateDrawable.createCircularDrawable(
webRtcCallActivity, activity,
CircularProgressIndicatorSpec(webRtcCallActivity, null).apply { CircularProgressIndicatorSpec(activity, null).apply {
indicatorSize = 20.dp indicatorSize = 20.dp
indicatorInset = 0.dp indicatorInset = 0.dp
trackThickness = 2.dp trackThickness = 2.dp
trackCornerRadius = 1.dp trackCornerRadius = 1.dp
indicatorColors = intArrayOf(ContextCompat.getColor(webRtcCallActivity, R.color.signal_colorOnBackground)) indicatorColors = intArrayOf(ContextCompat.getColor(activity, R.color.signal_colorOnBackground))
trackColor = Color.TRANSPARENT trackColor = Color.TRANSPARENT
} }
) )
@@ -133,7 +133,7 @@ class ControlsAndInfoController private constructor(
private var previousCallControlHeightData = HeightData() private var previousCallControlHeightData = HeightData()
private var controlState: WebRtcControls = WebRtcControls.NONE private var controlState: WebRtcControls = WebRtcControls.NONE
private val callInfoCallbacks = CallInfoCallbacks(webRtcCallActivity, controlsAndInfoViewModel) private val callInfoCallbacks = CallInfoCallbacks(activity, controlsAndInfoViewModel)
init { init {
raiseHandComposeView.apply { raiseHandComposeView.apply {
@@ -179,9 +179,9 @@ class ControlsAndInfoController private constructor(
hide(delay = HIDE_CONTROL_DELAY) hide(delay = HIDE_CONTROL_DELAY)
} }
webRtcCallActivity activity
.supportFragmentManager .supportFragmentManager
.setFragmentResultListener(EditCallLinkNameDialogFragment.RESULT_KEY, webRtcCallActivity) { resultKey, bundle -> .setFragmentResultListener(EditCallLinkNameDialogFragment.RESULT_KEY, activity) { resultKey, bundle ->
if (bundle.containsKey(resultKey)) { if (bundle.containsKey(resultKey)) {
setName(bundle.getString(resultKey)!!) setName(bundle.getString(resultKey)!!)
} }
@@ -193,7 +193,7 @@ class ControlsAndInfoController private constructor(
.setTopRightCorner(CornerFamily.ROUNDED, 18.dp.toFloat()) .setTopRightCorner(CornerFamily.ROUNDED, 18.dp.toFloat())
.build() .build()
).apply { ).apply {
fillColor = ColorStateList.valueOf(ContextCompat.getColor(webRtcCallActivity, R.color.signal_colorSurface)) fillColor = ColorStateList.valueOf(ContextCompat.getColor(activity, R.color.signal_colorSurface))
} }
behavior.isHideable = true behavior.isHideable = true
@@ -440,7 +440,7 @@ class ControlsAndInfoController private constructor(
} }
private fun toastFailure() { private fun toastFailure() {
Toast.makeText(webRtcCallActivity, R.string.CallLinkDetailsFragment__couldnt_save_changes, Toast.LENGTH_LONG).show() Toast.makeText(activity, R.string.CallLinkDetailsFragment__couldnt_save_changes, Toast.LENGTH_LONG).show()
} }
private fun ConstraintSet.setControlConstraints(@IdRes viewId: Int, visible: Boolean, @Px horizontalMargins: Int) { private fun ConstraintSet.setControlConstraints(@IdRes viewId: Int, visible: Boolean, @Px horizontalMargins: Int) {

View File

@@ -8,7 +8,6 @@ package org.thoughtcrime.securesms.components.webrtc.v2
import android.app.Activity import android.app.Activity
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import org.thoughtcrime.securesms.WebRtcCallActivity
import org.thoughtcrime.securesms.keyvalue.SignalStore import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.util.RemoteConfig import org.thoughtcrime.securesms.util.RemoteConfig
@@ -23,7 +22,8 @@ class CallIntent(
private const val CALL_INTENT_PREFIX = "CallIntent" private const val CALL_INTENT_PREFIX = "CallIntent"
private fun getActivityClass(): Class<out Activity> = if (RemoteConfig.newCallUi || SignalStore.internal.newCallingUi) { @JvmStatic
fun getActivityClass(): Class<out Activity> = if (RemoteConfig.newCallUi || SignalStore.internal.newCallingUi) {
CallActivity::class.java CallActivity::class.java
} else { } else {
WebRtcCallActivity::class.java WebRtcCallActivity::class.java

View File

@@ -34,7 +34,6 @@ import org.signal.ringrtc.NetworkRoute;
import org.signal.ringrtc.PeekInfo; import org.signal.ringrtc.PeekInfo;
import org.signal.ringrtc.Remote; import org.signal.ringrtc.Remote;
import org.signal.storageservice.protos.groups.GroupExternalCredential; import org.signal.storageservice.protos.groups.GroupExternalCredential;
import org.thoughtcrime.securesms.WebRtcCallActivity;
import org.thoughtcrime.securesms.components.webrtc.v2.CallIntent; import org.thoughtcrime.securesms.components.webrtc.v2.CallIntent;
import org.thoughtcrime.securesms.crypto.SealedSenderAccessUtil; import org.thoughtcrime.securesms.crypto.SealedSenderAccessUtil;
import org.thoughtcrime.securesms.database.CallLinkTable; import org.thoughtcrime.securesms.database.CallLinkTable;
@@ -538,7 +537,7 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
return false; return false;
} }
context.startActivity(new Intent(context, WebRtcCallActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); context.startActivity(new Intent(context, CallIntent.getActivityClass()).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
return true; return true;
} }

View File

@@ -29,9 +29,7 @@ import org.signal.core.util.concurrent.SimpleTask;
import org.signal.core.util.logging.Log; import org.signal.core.util.logging.Log;
import org.signal.ringrtc.CallLinkRootKey; import org.signal.ringrtc.CallLinkRootKey;
import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.WebRtcCallActivity;
import org.thoughtcrime.securesms.calls.links.CallLinks; import org.thoughtcrime.securesms.calls.links.CallLinks;
import org.thoughtcrime.securesms.components.webrtc.v2.CallActivity;
import org.thoughtcrime.securesms.components.webrtc.v2.CallIntent; import org.thoughtcrime.securesms.components.webrtc.v2.CallIntent;
import org.thoughtcrime.securesms.contacts.sync.ContactDiscovery; import org.thoughtcrime.securesms.contacts.sync.ContactDiscovery;
import org.thoughtcrime.securesms.conversation.ConversationIntents; import org.thoughtcrime.securesms.conversation.ConversationIntents;

View File

@@ -7,11 +7,11 @@ import android.os.Bundle;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.text.TextUtils; import android.text.TextUtils;
import org.signal.core.util.concurrent.SimpleTask;
import org.signal.core.util.logging.Log; import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.WebRtcCallActivity; import org.thoughtcrime.securesms.components.webrtc.v2.CallIntent;
import org.thoughtcrime.securesms.dependencies.AppDependencies; import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.signal.core.util.concurrent.SimpleTask;
public class VoiceCallShare extends Activity { public class VoiceCallShare extends Activity {
@@ -40,7 +40,7 @@ public class VoiceCallShare extends Activity {
AppDependencies.getSignalCallManager().startOutgoingAudioCall(recipient); AppDependencies.getSignalCallManager().startOutgoingAudioCall(recipient);
} }
Intent activityIntent = new Intent(this, WebRtcCallActivity.class); Intent activityIntent = new Intent(this, CallIntent.getActivityClass());
activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(activityIntent); startActivity(activityIntent);
} }