react-native-flic2 2.0.0-beta.1 → 2.0.0-beta.3

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/README.md CHANGED
@@ -66,6 +66,65 @@ The library automatically includes the necessary permissions in `AndroidManifest
66
66
 
67
67
  You'll need to request these permissions before scanning for buttons. Use a library like `react-native-permissions` or implement permission requests manually.
68
68
 
69
+ #### Customizing the Foreground Service Notification (Android)
70
+
71
+ The library runs a foreground service to keep Flic2 buttons connected in the background. You can customize the notification appearance by adding metadata to your app's `AndroidManifest.xml`:
72
+
73
+ ```xml
74
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
75
+ <application>
76
+ <!-- Your existing application configuration -->
77
+
78
+ <!-- Customize Flic2 foreground service notification -->
79
+ <meta-data
80
+ android:name="nl.xguard.flic2.notification_title"
81
+ android:value="My Flic2 Service" />
82
+ <meta-data
83
+ android:name="nl.xguard.flic2.notification_text"
84
+ android:value="Flic2 buttons are active" />
85
+ <meta-data
86
+ android:name="nl.xguard.flic2.notification_icon"
87
+ android:resource="@drawable/ic_notification" />
88
+ <meta-data
89
+ android:name="nl.xguard.flic2.notification_channel_name"
90
+ android:value="Flic2 Notifications" />
91
+ <meta-data
92
+ android:name="nl.xguard.flic2.notification_channel_description"
93
+ android:value="Notifications for Flic2 button connections" />
94
+ <meta-data
95
+ android:name="nl.xguard.flic2.notification_id"
96
+ android:value="123321" />
97
+ <meta-data
98
+ android:name="nl.xguard.flic2.notification_channel_id"
99
+ android:value="my_custom_channel_id" />
100
+ </application>
101
+ </manifest>
102
+ ```
103
+
104
+ **Available Configuration Options:**
105
+
106
+ - `nl.xguard.flic2.notification_title` - Notification title (default: "Flic 2")
107
+ - `nl.xguard.flic2.notification_text` - Notification text (default: "Flic 2 service is running")
108
+ - `nl.xguard.flic2.notification_icon` - Notification icon resource ID (default: system info icon)
109
+ - Use `@drawable/your_icon_name` or `@mipmap/your_icon_name` format
110
+ - `nl.xguard.flic2.notification_channel_name` - Notification channel name (default: "Flic2Channel")
111
+ - `nl.xguard.flic2.notification_channel_description` - Notification channel description (default: "Flic2Channel")
112
+ - `nl.xguard.flic2.notification_id` - Notification ID integer (default: 123321)
113
+ - `nl.xguard.flic2.notification_channel_id` - Notification channel ID string (default: "Notification_Channel_Flic2Service")
114
+
115
+ **Example with Custom Icon:**
116
+
117
+ 1. Add your notification icon to `android/app/src/main/res/drawable/` (e.g., `ic_flic2_notification.png`)
118
+
119
+ 2. Add metadata to `AndroidManifest.xml`:
120
+ ```xml
121
+ <meta-data
122
+ android:name="nl.xguard.flic2.notification_icon"
123
+ android:resource="@drawable/ic_flic2_notification" />
124
+ ```
125
+
126
+ **Note:** The notification icon must be a white/transparent icon suitable for Android notifications. If you don't specify a custom icon, the system default info icon will be used.
127
+
69
128
  ## Basic Usage
70
129
 
71
130
  ### 1. Initialize the Library (Global Setup)
@@ -26,7 +26,7 @@ def getExtOrIntegerDefault(name) {
26
26
  }
27
27
 
28
28
  android {
29
- namespace "com.flic2"
29
+ namespace "nl.xguard.flic2"
30
30
 
31
31
  compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
32
32
 
@@ -15,6 +15,7 @@
15
15
  <!-- Foreground service permission -->
16
16
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
17
17
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" />
18
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
18
19
 
19
20
  <application>
20
21
  <service
@@ -22,6 +23,28 @@
22
23
  android:enabled="true"
23
24
  android:exported="false"
24
25
  android:foregroundServiceType="connectedDevice" />
26
+
27
+ <receiver
28
+ android:name=".Flic2Service$BootUpReceiver"
29
+ android:enabled="true"
30
+ android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
31
+ android:exported="false">
32
+ <intent-filter>
33
+ <action android:name="android.intent.action.BOOT_COMPLETED" />
34
+ <category android:name="android.intent.category.DEFAULT" />
35
+ </intent-filter>
36
+ </receiver>
37
+
38
+ <receiver
39
+ android:name=".Flic2Service$UpdateReceiver"
40
+ android:enabled="true"
41
+ android:exported="false">
42
+ <intent-filter>
43
+ <action android:name="android.intent.action.PACKAGE_REPLACED" />
44
+ <data
45
+ android:scheme="package" />
46
+ </intent-filter>
47
+ </receiver>
25
48
  </application>
26
49
 
27
50
  </manifest>
@@ -0,0 +1,29 @@
1
+ package nl.xguard.flic2
2
+
3
+ import android.app.ActivityManager
4
+ import android.content.Context
5
+ import android.content.Intent
6
+ import android.os.Build
7
+
8
+ object ActivityUtil {
9
+ private const val TAG = "ActivityUtil"
10
+
11
+ fun isServiceRunning(context: Context, serviceClass: Class<*>): Boolean {
12
+ val manager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
13
+ for (service in manager.getRunningServices(Integer.MAX_VALUE)) {
14
+ if (serviceClass.name == service.service.className) {
15
+ return true
16
+ }
17
+ }
18
+ return false
19
+ }
20
+
21
+ fun startForegroundService(context: Context, intent: Intent) {
22
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
23
+ context.startForegroundService(intent)
24
+ } else {
25
+ context.startService(intent)
26
+ }
27
+ }
28
+ }
29
+
@@ -1,4 +1,4 @@
1
- package com.flic2
1
+ package nl.xguard.flic2
2
2
 
3
3
  import com.facebook.react.bridge.Arguments
4
4
  import com.facebook.react.bridge.WritableMap
@@ -1,4 +1,4 @@
1
- package com.flic2
1
+ package nl.xguard.flic2
2
2
 
3
3
  import com.facebook.react.bridge.Arguments
4
4
  import com.facebook.react.bridge.WritableArray
@@ -1,4 +1,4 @@
1
- package com.flic2
1
+ package nl.xguard.flic2
2
2
 
3
3
  import android.content.ComponentName
4
4
  import android.content.Context
@@ -57,6 +57,8 @@ class Flic2Module(reactContext: ReactApplicationContext) :
57
57
  manager.buttons.forEach { button ->
58
58
  setupButtonListener(button)
59
59
  }
60
+ // Update foreground service state based on button count
61
+ updateForegroundServiceState(manager.buttons.size)
60
62
  }
61
63
 
62
64
  // Resolve the initialize promise if pending
@@ -104,11 +106,11 @@ class Flic2Module(reactContext: ReactApplicationContext) :
104
106
 
105
107
  val intent = Intent(reactApplicationContext, Flic2Service::class.java)
106
108
 
107
- // Start service
108
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
109
- reactApplicationContext.startForegroundService(intent)
110
- } else {
111
- reactApplicationContext.startService(intent)
109
+ // Check if service is already running
110
+ val isRunning = ActivityUtil.isServiceRunning(reactApplicationContext, Flic2Service::class.java)
111
+ if (!isRunning) {
112
+ // Start service
113
+ ActivityUtil.startForegroundService(reactApplicationContext, intent)
112
114
  }
113
115
 
114
116
  // Bind to service - promise will be resolved in onServiceConnected
@@ -188,6 +190,11 @@ class Flic2Module(reactContext: ReactApplicationContext) :
188
190
 
189
191
  setupButtonListener(button)
190
192
 
193
+ // Update foreground service state after adding button
194
+ flic2Service?.getManager()?.let { manager ->
195
+ updateForegroundServiceState(manager.buttons.size)
196
+ }
197
+
191
198
  // Emit discovered event as button event (like iOS)
192
199
  emitOnButtonEvent(Arguments.createMap().apply {
193
200
  putString("uuid", button.uuid)
@@ -259,6 +266,9 @@ class Flic2Module(reactContext: ReactApplicationContext) :
259
266
  // Forget button
260
267
  manager.forgetButton(button)
261
268
 
269
+ // Update foreground service state after removing button
270
+ updateForegroundServiceState(manager.buttons.size)
271
+
262
272
  promise.resolve(Arguments.createMap().apply {
263
273
  putBoolean("success", true)
264
274
  putString("message", "Button forgotten")
@@ -414,6 +424,9 @@ class Flic2Module(reactContext: ReactApplicationContext) :
414
424
  manager.forgetButton(button)
415
425
  }
416
426
 
427
+ // Update foreground service state after removing all buttons
428
+ updateForegroundServiceState(manager.buttons.size)
429
+
417
430
  promise.resolve(Arguments.createMap().apply {
418
431
  putBoolean("success", true)
419
432
  putString("message", "All buttons forgotten")
@@ -462,6 +475,16 @@ class Flic2Module(reactContext: ReactApplicationContext) :
462
475
  buttonListeners[button.uuid] = listener
463
476
  }
464
477
 
478
+ private fun updateForegroundServiceState(buttonCount: Int) {
479
+ if (buttonCount > 0) {
480
+ // Start foreground service when buttons exist
481
+ flic2Service?.startForegroundService()
482
+ } else {
483
+ // Stop foreground service when no buttons
484
+ flic2Service?.stopForegroundService()
485
+ }
486
+ }
487
+
465
488
  private fun mapScanResultToCode(result: Int): Int {
466
489
  // Map Android library's 9 result codes (0-8) to TypeScript enum codes (0-21) matching iOS
467
490
  // Android library only provides these constants, so we map them to the closest equivalent
@@ -479,3 +502,4 @@ class Flic2Module(reactContext: ReactApplicationContext) :
479
502
  }
480
503
  }
481
504
  }
505
+
@@ -1,4 +1,4 @@
1
- package com.flic2
1
+ package nl.xguard.flic2
2
2
 
3
3
  import com.facebook.react.BaseReactPackage
4
4
  import com.facebook.react.bridge.NativeModule
@@ -31,3 +31,4 @@ class Flic2Package : BaseReactPackage() {
31
31
  }
32
32
  }
33
33
  }
34
+
@@ -0,0 +1,285 @@
1
+ package nl.xguard.flic2
2
+
3
+ import android.app.Notification
4
+ import android.app.NotificationChannel
5
+ import android.app.NotificationManager
6
+ import android.app.PendingIntent
7
+ import android.app.Service
8
+ import android.content.BroadcastReceiver
9
+ import android.content.Context
10
+ import android.content.Intent
11
+ import android.content.pm.PackageManager
12
+ import android.os.Binder
13
+ import android.os.Build
14
+ import android.os.Handler
15
+ import android.os.IBinder
16
+ import android.os.Looper
17
+ import android.util.Log
18
+ import androidx.core.app.NotificationCompat
19
+ import io.flic.flic2libandroid.Flic2Manager
20
+
21
+ class Flic2Service : Service() {
22
+
23
+ private val binder = Flic2ServiceBinder()
24
+ private var manager: Flic2Manager? = null
25
+ private var isServiceStarted = false
26
+ private var notification: Notification? = null
27
+
28
+ companion object {
29
+ private const val TAG = "Flic2Service"
30
+ private const val DEFAULT_NOTIFICATION_ID = 123321
31
+ private const val DEFAULT_CHANNEL_ID = "Notification_Channel_Flic2Service"
32
+
33
+ // Metadata keys for notification configuration
34
+ private const val KEY_CHANNEL_NAME = "nl.xguard.flic2.notification_channel_name"
35
+ private const val KEY_CHANNEL_DESCRIPTION = "nl.xguard.flic2.notification_channel_description"
36
+ private const val NOTIFICATION_TITLE_KEY = "nl.xguard.flic2.notification_title"
37
+ private const val NOTIFICATION_TEXT_KEY = "nl.xguard.flic2.notification_text"
38
+ private const val NOTIFICATION_ICON_KEY = "nl.xguard.flic2.notification_icon"
39
+ private const val NOTIFICATION_ID_KEY = "nl.xguard.flic2.notification_id"
40
+ private const val CHANNEL_ID_KEY = "nl.xguard.flic2.notification_channel_id"
41
+ }
42
+
43
+ inner class Flic2ServiceBinder : Binder() {
44
+ fun getService(): Flic2Service = this@Flic2Service
45
+ }
46
+
47
+ override fun onCreate() {
48
+ super.onCreate()
49
+ Log.d(TAG, "Service onCreate")
50
+
51
+ try {
52
+ // Initialize Flic2Manager on main thread with Handler
53
+ // v1.1.0 API: init() returns void, must call getInstance() after
54
+ Flic2Manager.init(
55
+ applicationContext,
56
+ Handler(Looper.getMainLooper())
57
+ )
58
+ manager = Flic2Manager.getInstance()
59
+ Log.d(TAG, "Flic2Manager initialized successfully")
60
+ } catch (e: Exception) {
61
+ Log.e(TAG, "Failed to initialize Flic2Manager", e)
62
+ }
63
+
64
+ // Create notification channel and notification in onCreate
65
+ createNotificationChannel()
66
+ notification = createNotification()
67
+ }
68
+
69
+ override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
70
+ Log.d(TAG, "Service onStartCommand")
71
+
72
+ if (intent != null) {
73
+ if (Intent.ACTION_BOOT_COMPLETED == intent.action) {
74
+ Log.d(TAG, "onStartCommand: ACTION_BOOT_COMPLETED")
75
+ }
76
+ }
77
+
78
+ // Start foreground service if notification is ready
79
+ if (notification != null) {
80
+ startForegroundService()
81
+ }
82
+
83
+ return START_STICKY
84
+ }
85
+
86
+ override fun onBind(intent: Intent?): IBinder {
87
+ Log.d(TAG, "Service onBind")
88
+ return binder
89
+ }
90
+
91
+ override fun onDestroy() {
92
+ Log.d(TAG, "Service onDestroy")
93
+ super.onDestroy()
94
+ }
95
+
96
+ fun getManager(): Flic2Manager? = manager
97
+
98
+ fun isManagerInitialized(): Boolean = manager != null
99
+
100
+ fun startForegroundService() {
101
+ if (!isServiceStarted && notification != null) {
102
+ isServiceStarted = true
103
+ try {
104
+ val notificationId = getNotificationId()
105
+ startForeground(notificationId, notification)
106
+ } catch (e: Exception) {
107
+ Log.w(TAG, "startForegroundService() exception", e)
108
+ }
109
+ }
110
+ }
111
+
112
+ fun stopForegroundService() {
113
+ if (isServiceStarted) {
114
+ isServiceStarted = false
115
+ stopForeground(true)
116
+ }
117
+ }
118
+
119
+ private fun createNotificationChannel() {
120
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
121
+ val channelId = getChannelId()
122
+ val channelName = getChannelName()
123
+ val channelDescription = getChannelDescription()
124
+
125
+ val channel = NotificationChannel(
126
+ channelId,
127
+ channelName,
128
+ NotificationManager.IMPORTANCE_LOW
129
+ ).apply {
130
+ description = channelDescription
131
+ setShowBadge(false)
132
+ }
133
+
134
+ val notificationManager = getSystemService(NotificationManager::class.java)
135
+ notificationManager.createNotificationChannel(channel)
136
+ }
137
+ }
138
+
139
+ private fun createNotification(): Notification {
140
+ val notificationIntent = Intent(this, Flic2Service::class.java)
141
+ val pendingIntent = PendingIntent.getActivity(
142
+ this,
143
+ 0,
144
+ notificationIntent,
145
+ PendingIntent.FLAG_IMMUTABLE
146
+ )
147
+
148
+ val channelId = getChannelId()
149
+ val title = getNotificationTitle()
150
+ val text = getNotificationText()
151
+ val icon = getNotificationIcon()
152
+
153
+ return NotificationCompat.Builder(this, channelId)
154
+ .setContentTitle(title)
155
+ .setContentText(text)
156
+ .setSmallIcon(icon)
157
+ .setContentIntent(pendingIntent)
158
+ .setPriority(NotificationCompat.PRIORITY_LOW)
159
+ .setOngoing(true)
160
+ .build()
161
+ }
162
+
163
+ private fun getNotificationId(): Int {
164
+ return try {
165
+ val metadata = applicationContext.packageManager
166
+ .getApplicationInfo(applicationContext.packageName, PackageManager.GET_META_DATA)
167
+ .metaData
168
+ metadata?.getInt(NOTIFICATION_ID_KEY, DEFAULT_NOTIFICATION_ID) ?: DEFAULT_NOTIFICATION_ID
169
+ } catch (e: PackageManager.NameNotFoundException) {
170
+ Log.w(TAG, "getNotificationId() NameNotFoundException", e)
171
+ DEFAULT_NOTIFICATION_ID
172
+ } catch (e: Exception) {
173
+ Log.w(TAG, "getNotificationId() exception", e)
174
+ DEFAULT_NOTIFICATION_ID
175
+ }
176
+ }
177
+
178
+ private fun getChannelId(): String {
179
+ return try {
180
+ val metadata = applicationContext.packageManager
181
+ .getApplicationInfo(applicationContext.packageName, PackageManager.GET_META_DATA)
182
+ .metaData
183
+ metadata?.getString(CHANNEL_ID_KEY) ?: DEFAULT_CHANNEL_ID
184
+ } catch (e: PackageManager.NameNotFoundException) {
185
+ Log.w(TAG, "getChannelId() NameNotFoundException", e)
186
+ DEFAULT_CHANNEL_ID
187
+ } catch (e: Exception) {
188
+ Log.w(TAG, "getChannelId() exception", e)
189
+ DEFAULT_CHANNEL_ID
190
+ }
191
+ }
192
+
193
+ private fun getChannelName(): String {
194
+ return try {
195
+ val metadata = applicationContext.packageManager
196
+ .getApplicationInfo(applicationContext.packageName, PackageManager.GET_META_DATA)
197
+ .metaData
198
+ metadata?.getString(KEY_CHANNEL_NAME) ?: "Flic2Channel"
199
+ } catch (e: PackageManager.NameNotFoundException) {
200
+ Log.w(TAG, "getChannelName() NameNotFoundException", e)
201
+ "Flic2Channel"
202
+ } catch (e: Exception) {
203
+ Log.w(TAG, "getChannelName() exception", e)
204
+ "Flic2Channel"
205
+ }
206
+ }
207
+
208
+ private fun getChannelDescription(): String {
209
+ return try {
210
+ val metadata = applicationContext.packageManager
211
+ .getApplicationInfo(applicationContext.packageName, PackageManager.GET_META_DATA)
212
+ .metaData
213
+ metadata?.getString(KEY_CHANNEL_DESCRIPTION) ?: "Flic2Channel"
214
+ } catch (e: PackageManager.NameNotFoundException) {
215
+ Log.w(TAG, "getChannelDescription() NameNotFoundException", e)
216
+ "Flic2Channel"
217
+ } catch (e: Exception) {
218
+ Log.w(TAG, "getChannelDescription() exception", e)
219
+ "Flic2Channel"
220
+ }
221
+ }
222
+
223
+ private fun getNotificationTitle(): String {
224
+ return try {
225
+ val metadata = applicationContext.packageManager
226
+ .getApplicationInfo(applicationContext.packageName, PackageManager.GET_META_DATA)
227
+ .metaData
228
+ metadata?.getString(NOTIFICATION_TITLE_KEY) ?: "Flic 2"
229
+ } catch (e: PackageManager.NameNotFoundException) {
230
+ Log.w(TAG, "getNotificationTitle() NameNotFoundException", e)
231
+ "Flic 2"
232
+ } catch (e: Exception) {
233
+ Log.w(TAG, "getNotificationTitle() exception", e)
234
+ "Flic 2"
235
+ }
236
+ }
237
+
238
+ private fun getNotificationText(): String {
239
+ return try {
240
+ val metadata = applicationContext.packageManager
241
+ .getApplicationInfo(applicationContext.packageName, PackageManager.GET_META_DATA)
242
+ .metaData
243
+ metadata?.getString(NOTIFICATION_TEXT_KEY) ?: "Flic 2 service is running"
244
+ } catch (e: PackageManager.NameNotFoundException) {
245
+ Log.w(TAG, "getNotificationText() NameNotFoundException", e)
246
+ "Flic 2 service is running"
247
+ } catch (e: Exception) {
248
+ Log.w(TAG, "getNotificationText() exception", e)
249
+ "Flic 2 service is running"
250
+ }
251
+ }
252
+
253
+ private fun getNotificationIcon(): Int {
254
+ return try {
255
+ val metadata = applicationContext.packageManager
256
+ .getApplicationInfo(applicationContext.packageName, PackageManager.GET_META_DATA)
257
+ .metaData
258
+ val icon = metadata?.getInt(NOTIFICATION_ICON_KEY, 0) ?: 0
259
+ if (icon != 0) icon else android.R.drawable.ic_dialog_info
260
+ } catch (e: PackageManager.NameNotFoundException) {
261
+ Log.w(TAG, "getNotificationIcon() NameNotFoundException", e)
262
+ android.R.drawable.ic_dialog_info
263
+ } catch (e: Exception) {
264
+ Log.w(TAG, "getNotificationIcon() exception", e)
265
+ android.R.drawable.ic_dialog_info
266
+ }
267
+ }
268
+
269
+ // BootUpReceiver for handling device boot
270
+ class BootUpReceiver : BroadcastReceiver() {
271
+ override fun onReceive(context: Context, intent: Intent) {
272
+ Log.d(TAG, "BootUpReceiver()")
273
+ // The Application class's onCreate has already been called at this point, which is what we want
274
+ }
275
+ }
276
+
277
+ // UpdateReceiver for handling app updates
278
+ class UpdateReceiver : BroadcastReceiver() {
279
+ override fun onReceive(context: Context, intent: Intent) {
280
+ Log.d(TAG, "UpdateReceiver()")
281
+ // The Application class's onCreate has already been called at this point, which is what we want
282
+ }
283
+ }
284
+ }
285
+
@@ -11,10 +11,6 @@ class Flic2 {
11
11
  * @version 2.0.0
12
12
  */
13
13
  constructor() {
14
- // generate a random session ID for the instance
15
- this.sessionId = Math.random().toString(36).substring(2, 15);
16
- console.log('Created new Flic2 instance with sessionId', this.sessionId);
17
-
18
14
  // create event emitter
19
15
  this.eventEmitter = new TypedEmitter();
20
16
 
@@ -1 +1 @@
1
- {"version":3,"names":["TypedEmitter","NativeFlic2","Flic2","isFlic2ManagerInitialized","constructor","sessionId","Math","random","toString","substring","console","log","eventEmitter","onButtonEvent","onNativeButtonEvent","bind","onManagerStateChange","onNativeManagerStateChange","onScanStatusChange","onNativeScanStatusChange","initialize","isInitialized","Error","result","success","message","onInitialized","startScan","scanForButtons","stopScan","connectAllKnownButtons","disconnectAllKnownButtons","forgetAllButtons","isScanning","forgetButton","uuid","buttonConnect","connectButton","buttonDisconnect","disconnectButton","buttonSetTriggerMode","mode","setTriggerMode","buttonSetLatencyMode","setLatencyMode","buttonSetNickname","nickname","setNickname","getButtons","getButton","buttons","button","find","item","getBatteryHealth","isBatteryVoltageOk","batteryVoltage","voltage","event","enrichedEvent","batteryVoltageOk","emit"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAAyB;AACtD,OAAOC,WAAW,MAOX,kBAAe;AAEtB,MAAMC,KAAK,CAAC;EAEFC,yBAAyB,GAAY,KAAK;EAWlD;AACF;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAAA,EA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AK,QAAQ,GAAGC,KAAK,CAACD,OAAO,GAAGC,KAAK,CAACP,MAAM,EAAEK,cAAc;MAEhG,MAAMG,aAA0B,GAAG;QACjC,GAAGD,KAAK;QACRE,gBAAgB,EAAE,IAAI,CAACL,kBAAkB,CAACE,OAAO,IAAI,CAAC;MACxD,CAAC;MAED,IAAI,CAAC7C,YAAY,CAACiD,IAAI,CAAC,aAAa,EAAEF,aAAa,CAAC;MAEpD;IAEF;IAEA,IAAI,CAAC/C,YAAY,CAACiD,IAAI,CAAC,aAAa,EAAEH,KAAK,CAAC;EAE9C;;EAEA;AACF;AACA;AACA;AACA;EACUzC,0BAA0BA,CAACyC,KAA8B,EAAQ;IAEvE,IAAI,CAAC9C,YAAY,CAACiD,IAAI,CAAC,oBAAoB,EAAEH,KAAK,CAAC;EAErD;;EAEA;AACF;AACA;AACA;AACA;EACUvC,wBAAwBA,CAACuC,KAA4B,EAAQ;IAEnE,IAAI,CAAC9C,YAAY,CAACiD,IAAI,CAAC,kBAAkB,EAAEH,KAAK,CAAC;EAEnD;AAEF;;AAEA;AACA,eAAe,IAAIxD,KAAK,CAAC,CAAC;;AAE1B","ignoreList":[]}
1
+ {"version":3,"names":["TypedEmitter","NativeFlic2","Flic2","isFlic2ManagerInitialized","constructor","eventEmitter","onButtonEvent","onNativeButtonEvent","bind","onManagerStateChange","onNativeManagerStateChange","onScanStatusChange","onNativeScanStatusChange","initialize","isInitialized","Error","result","success","message","onInitialized","startScan","scanForButtons","stopScan","connectAllKnownButtons","disconnectAllKnownButtons","forgetAllButtons","isScanning","forgetButton","uuid","buttonConnect","connectButton","buttonDisconnect","disconnectButton","buttonSetTriggerMode","mode","setTriggerMode","buttonSetLatencyMode","setLatencyMode","buttonSetNickname","nickname","setNickname","getButtons","getButton","buttons","button","find","item","getBatteryHealth","isBatteryVoltageOk","batteryVoltage","voltage","event","enrichedEvent","batteryVoltageOk","emit"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SAASA,YAAY,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c;MAEhG,MAAMG,aAA0B,GAAG;QACjC,GAAGD,KAAK;QACRE,gBAAgB,EAAE,IAAI,CAACL,kBAAkB,CAACE,OAAO,IAAI,CAAC;MACxD,CAAC;MAED,IAAI,CAAC7C,YAAY,CAACiD,IAAI,CAAC,aAAa,EAAEF,aAAa,CAAC;MAEpD;IAEF;IAEA,IAAI,CAAC/C,YAAY,CAACiD,IAAI,CAAC,aAAa,EAAEH,KAAK,CAAC;EAE9C;;EAEA;AACF;AACA;AACA;AACA;EACUzC,0BAA0BA,CAACyC,KAA8B,EAAQ;IAEvE,IAAI,CAAC9C,YAAY,CAACiD,IAAI,CAAC,oBAAoB,EAAEH,KAAK,CAAC;EAErD;;EAEA;AACF;AACA;AACA;AACA;EACUvC,wBAAwBA,CAACuC,KAA4B,EAAQ;IAEnE,IAAI,CAAC9C,YAAY,CAACiD,IAAI,CAAC,kBAAkB,EAAEH,KAAK,CAAC;EAEnD;AAEF;;AAEA;AACA,eAAe,IAAIjD,KAAK,CAAC,CAAC;;AAE1B","ignoreList":[]}
@@ -2,7 +2,6 @@ import { TypedEmitter } from './lib/typedEventEmitter';
2
2
  import { type ButtonEvent, type FlicButton, type LatencyModeType, type ManagerStateChangeEvent, type ScanStatusChangeEvent, type TriggerModeType } from './NativeFlic2';
3
3
  declare class Flic2 {
4
4
  private isFlic2ManagerInitialized;
5
- private sessionId;
6
5
  eventEmitter: TypedEmitter<{
7
6
  buttonEvent: (event: ButtonEvent) => void;
8
7
  managerStateChange: (event: ManagerStateChangeEvent) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAoB,EAClB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;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AC;IAMjD;;;;OAIG;IACI,UAAU,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAM1C;;;;;OAKG;IACU,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAShE;;;;;;OAMG;IACU,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAe7D;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAM1B;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAsB3B;;;;OAIG;IACH,OAAO,CAAC,0BAA0B;IAMlC;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;CAMjC;;AAGD,wBAA2B;AAG3B,mBAAmB,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-flic2",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.3",
4
4
  "description": "React Native Flic plugin made with the Flic2 SDK (unofficial)",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -57,31 +57,31 @@
57
57
  "registry": "https://registry.npmjs.org/"
58
58
  },
59
59
  "devDependencies": {
60
- "@eslint/compat": "^1.3.2",
61
- "@eslint/eslintrc": "^3.3.1",
62
- "@eslint/js": "^9.35.0",
63
- "@evilmartians/lefthook": "^1.12.3",
60
+ "@eslint/compat": "1.3.2",
61
+ "@eslint/eslintrc": "3.3.1",
62
+ "@eslint/js": "9.35.0",
63
+ "@evilmartians/lefthook": "1.12.3",
64
64
  "@react-native-community/cli": "20.0.1",
65
65
  "@react-native/babel-preset": "0.81.1",
66
- "@react-native/eslint-config": "^0.81.1",
67
- "@release-it/conventional-changelog": "^10.0.1",
68
- "@types/react": "^19.1.0",
69
- "@typescript-eslint/eslint-plugin": "^8.46.2",
70
- "@typescript-eslint/parser": "^8.46.2",
71
- "del-cli": "^6.0.0",
72
- "eslint": "^8.57.1",
73
- "eslint-config-prettier": "^10.1.8",
74
- "eslint-plugin-ft-flow": "^3.0.11",
75
- "eslint-plugin-jest": "^29.0.1",
76
- "eslint-plugin-prettier": "^5.5.4",
77
- "eslint-plugin-react-native": "^5.0.0",
78
- "prettier": "^3.6.2",
66
+ "@react-native/eslint-config": "0.81.1",
67
+ "@release-it/conventional-changelog": "10.0.1",
68
+ "@types/react": "19.1.0",
69
+ "@typescript-eslint/eslint-plugin": "8.46.2",
70
+ "@typescript-eslint/parser": "8.46.2",
71
+ "del-cli": "6.0.0",
72
+ "eslint": "8.57.1",
73
+ "eslint-config-prettier": "10.1.8",
74
+ "eslint-plugin-ft-flow": "3.0.11",
75
+ "eslint-plugin-jest": "29.0.1",
76
+ "eslint-plugin-prettier": "5.5.4",
77
+ "eslint-plugin-react-native": "5.0.0",
78
+ "prettier": "3.6.2",
79
79
  "react": "19.1.0",
80
80
  "react-native": "0.81.1",
81
- "react-native-builder-bob": "^0.40.13",
82
- "release-it": "^19.0.4",
83
- "turbo": "^2.5.6",
84
- "typescript": "^5.9.2"
81
+ "react-native-builder-bob": "0.40.13",
82
+ "release-it": "19.0.4",
83
+ "turbo": "2.5.6",
84
+ "typescript": "5.9.2"
85
85
  },
86
86
  "peerDependencies": {
87
87
  "react": "*",
@@ -136,7 +136,7 @@
136
136
  "type": "modules",
137
137
  "jsSrcsDir": "src",
138
138
  "android": {
139
- "javaPackageName": "com.flic2"
139
+ "javaPackageName": "nl.xguard.flic2"
140
140
  }
141
141
  },
142
142
  "create-react-native-library": {
package/src/index.ts CHANGED
@@ -12,8 +12,6 @@ class Flic2 {
12
12
 
13
13
  private isFlic2ManagerInitialized: boolean = false;
14
14
 
15
- private sessionId: string;
16
-
17
15
  public eventEmitter: TypedEmitter<{
18
16
  buttonEvent: (event: ButtonEvent) => void;
19
17
  managerStateChange: (event: ManagerStateChangeEvent) => void;
@@ -29,11 +27,6 @@ class Flic2 {
29
27
  */
30
28
  constructor() {
31
29
 
32
- // generate a random session ID for the instance
33
- this.sessionId = Math.random().toString(36).substring(2, 15);
34
-
35
- console.log('Created new Flic2 instance with sessionId', this.sessionId);
36
-
37
30
  // create event emitter
38
31
  this.eventEmitter = new TypedEmitter<{
39
32
  buttonEvent: (event: ButtonEvent) => void;
@@ -1,112 +0,0 @@
1
- package com.flic2
2
-
3
- import android.app.Notification
4
- import android.app.NotificationChannel
5
- import android.app.NotificationManager
6
- import android.app.PendingIntent
7
- import android.app.Service
8
- import android.content.Intent
9
- import android.os.Binder
10
- import android.os.Build
11
- import android.os.Handler
12
- import android.os.IBinder
13
- import android.os.Looper
14
- import android.util.Log
15
- import androidx.core.app.NotificationCompat
16
- import io.flic.flic2libandroid.Flic2Manager
17
-
18
- class Flic2Service : Service() {
19
-
20
- private val binder = Flic2ServiceBinder()
21
- private var manager: Flic2Manager? = null
22
-
23
- companion object {
24
- private const val TAG = "Flic2Service"
25
- private const val NOTIFICATION_ID = 1
26
- private const val CHANNEL_ID = "Flic2ServiceChannel"
27
- private const val CHANNEL_NAME = "Flic2 Service"
28
- }
29
-
30
- inner class Flic2ServiceBinder : Binder() {
31
- fun getService(): Flic2Service = this@Flic2Service
32
- }
33
-
34
- override fun onCreate() {
35
- super.onCreate()
36
- Log.d(TAG, "Service onCreate")
37
-
38
- try {
39
- // Initialize Flic2Manager on main thread with Handler
40
- // v1.1.0 API: init() returns void, must call getInstance() after
41
- Flic2Manager.init(
42
- applicationContext,
43
- Handler(Looper.getMainLooper())
44
- )
45
- manager = Flic2Manager.getInstance()
46
- Log.d(TAG, "Flic2Manager initialized successfully")
47
- } catch (e: Exception) {
48
- Log.e(TAG, "Failed to initialize Flic2Manager", e)
49
- }
50
- }
51
-
52
- override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
53
- Log.d(TAG, "Service onStartCommand")
54
-
55
- // Create notification channel for Android O and above
56
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
57
- val channel = NotificationChannel(
58
- CHANNEL_ID,
59
- CHANNEL_NAME,
60
- NotificationManager.IMPORTANCE_LOW
61
- ).apply {
62
- description = "Keeps Flic2 buttons connected in the background"
63
- setShowBadge(false)
64
- }
65
-
66
- val notificationManager = getSystemService(NotificationManager::class.java)
67
- notificationManager.createNotificationChannel(channel)
68
- }
69
-
70
- // Create notification
71
- val notification = createNotification()
72
-
73
- // Start as foreground service
74
- startForeground(NOTIFICATION_ID, notification)
75
-
76
- return START_STICKY
77
- }
78
-
79
- override fun onBind(intent: Intent?): IBinder {
80
- Log.d(TAG, "Service onBind")
81
- return binder
82
- }
83
-
84
- override fun onDestroy() {
85
- Log.d(TAG, "Service onDestroy")
86
- super.onDestroy()
87
- }
88
-
89
- fun getManager(): Flic2Manager? = manager
90
-
91
- fun isManagerInitialized(): Boolean = manager != null
92
-
93
- private fun createNotification(): Notification {
94
- val notificationIntent = Intent(this, Flic2Service::class.java)
95
- val pendingIntent = PendingIntent.getActivity(
96
- this,
97
- 0,
98
- notificationIntent,
99
- PendingIntent.FLAG_IMMUTABLE
100
- )
101
-
102
- return NotificationCompat.Builder(this, CHANNEL_ID)
103
- .setContentTitle("Flic2 Service")
104
- .setContentText("Flic2 buttons are connected")
105
- .setSmallIcon(android.R.drawable.ic_dialog_info)
106
- .setContentIntent(pendingIntent)
107
- .setPriority(NotificationCompat.PRIORITY_LOW)
108
- .setOngoing(true)
109
- .build()
110
- }
111
- }
112
-