rns-nativecall 0.6.5 → 0.6.6
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.
|
@@ -13,6 +13,7 @@ class AcceptCallActivity : Activity() {
|
|
|
13
13
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
14
14
|
super.onCreate(savedInstanceState)
|
|
15
15
|
|
|
16
|
+
// Ensure we show over the lockscreen
|
|
16
17
|
window.addFlags(
|
|
17
18
|
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
|
|
18
19
|
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or
|
|
@@ -34,36 +35,30 @@ class AcceptCallActivity : Activity() {
|
|
|
34
35
|
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
35
36
|
uuid?.let { notificationManager.cancel(it.hashCode()) }
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
val dataMap = mutableMapOf<String, String>()
|
|
39
|
+
extras?.keySet()?.forEach { key ->
|
|
40
|
+
extras.get(key)?.let { dataMap[key] = it.toString() }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// 1. Set the data for JS (Cold start support)
|
|
44
|
+
CallModule.setPendingCallData("onCallAccepted_pending", dataMap)
|
|
45
|
+
|
|
46
|
+
// 2. Fire event immediately if JS is alive
|
|
47
|
+
if (CallModule.isReady()) {
|
|
48
|
+
CallModule.sendEventToJS("onCallAccepted", dataMap)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 3. Bring the Main App to the front
|
|
39
52
|
openMainApp(extras)
|
|
40
53
|
finish()
|
|
41
54
|
}
|
|
42
55
|
|
|
43
56
|
private fun openMainApp(extras: Bundle?) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
setClassName(packageName, mainActivityClassName)
|
|
50
|
-
action = "com.rnsnativecall.ACTION_ANSWER"
|
|
51
|
-
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
|
52
|
-
|
|
53
|
-
// Ensure extras are carried over
|
|
54
|
-
extras?.let { putExtras(it) }
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
startActivity(intent)
|
|
58
|
-
} catch (e: Exception) {
|
|
59
|
-
// Fallback: If explicit mapping fails, try the launch intent but force the action
|
|
60
|
-
val launchIntent = packageManager.getLaunchIntentForPackage(packageName)
|
|
61
|
-
launchIntent?.apply {
|
|
62
|
-
action = "com.rnsnativecall.ACTION_ANSWER"
|
|
63
|
-
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
|
64
|
-
extras?.let { putExtras(it) }
|
|
65
|
-
startActivity(this)
|
|
66
|
-
}
|
|
57
|
+
val launchIntent = packageManager.getLaunchIntentForPackage(packageName)
|
|
58
|
+
launchIntent?.apply {
|
|
59
|
+
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
|
60
|
+
putExtras(extras ?: Bundle())
|
|
61
|
+
startActivity(this)
|
|
67
62
|
}
|
|
68
63
|
}
|
|
69
64
|
}
|
package/package.json
CHANGED
package/withNativeCallVoip.js
CHANGED
|
@@ -5,32 +5,10 @@ function withMainActivityDataFix(config) {
|
|
|
5
5
|
return withMainActivity(config, (config) => {
|
|
6
6
|
let contents = config.modResults.contents;
|
|
7
7
|
|
|
8
|
-
// Ensure imports exist
|
|
9
|
-
if (!contents.includes('import android.content.Intent')) {
|
|
10
|
-
contents = contents.replace(/package .*/, (match) => `${match}\n\nimport android.content.Intent`);
|
|
11
|
-
}
|
|
12
|
-
if (!contents.includes('import android.os.Bundle')) {
|
|
13
|
-
contents = contents.replace(/package .*/, (match) => `${match}\n\nimport android.os.Bundle`);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
8
|
const onNewIntentCode = `
|
|
17
9
|
override fun onNewIntent(intent: Intent) {
|
|
18
10
|
super.onNewIntent(intent)
|
|
19
11
|
setIntent(intent)
|
|
20
|
-
|
|
21
|
-
// Check for the specific Answer Action
|
|
22
|
-
val isAnswerAction = intent.action == "com.rnsnativecall.ACTION_ANSWER"
|
|
23
|
-
|
|
24
|
-
val dataMap = mutableMapOf<String, String>()
|
|
25
|
-
intent.extras?.keySet()?.forEach { key ->
|
|
26
|
-
dataMap[key] = intent.extras?.get(key)?.toString() ?: ""
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// FIRE if it's the answer action, even if extras are slim
|
|
30
|
-
if (isAnswerAction) {
|
|
31
|
-
com.rnsnativecall.CallModule.setPendingCallData("onCallAccepted_pending", dataMap)
|
|
32
|
-
com.rnsnativecall.CallModule.sendEventToJS("onCallAccepted", dataMap)
|
|
33
|
-
}
|
|
34
12
|
}
|
|
35
13
|
`;
|
|
36
14
|
|
|
@@ -38,25 +16,12 @@ function withMainActivityDataFix(config) {
|
|
|
38
16
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
39
17
|
super.onCreate(savedInstanceState)
|
|
40
18
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// Logic for Cold Start (App was dead, user answered)
|
|
44
|
-
if (isAnswerAction) {
|
|
45
|
-
val dataMap = mutableMapOf<String, String>()
|
|
46
|
-
intent.extras?.keySet()?.forEach { key ->
|
|
47
|
-
dataMap[key] = intent.extras?.get(key)?.toString() ?: ""
|
|
48
|
-
}
|
|
49
|
-
com.rnsnativecall.CallModule.setPendingCallData(dataMap)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Move to back if it's a background wake (FCM) and NOT an answer click
|
|
53
|
-
if (intent.getBooleanExtra("background_wake", false) && !isAnswerAction) {
|
|
19
|
+
// If background wake from FCM, move to back to let LockScreen UI show
|
|
20
|
+
if (intent.getBooleanExtra("background_wake", false)) {
|
|
54
21
|
moveTaskToBack(true)
|
|
55
22
|
}
|
|
56
23
|
}
|
|
57
24
|
`;
|
|
58
|
-
|
|
59
|
-
// Inject codes
|
|
60
25
|
if (!contents.includes('override fun onNewIntent')) {
|
|
61
26
|
const lastBraceIndex = contents.lastIndexOf('}');
|
|
62
27
|
contents = contents.slice(0, lastBraceIndex) + onNewIntentCode + contents.slice(lastBraceIndex);
|