rns-nativecall 0.4.0 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rns-nativecall",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "RNS nativecall component with native Android/iOS for handling native call ui, when app is not open or open.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -53,88 +53,49 @@ function withMainActivityDataFix(config) {
53
53
  return withMainActivity(config, (config) => {
54
54
  let contents = config.modResults.contents;
55
55
 
56
- // --- 1. Imports ---
57
- const neededImports = [
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
- // --- 2. Replace onCreate ---
70
- // We look for the existing onCreate and replace the entire block with your version
71
- const editedOnCreate = `
72
- // override fun onCreate(savedInstanceState: Bundle?) {
73
- // setTheme(R.style.AppTheme)
74
- // super.onCreate(savedInstanceState)
75
-
76
- // // --- LOCK SCREEN WAKE LOGIC ---
77
- // // This allows the Activity to appear over the lock screen when Answer is pressed
78
- // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
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
- // Regex to find the existing onCreate block (including the setTheme and super calls)
116
- const onCreateRegex = /override fun onCreate\(savedInstanceState: Bundle\?\).*?\{[\s\S]*?super\.onCreate\(null\)\n\s*\}/;
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
- // --- 3. Update createReactActivityDelegate ---
122
- // Removing the "object :" and the empty trailing block "{})" to match your edited version
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 + "\n" + contents.slice(lastBraceIndex);
98
+ contents = contents.slice(0, lastBraceIndex) + onNewIntentCode + contents.slice(lastBraceIndex);
138
99
  }
139
100
 
140
101
  config.modResults.contents = contents;