@cometchat/calls-sdk-react-native 5.0.2 → 5.0.3-beta.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.
|
@@ -25,6 +25,7 @@ import android.os.Build;
|
|
|
25
25
|
import com.cometchat.calls.utils.CometChatLogger;
|
|
26
26
|
|
|
27
27
|
import java.util.HashSet;
|
|
28
|
+
import java.util.List;
|
|
28
29
|
import java.util.Set;
|
|
29
30
|
|
|
30
31
|
|
|
@@ -170,6 +171,57 @@ import java.util.Set;
|
|
|
170
171
|
});
|
|
171
172
|
}
|
|
172
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Returns the {@link AudioDeviceInfo} types that can satisfy the given
|
|
176
|
+
* "DEVICE_" constant, in order of preference.
|
|
177
|
+
*/
|
|
178
|
+
private static int[] communicationDeviceTypes(String device) {
|
|
179
|
+
switch (device) {
|
|
180
|
+
case AudioModeModule.DEVICE_SPEAKER:
|
|
181
|
+
return new int[] { AudioDeviceInfo.TYPE_BUILTIN_SPEAKER };
|
|
182
|
+
case AudioModeModule.DEVICE_EARPIECE:
|
|
183
|
+
return new int[] { AudioDeviceInfo.TYPE_BUILTIN_EARPIECE };
|
|
184
|
+
case AudioModeModule.DEVICE_BLUETOOTH:
|
|
185
|
+
return new int[] {
|
|
186
|
+
AudioDeviceInfo.TYPE_BLUETOOTH_SCO,
|
|
187
|
+
AudioDeviceInfo.TYPE_BLE_HEADSET
|
|
188
|
+
};
|
|
189
|
+
case AudioModeModule.DEVICE_HEADPHONES:
|
|
190
|
+
return new int[] {
|
|
191
|
+
AudioDeviceInfo.TYPE_WIRED_HEADSET,
|
|
192
|
+
AudioDeviceInfo.TYPE_WIRED_HEADPHONES,
|
|
193
|
+
TYPE_USB_HEADSET,
|
|
194
|
+
TYPE_HEARING_AID
|
|
195
|
+
};
|
|
196
|
+
default:
|
|
197
|
+
return new int[0];
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Sets the audio route using the modern (API 31+) communication device
|
|
203
|
+
* API. Unlike the deprecated setSpeakerphoneOn() / startBluetoothSco()
|
|
204
|
+
* calls, a setCommunicationDevice() request participates in the system's
|
|
205
|
+
* per-client route arbitration and takes precedence over stale requests
|
|
206
|
+
* left behind by other libraries in the same app.
|
|
207
|
+
*/
|
|
208
|
+
private void setCommunicationRoute(String device) {
|
|
209
|
+
List<AudioDeviceInfo> availableDevices = audioManager.getAvailableCommunicationDevices();
|
|
210
|
+
|
|
211
|
+
for (int type : communicationDeviceTypes(device)) {
|
|
212
|
+
for (AudioDeviceInfo info : availableDevices) {
|
|
213
|
+
if (info.getType() == type) {
|
|
214
|
+
if (audioManager.setCommunicationDevice(info)) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
CometChatLogger.w(TAG, "setCommunicationDevice failed for type: " + type);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
CometChatLogger.w(TAG, "No available communication device for: " + device);
|
|
223
|
+
}
|
|
224
|
+
|
|
173
225
|
/**
|
|
174
226
|
* Helper method to set the output route to a Bluetooth device.
|
|
175
227
|
*
|
|
@@ -205,6 +257,11 @@ import java.util.Set;
|
|
|
205
257
|
|
|
206
258
|
@Override
|
|
207
259
|
public void setAudioRoute(String device) {
|
|
260
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
261
|
+
setCommunicationRoute(device);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
|
|
208
265
|
// Turn speaker on / off
|
|
209
266
|
audioManager.setSpeakerphoneOn(device.equals(AudioModeModule.DEVICE_SPEAKER));
|
|
210
267
|
|
|
@@ -218,8 +275,12 @@ import java.util.Set;
|
|
|
218
275
|
audioFocusLost = false;
|
|
219
276
|
audioManager.setMode(AudioManager.MODE_NORMAL);
|
|
220
277
|
audioManager.abandonAudioFocus(this);
|
|
221
|
-
|
|
222
|
-
|
|
278
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
279
|
+
audioManager.clearCommunicationDevice();
|
|
280
|
+
} else {
|
|
281
|
+
audioManager.setSpeakerphoneOn(false);
|
|
282
|
+
setBluetoothAudioRoute(false);
|
|
283
|
+
}
|
|
223
284
|
|
|
224
285
|
return true;
|
|
225
286
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as zustand3 from "zustand";
|
|
2
2
|
import * as zustand_middleware0 from "zustand/middleware";
|
|
3
3
|
import { AppStateStatus } from "react-native";
|
|
4
4
|
import JitsiMeetJS from "@cometchat/calls-lib-webrtc";
|
|
@@ -390,7 +390,7 @@ type Actions$5 = {
|
|
|
390
390
|
isMobileSDK: () => boolean;
|
|
391
391
|
isMobile: () => boolean;
|
|
392
392
|
};
|
|
393
|
-
declare const useBaseStore:
|
|
393
|
+
declare const useBaseStore: zustand3.UseBoundStore<Omit<Omit<zustand3.StoreApi<BaseState & Actions$5>, "subscribe"> & {
|
|
394
394
|
subscribe: {
|
|
395
395
|
(listener: (selectedState: BaseState & Actions$5, previousSelectedState: BaseState & Actions$5) => void): () => void;
|
|
396
396
|
<U>(selector: (state: BaseState & Actions$5) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
@@ -476,7 +476,7 @@ type Actions$4 = {
|
|
|
476
476
|
endConference: () => Promise<void>;
|
|
477
477
|
stopRecording: () => Promise<void>;
|
|
478
478
|
};
|
|
479
|
-
declare const useConferenceStore:
|
|
479
|
+
declare const useConferenceStore: zustand3.UseBoundStore<Omit<zustand3.StoreApi<ConferenceState & Actions$4>, "subscribe"> & {
|
|
480
480
|
subscribe: {
|
|
481
481
|
(listener: (selectedState: ConferenceState & Actions$4, previousSelectedState: ConferenceState & Actions$4) => void): () => void;
|
|
482
482
|
<U>(selector: (state: ConferenceState & Actions$4) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
@@ -833,7 +833,7 @@ type ConfigState = ConfigStateInternal & ConfigStateMobile & ConfigStateWeb & Co
|
|
|
833
833
|
type Actions$3 = {
|
|
834
834
|
reset: () => void;
|
|
835
835
|
};
|
|
836
|
-
declare const useConfigStore:
|
|
836
|
+
declare const useConfigStore: zustand3.UseBoundStore<Omit<zustand3.StoreApi<ConfigStateInternal & ConfigStateMobile & ConfigStateWeb & ConfigStateBoth & Actions$3>, "subscribe"> & {
|
|
837
837
|
subscribe: {
|
|
838
838
|
(listener: (selectedState: ConfigStateInternal & ConfigStateMobile & ConfigStateWeb & ConfigStateBoth & Actions$3, previousSelectedState: ConfigStateInternal & ConfigStateMobile & ConfigStateWeb & ConfigStateBoth & Actions$3) => void): () => void;
|
|
839
839
|
<U>(selector: (state: ConfigStateInternal & ConfigStateMobile & ConfigStateWeb & ConfigStateBoth & Actions$3) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
@@ -986,7 +986,7 @@ type Actions$2 = {
|
|
|
986
986
|
disconnect: () => Promise<void>;
|
|
987
987
|
reset: () => void;
|
|
988
988
|
};
|
|
989
|
-
declare const useConnectionStore:
|
|
989
|
+
declare const useConnectionStore: zustand3.UseBoundStore<Omit<zustand3.StoreApi<ConnectionState & Actions$2>, "subscribe"> & {
|
|
990
990
|
subscribe: {
|
|
991
991
|
(listener: (selectedState: ConnectionState & Actions$2, previousSelectedState: ConnectionState & Actions$2) => void): () => void;
|
|
992
992
|
<U>(selector: (state: ConnectionState & Actions$2) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
@@ -1037,7 +1037,7 @@ type Actions$1 = {
|
|
|
1037
1037
|
getParticipantById: (pid: string) => HumanParticipant | undefined;
|
|
1038
1038
|
reset: () => void;
|
|
1039
1039
|
};
|
|
1040
|
-
declare const useParticipantStore:
|
|
1040
|
+
declare const useParticipantStore: zustand3.UseBoundStore<Omit<zustand3.StoreApi<ParticipantsState & Actions$1>, "subscribe"> & {
|
|
1041
1041
|
subscribe: {
|
|
1042
1042
|
(listener: (selectedState: ParticipantsState & Actions$1, previousSelectedState: ParticipantsState & Actions$1) => void): () => void;
|
|
1043
1043
|
<U>(selector: (state: ParticipantsState & Actions$1) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
@@ -1084,7 +1084,7 @@ interface ToastActions {
|
|
|
1084
1084
|
clearAll: () => void;
|
|
1085
1085
|
reset: () => void;
|
|
1086
1086
|
}
|
|
1087
|
-
declare const useToastStore:
|
|
1087
|
+
declare const useToastStore: zustand3.UseBoundStore<zustand3.StoreApi<ToastState & ToastActions>>;
|
|
1088
1088
|
declare function showToast(params: {
|
|
1089
1089
|
id?: string;
|
|
1090
1090
|
message: string;
|
|
@@ -1120,7 +1120,7 @@ type Actions = {
|
|
|
1120
1120
|
updateTrack: (originalTrack: any, updatedTrack: Partial<Track>) => void;
|
|
1121
1121
|
updateLocalTrack: (mediaType: MediaType, updatedTrack: Partial<Track>) => void;
|
|
1122
1122
|
};
|
|
1123
|
-
declare const useTracksStore:
|
|
1123
|
+
declare const useTracksStore: zustand3.UseBoundStore<Omit<zustand3.StoreApi<TracksState & Actions>, "subscribe"> & {
|
|
1124
1124
|
subscribe: {
|
|
1125
1125
|
(listener: (selectedState: TracksState & Actions, previousSelectedState: TracksState & Actions) => void): () => void;
|
|
1126
1126
|
<U>(selector: (state: TracksState & Actions) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
@@ -1628,7 +1628,7 @@ interface TranslationState {
|
|
|
1628
1628
|
translations: Record<string, typeof __json_default_export>;
|
|
1629
1629
|
currentLocale: CometChatSupportedLocale | Omit<string, CometChatSupportedLocale>;
|
|
1630
1630
|
}
|
|
1631
|
-
declare const useTranslationStore:
|
|
1631
|
+
declare const useTranslationStore: zustand3.UseBoundStore<Omit<zustand3.StoreApi<Omit<TranslationState, "reset" | "setLocale"> & {
|
|
1632
1632
|
reset: () => void;
|
|
1633
1633
|
setLocale: (locale: CometChatSupportedLocale) => void;
|
|
1634
1634
|
}>, "subscribe"> & {
|