@capgo/capacitor-stream-call 0.0.2 → 0.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.
@@ -3,7 +3,7 @@ require 'json'
3
3
  package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
4
 
5
5
  Pod::Spec.new do |s|
6
- s.name = 'StreamCall'
6
+ s.name = 'CapgoCapacitorStreamCall'
7
7
  s.version = package['version']
8
8
  s.summary = package['description']
9
9
  s.license = package['license']
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # stream-call
1
+ # @capgo/capacitor-stream-call
2
2
  <a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
3
3
 
4
4
  <div align="center">
@@ -12,7 +12,7 @@ Uses the https://getstream.io/ SDK to implement calling in Capacitor
12
12
  ## Install
13
13
 
14
14
  ```bash
15
- npm install stream-call
15
+ npm install @capgo/capacitor-stream-call
16
16
  npx cap sync
17
17
  ```
18
18
 
@@ -131,8 +131,8 @@ The SDK will automatically use the system language and these translations.
131
131
  * [`removeAllListeners()`](#removealllisteners)
132
132
  * [`acceptCall()`](#acceptcall)
133
133
  * [`rejectCall()`](#rejectcall)
134
+ * [`isCameraEnabled()`](#iscameraenabled)
134
135
  * [Interfaces](#interfaces)
135
- * [Type Aliases](#type-aliases)
136
136
 
137
137
  </docgen-index>
138
138
 
@@ -288,6 +288,17 @@ Reject an incoming call
288
288
  --------------------
289
289
 
290
290
 
291
+ ### isCameraEnabled()
292
+
293
+ ```typescript
294
+ isCameraEnabled() => Promise<CameraEnabledResponse>
295
+ ```
296
+
297
+ **Returns:** <code>Promise&lt;<a href="#cameraenabledresponse">CameraEnabledResponse</a>&gt;</code>
298
+
299
+ --------------------
300
+
301
+
291
302
  ### Interfaces
292
303
 
293
304
 
@@ -300,41 +311,38 @@ Reject an incoming call
300
311
 
301
312
  #### LoginOptions
302
313
 
303
- | Prop | Type | Description |
304
- | ------------------ | ------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
305
- | **`token`** | <code>string</code> | Stream Video API token |
306
- | **`userId`** | <code>string</code> | User ID for the current user |
307
- | **`name`** | <code>string</code> | Display name for the current user |
308
- | **`imageURL`** | <code>string</code> | Optional avatar URL for the current user |
309
- | **`apiKey`** | <code>string</code> | Stream Video API key |
310
- | **`magicDivId`** | <code>string</code> | ID of the HTML element where the video will be rendered |
311
- | **`refreshToken`** | <code>{ url: string; headers?: <a href="#record">Record</a>&lt;string, string&gt;; }</code> | Configuration for token refresh |
314
+ | Prop | Type | Description |
315
+ | ---------------- | ------------------- | ------------------------------------------------------- |
316
+ | **`token`** | <code>string</code> | Stream Video API token |
317
+ | **`userId`** | <code>string</code> | User ID for the current user |
318
+ | **`name`** | <code>string</code> | Display name for the current user |
319
+ | **`imageURL`** | <code>string</code> | Optional avatar URL for the current user |
320
+ | **`apiKey`** | <code>string</code> | Stream Video API key |
321
+ | **`magicDivId`** | <code>string</code> | ID of the HTML element where the video will be rendered |
312
322
 
313
323
 
314
324
  #### CallOptions
315
325
 
316
- | Prop | Type | Description |
317
- | ------------ | -------------------- | ------------------------------------------------ |
318
- | **`userId`** | <code>string</code> | User ID of the person to call |
319
- | **`type`** | <code>string</code> | Type of call, defaults to 'default' |
320
- | **`ring`** | <code>boolean</code> | Whether to ring the other user, defaults to true |
326
+ | Prop | Type | Description |
327
+ | ------------- | --------------------- | ------------------------------------------------ |
328
+ | **`userIds`** | <code>string[]</code> | User ID of the person to call |
329
+ | **`type`** | <code>string</code> | Type of call, defaults to 'default' |
330
+ | **`ring`** | <code>boolean</code> | Whether to ring the other user, defaults to true |
321
331
 
322
332
 
323
333
  #### CallEvent
324
334
 
325
- | Prop | Type | Description |
326
- | ------------ | ------------------- | ------------------------- |
327
- | **`callId`** | <code>string</code> | ID of the call |
328
- | **`state`** | <code>string</code> | Current state of the call |
329
-
330
-
331
- ### Type Aliases
332
-
335
+ | Prop | Type | Description |
336
+ | ------------ | ------------------- | -------------------------------------------------------------- |
337
+ | **`callId`** | <code>string</code> | ID of the call |
338
+ | **`state`** | <code>string</code> | Current state of the call |
339
+ | **`userId`** | <code>string</code> | User ID of the participant in the call who triggered the event |
333
340
 
334
- #### Record
335
341
 
336
- Construct a type with a set of properties K of type T
342
+ #### CameraEnabledResponse
337
343
 
338
- <code>{
339
344
  [P in K]: T;
340
345
  }</code>
346
+ | Prop | Type |
347
+ | ------------- | -------------------- |
348
+ | **`enabled`** | <code>boolean</code> |
341
349
 
342
350
  </docgen-api>
@@ -5,24 +5,13 @@ import android.widget.Toast
5
5
  import androidx.compose.foundation.background
6
6
  import androidx.compose.foundation.layout.Box
7
7
  import androidx.compose.foundation.layout.BoxScope
8
- import androidx.compose.foundation.layout.Column
9
- import androidx.compose.foundation.layout.IntrinsicSize
10
8
  import androidx.compose.foundation.layout.WindowInsets
11
9
  import androidx.compose.foundation.layout.asPaddingValues
12
- import androidx.compose.foundation.layout.defaultMinSize
13
10
  import androidx.compose.foundation.layout.fillMaxSize
14
- import androidx.compose.foundation.layout.fillMaxWidth
15
- import androidx.compose.foundation.layout.height
16
- import androidx.compose.foundation.layout.heightIn
17
11
  import androidx.compose.foundation.layout.padding
18
12
  import androidx.compose.foundation.layout.safeDrawing
19
- import androidx.compose.foundation.layout.width
20
- import androidx.compose.foundation.layout.wrapContentHeight
21
- import androidx.compose.foundation.lazy.LazyColumn
22
- import androidx.compose.foundation.lazy.items
23
13
  import androidx.compose.material3.Text
24
14
  import androidx.compose.runtime.Composable
25
- import androidx.compose.runtime.DisposableEffect
26
15
  import androidx.compose.runtime.LaunchedEffect
27
16
  import androidx.compose.runtime.collectAsState
28
17
  import androidx.compose.runtime.getValue
@@ -32,7 +21,6 @@ import androidx.compose.runtime.setValue
32
21
  import androidx.compose.ui.Alignment
33
22
  import androidx.compose.ui.Modifier
34
23
  import androidx.compose.ui.draw.clip
35
- import androidx.compose.ui.layout.ContentScale
36
24
  import androidx.compose.ui.layout.onSizeChanged
37
25
  import androidx.compose.ui.platform.LocalConfiguration
38
26
  import androidx.compose.ui.platform.LocalInspectionMode
@@ -49,54 +37,13 @@ import io.getstream.video.android.compose.ui.components.call.renderer.Participan
49
37
  import io.getstream.video.android.compose.ui.components.call.renderer.ParticipantsLayout
50
38
  import io.getstream.video.android.compose.ui.components.call.renderer.RegularVideoRendererStyle
51
39
  import io.getstream.video.android.compose.ui.components.call.renderer.VideoRendererStyle
52
- import io.getstream.video.android.compose.ui.components.call.renderer.copy
53
- import io.getstream.video.android.core.GEO
54
40
  import io.getstream.video.android.core.ParticipantState
55
41
  import io.getstream.video.android.core.RealtimeConnection
56
42
  import io.getstream.video.android.core.StreamVideo
57
- import io.getstream.video.android.core.StreamVideoBuilder
58
- import io.getstream.video.android.model.User
59
43
  import io.getstream.video.android.core.Call
60
- import io.getstream.video.android.compose.ui.components.video.VideoRenderer
61
44
  import io.getstream.video.android.compose.ui.components.video.VideoScalingType
62
- import io.getstream.video.android.compose.ui.components.video.config.VideoRendererConfig
63
- import stream.video.sfu.models.TrackType
64
45
  import androidx.compose.ui.graphics.Color
65
46
 
66
- @Composable
67
- private fun ParticipantVideoView(
68
- call: Call,
69
- participant: ParticipantState,
70
- parentSize: IntSize,
71
- onVisibilityChanged: ((ParticipantState, Boolean) -> Unit)? = null
72
- ) {
73
- LaunchedEffect(participant) {
74
- onVisibilityChanged?.invoke(participant, true)
75
- }
76
-
77
- DisposableEffect(participant) {
78
- onDispose {
79
- onVisibilityChanged?.invoke(participant, false)
80
- }
81
- }
82
-
83
- Box(
84
- modifier = Modifier
85
- .fillMaxWidth()
86
- .height(300.dp)
87
- .background(VideoTheme.colors.baseSenary),
88
- contentAlignment = Alignment.Center
89
- ) {
90
- ParticipantVideo(
91
- modifier = Modifier
92
- .fillMaxWidth()
93
- .height(IntrinsicSize.Min),
94
- call = call,
95
- participant = participant
96
- )
97
- }
98
- }
99
-
100
47
  @Composable
101
48
  fun CallOverlayView(
102
49
  context: Context,
@@ -12,6 +12,9 @@ import androidx.core.app.NotificationCompat
12
12
  import io.getstream.video.android.core.notifications.DefaultNotificationHandler
13
13
  import io.getstream.video.android.model.StreamCallId
14
14
 
15
+ // declare "incoming_calls_custom" as a constant
16
+ const val INCOMING_CALLS_CUSTOM = "incoming_calls_custom"
17
+
15
18
  class CustomNotificationHandler(
16
19
  val application: Application,
17
20
  private val endCall: (callId: StreamCallId) -> Unit = {},
@@ -30,8 +33,6 @@ class CustomNotificationHandler(
30
33
  callerName: String?,
31
34
  shouldHaveContentIntent: Boolean,
32
35
  ): Notification {
33
- val showAsHighPriority = true
34
- val channelId = "incoming_calls_custom"
35
36
 
36
37
  customCreateIncomingCallChannel(channelId, showAsHighPriority)
37
38
 
@@ -41,7 +42,7 @@ class CustomNotificationHandler(
41
42
  rejectCallPendingIntent,
42
43
  callerName,
43
44
  shouldHaveContentIntent,
44
- channelId,
45
+ INCOMING_CALLS_CUSTOM,
45
46
  true // Include sound
46
47
  )
47
48
  }
@@ -100,27 +101,17 @@ class CustomNotificationHandler(
100
101
  super.onMissedCall(callId, callDisplayName)
101
102
  }
102
103
 
103
- open fun customCreateIncomingCallChannel(channelId: String, showAsHighPriority: Boolean) {
104
+ private fun customCreateIncomingCallChannel() {
104
105
  maybeCreateChannel(
105
- channelId = channelId,
106
+ channelId = INCOMING_CALLS_CUSTOM,
106
107
  context = application,
107
108
  configure = {
108
109
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
109
110
  name = application.getString(
110
111
  R.string.stream_video_incoming_call_notification_channel_title,
111
112
  )
112
- description = application.getString(
113
- if (showAsHighPriority) {
114
- R.string.stream_video_incoming_call_notification_channel_description
115
- } else {
116
- R.string.stream_video_incoming_call_low_priority_notification_channel_description
117
- },
118
- )
119
- importance = if (showAsHighPriority) {
120
- NotificationManager.IMPORTANCE_HIGH
121
- } else {
122
- NotificationManager.IMPORTANCE_LOW
123
- }
113
+ description = application.getString(R.string.stream_video_incoming_call_notification_channel_description)
114
+ importance = NotificationManager.IMPORTANCE_HIGH
124
115
  this.lockscreenVisibility = Notification.VISIBILITY_PUBLIC
125
116
  this.setShowBadge(true)
126
117
 
@@ -139,4 +130,4 @@ class CustomNotificationHandler(
139
130
  public fun clone(): CustomNotificationHandler {
140
131
  return CustomNotificationHandler(this.application, this.endCall, this.incomingCall)
141
132
  }
142
- }
133
+ }
@@ -21,7 +21,6 @@ import androidx.compose.runtime.getValue
21
21
  import androidx.compose.ui.Alignment
22
22
  import androidx.compose.ui.Modifier
23
23
  import androidx.compose.ui.graphics.Color
24
- import androidx.compose.ui.platform.LocalContext
25
24
  import androidx.compose.ui.platform.LocalLayoutDirection
26
25
  import io.getstream.video.android.compose.theme.VideoTheme
27
26
  import io.getstream.video.android.compose.ui.components.background.CallBackground
@@ -33,8 +32,8 @@ import io.getstream.video.android.core.RingingState
33
32
  import io.getstream.video.android.core.StreamVideo
34
33
  import io.getstream.video.android.core.call.state.AcceptCall
35
34
  import io.getstream.video.android.core.call.state.DeclineCall
35
+ import io.getstream.video.android.core.call.state.ToggleCamera
36
36
  import io.getstream.video.android.model.User
37
- import java.time.OffsetDateTime
38
37
 
39
38
  @Composable
40
39
  fun IncomingCallView(
@@ -47,10 +46,19 @@ fun IncomingCallView(
47
46
  val ringingState = call?.state?.ringingState?.collectAsState(initial = RingingState.Idle)
48
47
 
49
48
  LaunchedEffect(ringingState?.value) {
50
- Log.d("IncomingCallView", "Changing ringingState to $ringingState?.value")
51
- if (ringingState?.value == RingingState.TimeoutNoAnswer || ringingState?.value == RingingState.RejectedByAll) {
52
- Log.d("IncomingCallView", "Call timed out, hiding incoming call view")
53
- onHideIncomingCall?.invoke()
49
+ Log.d("IncomingCallView", "Changing ringingState to ${ringingState?.value}")
50
+ when (ringingState?.value) {
51
+ RingingState.TimeoutNoAnswer, RingingState.RejectedByAll -> {
52
+ Log.d("IncomingCallView", "Call ended (${ringingState.value}), hiding incoming call view")
53
+ onHideIncomingCall?.invoke()
54
+ }
55
+ RingingState.Active -> {
56
+ Log.d("IncomingCallView", "Call accepted, hiding incoming call view")
57
+ onHideIncomingCall?.invoke()
58
+ }
59
+ else -> {
60
+ // Keep the view visible for other states
61
+ }
54
62
  }
55
63
  }
56
64
 
@@ -130,6 +138,9 @@ fun IncomingCallView(
130
138
  when (action) {
131
139
  DeclineCall -> onDeclineCall?.invoke(call)
132
140
  AcceptCall -> onAcceptCall?.invoke(call)
141
+ is ToggleCamera -> {
142
+ call.camera.setEnabled(action.isEnabled)
143
+ }
133
144
  else -> { /* ignore other actions */ }
134
145
  }
135
146
  }
@@ -144,4 +155,4 @@ fun IncomingCallView(
144
155
  .background(backgroundColor)
145
156
  )
146
157
  }
147
- }
158
+ }
@@ -1,13 +1,11 @@
1
1
  package ee.forgr.capacitor.streamcall
2
2
 
3
3
  import android.app.Application
4
- import android.app.Notification
5
4
  import android.app.NotificationManager
6
5
  import android.content.Context
7
6
  import android.media.AudioAttributes
8
7
  import android.media.MediaPlayer
9
8
  import android.media.RingtoneManager
10
- import android.os.Build
11
9
  import android.os.Handler
12
10
  import android.os.Looper
13
11
  import android.util.Log