@poolse/react-native-calls 0.1.2 → 0.1.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.
|
@@ -57,14 +57,28 @@ internal class AndroidRingSurface(
|
|
|
57
57
|
)
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
context,
|
|
62
|
-
ring.callId.hashCode(),
|
|
63
|
-
Intent(context, IncomingCallActivity::class.java)
|
|
60
|
+
fun incomingActivity(autoAnswer: Boolean, requestOffset: Int): PendingIntent {
|
|
61
|
+
val intent = Intent(context, IncomingCallActivity::class.java)
|
|
64
62
|
.putExtra(EXTRA_RING, extras)
|
|
65
|
-
.
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
.putExtra(EXTRA_AUTO_ANSWER, autoAnswer)
|
|
64
|
+
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
65
|
+
return PendingIntent.getActivity(
|
|
66
|
+
context,
|
|
67
|
+
ring.callId.hashCode() + requestOffset,
|
|
68
|
+
intent,
|
|
69
|
+
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
val fullScreen = incomingActivity(autoAnswer = false, requestOffset = 0)
|
|
74
|
+
|
|
75
|
+
// Answer launches an ACTIVITY, not a broadcast: a background receiver
|
|
76
|
+
// cannot start an activity (Android 10+), so answering from the
|
|
77
|
+
// notification used to connect audio while the app stayed hidden. An
|
|
78
|
+
// activity launched from a notification tap is allowed to come
|
|
79
|
+
// forward — it answers and brings the app up. Decline stays a
|
|
80
|
+
// broadcast; it needs no UI.
|
|
81
|
+
val answer = incomingActivity(autoAnswer = true, requestOffset = 2)
|
|
68
82
|
|
|
69
83
|
val caller = Person.Builder()
|
|
70
84
|
.setName(ring.conversationName ?: ring.callerName ?: "Incoming call")
|
|
@@ -83,7 +97,7 @@ internal class AndroidRingSurface(
|
|
|
83
97
|
NotificationCompat.CallStyle.forIncomingCall(
|
|
84
98
|
caller,
|
|
85
99
|
actionPending(ACTION_DECLINE, 1),
|
|
86
|
-
|
|
100
|
+
answer,
|
|
87
101
|
),
|
|
88
102
|
)
|
|
89
103
|
.build()
|
|
@@ -169,6 +183,7 @@ internal class AndroidRingSurface(
|
|
|
169
183
|
const val ACTION_DECLINE = "DECLINE"
|
|
170
184
|
const val ACTION_OPEN = "OPEN"
|
|
171
185
|
const val EXTRA_RING = "poolse_ring"
|
|
186
|
+
const val EXTRA_AUTO_ANSWER = "poolse_auto_answer"
|
|
172
187
|
|
|
173
188
|
/** Stable per-call notification id, so teardown targets the right one. */
|
|
174
189
|
fun String.notificationId(): Int = hashCode()
|
|
@@ -37,6 +37,16 @@ class IncomingCallActivity : Activity() {
|
|
|
37
37
|
val ring = intent.getBundleExtra(EXTRA_RING)?.toRingContext()
|
|
38
38
|
if (ring == null) { finish(); return }
|
|
39
39
|
|
|
40
|
+
// Answered from the notification: this activity exists only to be the
|
|
41
|
+
// foreground context that is ALLOWED to bring the app up (a
|
|
42
|
+
// background receiver is not). Answer and get out before drawing —
|
|
43
|
+
// onUserAnswer launches the app over the keyguard.
|
|
44
|
+
if (intent.getBooleanExtra(AndroidRingSurface.EXTRA_AUTO_ANSWER, false)) {
|
|
45
|
+
CallCore.get(this).onUserAnswer(ring)
|
|
46
|
+
finish()
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
|
|
40
50
|
val title = ring.conversationName ?: ring.callerName ?: "Incoming call"
|
|
41
51
|
val body = if (ring.media == "video") "Incoming video call" else "Incoming call"
|
|
42
52
|
setContentView(buildScene(title, body, ring))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poolse/react-native-calls",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Native call core for poolse — Kotlin/Swift calling engine with a thin React Native bridge. Ring, answer and carry audio with the app killed and the phone locked.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|