rns-nativecall 0.1.4 → 0.1.5
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.
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/////
|
|
2
|
-
// Users/bush/Desktop/Apps/Raiidr/package/android/src/main/java/com/rnsnativecall/MyConnectionService.kt
|
|
3
1
|
package com.rnsnativecall
|
|
4
2
|
|
|
3
|
+
import android.net.Uri // <--- ADD THIS IMPORT
|
|
5
4
|
import android.telecom.Connection
|
|
6
5
|
import android.telecom.ConnectionRequest
|
|
7
6
|
import android.telecom.ConnectionService
|
|
@@ -28,13 +27,16 @@ class MyConnectionService : ConnectionService() {
|
|
|
28
27
|
request: ConnectionRequest?
|
|
29
28
|
): Connection {
|
|
30
29
|
|
|
31
|
-
// 1. Read extras
|
|
32
30
|
val extras = request?.extras
|
|
33
31
|
val callUUID = extras?.getString("EXTRA_CALL_UUID")
|
|
34
32
|
val playRing = extras?.getBoolean("EXTRA_PLAY_RING", true) ?: true
|
|
35
|
-
val callerName = extras?.getString(TelecomManager.EXTRA_CALL_SUBJECT)
|
|
36
33
|
|
|
37
|
-
//
|
|
34
|
+
// 1. "John Doe" (Top slot)
|
|
35
|
+
val actualPersonName = extras?.getString("EXTRA_CALLER_NAME") ?: "Someone"
|
|
36
|
+
|
|
37
|
+
// 2. "Raiidr Video Call" (Middle/Number slot)
|
|
38
|
+
val appLabel = extras?.getString(TelecomManager.EXTRA_CALL_SUBJECT) ?: "Incoming Call"
|
|
39
|
+
|
|
38
40
|
val connection =
|
|
39
41
|
MyCallConnection(
|
|
40
42
|
context = applicationContext,
|
|
@@ -48,21 +50,26 @@ class MyConnectionService : ConnectionService() {
|
|
|
48
50
|
}
|
|
49
51
|
)
|
|
50
52
|
|
|
51
|
-
// 3. Set
|
|
52
|
-
|
|
53
|
+
// 3. Set the LARGE text on top to the Person's Name
|
|
54
|
+
connection.setCallerDisplayName(actualPersonName, TelecomManager.PRESENTATION_ALLOWED)
|
|
53
55
|
|
|
54
56
|
// 4. Standard Telecom setup
|
|
55
57
|
connection.connectionCapabilities =
|
|
56
58
|
Connection.CAPABILITY_MUTE or Connection.CAPABILITY_SUPPORT_HOLD
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
// --- THE UI FIX ---
|
|
61
|
+
// We force the App Label (e.g. "Raiidr Video Call") into the Address slot
|
|
62
|
+
// This replaces the raw phone number/handle on the incoming call screen.
|
|
63
|
+
val labelUri = Uri.fromParts("tel", appLabel, null)
|
|
64
|
+
connection.setAddress(labelUri, TelecomManager.PRESENTATION_ALLOWED)
|
|
65
|
+
|
|
59
66
|
connection.setInitializing()
|
|
60
67
|
connection.setRinging()
|
|
61
68
|
|
|
62
|
-
//
|
|
69
|
+
// Emit event to JS so the app can send the 'ringing' status
|
|
63
70
|
callUUID?.let { CallModule.sendEventToJS("onCallDisplayed", it) }
|
|
64
71
|
|
|
65
|
-
//
|
|
72
|
+
// Track connection
|
|
66
73
|
callUUID?.let { addConnection(it, connection) }
|
|
67
74
|
|
|
68
75
|
return connection
|
|
@@ -10,33 +10,29 @@ import android.telecom.VideoProfile
|
|
|
10
10
|
|
|
11
11
|
object NativeCallManager {
|
|
12
12
|
|
|
13
|
-
// Inside NativeCallManager.kt
|
|
14
|
-
|
|
15
13
|
fun handleIncomingPush(context: Context, data: Map<String, String>) {
|
|
16
14
|
val uuid = data["callId"] ?: return
|
|
17
15
|
val handle = data["from"] ?: "Unknown"
|
|
18
|
-
val callType = data["callType"] ?: "audio"
|
|
16
|
+
val callType = data["callType"] ?: "audio"
|
|
19
17
|
val name = data["name"] ?: handle
|
|
20
18
|
val playRing = data["playRing"]?.toBoolean() ?: true
|
|
21
19
|
|
|
22
|
-
// 1. Get
|
|
20
|
+
// 1. Get Dynamic App Name
|
|
23
21
|
val appName =
|
|
24
22
|
try {
|
|
25
23
|
val pm = context.packageManager
|
|
26
24
|
val ai = pm.getApplicationInfo(context.packageName, 0)
|
|
27
25
|
pm.getApplicationLabel(ai).toString()
|
|
28
26
|
} catch (e: Exception) {
|
|
29
|
-
"App"
|
|
27
|
+
"App"
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
// 2.
|
|
30
|
+
// 2. Format Sub-label (e.g., "Raiidr Video Call")
|
|
33
31
|
val capitalizedCallType =
|
|
34
32
|
callType.replaceFirstChar {
|
|
35
33
|
if (it.isLowerCase()) it.titlecase() else it.toString()
|
|
36
34
|
}
|
|
37
|
-
|
|
38
|
-
// 3. Construct the robust label: "Incoming [AppName] [Video/Audio] Call"
|
|
39
|
-
val displayLabel = "Incoming $appName $capitalizedCallType Call"
|
|
35
|
+
val subLabel = "$appName $capitalizedCallType Call"
|
|
40
36
|
|
|
41
37
|
val telecomManager = context.getSystemService(Context.TELECOM_SERVICE) as TelecomManager
|
|
42
38
|
val phoneAccountHandle = getPhoneAccountHandle(context)
|
|
@@ -48,20 +44,22 @@ object NativeCallManager {
|
|
|
48
44
|
Uri.fromParts("sip", handle, null)
|
|
49
45
|
)
|
|
50
46
|
putString("EXTRA_CALL_UUID", uuid)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
|
|
48
|
+
// This goes to the SECONDARY slot in MyConnectionService
|
|
49
|
+
putString(TelecomManager.EXTRA_CALL_SUBJECT, subLabel)
|
|
50
|
+
|
|
51
|
+
// This goes to the PRIMARY slot (The Name) in MyConnectionService
|
|
52
|
+
putString("EXTRA_CALLER_NAME", name)
|
|
53
|
+
|
|
55
54
|
putBoolean("EXTRA_PLAY_RING", playRing)
|
|
56
55
|
|
|
57
|
-
// Ensure hasVideo is properly mapped to Telecom constants
|
|
58
56
|
val isVideo = callType.equals("video", ignoreCase = true)
|
|
59
57
|
val videoState =
|
|
60
58
|
if (isVideo) VideoProfile.STATE_BIDIRECTIONAL
|
|
61
59
|
else VideoProfile.STATE_AUDIO_ONLY
|
|
62
60
|
putInt(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, videoState)
|
|
63
61
|
|
|
64
|
-
//
|
|
62
|
+
// Forward all other data
|
|
65
63
|
data.forEach { (key, value) -> putString(key, value) }
|
|
66
64
|
}
|
|
67
65
|
|
|
@@ -72,6 +70,7 @@ object NativeCallManager {
|
|
|
72
70
|
}
|
|
73
71
|
}
|
|
74
72
|
|
|
73
|
+
// This function must be OUTSIDE handleIncomingPush but INSIDE the object
|
|
75
74
|
private fun getPhoneAccountHandle(context: Context): PhoneAccountHandle {
|
|
76
75
|
val componentName = ComponentName(context, MyConnectionService::class.java)
|
|
77
76
|
return PhoneAccountHandle(componentName, "${context.packageName}.voip")
|
package/package.json
CHANGED