@capgo/capacitor-stream-call 7.0.2 → 7.0.3

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.
@@ -399,18 +399,35 @@ class StreamCallPlugin : Plugin() {
399
399
  }
400
400
 
401
401
  private fun addTouchInterceptor() {
402
- val originalParent = bridge?.webView?.parent as? ViewGroup ?: return
402
+ val webView = bridge?.webView
403
+ if (webView == null) {
404
+ Log.e("StreamCallPlugin", "addTouchInterceptor: WebView is null, cannot add touch interceptor")
405
+ return
406
+ }
407
+
408
+ val originalParent = webView.parent as? ViewGroup
409
+ if (originalParent == null) {
410
+ Log.e("StreamCallPlugin", "addTouchInterceptor: WebView parent is null or not a ViewGroup")
411
+ return
412
+ }
403
413
 
404
414
  // Check if touch interceptor already exists
405
415
  if (touchInterceptWrapper != null) {
406
- Log.d("StreamCallPlugin", "Touch interceptor already exists, skipping creation")
416
+ Log.d("StreamCallPlugin", "addTouchInterceptor: Touch interceptor already exists, skipping creation")
407
417
  return
408
418
  }
409
419
 
420
+ Log.d("StreamCallPlugin", "addTouchInterceptor: Starting setup")
421
+ Log.d("StreamCallPlugin", "addTouchInterceptor: Original parent type: ${originalParent.javaClass.simpleName}")
422
+ Log.d("StreamCallPlugin", "addTouchInterceptor: Original parent child count: ${originalParent.childCount}")
423
+
410
424
  // Wrap original parent with TouchInterceptWrapper to allow touch passthrough
411
425
  val rootParent = originalParent.parent as? ViewGroup
412
426
  val indexInRoot = rootParent?.indexOfChild(originalParent) ?: -1
427
+
413
428
  if (rootParent != null && indexInRoot >= 0) {
429
+ Log.d("StreamCallPlugin", "addTouchInterceptor: Root parent type: ${rootParent.javaClass.simpleName}")
430
+
414
431
  rootParent.removeViewAt(indexInRoot)
415
432
  touchInterceptWrapper = TouchInterceptWrapper(originalParent).apply {
416
433
  setBackgroundColor(Color.TRANSPARENT)
@@ -425,10 +442,19 @@ class StreamCallPlugin : Plugin() {
425
442
  }
426
443
  if (barrierView?.parent != parent) {
427
444
  (barrierView?.parent as? ViewGroup)?.removeView(barrierView)
428
- parent.addView(barrierView, parent.indexOfChild(bridge?.webView) + 1)
445
+ parent.addView(barrierView, parent.indexOfChild(webView) + 1)
429
446
  }
430
447
 
431
- Log.d("StreamCallPlugin", "Touch interceptor added for active call")
448
+ Log.d("StreamCallPlugin", "addTouchInterceptor: Touch interceptor added successfully")
449
+ Log.d("StreamCallPlugin", "addTouchInterceptor: TouchWrapper child count: ${parent.childCount}")
450
+
451
+ // Log children of touch wrapper
452
+ for (i in 0 until parent.childCount) {
453
+ val child = parent.getChildAt(i)
454
+ Log.d("StreamCallPlugin", "addTouchInterceptor: TouchWrapper child $i: ${child.javaClass.simpleName}")
455
+ }
456
+ } else {
457
+ Log.e("StreamCallPlugin", "addTouchInterceptor: Could not add touch interceptor - rootParent=$rootParent, indexInRoot=$indexInRoot")
432
458
  }
433
459
  }
434
460
 
@@ -437,36 +463,91 @@ class StreamCallPlugin : Plugin() {
437
463
  val rootParent = touchWrapper.parent as? ViewGroup ?: return
438
464
  val indexInRoot = rootParent.indexOfChild(touchWrapper)
439
465
 
440
- // Get the original parent (should be the only child of touchWrapper)
441
- val originalParent = touchWrapper.getChildAt(0) as? ViewGroup
442
- if (originalParent != null && originalParent !is ComposeView) {
443
- // Move views back to original parent (only if it's not a ComposeView)
444
- if (overlayView?.parent == touchWrapper) {
445
- touchWrapper.removeView(overlayView)
446
- originalParent.addView(overlayView, 0)
447
- }
448
- if (barrierView?.parent == touchWrapper) {
449
- touchWrapper.removeView(barrierView)
450
- originalParent.addView(barrierView, originalParent.indexOfChild(bridge?.webView) + 1)
466
+ Log.d("StreamCallPlugin", "removeTouchInterceptor: Starting removal process")
467
+ Log.d("StreamCallPlugin", "removeTouchInterceptor: TouchWrapper has ${touchWrapper.childCount} children")
468
+ Log.d("StreamCallPlugin", "removeTouchInterceptor: RootParent type: ${rootParent.javaClass.simpleName}")
469
+
470
+ // Log all children of touchWrapper
471
+ for (i in 0 until touchWrapper.childCount) {
472
+ val child = touchWrapper.getChildAt(i)
473
+ Log.d("StreamCallPlugin", "removeTouchInterceptor: Child $i: ${child.javaClass.simpleName}")
474
+ }
475
+
476
+ // Store references to all children before removing
477
+ val childrenToRestore = mutableListOf<View>()
478
+ for (i in 0 until touchWrapper.childCount) {
479
+ childrenToRestore.add(touchWrapper.getChildAt(i))
480
+ }
481
+
482
+ // Find which child should be the new container (usually the one that was the original parent)
483
+ // This is typically a FrameLayout or similar ViewGroup, but NOT ComposeView
484
+ var newParent: ViewGroup? = null
485
+
486
+ // Look for a ViewGroup that is not a ComposeView to be the new parent
487
+ for (child in childrenToRestore) {
488
+ if (child is ViewGroup && child !is ComposeView) {
489
+ // Check if this ViewGroup originally contained the WebView or other views
490
+ newParent = child
491
+ Log.d("StreamCallPlugin", "removeTouchInterceptor: Found potential parent: ${child.javaClass.simpleName}")
492
+ break
493
+ }
494
+ }
495
+
496
+ // If we didn't find a suitable parent, create a new FrameLayout
497
+ if (newParent == null) {
498
+ Log.d("StreamCallPlugin", "removeTouchInterceptor: No suitable parent found, creating new FrameLayout")
499
+ newParent = FrameLayout(touchWrapper.context).apply {
500
+ layoutParams = touchWrapper.layoutParams
451
501
  }
452
502
 
453
- // Remove touch wrapper and restore original parent
454
- touchWrapper.removeView(originalParent)
455
- rootParent.removeView(touchWrapper)
456
- rootParent.addView(originalParent, indexInRoot)
457
-
458
- touchInterceptWrapper = null
459
- Log.d("StreamCallPlugin", "Touch interceptor removed after call ended")
503
+ // Move all children from touchWrapper to the new parent
504
+ touchWrapper.removeAllViews()
505
+ for (child in childrenToRestore) {
506
+ newParent.addView(child)
507
+ }
460
508
  } else {
461
- // If original parent is a ComposeView or null, just remove the touch wrapper
462
- // The views will stay where they are
463
- if (originalParent != null) {
464
- touchWrapper.removeView(originalParent)
465
- rootParent.removeView(touchWrapper)
466
- rootParent.addView(originalParent, indexInRoot)
509
+ // If we found an existing parent, move other children to it
510
+ touchWrapper.removeAllViews()
511
+
512
+ // First add the parent back
513
+ rootParent.addView(newParent, indexInRoot)
514
+
515
+ // Then add other children to this parent if they're not already there
516
+ for (child in childrenToRestore) {
517
+ if (child != newParent && child.parent == null) {
518
+ when (child) {
519
+ is ComposeView -> newParent.addView(child, 0) // Add ComposeView at bottom
520
+ bridge?.webView -> newParent.addView(child) // Add WebView on top
521
+ else -> newParent.addView(child) // Add other views
522
+ }
523
+ }
524
+ }
525
+ }
526
+
527
+ // Remove the touch wrapper from root if not done yet
528
+ if (touchWrapper.parent != null) {
529
+ rootParent.removeView(touchWrapper)
530
+ if (newParent.parent == null) {
531
+ rootParent.addView(newParent, indexInRoot)
467
532
  }
468
- touchInterceptWrapper = null
469
- Log.d("StreamCallPlugin", "Touch interceptor removed (ComposeView parent case)")
533
+ }
534
+
535
+ // Ensure WebView is still visible and has correct background
536
+ bridge?.webView?.let { webView ->
537
+ webView.visibility = View.VISIBLE
538
+ webView.setBackgroundColor(Color.WHITE)
539
+ webView.bringToFront()
540
+ Log.d("StreamCallPlugin", "removeTouchInterceptor: WebView visibility set to VISIBLE, background set to WHITE")
541
+ }
542
+
543
+ touchInterceptWrapper = null
544
+ Log.d("StreamCallPlugin", "Touch interceptor removed successfully")
545
+
546
+ // Log final state
547
+ Log.d("StreamCallPlugin", "removeTouchInterceptor: Final rootParent child count: ${rootParent.childCount}")
548
+ for (i in 0 until rootParent.childCount) {
549
+ val child = rootParent.getChildAt(i)
550
+ Log.d("StreamCallPlugin", "removeTouchInterceptor: Final child $i: ${child.javaClass.simpleName}")
470
551
  }
471
552
  }
472
553
 
@@ -1962,29 +2043,39 @@ class StreamCallPlugin : Plugin() {
1962
2043
  }
1963
2044
  }
1964
2045
 
1965
- val savedCapacitorActivity = savedActivity
1966
- if (savedCapacitorActivity != null) {
1967
-
1968
- if (savedActivityPaused) {
1969
- Log.d("StreamCallPlugin", "Activity is paused. Adding call ${call.id} to savedCallsToEndOnResume")
1970
- savedCallsToEndOnResume.add(call)
1971
- } else {
1972
- transEndCallRaw(call)
1973
- }
1974
-
1975
- return@runOnMainThread
1976
- }
1977
-
2046
+ // Always clean up the UI regardless of savedCapacitorActivity state
2047
+ Log.d("StreamCallPlugin", "endCallRaw: Cleaning up UI for call $callId")
2048
+ Log.d("StreamCallPlugin", "endCallRaw: WebView visible before: ${bridge?.webView?.visibility}")
2049
+ Log.d("StreamCallPlugin", "endCallRaw: TouchInterceptWrapper exists: ${touchInterceptWrapper != null}")
2050
+
1978
2051
  setOverlayContent(call)
1979
2052
  overlayView?.isVisible = false
1980
2053
  bridge?.webView?.setBackgroundColor(Color.WHITE) // Restore webview opacity
2054
+ bridge?.webView?.visibility = View.VISIBLE // Ensure WebView is visible
1981
2055
 
1982
2056
  // Remove touch interceptor
1983
- removeTouchInterceptor()
2057
+ if (touchInterceptWrapper != null) {
2058
+ Log.d("StreamCallPlugin", "endCallRaw: Removing touch interceptor")
2059
+ removeTouchInterceptor()
2060
+ } else {
2061
+ Log.d("StreamCallPlugin", "endCallRaw: No touch interceptor to remove")
2062
+ }
1984
2063
 
1985
2064
  // Also hide incoming call view if visible
1986
- Log.d("StreamCallPlugin", "Hiding incoming call view for call $callId")
2065
+ Log.d("StreamCallPlugin", "endCallRaw: Hiding incoming call view for call $callId")
1987
2066
  // No dedicated incoming-call native view anymore; UI handled by web layer
2067
+
2068
+ Log.d("StreamCallPlugin", "endCallRaw: WebView visible after: ${bridge?.webView?.visibility}")
2069
+
2070
+ val savedCapacitorActivity = savedActivity
2071
+ if (savedCapacitorActivity != null) {
2072
+ if (savedActivityPaused) {
2073
+ Log.d("StreamCallPlugin", "endCallRaw: Activity is paused. Adding call ${call.id} to savedCallsToEndOnResume")
2074
+ savedCallsToEndOnResume.add(call)
2075
+ } else {
2076
+ transEndCallRaw(call)
2077
+ }
2078
+ }
1988
2079
  }
1989
2080
 
1990
2081
  // Notify that call has ended using helper
@@ -2245,10 +2336,30 @@ class StreamCallPlugin : Plugin() {
2245
2336
 
2246
2337
  // Hide UI elements directly without setting content
2247
2338
  runOnMainThread {
2248
- Log.d("StreamCallPlugin", "Hiding UI elements for call $callCid (one-time cleanup)")
2339
+ Log.d("StreamCallPlugin", "cleanupCall: Hiding UI elements for call $callCid")
2340
+
2341
+ // Log current state before cleanup
2342
+ Log.d("StreamCallPlugin", "cleanupCall: OverlayView visible: ${overlayView?.isVisible}")
2343
+ Log.d("StreamCallPlugin", "cleanupCall: WebView visible: ${bridge?.webView?.visibility}")
2344
+ Log.d("StreamCallPlugin", "cleanupCall: TouchInterceptWrapper exists: ${touchInterceptWrapper != null}")
2345
+
2249
2346
  overlayView?.isVisible = false
2347
+ bridge?.webView?.setBackgroundColor(Color.WHITE) // Restore webview opacity
2348
+ bridge?.webView?.visibility = View.VISIBLE // Ensure WebView is visible
2349
+
2350
+ // Remove touch interceptor if it exists
2351
+ if (touchInterceptWrapper != null) {
2352
+ Log.d("StreamCallPlugin", "cleanupCall: Removing touch interceptor")
2353
+ removeTouchInterceptor()
2354
+ } else {
2355
+ Log.d("StreamCallPlugin", "cleanupCall: No touch interceptor to remove")
2356
+ }
2357
+
2250
2358
  // here we will also make sure we don't show on lock screen
2251
2359
  changeActivityAsVisibleOnLockScreen(this.activity, false)
2360
+
2361
+ // Log final state after cleanup
2362
+ Log.d("StreamCallPlugin", "cleanupCall: Cleanup complete. WebView visible: ${bridge?.webView?.visibility}")
2252
2363
  }
2253
2364
 
2254
2365
  Log.d("StreamCallPlugin", "Cleaned up resources for ended call: $callCid")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-stream-call",
3
- "version": "7.0.2",
3
+ "version": "7.0.3",
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",