rns-nativecall 0.3.9 → 0.4.1
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.
- package/package.json +1 -1
- package/withCallPermissions.js +2 -1
- package/withNativeCallVoip.js +28 -67
package/package.json
CHANGED
package/withCallPermissions.js
CHANGED
package/withNativeCallVoip.js
CHANGED
|
@@ -53,88 +53,49 @@ function withMainActivityDataFix(config) {
|
|
|
53
53
|
return withMainActivity(config, (config) => {
|
|
54
54
|
let contents = config.modResults.contents;
|
|
55
55
|
|
|
56
|
-
//
|
|
57
|
-
const
|
|
56
|
+
// 1. Add necessary Imports safely
|
|
57
|
+
const imports = [
|
|
58
58
|
'import android.view.WindowManager',
|
|
59
59
|
'import android.os.Build',
|
|
60
|
-
'import android.os.Bundle'
|
|
60
|
+
'import android.os.Bundle',
|
|
61
|
+
'import android.content.Intent'
|
|
61
62
|
];
|
|
62
|
-
|
|
63
|
-
neededImports.forEach(imp => {
|
|
63
|
+
imports.forEach(imp => {
|
|
64
64
|
if (!contents.includes(imp)) {
|
|
65
65
|
contents = contents.replace(/package .*/, (match) => `${match}\n${imp}`);
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
//
|
|
70
|
-
// We look for
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
// setShowWhenLocked(true)
|
|
80
|
-
// setTurnScreenOn(true)
|
|
81
|
-
// } else {
|
|
82
|
-
// @Suppress("DEPRECATION")
|
|
83
|
-
// window.addFlags(
|
|
84
|
-
// WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
|
|
85
|
-
// WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or
|
|
86
|
-
// WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
|
87
|
-
// )
|
|
88
|
-
// }
|
|
89
|
-
// }
|
|
90
|
-
override fun onCreate(savedInstanceState: Bundle?) {
|
|
91
|
-
setTheme(R.style.AppTheme)
|
|
92
|
-
super.onCreate(savedInstanceState)
|
|
93
|
-
|
|
94
|
-
// Only wake the screen/bypass lock if we are coming from a notification interaction
|
|
95
|
-
// Otherwise, let the notification pill handle the UI.
|
|
96
|
-
if (intent?.action?.startsWith("ACTION_SHOW_UI") == true) {
|
|
97
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
|
98
|
-
setShowWhenLocked(true)
|
|
99
|
-
setTurnScreenOn(true)
|
|
100
|
-
} else {
|
|
101
|
-
@Suppress("DEPRECATION")
|
|
102
|
-
window.addFlags(
|
|
103
|
-
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
|
|
104
|
-
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or
|
|
105
|
-
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
|
106
|
-
)
|
|
107
|
-
}
|
|
69
|
+
// 2. Inject onCreate logic without breaking the existing structure
|
|
70
|
+
// We look for super.onCreate(null) or super.onCreate(savedInstanceState)
|
|
71
|
+
const wakeLogig = `
|
|
72
|
+
super.onCreate(savedInstanceState)
|
|
73
|
+
if (intent?.action?.startsWith("ACTION_SHOW_UI") == true || intent?.getBooleanExtra("background_wake", false) == true) {
|
|
74
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
|
75
|
+
setShowWhenLocked(true)
|
|
76
|
+
setTurnScreenOn(true)
|
|
77
|
+
} else {
|
|
78
|
+
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
|
|
108
79
|
}
|
|
109
|
-
}
|
|
110
|
-
`;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
80
|
+
}`;
|
|
114
81
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (contents.match(onCreateRegex)) {
|
|
118
|
-
contents = contents.replace(onCreateRegex, editedOnCreate);
|
|
82
|
+
if (!contents.includes('setShowWhenLocked')) {
|
|
83
|
+
contents = contents.replace(/super\.onCreate\(.*\)/, wakeLogig);
|
|
119
84
|
}
|
|
120
85
|
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
contents = contents.replace(
|
|
124
|
-
/return ReactActivityDelegateWrapper\([\s\S]*?object : (DefaultReactActivityDelegate\([\s\S]*?\))\{\}\)/,
|
|
125
|
-
'return ReactActivityDelegateWrapper($1)'
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
// --- 4. Ensure onNewIntent exists ---
|
|
129
|
-
const onNewIntentCode = `
|
|
130
|
-
override fun onNewIntent(intent: Intent) {
|
|
131
|
-
super.onNewIntent(intent)
|
|
132
|
-
setIntent(intent)
|
|
133
|
-
}`;
|
|
86
|
+
// 3. REMOVE the "Update createReactActivityDelegate" section entirely.
|
|
87
|
+
// Modern Expo handles the Wrapper correctly; your regex was breaking the Kotlin syntax.
|
|
134
88
|
|
|
89
|
+
// 4. Ensure onNewIntent exists
|
|
135
90
|
if (!contents.includes('override fun onNewIntent')) {
|
|
91
|
+
const onNewIntentCode = `
|
|
92
|
+
override fun onNewIntent(intent: Intent) {
|
|
93
|
+
super.onNewIntent(intent)
|
|
94
|
+
setIntent(intent)
|
|
95
|
+
}\n`;
|
|
96
|
+
// Insert it before the last closing brace of the class
|
|
136
97
|
const lastBraceIndex = contents.lastIndexOf('}');
|
|
137
|
-
contents = contents.slice(0, lastBraceIndex) + onNewIntentCode +
|
|
98
|
+
contents = contents.slice(0, lastBraceIndex) + onNewIntentCode + contents.slice(lastBraceIndex);
|
|
138
99
|
}
|
|
139
100
|
|
|
140
101
|
config.modResults.contents = contents;
|