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

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.
@@ -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
-
@@ -1,161 +0,0 @@
1
- // import type { CodegenTypes } from 'react-native';
2
- // import type {
3
- // MultiplyEvent,
4
- // ManagerStateChangeEvent,
5
- // ScanStatusChangeEvent,
6
- // ButtonEvent,
7
- // FlicButton,
8
- // TriggerModeType,
9
- // LatencyModeType,
10
- // } from './NativeFlic2';
11
- // import NativeFlic2 from './NativeFlic2';
12
-
13
- // // MARK: - Example Functions (keeping for compatibility)
14
-
15
- // export function multiply(a: number, b: number): number {
16
- // return NativeFlic2.multiply(a, b);
17
- // }
18
-
19
- // export const onMultiply =
20
- // NativeFlic2.onMultiply as CodegenTypes.EventEmitter<MultiplyEvent>;
21
-
22
- // // MARK: - Manager Functions
23
-
24
- // export function initialize(
25
- // background: boolean
26
- // ): Promise<{ success: boolean; message: string }> {
27
- // return NativeFlic2.initialize(background);
28
- // }
29
-
30
- // export function getButtons(): Promise<FlicButton[]> {
31
- // return NativeFlic2.getButtons();
32
- // }
33
-
34
- // export function scanForButtons(): Promise<{
35
- // success: boolean;
36
- // message: string;
37
- // }> {
38
- // return NativeFlic2.scanForButtons();
39
- // }
40
-
41
- // export function stopScan(): Promise<{ success: boolean; message: string }> {
42
- // return NativeFlic2.stopScan();
43
- // }
44
-
45
- // export function forgetButton(
46
- // uuid: string
47
- // ): Promise<{ success: boolean; message: string }> {
48
- // return NativeFlic2.forgetButton(uuid);
49
- // }
50
-
51
- // export function connectAllKnownButtons(): Promise<{
52
- // success: boolean;
53
- // message: string;
54
- // }> {
55
- // return NativeFlic2.connectAllKnownButtons();
56
- // }
57
-
58
- // export function disconnectAllKnownButtons(): Promise<{
59
- // success: boolean;
60
- // message: string;
61
- // }> {
62
- // return NativeFlic2.disconnectAllKnownButtons();
63
- // }
64
-
65
- // export function forgetAllButtons(): Promise<{
66
- // success: boolean;
67
- // message: string;
68
- // }> {
69
- // return NativeFlic2.forgetAllButtons();
70
- // }
71
-
72
- // export function isScanning(): Promise<boolean> {
73
- // return NativeFlic2.isScanning();
74
- // }
75
-
76
- // // MARK: - Button Functions
77
-
78
- // export function connectButton(
79
- // uuid: string
80
- // ): Promise<{ success: boolean; message: string }> {
81
- // return NativeFlic2.connectButton(uuid);
82
- // }
83
-
84
- // export function disconnectButton(
85
- // uuid: string
86
- // ): Promise<{ success: boolean; message: string }> {
87
- // return NativeFlic2.disconnectButton(uuid);
88
- // }
89
-
90
- // /**
91
- // * Sets the trigger mode for a button.
92
- // *
93
- // * @platform iOS
94
- // * @param uuid - Button UUID
95
- // * @param mode - Trigger mode (0-3)
96
- // * @returns Promise that resolves on iOS, rejects with NOT_SUPPORTED_ON_ANDROID on Android
97
- // *
98
- // * **Note:** This feature is only available on iOS. On Android, this will reject due to
99
- // * limitations in the Android Flic2 library v1.1.0+.
100
- // */
101
- // export function setTriggerMode(
102
- // uuid: string,
103
- // mode: TriggerModeType
104
- // ): Promise<{ success: boolean; message: string }> {
105
- // return NativeFlic2.setTriggerMode(uuid, mode);
106
- // }
107
-
108
- // /**
109
- // * Sets the latency mode for a button.
110
- // *
111
- // * @platform iOS
112
- // * @param uuid - Button UUID
113
- // * @param mode - Latency mode (0-1)
114
- // * @returns Promise that resolves on iOS, rejects with NOT_SUPPORTED_ON_ANDROID on Android
115
- // *
116
- // * **Note:** This feature is only available on iOS. On Android, this will reject due to
117
- // * limitations in the Android Flic2 library v1.1.0+.
118
- // */
119
- // export function setLatencyMode(
120
- // uuid: string,
121
- // mode: LatencyModeType
122
- // ): Promise<{ success: boolean; message: string }> {
123
- // return NativeFlic2.setLatencyMode(uuid, mode);
124
- // }
125
-
126
- // export function setNickname(
127
- // uuid: string,
128
- // nickname: string
129
- // ): Promise<{ success: boolean; message: string }> {
130
- // return NativeFlic2.setNickname(uuid, nickname);
131
- // }
132
-
133
- // // MARK: - Event Emitters
134
-
135
- // export const onManagerStateChange =
136
- // NativeFlic2.onManagerStateChange as CodegenTypes.EventEmitter<ManagerStateChangeEvent>;
137
-
138
- // export const onScanStatusChange =
139
- // NativeFlic2.onScanStatusChange as CodegenTypes.EventEmitter<ScanStatusChangeEvent>;
140
-
141
- // export const onButtonEvent =
142
- // NativeFlic2.onButtonEvent as CodegenTypes.EventEmitter<ButtonEvent>;
143
-
144
- // // MARK: - Re-export Types
145
-
146
- // export type {
147
- // MultiplyEvent,
148
- // ManagerStateChangeEvent,
149
- // ScanStatusChangeEvent,
150
- // ButtonEvent,
151
- // FlicButton,
152
- // FlicManagerState,
153
- // FlicButtonState,
154
- // FlicTriggerMode,
155
- // FlicLatencyMode,
156
- // FlicScannerEvent,
157
- // TriggerModeType,
158
- // LatencyModeType,
159
- // } from './NativeFlic2';
160
- "use strict";
161
- //# sourceMappingURL=index.bak.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../src","sources":["index.bak.tsx"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=index.bak.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.bak.d.ts","sourceRoot":"","sources":["../../../src/index.bak.tsx"],"names":[],"mappings":""}
package/src/index.bak.tsx DELETED
@@ -1,159 +0,0 @@
1
- // import type { CodegenTypes } from 'react-native';
2
- // import type {
3
- // MultiplyEvent,
4
- // ManagerStateChangeEvent,
5
- // ScanStatusChangeEvent,
6
- // ButtonEvent,
7
- // FlicButton,
8
- // TriggerModeType,
9
- // LatencyModeType,
10
- // } from './NativeFlic2';
11
- // import NativeFlic2 from './NativeFlic2';
12
-
13
- // // MARK: - Example Functions (keeping for compatibility)
14
-
15
- // export function multiply(a: number, b: number): number {
16
- // return NativeFlic2.multiply(a, b);
17
- // }
18
-
19
- // export const onMultiply =
20
- // NativeFlic2.onMultiply as CodegenTypes.EventEmitter<MultiplyEvent>;
21
-
22
- // // MARK: - Manager Functions
23
-
24
- // export function initialize(
25
- // background: boolean
26
- // ): Promise<{ success: boolean; message: string }> {
27
- // return NativeFlic2.initialize(background);
28
- // }
29
-
30
- // export function getButtons(): Promise<FlicButton[]> {
31
- // return NativeFlic2.getButtons();
32
- // }
33
-
34
- // export function scanForButtons(): Promise<{
35
- // success: boolean;
36
- // message: string;
37
- // }> {
38
- // return NativeFlic2.scanForButtons();
39
- // }
40
-
41
- // export function stopScan(): Promise<{ success: boolean; message: string }> {
42
- // return NativeFlic2.stopScan();
43
- // }
44
-
45
- // export function forgetButton(
46
- // uuid: string
47
- // ): Promise<{ success: boolean; message: string }> {
48
- // return NativeFlic2.forgetButton(uuid);
49
- // }
50
-
51
- // export function connectAllKnownButtons(): Promise<{
52
- // success: boolean;
53
- // message: string;
54
- // }> {
55
- // return NativeFlic2.connectAllKnownButtons();
56
- // }
57
-
58
- // export function disconnectAllKnownButtons(): Promise<{
59
- // success: boolean;
60
- // message: string;
61
- // }> {
62
- // return NativeFlic2.disconnectAllKnownButtons();
63
- // }
64
-
65
- // export function forgetAllButtons(): Promise<{
66
- // success: boolean;
67
- // message: string;
68
- // }> {
69
- // return NativeFlic2.forgetAllButtons();
70
- // }
71
-
72
- // export function isScanning(): Promise<boolean> {
73
- // return NativeFlic2.isScanning();
74
- // }
75
-
76
- // // MARK: - Button Functions
77
-
78
- // export function connectButton(
79
- // uuid: string
80
- // ): Promise<{ success: boolean; message: string }> {
81
- // return NativeFlic2.connectButton(uuid);
82
- // }
83
-
84
- // export function disconnectButton(
85
- // uuid: string
86
- // ): Promise<{ success: boolean; message: string }> {
87
- // return NativeFlic2.disconnectButton(uuid);
88
- // }
89
-
90
- // /**
91
- // * Sets the trigger mode for a button.
92
- // *
93
- // * @platform iOS
94
- // * @param uuid - Button UUID
95
- // * @param mode - Trigger mode (0-3)
96
- // * @returns Promise that resolves on iOS, rejects with NOT_SUPPORTED_ON_ANDROID on Android
97
- // *
98
- // * **Note:** This feature is only available on iOS. On Android, this will reject due to
99
- // * limitations in the Android Flic2 library v1.1.0+.
100
- // */
101
- // export function setTriggerMode(
102
- // uuid: string,
103
- // mode: TriggerModeType
104
- // ): Promise<{ success: boolean; message: string }> {
105
- // return NativeFlic2.setTriggerMode(uuid, mode);
106
- // }
107
-
108
- // /**
109
- // * Sets the latency mode for a button.
110
- // *
111
- // * @platform iOS
112
- // * @param uuid - Button UUID
113
- // * @param mode - Latency mode (0-1)
114
- // * @returns Promise that resolves on iOS, rejects with NOT_SUPPORTED_ON_ANDROID on Android
115
- // *
116
- // * **Note:** This feature is only available on iOS. On Android, this will reject due to
117
- // * limitations in the Android Flic2 library v1.1.0+.
118
- // */
119
- // export function setLatencyMode(
120
- // uuid: string,
121
- // mode: LatencyModeType
122
- // ): Promise<{ success: boolean; message: string }> {
123
- // return NativeFlic2.setLatencyMode(uuid, mode);
124
- // }
125
-
126
- // export function setNickname(
127
- // uuid: string,
128
- // nickname: string
129
- // ): Promise<{ success: boolean; message: string }> {
130
- // return NativeFlic2.setNickname(uuid, nickname);
131
- // }
132
-
133
- // // MARK: - Event Emitters
134
-
135
- // export const onManagerStateChange =
136
- // NativeFlic2.onManagerStateChange as CodegenTypes.EventEmitter<ManagerStateChangeEvent>;
137
-
138
- // export const onScanStatusChange =
139
- // NativeFlic2.onScanStatusChange as CodegenTypes.EventEmitter<ScanStatusChangeEvent>;
140
-
141
- // export const onButtonEvent =
142
- // NativeFlic2.onButtonEvent as CodegenTypes.EventEmitter<ButtonEvent>;
143
-
144
- // // MARK: - Re-export Types
145
-
146
- // export type {
147
- // MultiplyEvent,
148
- // ManagerStateChangeEvent,
149
- // ScanStatusChangeEvent,
150
- // ButtonEvent,
151
- // FlicButton,
152
- // FlicManagerState,
153
- // FlicButtonState,
154
- // FlicTriggerMode,
155
- // FlicLatencyMode,
156
- // FlicScannerEvent,
157
- // TriggerModeType,
158
- // LatencyModeType,
159
- // } from './NativeFlic2';