react-native-acoustic-connect-beta 18.0.10 → 18.0.12

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.
Files changed (49) hide show
  1. package/Examples/SampleUI/ConnectConfig.json +180 -0
  2. package/Examples/SampleUI/android/app/build.gradle +2 -0
  3. package/Examples/SampleUI/android/app/src/main/AndroidManifest.xml +18 -13
  4. package/Examples/SampleUI/android/app/src/main/java/com/sampleui/MainActivity.kt +47 -5
  5. package/Examples/SampleUI/ios/SampleUI.xcodeproj/xcshareddata/xcschemes/SampleUI.xcscheme +17 -0
  6. package/Examples/SampleUI/metro.config.js +2 -1
  7. package/Examples/SampleUI/package.json +3 -2
  8. package/Examples/SampleUI/src/RootNavigator.tsx +10 -1
  9. package/README.md +4 -0
  10. package/android/config.gradle +1 -1
  11. package/android/src/main/assets/ConnectAdvancedConfig.json +1 -1
  12. package/android/src/main/java/com/acousticconnectrn/AcousticConnectRNPackage.java +32 -3
  13. package/android/src/main/java/com/acousticconnectrn/HybridAcousticConnectRN.kt +116 -6
  14. package/ios/HybridAcousticConnectRN.swift +2 -44
  15. package/lib/commonjs/components/Connect.js +98 -0
  16. package/lib/commonjs/components/Connect.js.map +1 -0
  17. package/lib/commonjs/index.js +10 -1
  18. package/lib/commonjs/index.js.map +1 -1
  19. package/lib/module/components/Connect.js +91 -0
  20. package/lib/module/components/Connect.js.map +1 -0
  21. package/lib/module/index.js +2 -1
  22. package/lib/module/index.js.map +1 -1
  23. package/lib/typescript/src/components/Connect.d.ts +17 -0
  24. package/lib/typescript/src/components/Connect.d.ts.map +1 -0
  25. package/lib/typescript/src/index.d.ts +2 -0
  26. package/lib/typescript/src/index.d.ts.map +1 -1
  27. package/lib/typescript/src/specs/react-native-acoustic-connect.nitro.d.ts.map +1 -1
  28. package/package.json +2 -1
  29. package/scripts/ConnectConfig.json +1 -1
  30. package/scripts/gradleParser.js +4 -1
  31. package/scripts/javaParser.js +104 -68
  32. package/scripts/postInstallScripts.sh +3 -3
  33. package/scripts/xmlparser.js +7 -5
  34. package/src/components/Connect.tsx +110 -0
  35. package/src/index.ts +3 -3
  36. package/src/specs/react-native-acoustic-connect.nitro.ts +1 -15
  37. package/Examples/SampleUI/package-lock.json +0 -17033
  38. package/android/src/main/java/com/acousticconnectrn/AcousticConnectRNImpl.kt +0 -106
  39. package/ios/AcousticConnectRNImpl.swift +0 -64
  40. package/jslib/components/Connect.js +0 -85
  41. package/lib/commonjs/types.js +0 -24
  42. package/lib/commonjs/types.js.map +0 -1
  43. package/lib/module/types.js +0 -24
  44. package/lib/module/types.js.map +0 -1
  45. package/lib/typescript/jslib/components/Connect.d.ts +0 -4
  46. package/lib/typescript/jslib/components/Connect.d.ts.map +0 -1
  47. package/lib/typescript/src/types.d.ts +0 -1
  48. package/lib/typescript/src/types.d.ts.map +0 -1
  49. package/src/types.ts +0 -23
@@ -0,0 +1,180 @@
1
+ {
2
+ "Connect": {
3
+ "AndroidVersion": "10.4.30",
4
+ "AppKey": "b6c3709b7a4c479bb4b5a9fb8fec324c",
5
+ "KillSwitchUrl": "https://lib-us-2.brilliantcollector.com/collector/switch/b6c3709b7a4c479bb4b5a9fb8fec324c",
6
+ "PostMessageUrl": "https://lib-us-2.brilliantcollector.com/collector/collectorPost",
7
+ "iOSVersion": "",
8
+ "layoutConfigAndroid": {
9
+ "AppendMapIds": {
10
+ "[w,9290],[v,0]": {
11
+ "mid": "ASimpleUIView"
12
+ },
13
+ "idxPathValue": {
14
+ "mid": "giveAdditionalId2"
15
+ },
16
+ "tag2999999": {
17
+ "mid": "giveAdditionalId1"
18
+ }
19
+ },
20
+ "AutoLayout": {
21
+ "ExampleMaskingPage": {
22
+ "CaptureLayoutDelay": 0,
23
+ "CaptureLayoutOn": 0,
24
+ "CaptureScreenVisits": false,
25
+ "CaptureScreenshotOn": 0,
26
+ "CaptureUserEvents": false,
27
+ "DisplayName": "",
28
+ "Masking": {
29
+ "HasCustomMask": true,
30
+ "HasMasking": true,
31
+ "MaskAccessibilityIdList": [
32
+
33
+ ],
34
+ "MaskAccessibilityLabelList": [
35
+
36
+ ],
37
+ "MaskIdList": [
38
+ "^9[0-9][0-9][0-9]$",
39
+ "^\\[wvv,0\\],\\[dddv,0\\],\\[v,0\\],\\[v,0\\],\\[v,0\\],\\[b,0\\](.)*$"
40
+ ],
41
+ "MaskValueList": [
42
+ "^4[0-9]{12}(?:[0-9]{3})?$",
43
+ "^3[47][0-9]{13}$",
44
+ "^65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})$",
45
+ "^(5[1-5][0-9]{14}|2(22[1-9][0-9]{12}|2[3-9][0-9]{13}|[3-6][0-9]{14}|7[0-1][0-9]{13}|720[0-9]{12}))$"
46
+ ],
47
+ "Sensitive": {
48
+ "capitalCaseAlphabet": "X",
49
+ "number": "9",
50
+ "smallCaseAlphabet": "x",
51
+ "symbol": "#"
52
+ }
53
+ },
54
+ "NumberOfWebViews": 0,
55
+ "ScreenChange": false,
56
+ "ScreenShot": false
57
+ },
58
+ "GlobalScreenSettings": {
59
+ "CaptureLayoutDelay": 1,
60
+ "CaptureLayoutOn": 2,
61
+ "CaptureScreenVisits": false,
62
+ "CaptureScreenshotOn": 2,
63
+ "CaptureUserEvents": true,
64
+ "DisplayName": "",
65
+ "Masking": {
66
+ "HasCustomMask": true,
67
+ "HasMasking": true,
68
+ "MaskAccessibilityIdList": [
69
+
70
+ ],
71
+ "MaskAccessibilityLabelList": [
72
+
73
+ ],
74
+ "MaskIdList": [
75
+
76
+ ],
77
+ "MaskValueList": [
78
+
79
+ ],
80
+ "Sensitive": {
81
+ "capitalCaseAlphabet": "X",
82
+ "number": "9",
83
+ "smallCaseAlphabet": "x",
84
+ "symbol": "#"
85
+ }
86
+ },
87
+ "NumberOfWebViews": 0,
88
+ "ScreenChange": true,
89
+ "ScreenShot": true
90
+ }
91
+ }
92
+ },
93
+ "layoutConfigIos": {
94
+ "AppendMapIds": {
95
+ "[w,9290],[v,0]": {
96
+ "mid": "ASimpleUIView"
97
+ },
98
+ "idxPathValue": {
99
+ "mid": "giveAdditionalId2"
100
+ },
101
+ "tag2999999": {
102
+ "mid": "giveAdditionalId1"
103
+ }
104
+ },
105
+ "AutoLayout": {
106
+ "ExampleMaskingPage": {
107
+ "CaptureLayoutDelay": 0,
108
+ "CaptureLayoutOn": 0,
109
+ "CaptureScreenVisits": false,
110
+ "CaptureScreenshotOn": 0,
111
+ "CaptureUserEvents": false,
112
+ "DisplayName": "",
113
+ "Masking": {
114
+ "HasCustomMask": true,
115
+ "HasMasking": true,
116
+ "MaskAccessibilityIdList": [
117
+
118
+ ],
119
+ "MaskAccessibilityLabelList": [
120
+
121
+ ],
122
+ "MaskIdList": [
123
+ "^9[0-9][0-9][0-9]$",
124
+ "^\\[wvv,0\\],\\[dddv,0\\],\\[v,0\\],\\[v,0\\],\\[v,0\\],\\[b,0\\](.)*$"
125
+ ],
126
+ "MaskValueList": [
127
+ "^4[0-9]{12}(?:[0-9]{3})?$",
128
+ "^3[47][0-9]{13}$",
129
+ "^65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})$",
130
+ "^(5[1-5][0-9]{14}|2(22[1-9][0-9]{12}|2[3-9][0-9]{13}|[3-6][0-9]{14}|7[0-1][0-9]{13}|720[0-9]{12}))$"
131
+ ],
132
+ "Sensitive": {
133
+ "capitalCaseAlphabet": "X",
134
+ "number": "9",
135
+ "smallCaseAlphabet": "x",
136
+ "symbol": "#"
137
+ }
138
+ },
139
+ "NumberOfWebViews": 0,
140
+ "ScreenChange": false,
141
+ "ScreenShot": false
142
+ },
143
+ "GlobalScreenSettings": {
144
+ "CaptureLayoutDelay": 1,
145
+ "CaptureLayoutOn": 2,
146
+ "CaptureScreenVisits": false,
147
+ "CaptureScreenshotOn": 2,
148
+ "CaptureUserEvents": true,
149
+ "DisplayName": "",
150
+ "Masking": {
151
+ "HasCustomMask": true,
152
+ "HasMasking": true,
153
+ "MaskAccessibilityIdList": [
154
+
155
+ ],
156
+ "MaskAccessibilityLabelList": [
157
+
158
+ ],
159
+ "MaskIdList": [
160
+
161
+ ],
162
+ "MaskValueList": [
163
+
164
+ ],
165
+ "Sensitive": {
166
+ "capitalCaseAlphabet": "X",
167
+ "number": "9",
168
+ "smallCaseAlphabet": "x",
169
+ "symbol": "#"
170
+ }
171
+ },
172
+ "NumberOfWebViews": 0,
173
+ "ScreenChange": true,
174
+ "ScreenShot": true
175
+ }
176
+ }
177
+ },
178
+ "useRelease": false
179
+ }
180
+ }
@@ -122,3 +122,5 @@ dependencies {
122
122
  implementation jscFlavor
123
123
  }
124
124
  }
125
+
126
+ apply from: project(':react-native-acoustic-connect-beta').projectDir.getPath() + "/config.gradle"
@@ -1,22 +1,27 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
3
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
4
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
2
5
 
3
6
  <uses-permission android:name="android.permission.INTERNET" />
4
7
 
5
8
  <application
6
- android:name=".MainApplication"
7
- android:label="@string/app_name"
8
- android:icon="@mipmap/ic_launcher"
9
- android:roundIcon="@mipmap/ic_launcher_round"
10
- android:allowBackup="false"
11
- android:theme="@style/AppTheme"
12
- android:supportsRtl="true">
9
+ android:name=".MainApplication"
10
+ android:label="@string/app_name"
11
+ android:icon="@mipmap/ic_launcher"
12
+ android:roundIcon="@mipmap/ic_launcher_round"
13
+ android:allowBackup="false"
14
+ android:theme="@style/AppTheme"
15
+ android:supportsRtl="true"
16
+ >
13
17
  <activity
14
- android:name=".MainActivity"
15
- android:label="@string/app_name"
16
- android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
17
- android:launchMode="singleTask"
18
- android:windowSoftInputMode="adjustResize"
19
- android:exported="true">
18
+ android:name=".MainActivity"
19
+ android:label="@string/app_name"
20
+ android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
21
+ android:launchMode="singleTask"
22
+ android:windowSoftInputMode="adjustResize"
23
+ android:exported="true"
24
+ >
20
25
  <intent-filter>
21
26
  <action android:name="android.intent.action.MAIN" />
22
27
  <category android:name="android.intent.category.LAUNCHER" />
@@ -1,4 +1,6 @@
1
1
  package com.sampleui
2
+ import com.acoustic.connect.android.connectmod.Connect
3
+ import android.view.MotionEvent
2
4
  import expo.modules.ReactActivityDelegateWrapper
3
5
 
4
6
  import com.facebook.react.ReactActivity
@@ -8,16 +10,56 @@ import com.facebook.react.defaults.DefaultReactActivityDelegate
8
10
 
9
11
  class MainActivity : ReactActivity() {
10
12
 
11
- /**
13
+ /**
12
14
  * Returns the name of the main component registered from JavaScript. This is used to schedule
13
15
  * rendering of the component.
14
16
  */
15
- override fun getMainComponentName(): String = "SampleUI"
17
+ override fun getMainComponentName(): String = "SampleUI"
16
18
 
17
- /**
19
+ /**
18
20
  * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
19
21
  * which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
20
22
  */
21
- override fun createReactActivityDelegate(): ReactActivityDelegate =
22
- ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled))
23
+ override fun createReactActivityDelegate(): ReactActivityDelegate = ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled))
24
+
25
+ override fun dispatchTouchEvent(e: MotionEvent?): Boolean {
26
+ Connect.dispatchTouchEvent(this, e)
27
+ return super.dispatchTouchEvent(e)
28
+ }
29
+
30
+ override fun dispatchTouchEvent(e: MotionEvent?): Boolean {
31
+ Connect.dispatchTouchEvent(this, e)
32
+ return super.dispatchTouchEvent(e)
33
+ }
34
+
35
+ override fun dispatchTouchEvent(e: MotionEvent?): Boolean {
36
+ Connect.dispatchTouchEvent(this, e)
37
+ return super.dispatchTouchEvent(e)
38
+ }
39
+
40
+ override fun dispatchTouchEvent(e: MotionEvent?): Boolean {
41
+ Connect.dispatchTouchEvent(this, e)
42
+ return super.dispatchTouchEvent(e)
43
+ }
44
+
45
+ override fun dispatchTouchEvent(e: MotionEvent?): Boolean {
46
+ Connect.dispatchTouchEvent(this, e)
47
+ return super.dispatchTouchEvent(e)
48
+ }
49
+
50
+ override fun dispatchTouchEvent(e: MotionEvent?): Boolean {
51
+ Connect.dispatchTouchEvent(this, e)
52
+ return super.dispatchTouchEvent(e)
53
+ }
54
+
55
+ override fun dispatchTouchEvent(e: MotionEvent?): Boolean {
56
+ Connect.dispatchTouchEvent(this, e)
57
+ return super.dispatchTouchEvent(e)
58
+ }
59
+
60
+ override fun dispatchTouchEvent(e: MotionEvent?): Boolean {
61
+ Connect.dispatchTouchEvent(this, e)
62
+ return super.dispatchTouchEvent(e)
63
+ }
23
64
  }
65
+
@@ -60,6 +60,23 @@
60
60
  ReferencedContainer = "container:SampleUI.xcodeproj">
61
61
  </BuildableReference>
62
62
  </BuildableProductRunnable>
63
+ <EnvironmentVariables>
64
+ <EnvironmentVariable
65
+ key = "EODebug"
66
+ value = "1"
67
+ isEnabled = "YES">
68
+ </EnvironmentVariable>
69
+ <EnvironmentVariable
70
+ key = "TLF_DEBUG"
71
+ value = "1"
72
+ isEnabled = "YES">
73
+ </EnvironmentVariable>
74
+ <EnvironmentVariable
75
+ key = "CONNECT_DEBUG"
76
+ value = "1"
77
+ isEnabled = "YES">
78
+ </EnvironmentVariable>
79
+ </EnvironmentVariables>
63
80
  </LaunchAction>
64
81
  <ProfileAction
65
82
  buildConfiguration = "Release"
@@ -15,7 +15,8 @@ const modules = [
15
15
  'react-native',
16
16
  'react-native-safe-area-context',
17
17
  'react-native-vector-icons',
18
- '@expo/vector-icons'
18
+ '@expo/vector-icons',
19
+ // 'react-native-acoustic-connect-beta',
19
20
  ];
20
21
 
21
22
  module.exports = {
@@ -7,7 +7,8 @@
7
7
  "ios": "cd ios && pod install && cd .. && react-native run-ios",
8
8
  "lint": "eslint .",
9
9
  "start": "react-native start",
10
- "test": "jest"
10
+ "test": "jest",
11
+ "updateYalc": "yalc update react-native-acoustic-connect-beta && cd ios && pod install && cd .."
11
12
  },
12
13
  "dependencies": {
13
14
  "@babel/plugin-proposal-export-namespace-from": "^7.18.9",
@@ -25,7 +26,7 @@
25
26
  "expo-status-bar": "^2.0.1",
26
27
  "react": "18.3.1",
27
28
  "react-native": "0.76.9",
28
- "react-native-acoustic-connect-beta": "^18.0.7",
29
+ "react-native-acoustic-connect-beta": "file:.yalc/react-native-acoustic-connect-beta",
29
30
  "react-native-gesture-handler": "~2.20.2",
30
31
  "react-native-get-random-values": "^1.11.0",
31
32
  "react-native-nitro-modules": "^0.25.2",
@@ -11,6 +11,15 @@ import { Appbar } from 'react-native-paper';
11
11
 
12
12
  import ExampleList, { examples } from './ExampleList';
13
13
 
14
+ // import { AcousticConnectRN, Connect } from 'react-native-acoustic-connect-beta';
15
+ // Log all exported items from the module
16
+ import AcousticConnectRN from 'react-native-acoustic-connect-beta';
17
+ import * as AcousticConnectBeta from 'react-native-acoustic-connect-beta';
18
+ console.log('Exported items from react-native-acoustic-connect-beta:', AcousticConnectBeta);
19
+
20
+ const result = AcousticConnectRN.logCustomEvent('test', {test: 'test'}, 1);
21
+ console.log('result', result);
22
+
14
23
  const Stack = createStackNavigator();
15
24
 
16
25
  export default function Root() {
@@ -53,7 +62,7 @@ export default function Root() {
53
62
  name="ExampleList"
54
63
  component={ExampleList}
55
64
  options={{
56
- title: 'Examples',
65
+ title: 'Examples: Acoustic Connect',
57
66
  }}
58
67
  />
59
68
  {(Object.keys(examples) as Array<keyof typeof examples>).map((id) => {
package/README.md CHANGED
@@ -8,7 +8,11 @@
8
8
  ## Installation
9
9
 
10
10
  ```bash
11
+ // To add to your package
11
12
  npm add react-native-acoustic-connect-beta react-native-nitro-modules
13
+ // To install on your application and view debug information during install
14
+ npm install --foreground-scripts --force
15
+
12
16
  ```
13
17
 
14
18
 
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************************
2
- * Copyright (C) 2024 Acoustic, L.P. All rights reserved.
2
+ * Copyright (C) 2025 Acoustic, L.P. All rights reserved.
3
3
  *
4
4
  * NOTICE: This file contains material that is confidential and proprietary to
5
5
  * Acoustic, L.P. and/or other developers. No license is granted under any intellectual or
@@ -24,7 +24,7 @@
24
24
  "IpPlaceholder": "N/A",
25
25
  "KillSwitchAsync": true,
26
26
  "KillSwitchDelay": 300,
27
- "LibraryVersion": "10.4.32",
27
+ "LibraryVersion": "10.4.37",
28
28
  "LogFullRequestResponsePayloads": true,
29
29
  "MessageTypeHeader": "WorklightHit",
30
30
  "MessageTypes": "4,5",
@@ -1,4 +1,4 @@
1
- // Copyright (C) 2024 Acoustic, L.P. All rights reserved.
1
+ // Copyright (C) 2025 Acoustic, L.P. All rights reserved.
2
2
  //
3
3
  // NOTICE: This file contains material that is confidential and proprietary to
4
4
  // Acoustic, L.P. and/or other developers. No license is granted under any intellectual or
@@ -12,6 +12,8 @@
12
12
 
13
13
  package com.acousticconnectrn;
14
14
 
15
+ import android.os.Handler;
16
+ import android.os.Looper;
15
17
  import android.util.Log;
16
18
  import androidx.annotation.Nullable;
17
19
  import androidx.annotation.NonNull;
@@ -20,11 +22,10 @@ import com.facebook.react.bridge.NativeModule;
20
22
  import com.facebook.react.bridge.ReactApplicationContext;
21
23
  import com.facebook.react.module.model.ReactModuleInfoProvider;
22
24
  import com.facebook.react.TurboReactPackage;
23
- import com.margelo.nitro.core.HybridObject;
25
+ import com.margelo.nitro.NitroModules;
24
26
  import com.margelo.nitro.acousticconnectrn.AcousticConnectRNOnLoad;
25
27
 
26
28
  import java.util.HashMap;
27
- import java.util.function.Supplier;
28
29
 
29
30
  public class AcousticConnectRNPackage extends TurboReactPackage {
30
31
  @Nullable
@@ -41,5 +42,33 @@ public class AcousticConnectRNPackage extends TurboReactPackage {
41
42
 
42
43
  static {
43
44
  AcousticConnectRNOnLoad.initializeNative();
45
+ try {
46
+ // Start a background thread to wait for the context
47
+ new Thread(() -> {
48
+ ReactApplicationContext reactContext = null;
49
+
50
+ // Poll until NitroModules.getApplicationContext() is not null
51
+ while (reactContext == null) {
52
+ reactContext = NitroModules.getApplicationContext();
53
+ if (reactContext == null) {
54
+ try {
55
+ Thread.sleep(100); // Sleep for 100ms before checking again
56
+ } catch (InterruptedException e) {
57
+ Log.e("AcousticConnectRNPackage", "Thread interrupted while waiting for ReactApplicationContext.", e);
58
+ return;
59
+ }
60
+ }
61
+ }
62
+
63
+ // Post initialization logic to the main (UI) thread
64
+ ReactApplicationContext finalReactContext = reactContext;
65
+ new Handler(Looper.getMainLooper()).post(() -> {
66
+ HybridAcousticConnectRN hybridInstance = new HybridAcousticConnectRN(finalReactContext);
67
+ Log.i("AcousticConnectRNPackage", "HybridAcousticConnectRN initialized successfully.");
68
+ });
69
+ }).start();
70
+ } catch (Exception e) {
71
+ Log.e("AcousticConnectRNPackage", "Failed to initialize HybridAcousticConnectRN.", e);
72
+ }
44
73
  }
45
74
  }
@@ -1,4 +1,4 @@
1
- // Copyright (C) 2024 Acoustic, L.P. All rights reserved.
1
+ // Copyright (C) 2025 Acoustic, L.P. All rights reserved.
2
2
  //
3
3
  // NOTICE: This file contains material that is confidential and proprietary to
4
4
  // Acoustic, L.P. and/or other developers. No license is granted under any intellectual or
@@ -12,9 +12,11 @@
12
12
 
13
13
  package com.acousticconnectrn
14
14
 
15
- //import com.margelo.nitro.acousticconnectrn.Variant_String_Double_Boolean_KeyValueObject
16
15
  import android.app.Activity
16
+ import android.app.Application
17
17
  import android.content.Context
18
+ import android.os.Handler
19
+ import android.os.Looper
18
20
  import android.text.TextUtils
19
21
  import android.view.View
20
22
  import android.view.View.OnFocusChangeListener
@@ -26,13 +28,19 @@ import com.acoustic.connect.android.connectmod.Connect.TLF_ON_FOCUS_CHANGE_IN
26
28
  import com.acoustic.connect.android.connectmod.Connect.TLF_ON_FOCUS_CHANGE_OUT
27
29
  import com.acoustic.connect.android.connectmod.Connect.TLF_UI_KEYBOARD_DID_HIDE_NOTIFICATION
28
30
  import com.acoustic.connect.android.connectmod.Connect.TLF_UI_KEYBOARD_DID_SHOW_NOTIFICATION
31
+ import com.acoustic.connect.android.connectmod.Connect.enable
32
+ import com.acoustic.connect.android.connectmod.Connect.getApplication
33
+ import com.acoustic.connect.android.connectmod.Connect.init
34
+ import com.acoustic.connect.android.connectmod.Connect.isEnabled
29
35
  import com.acoustic.connect.android.connectmod.Connect.logEvent
30
36
  import com.acoustic.connect.android.connectmod.Connect.logGeolocation
31
37
  import com.acoustic.connect.android.connectmod.Connect.logLocationUpdateEventWithLatitude
32
38
  import com.acoustic.connect.android.connectmod.Connect.logScreenLayout
33
39
  import com.acoustic.connect.android.connectmod.Connect.logScreenview
40
+ import com.acoustic.connect.android.connectmod.Connect.onResume
34
41
  import com.acoustic.connect.android.connectmod.Connect.registerFormField
35
42
  import com.acoustic.connect.android.connectmod.Connect.resumeConnect
43
+ import com.facebook.react.bridge.LifecycleEventListener
36
44
  import com.facebook.react.bridge.ReactApplicationContext
37
45
  import com.facebook.react.uimanager.NativeViewHierarchyManager
38
46
  import com.facebook.react.uimanager.UIManagerModule
@@ -41,14 +49,26 @@ import com.ibm.eo.model.EOMonitoringLevel
41
49
  import com.margelo.nitro.NitroModules
42
50
  import com.margelo.nitro.acousticconnectrn.HybridAcousticConnectRNSpec
43
51
  import com.margelo.nitro.acousticconnectrn.Variant_String_Double_Boolean
52
+ import com.tl.uic.Tealeaf
44
53
  import com.tl.uic.model.ScreenviewType
45
54
  import com.tl.uic.util.LayoutUtil
46
55
  import com.tl.uic.util.keyboardview.KeyboardView
47
56
  import java.util.Objects
48
57
 
58
+ class HybridAcousticConnectRN(private val reactContext: ReactApplicationContext) : HybridAcousticConnectRNSpec(), LifecycleEventListener {
49
59
 
50
- class HybridAcousticConnectRN(private val reactContext: ReactApplicationContext) : HybridAcousticConnectRNSpec() {
51
- private val context = NitroModules.applicationContext ?: throw Exception("Context is null")
60
+ init {
61
+ // Add your listener logic here
62
+ println("HybridAcousticConnectRNSpec has been initialized")
63
+
64
+ Handler(Looper.getMainLooper()).post {
65
+ if (reactContext.hasActiveCatalystInstance()) {
66
+ reactContext.addLifecycleEventListener(this)
67
+ } else {
68
+ println("ReactContext is not ready. LifecycleEventListener not registered.")
69
+ }
70
+ }
71
+ }
52
72
 
53
73
  /**
54
74
  * Sets the module's boolean configuration item from AdvancedConfig.json or BasicConfig.properties that matches the specified key.
@@ -491,7 +511,97 @@ class HybridAcousticConnectRN(private val reactContext: ReactApplicationContext)
491
511
  registerFormField(textView, activity)
492
512
  }
493
513
 
494
- // companion object {
495
- // const val TAG = "AcousticConnectStatusInoRNBeta"
514
+ // override fun onWindowFocusChanged(hasFocus: Boolean) {
515
+ // if (!reactContext.hasActiveCatalystInstance()) {
516
+ // logEvent("WindowFocus", "Context is not ready. Skipping onWindowFocusChanged.")
517
+ // return
518
+ // }
519
+ //
520
+ // // Handle window focus change
521
+ // if (hasFocus) {
522
+ // logEvent("WindowFocus", "Window gained focus")
523
+ // } else {
524
+ // logEvent("WindowFocus", "Window lost focus")
525
+ // }
526
+ // }
527
+
528
+ // override fun onWindowFocusChanged(hasFocus: Boolean) {
529
+ // super.onWindowFocusChanged(hasFocus)
530
+ //
531
+ // val reactHost = (application as MainApplication).reactHost
532
+ // if (reactHost != null) {
533
+ // reactHost.onWindowFocusChange(hasFocus)
496
534
  // }
535
+ // }
536
+
537
+ fun onWindowFocusChanged(hasFocus: Boolean) {
538
+ if (!reactContext.hasActiveCatalystInstance()) {
539
+ // logEvent("WindowFocus", "Context is not ready. Skipping onWindowFocusChanged.")
540
+ return
541
+ }
542
+
543
+ // Handle window focus change
544
+ if (hasFocus) {
545
+ // logEvent("WindowFocus", "Window gained focus")
546
+ } else {
547
+ // logEvent("WindowFocus", "Window lost focus")
548
+ }
549
+ }
550
+
551
+ /**
552
+ * Used when host resumes.
553
+ */
554
+ override fun onHostResume() {
555
+ // Initialize Connect library, and hook into activity lifecycle events to help detect if app is in background
556
+ if (!reactContext.hasActiveCatalystInstance()) {
557
+ // logEvent("Lifecycle", "onHostResume skipped: ReactContext is not ready")
558
+ return
559
+ }
560
+
561
+ val activity = getCurrentActivity()
562
+ if (activity == null) {
563
+ // logEvent("Lifecycle", "onHostResume skipped: Activity is null")
564
+ return
565
+ }
566
+
567
+ if (!isEnabled()) {
568
+ if (getApplication() == null) {
569
+ init((reactContext.applicationContext as Application))
570
+ }
571
+ enable()
572
+ }
573
+ onResume(activity, null)
574
+ }
575
+
576
+ /**
577
+ * Used when host gets paused.
578
+ */
579
+ override fun onHostPause() {
580
+ val activity = getCurrentActivity()
581
+ if (activity == null) {
582
+ // logEvent("Lifecycle", "onHostPause skipped: Activity is null")
583
+ return
584
+ }
585
+
586
+ Connect.onPause(activity, null)
587
+ }
588
+
589
+ /**
590
+ * Used when host gets destroyed.
591
+ */
592
+ override fun onHostDestroy() {
593
+ val activity = getCurrentActivity()
594
+ if (activity == null) {
595
+ // logEvent("Lifecycle", "onHostDestroy skipped: Activity is null")
596
+ return
597
+ }
598
+
599
+ Tealeaf.onDestroy(activity, null)
600
+ // Uncomment if Connect.onDestroy is needed
601
+ // Connect.onDestroy(activity, null)
602
+ }
603
+
604
+ companion object {
605
+ const val TAG = "AcousticConnectRN"
606
+ }
497
607
  }