@capgo/capacitor-stream-call 0.0.65 → 0.0.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -255,13 +255,6 @@ public class StreamCallPlugin : Plugin() {
255
255
  android.util.Log.d("StreamCallPlugin", "New Intent - Extras: $extras")
256
256
  }
257
257
 
258
- // Public method to handle ACCEPT_CALL intent from MainActivity
259
- @JvmOverloads
260
- public fun handleAcceptCallIntent(intent: android.content.Intent) {
261
- android.util.Log.d("StreamCallPlugin", "handleAcceptCallIntent called: action=${intent.action}")
262
- handleOnNewIntent(intent)
263
- }
264
-
265
258
  @OptIn(DelicateCoroutinesApi::class)
266
259
  private fun declineCall(call: Call) {
267
260
  android.util.Log.d("StreamCallPlugin", "declineCall called for call: ${call.id}")
@@ -326,37 +319,64 @@ public class StreamCallPlugin : Plugin() {
326
319
  ViewGroup.LayoutParams.MATCH_PARENT,
327
320
  ViewGroup.LayoutParams.MATCH_PARENT
328
321
  )
329
- setContent {
330
- VideoTheme {
331
- val activeCall = streamVideoClient?.state?.activeCall?.collectAsState()?.value
332
- if (activeCall != null) {
333
- val participants by activeCall.state.participants.collectAsStateWithLifecycle()
334
- val sortedParticipants by activeCall.state.sortedParticipants.collectAsStateWithLifecycle(emptyList())
335
- val callParticipants by remember(participants) {
336
- derivedStateOf {
337
- if (sortedParticipants.size > 6) {
338
- sortedParticipants
339
- } else {
340
- participants
341
- }
322
+ }
323
+ parent.addView(overlayView, 0) // Add at index 0 to ensure it's below WebView
324
+
325
+ // Initialize with active call content
326
+ setOverlayContent()
327
+
328
+ // Create barrier view (above webview for blocking interaction during call setup)
329
+ barrierView = View(context).apply {
330
+ isVisible = false
331
+ layoutParams = FrameLayout.LayoutParams(
332
+ ViewGroup.LayoutParams.MATCH_PARENT,
333
+ ViewGroup.LayoutParams.MATCH_PARENT
334
+ )
335
+ setBackgroundColor(Color.parseColor("#1a242c"))
336
+ }
337
+ parent.addView(barrierView, parent.indexOfChild(bridge?.webView) + 1) // Add above WebView
338
+ }
339
+
340
+ /**
341
+ * Centralized function to set the overlay content with call UI.
342
+ * This handles all the common Compose UI setup for video calls.
343
+ */
344
+ private fun setOverlayContent(call: Call? = null) {
345
+ overlayView?.setContent {
346
+ VideoTheme {
347
+ val activeCall = call ?: streamVideoClient?.state?.activeCall?.collectAsState()?.value
348
+ if (activeCall != null) {
349
+ val participants by activeCall.state.participants.collectAsStateWithLifecycle()
350
+ val sortedParticipants by activeCall.state.sortedParticipants.collectAsStateWithLifecycle(emptyList())
351
+ val callParticipants by remember(participants) {
352
+ derivedStateOf {
353
+ if (sortedParticipants.size > 6) {
354
+ sortedParticipants
355
+ } else {
356
+ participants
342
357
  }
343
358
  }
359
+ }
344
360
 
345
- val currentLocal by activeCall.state.me.collectAsStateWithLifecycle()
346
-
347
- CallContent(
348
- call = activeCall,
349
- onBackPressed = { /* Handle back press if needed */ },
350
- videoRenderer = { videoModifier, videoCall, videoParticipant, videoStyle ->
351
- ParticipantVideo(
352
- modifier = videoModifier,
353
- call = videoCall,
354
- participant = videoParticipant,
355
- style = videoStyle,
356
- actionsContent = {_, _, _ -> {}}
357
- )
358
- },
359
- floatingVideoRenderer = { call, parentSize ->
361
+ val currentLocal by activeCall.state.me.collectAsStateWithLifecycle()
362
+
363
+ CallContent(
364
+ call = activeCall,
365
+ onBackPressed = { /* Handle back press if needed */ },
366
+ controlsContent = { /* Empty to disable native controls */ },
367
+ appBarContent = { /* Empty to disable app bar with stop call button */ },
368
+ videoRenderer = { videoModifier, videoCall, videoParticipant, videoStyle ->
369
+ ParticipantVideo(
370
+ modifier = videoModifier,
371
+ call = videoCall,
372
+ participant = videoParticipant,
373
+ style = videoStyle,
374
+ actionsContent = {_, _, _ -> {}},
375
+ scalingType = VideoScalingType.SCALE_ASPECT_FIT
376
+ )
377
+ },
378
+ floatingVideoRenderer = { call, parentSize ->
379
+ currentLocal?.let {
360
380
  FloatingParticipantVideo(
361
381
  call = call,
362
382
  participant = currentLocal!!,
@@ -368,30 +388,19 @@ public class StreamCallPlugin : Plugin() {
368
388
  .fillMaxSize()
369
389
  .clip(VideoTheme.shapes.dialog),
370
390
  call = call,
371
- participant = currentLocal!!,
391
+ participant = it,
372
392
  style = RegularVideoRendererStyle().copy(isShowingConnectionQualityIndicator = false),
373
393
  actionsContent = {_, _, _ -> {}},
374
394
  )
375
395
  }
376
396
  )
377
397
  }
378
- )
379
- }
398
+
399
+ }
400
+ )
380
401
  }
381
402
  }
382
403
  }
383
- parent.addView(overlayView, 0) // Add at index 0 to ensure it's below WebView
384
-
385
- // Create barrier view (above webview for blocking interaction during call setup)
386
- barrierView = View(context).apply {
387
- isVisible = false
388
- layoutParams = FrameLayout.LayoutParams(
389
- ViewGroup.LayoutParams.MATCH_PARENT,
390
- ViewGroup.LayoutParams.MATCH_PARENT
391
- )
392
- setBackgroundColor(Color.parseColor("#1a242c"))
393
- }
394
- parent.addView(barrierView, parent.indexOfChild(bridge?.webView) + 1) // Add above WebView
395
404
  }
396
405
 
397
406
  @PluginMethod
@@ -1033,65 +1042,8 @@ public class StreamCallPlugin : Plugin() {
1033
1042
  call.microphone?.setEnabled(true)
1034
1043
  call.camera?.setEnabled(true)
1035
1044
  android.util.Log.d("StreamCallPlugin", "internalAcceptCall: Microphone and camera enabled for call ${call.id}")
1036
- overlayView?.setContent {
1037
- VideoTheme {
1038
- if (call != null) {
1039
- android.util.Log.d("StreamCallPlugin", "internalAcceptCall: Setting CallContent with active call ${call.id}")
1040
-
1041
- val participants by call.state.participants.collectAsStateWithLifecycle()
1042
- val sortedParticipants by call.state.sortedParticipants.collectAsStateWithLifecycle(emptyList())
1043
- val callParticipants by remember(participants) {
1044
- derivedStateOf {
1045
- if (sortedParticipants.size > 6) {
1046
- sortedParticipants
1047
- } else {
1048
- participants
1049
- }
1050
- }
1051
- }
1052
-
1053
- val currentLocal by call.state.me.collectAsStateWithLifecycle()
1054
-
1055
- CallContent(
1056
- call = call,
1057
- onBackPressed = { /* ... */ },
1058
- controlsContent = { /* ... */ },
1059
- appBarContent = { /* ... */ },
1060
- videoRenderer = { videoModifier, videoCall, videoParticipant, videoStyle ->
1061
- ParticipantVideo(
1062
- modifier = videoModifier,
1063
- call = videoCall,
1064
- participant = videoParticipant,
1065
- style = videoStyle,
1066
- actionsContent = {_, _, _ -> {}},
1067
- scalingType = VideoScalingType.SCALE_ASPECT_FIT
1068
- )
1069
- },
1070
- floatingVideoRenderer = { call, parentSize ->
1071
- FloatingParticipantVideo(
1072
- call = call,
1073
- participant = currentLocal!!,
1074
- style = RegularVideoRendererStyle().copy(isShowingConnectionQualityIndicator = false),
1075
- parentBounds = parentSize,
1076
- videoRenderer = { _ ->
1077
- ParticipantVideo(
1078
- modifier = Modifier
1079
- .fillMaxSize()
1080
- .clip(VideoTheme.shapes.dialog),
1081
- call = call,
1082
- participant = currentLocal!!,
1083
- style = RegularVideoRendererStyle().copy(isShowingConnectionQualityIndicator = false),
1084
- actionsContent = {_, _, _ ->},
1085
- )
1086
- }
1087
- )
1088
- }
1089
- )
1090
- } else {
1091
- android.util.Log.w("StreamCallPlugin", "internalAcceptCall: Active call is null, cannot set CallContent for call ${call.id}")
1092
- }
1093
- }
1094
- }
1045
+ android.util.Log.d("StreamCallPlugin", "internalAcceptCall: Setting CallContent with active call ${call.id}")
1046
+ setOverlayContent(call)
1095
1047
  android.util.Log.d("StreamCallPlugin", "internalAcceptCall: Content set for overlayView for call ${call.id}")
1096
1048
  overlayView?.isVisible = true
1097
1049
  android.util.Log.d("StreamCallPlugin", "internalAcceptCall: OverlayView set to visible for call ${call.id}, isVisible: ${overlayView?.isVisible}")
@@ -1111,61 +1063,8 @@ public class StreamCallPlugin : Plugin() {
1111
1063
  // Force refresh with active call from client
1112
1064
  val activeCall = streamVideoClient?.state?.activeCall?.value
1113
1065
  if (activeCall != null) {
1114
- overlayView?.setContent {
1115
- VideoTheme {
1116
- android.util.Log.d("StreamCallPlugin", "internalAcceptCall: Force refreshing CallContent with active call ${activeCall.id}")
1117
-
1118
- val participants by activeCall.state.participants.collectAsStateWithLifecycle()
1119
- val sortedParticipants by activeCall.state.sortedParticipants.collectAsStateWithLifecycle(emptyList())
1120
- val callParticipants by remember(participants) {
1121
- derivedStateOf {
1122
- if (sortedParticipants.size > 6) {
1123
- sortedParticipants
1124
- } else {
1125
- participants
1126
- }
1127
- }
1128
- }
1129
-
1130
- val currentLocal by activeCall.state.me.collectAsStateWithLifecycle()
1131
-
1132
- CallContent(
1133
- call = activeCall,
1134
- onBackPressed = { /* ... */ },
1135
- controlsContent = { /* ... */ },
1136
- appBarContent = { /* ... */ },
1137
- videoRenderer = { videoModifier, videoCall, videoParticipant, videoStyle ->
1138
- ParticipantVideo(
1139
- modifier = videoModifier,
1140
- call = videoCall,
1141
- participant = videoParticipant,
1142
- style = videoStyle,
1143
- actionsContent = {_, _, _ -> {}},
1144
- scalingType = VideoScalingType.SCALE_ASPECT_FIT
1145
- )
1146
- },
1147
- floatingVideoRenderer = { call, parentSize ->
1148
- FloatingParticipantVideo(
1149
- call = call,
1150
- participant = currentLocal!!,
1151
- style = RegularVideoRendererStyle().copy(isShowingConnectionQualityIndicator = false),
1152
- parentBounds = parentSize,
1153
- videoRenderer = { _ ->
1154
- ParticipantVideo(
1155
- modifier = Modifier
1156
- .fillMaxSize()
1157
- .clip(VideoTheme.shapes.dialog),
1158
- call = call,
1159
- participant = currentLocal!!,
1160
- style = RegularVideoRendererStyle().copy(isShowingConnectionQualityIndicator = false),
1161
- actionsContent = {_, _, _ -> {}},
1162
- )
1163
- }
1164
- )
1165
- }
1166
- )
1167
- }
1168
- }
1066
+ android.util.Log.d("StreamCallPlugin", "internalAcceptCall: Force refreshing CallContent with active call ${activeCall.id}")
1067
+ setOverlayContent(activeCall)
1169
1068
  android.util.Log.d("StreamCallPlugin", "internalAcceptCall: Content force refreshed for call ${activeCall.id}")
1170
1069
  } else {
1171
1070
  android.util.Log.w("StreamCallPlugin", "internalAcceptCall: Active call is null during force refresh for call ${call.id}")
@@ -1424,59 +1323,7 @@ public class StreamCallPlugin : Plugin() {
1424
1323
  return@runOnMainThread
1425
1324
  }
1426
1325
 
1427
- overlayView?.setContent {
1428
- VideoTheme {
1429
- val participants by call.state.participants.collectAsStateWithLifecycle()
1430
- val sortedParticipants by call.state.sortedParticipants.collectAsStateWithLifecycle(emptyList())
1431
- val callParticipants by remember(participants) {
1432
- derivedStateOf {
1433
- if (sortedParticipants.size > 6) {
1434
- sortedParticipants
1435
- } else {
1436
- participants
1437
- }
1438
- }
1439
- }
1440
-
1441
- val currentLocal by call.state.me.collectAsStateWithLifecycle()
1442
-
1443
- CallContent(
1444
- call = call,
1445
- onBackPressed = { /* Handle back press if needed */ },
1446
- controlsContent = { /* Empty to disable native controls */ },
1447
- appBarContent = { /* Empty to disable app bar with stop call button */ },
1448
- videoRenderer = { videoModifier, videoCall, videoParticipant, videoStyle ->
1449
- ParticipantVideo(
1450
- modifier = videoModifier,
1451
- call = videoCall,
1452
- participant = videoParticipant,
1453
- style = videoStyle,
1454
- actionsContent = {_, _, _ -> {}},
1455
- scalingType = VideoScalingType.SCALE_ASPECT_FIT
1456
- )
1457
- },
1458
- floatingVideoRenderer = { call, parentSize ->
1459
- FloatingParticipantVideo(
1460
- call = call,
1461
- participant = currentLocal!!,
1462
- style = RegularVideoRendererStyle().copy(isShowingConnectionQualityIndicator = false),
1463
- parentBounds = parentSize,
1464
- videoRenderer = { _ ->
1465
- ParticipantVideo(
1466
- modifier = Modifier
1467
- .fillMaxSize()
1468
- .clip(VideoTheme.shapes.dialog),
1469
- call = call,
1470
- participant = currentLocal!!,
1471
- style = RegularVideoRendererStyle().copy(isShowingConnectionQualityIndicator = false),
1472
- actionsContent = {_, _, _ -> {}},
1473
- )
1474
- }
1475
- )
1476
- }
1477
- )
1478
- }
1479
- }
1326
+ setOverlayContent(call)
1480
1327
  overlayView?.isVisible = false
1481
1328
  bridge?.webView?.setBackgroundColor(Color.WHITE) // Restore webview opacity
1482
1329
 
@@ -1646,62 +1493,7 @@ public class StreamCallPlugin : Plugin() {
1646
1493
 
1647
1494
  bridge?.webView?.setBackgroundColor(Color.TRANSPARENT) // Make webview transparent
1648
1495
  bridge?.webView?.bringToFront() // Ensure WebView is on top and transparent
1649
- overlayView?.setContent {
1650
- VideoTheme {
1651
- if (streamCall != null) {
1652
-
1653
- val participants by streamCall.state.participants.collectAsStateWithLifecycle()
1654
- val sortedParticipants by streamCall.state.sortedParticipants.collectAsStateWithLifecycle(emptyList())
1655
- val callParticipants by remember(participants) {
1656
- derivedStateOf {
1657
- if (sortedParticipants.size > 6) {
1658
- sortedParticipants
1659
- } else {
1660
- participants
1661
- }
1662
- }
1663
- }
1664
-
1665
- val currentLocal by streamCall.state.me.collectAsStateWithLifecycle()
1666
-
1667
- CallContent(
1668
- call = streamCall,
1669
- onBackPressed = { /* Handle back press if needed */ },
1670
- controlsContent = { /* Empty to disable native controls */ },
1671
- appBarContent = { /* Empty to disable app bar with stop call button */ },
1672
- videoRenderer = { videoModifier, videoCall, videoParticipant, videoStyle ->
1673
- ParticipantVideo(
1674
- modifier = videoModifier,
1675
- call = videoCall,
1676
- participant = videoParticipant,
1677
- style = videoStyle,
1678
- actionsContent = {_, _, _ -> {}},
1679
- scalingType = VideoScalingType.SCALE_ASPECT_FIT
1680
- )
1681
- },
1682
- floatingVideoRenderer = { call, parentSize ->
1683
- FloatingParticipantVideo(
1684
- call = call,
1685
- participant = currentLocal!!,
1686
- style = RegularVideoRendererStyle().copy(isShowingConnectionQualityIndicator = false),
1687
- parentBounds = parentSize,
1688
- videoRenderer = { _ ->
1689
- ParticipantVideo(
1690
- modifier = Modifier
1691
- .fillMaxSize()
1692
- .clip(VideoTheme.shapes.dialog),
1693
- call = call,
1694
- participant = currentLocal!!,
1695
- style = RegularVideoRendererStyle().copy(isShowingConnectionQualityIndicator = false),
1696
- actionsContent = {_, _, _ -> {}}
1697
- )
1698
- }
1699
- )
1700
- }
1701
- )
1702
- }
1703
- }
1704
- }
1496
+ setOverlayContent(streamCall)
1705
1497
  overlayView?.isVisible = true
1706
1498
  // Ensure overlay is behind WebView by adjusting its position in the parent
1707
1499
  val parent = overlayView?.parent as? ViewGroup
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-stream-call",
3
- "version": "0.0.65",
3
+ "version": "0.0.66",
4
4
  "description": "Uses the https://getstream.io/ SDK to implement calling in Capacitor",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",