@100mslive/react-native-hms 1.9.8 → 1.9.10

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 (212) hide show
  1. package/README.md +5 -4
  2. package/android/local.properties +8 -1
  3. package/android/src/main/java/com/reactnativehmssdk/HMSDecoder.kt +2 -0
  4. package/android/src/main/java/com/reactnativehmssdk/HMSManager.kt +98 -4
  5. package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +14 -7
  6. package/android/src/main/java/com/reactnativehmssdk/Interactivity/HMSInteractivityDecoder.kt +328 -0
  7. package/android/src/main/java/com/reactnativehmssdk/Interactivity/HMSInteractivityHelper.kt +352 -0
  8. package/android/src/main/java/com/reactnativehmssdk/Interactivity/HMSRNInteractivityCenter.kt +184 -0
  9. package/ios/HMSConstants.swift +1 -0
  10. package/ios/HMSDecoder.swift +3 -1
  11. package/ios/HMSInteractivityDecoder.swift +223 -0
  12. package/ios/HMSInteractivityHelper.swift +169 -0
  13. package/ios/HMSManager.m +17 -0
  14. package/ios/HMSManager.swift +30 -1
  15. package/ios/HMSRNInteractivityCenter.swift +89 -0
  16. package/ios/HMSRNSDK.swift +10 -4
  17. package/ios/Hmssdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  18. package/ios/Hmssdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  19. package/ios/Hmssdk.xcodeproj/project.xcworkspace/xcuserdata/jatinnagar.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  20. package/ios/Hmssdk.xcodeproj/xcuserdata/jatinnagar.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  21. package/lib/commonjs/classes/HMSInteractivityCenter.js +93 -0
  22. package/lib/commonjs/classes/HMSInteractivityCenter.js.map +1 -0
  23. package/lib/commonjs/classes/HMSInteractivityEncoder.js +33 -0
  24. package/lib/commonjs/classes/HMSInteractivityEncoder.js.map +1 -0
  25. package/lib/commonjs/classes/HMSPermissions.js +4 -0
  26. package/lib/commonjs/classes/HMSPermissions.js.map +1 -1
  27. package/lib/commonjs/classes/HMSPollsListenerActions.js +11 -0
  28. package/lib/commonjs/classes/HMSPollsListenerActions.js.map +1 -0
  29. package/lib/commonjs/classes/HMSSDK.js +8 -0
  30. package/lib/commonjs/classes/HMSSDK.js.map +1 -1
  31. package/lib/commonjs/classes/polls/HMSPoll.js +6 -0
  32. package/lib/commonjs/classes/polls/HMSPoll.js.map +1 -0
  33. package/lib/commonjs/classes/polls/HMSPollCategory.js +12 -0
  34. package/lib/commonjs/classes/polls/HMSPollCategory.js.map +1 -0
  35. package/lib/commonjs/classes/polls/HMSPollCreateParams.js +6 -0
  36. package/lib/commonjs/classes/polls/HMSPollCreateParams.js.map +1 -0
  37. package/lib/commonjs/classes/polls/HMSPollQuestion.js +6 -0
  38. package/lib/commonjs/classes/polls/HMSPollQuestion.js.map +1 -0
  39. package/lib/commonjs/classes/polls/HMSPollQuestionAnswer.js +2 -0
  40. package/lib/commonjs/classes/polls/HMSPollQuestionAnswer.js.map +1 -0
  41. package/lib/commonjs/classes/polls/HMSPollQuestionCreateParams.js +6 -0
  42. package/lib/commonjs/classes/polls/HMSPollQuestionCreateParams.js.map +1 -0
  43. package/lib/commonjs/classes/polls/HMSPollQuestionOption.js +2 -0
  44. package/lib/commonjs/classes/polls/HMSPollQuestionOption.js.map +1 -0
  45. package/lib/commonjs/classes/polls/HMSPollQuestionOptionCreateParams.js +6 -0
  46. package/lib/commonjs/classes/polls/HMSPollQuestionOptionCreateParams.js.map +1 -0
  47. package/lib/commonjs/classes/polls/HMSPollQuestionQuizOptionCreateParams.js +6 -0
  48. package/lib/commonjs/classes/polls/HMSPollQuestionQuizOptionCreateParams.js.map +1 -0
  49. package/lib/commonjs/classes/polls/HMSPollQuestionResponse.js +6 -0
  50. package/lib/commonjs/classes/polls/HMSPollQuestionResponse.js.map +1 -0
  51. package/lib/commonjs/classes/polls/HMSPollQuestionResponseCreateParams.js +6 -0
  52. package/lib/commonjs/classes/polls/HMSPollQuestionResponseCreateParams.js.map +1 -0
  53. package/lib/commonjs/classes/polls/HMSPollQuestionResponseResult.js +2 -0
  54. package/lib/commonjs/classes/polls/HMSPollQuestionResponseResult.js.map +1 -0
  55. package/lib/commonjs/classes/polls/HMSPollQuestionResult.js +2 -0
  56. package/lib/commonjs/classes/polls/HMSPollQuestionResult.js.map +1 -0
  57. package/lib/commonjs/classes/polls/HMSPollQuestionType.js +14 -0
  58. package/lib/commonjs/classes/polls/HMSPollQuestionType.js.map +1 -0
  59. package/lib/commonjs/classes/polls/HMSPollResponsePeerInfo.js +2 -0
  60. package/lib/commonjs/classes/polls/HMSPollResponsePeerInfo.js.map +1 -0
  61. package/lib/commonjs/classes/polls/HMSPollResult.js +6 -0
  62. package/lib/commonjs/classes/polls/HMSPollResult.js.map +1 -0
  63. package/lib/commonjs/classes/polls/HMSPollState.js +13 -0
  64. package/lib/commonjs/classes/polls/HMSPollState.js.map +1 -0
  65. package/lib/commonjs/classes/polls/HMSPollType.js +12 -0
  66. package/lib/commonjs/classes/polls/HMSPollType.js.map +1 -0
  67. package/lib/commonjs/classes/polls/HMSPollUpdateType.js +13 -0
  68. package/lib/commonjs/classes/polls/HMSPollUpdateType.js.map +1 -0
  69. package/lib/commonjs/classes/polls/HMSPollUserTrackingMode.js +13 -0
  70. package/lib/commonjs/classes/polls/HMSPollUserTrackingMode.js.map +1 -0
  71. package/lib/commonjs/hooks/polls.js +17 -0
  72. package/lib/commonjs/hooks/polls.js.map +1 -0
  73. package/lib/commonjs/index.js +68 -0
  74. package/lib/commonjs/index.js.map +1 -1
  75. package/lib/commonjs/stores/hms-interactivity-store.js +21 -0
  76. package/lib/commonjs/stores/hms-interactivity-store.js.map +1 -0
  77. package/lib/commonjs/stores/hms-polls-slice.js +19 -0
  78. package/lib/commonjs/stores/hms-polls-slice.js.map +1 -0
  79. package/lib/commonjs/stores/types.js.map +1 -1
  80. package/lib/commonjs/utils/emitter/EventEmitter.js +19 -0
  81. package/lib/commonjs/utils/emitter/EventEmitter.js.map +1 -1
  82. package/lib/commonjs/utils/windowController.js +30 -0
  83. package/lib/commonjs/utils/windowController.js.map +1 -0
  84. package/lib/module/classes/HMSInteractivityCenter.js +85 -0
  85. package/lib/module/classes/HMSInteractivityCenter.js.map +1 -0
  86. package/lib/module/classes/HMSInteractivityEncoder.js +26 -0
  87. package/lib/module/classes/HMSInteractivityEncoder.js.map +1 -0
  88. package/lib/module/classes/HMSPermissions.js +4 -0
  89. package/lib/module/classes/HMSPermissions.js.map +1 -1
  90. package/lib/module/classes/HMSPollsListenerActions.js +5 -0
  91. package/lib/module/classes/HMSPollsListenerActions.js.map +1 -0
  92. package/lib/module/classes/HMSSDK.js +8 -0
  93. package/lib/module/classes/HMSSDK.js.map +1 -1
  94. package/lib/module/classes/polls/HMSPoll.js +2 -0
  95. package/lib/module/classes/polls/HMSPoll.js.map +1 -0
  96. package/lib/module/classes/polls/HMSPollCategory.js +6 -0
  97. package/lib/module/classes/polls/HMSPollCategory.js.map +1 -0
  98. package/lib/module/classes/polls/HMSPollCreateParams.js +2 -0
  99. package/lib/module/classes/polls/HMSPollCreateParams.js.map +1 -0
  100. package/lib/module/classes/polls/HMSPollQuestion.js +2 -0
  101. package/lib/module/classes/polls/HMSPollQuestion.js.map +1 -0
  102. package/lib/module/classes/polls/HMSPollQuestionAnswer.js +2 -0
  103. package/lib/module/classes/polls/HMSPollQuestionAnswer.js.map +1 -0
  104. package/lib/module/classes/polls/HMSPollQuestionCreateParams.js +2 -0
  105. package/lib/module/classes/polls/HMSPollQuestionCreateParams.js.map +1 -0
  106. package/lib/module/classes/polls/HMSPollQuestionOption.js +2 -0
  107. package/lib/module/classes/polls/HMSPollQuestionOption.js.map +1 -0
  108. package/lib/module/classes/polls/HMSPollQuestionOptionCreateParams.js +2 -0
  109. package/lib/module/classes/polls/HMSPollQuestionOptionCreateParams.js.map +1 -0
  110. package/lib/module/classes/polls/HMSPollQuestionQuizOptionCreateParams.js +2 -0
  111. package/lib/module/classes/polls/HMSPollQuestionQuizOptionCreateParams.js.map +1 -0
  112. package/lib/module/classes/polls/HMSPollQuestionResponse.js +2 -0
  113. package/lib/module/classes/polls/HMSPollQuestionResponse.js.map +1 -0
  114. package/lib/module/classes/polls/HMSPollQuestionResponseCreateParams.js +2 -0
  115. package/lib/module/classes/polls/HMSPollQuestionResponseCreateParams.js.map +1 -0
  116. package/lib/module/classes/polls/HMSPollQuestionResponseResult.js +2 -0
  117. package/lib/module/classes/polls/HMSPollQuestionResponseResult.js.map +1 -0
  118. package/lib/module/classes/polls/HMSPollQuestionResult.js +2 -0
  119. package/lib/module/classes/polls/HMSPollQuestionResult.js.map +1 -0
  120. package/lib/module/classes/polls/HMSPollQuestionType.js +8 -0
  121. package/lib/module/classes/polls/HMSPollQuestionType.js.map +1 -0
  122. package/lib/module/classes/polls/HMSPollResponsePeerInfo.js +2 -0
  123. package/lib/module/classes/polls/HMSPollResponsePeerInfo.js.map +1 -0
  124. package/lib/module/classes/polls/HMSPollResult.js +2 -0
  125. package/lib/module/classes/polls/HMSPollResult.js.map +1 -0
  126. package/lib/module/classes/polls/HMSPollState.js +7 -0
  127. package/lib/module/classes/polls/HMSPollState.js.map +1 -0
  128. package/lib/module/classes/polls/HMSPollType.js +6 -0
  129. package/lib/module/classes/polls/HMSPollType.js.map +1 -0
  130. package/lib/module/classes/polls/HMSPollUpdateType.js +7 -0
  131. package/lib/module/classes/polls/HMSPollUpdateType.js.map +1 -0
  132. package/lib/module/classes/polls/HMSPollUserTrackingMode.js +7 -0
  133. package/lib/module/classes/polls/HMSPollUserTrackingMode.js.map +1 -0
  134. package/lib/module/hooks/polls.js +12 -0
  135. package/lib/module/hooks/polls.js.map +1 -0
  136. package/lib/module/index.js +8 -0
  137. package/lib/module/index.js.map +1 -1
  138. package/lib/module/stores/hms-interactivity-store.js +15 -0
  139. package/lib/module/stores/hms-interactivity-store.js.map +1 -0
  140. package/lib/module/stores/hms-polls-slice.js +12 -0
  141. package/lib/module/stores/hms-polls-slice.js.map +1 -0
  142. package/lib/module/stores/types.js.map +1 -1
  143. package/lib/module/utils/emitter/EventEmitter.js +19 -0
  144. package/lib/module/utils/emitter/EventEmitter.js.map +1 -1
  145. package/lib/module/utils/windowController.js +22 -0
  146. package/lib/module/utils/windowController.js.map +1 -0
  147. package/lib/typescript/classes/HMSInteractivityCenter.d.ts +35 -0
  148. package/lib/typescript/classes/HMSInteractivityEncoder.d.ts +4 -0
  149. package/lib/typescript/classes/HMSPermissions.d.ts +4 -0
  150. package/lib/typescript/classes/HMSPollsListenerActions.d.ts +3 -0
  151. package/lib/typescript/classes/HMSSDK.d.ts +3 -0
  152. package/lib/typescript/classes/polls/HMSPoll.d.ts +81 -0
  153. package/lib/typescript/classes/polls/HMSPollCategory.d.ts +10 -0
  154. package/lib/typescript/classes/polls/HMSPollCreateParams.d.ts +6 -0
  155. package/lib/typescript/classes/polls/HMSPollQuestion.d.ts +61 -0
  156. package/lib/typescript/classes/polls/HMSPollQuestionAnswer.d.ts +17 -0
  157. package/lib/typescript/classes/polls/HMSPollQuestionCreateParams.d.ts +25 -0
  158. package/lib/typescript/classes/polls/HMSPollQuestionOption.d.ts +21 -0
  159. package/lib/typescript/classes/polls/HMSPollQuestionOptionCreateParams.d.ts +3 -0
  160. package/lib/typescript/classes/polls/HMSPollQuestionQuizOptionCreateParams.d.ts +4 -0
  161. package/lib/typescript/classes/polls/HMSPollQuestionResponse.d.ts +47 -0
  162. package/lib/typescript/classes/polls/HMSPollQuestionResponseCreateParams.d.ts +2 -0
  163. package/lib/typescript/classes/polls/HMSPollQuestionResponseResult.d.ts +17 -0
  164. package/lib/typescript/classes/polls/HMSPollQuestionResult.d.ts +29 -0
  165. package/lib/typescript/classes/polls/HMSPollQuestionType.d.ts +18 -0
  166. package/lib/typescript/classes/polls/HMSPollResponsePeerInfo.d.ts +21 -0
  167. package/lib/typescript/classes/polls/HMSPollResult.d.ts +22 -0
  168. package/lib/typescript/classes/polls/HMSPollState.d.ts +14 -0
  169. package/lib/typescript/classes/polls/HMSPollType.d.ts +4 -0
  170. package/lib/typescript/classes/polls/HMSPollUpdateType.d.ts +5 -0
  171. package/lib/typescript/classes/polls/HMSPollUserTrackingMode.d.ts +14 -0
  172. package/lib/typescript/hooks/polls.d.ts +3 -0
  173. package/lib/typescript/index.d.ts +9 -0
  174. package/lib/typescript/stores/hms-interactivity-store.d.ts +9 -0
  175. package/lib/typescript/stores/hms-polls-slice.d.ts +5 -0
  176. package/lib/typescript/stores/types.d.ts +6 -0
  177. package/lib/typescript/utils/emitter/EventEmitter.d.ts +7 -0
  178. package/lib/typescript/utils/windowController.d.ts +10 -0
  179. package/package.json +1 -1
  180. package/sdk-versions.json +2 -2
  181. package/src/classes/HMSInteractivityCenter.ts +126 -0
  182. package/src/classes/HMSInteractivityEncoder.ts +29 -0
  183. package/src/classes/HMSPermissions.ts +6 -0
  184. package/src/classes/HMSPollsListenerActions.ts +3 -0
  185. package/src/classes/HMSSDK.tsx +10 -0
  186. package/src/classes/polls/HMSPoll.ts +108 -0
  187. package/src/classes/polls/HMSPollCategory.ts +11 -0
  188. package/src/classes/polls/HMSPollCreateParams.ts +19 -0
  189. package/src/classes/polls/HMSPollQuestion.ts +92 -0
  190. package/src/classes/polls/HMSPollQuestionAnswer.ts +29 -0
  191. package/src/classes/polls/HMSPollQuestionCreateParams.ts +36 -0
  192. package/src/classes/polls/HMSPollQuestionOption.ts +24 -0
  193. package/src/classes/polls/HMSPollQuestionOptionCreateParams.ts +8 -0
  194. package/src/classes/polls/HMSPollQuestionQuizOptionCreateParams.ts +6 -0
  195. package/src/classes/polls/HMSPollQuestionResponse.ts +72 -0
  196. package/src/classes/polls/HMSPollQuestionResponseCreateParams.ts +6 -0
  197. package/src/classes/polls/HMSPollQuestionResponseResult.ts +19 -0
  198. package/src/classes/polls/HMSPollQuestionResult.ts +41 -0
  199. package/src/classes/polls/HMSPollQuestionType.ts +21 -0
  200. package/src/classes/polls/HMSPollResponsePeerInfo.ts +24 -0
  201. package/src/classes/polls/HMSPollResult.ts +26 -0
  202. package/src/classes/polls/HMSPollState.ts +16 -0
  203. package/src/classes/polls/HMSPollType.ts +4 -0
  204. package/src/classes/polls/HMSPollUpdateType.ts +5 -0
  205. package/src/classes/polls/HMSPollUserTrackingMode.ts +16 -0
  206. package/src/hooks/polls.ts +14 -0
  207. package/src/index.ts +10 -0
  208. package/src/stores/hms-interactivity-store.ts +18 -0
  209. package/src/stores/hms-polls-slice.ts +20 -0
  210. package/src/stores/types.ts +20 -3
  211. package/src/utils/emitter/EventEmitter.ts +26 -0
  212. package/src/utils/windowController.ts +23 -0
package/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  </a>
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@100mslive/react-native-hms)](https://www.npmjs.com/package/@100mslive/react-native-hms)
6
+ [![Build](https://github.com/100mslive/100ms-react-native/actions/workflows/build.yml/badge.svg?branch=develop)](https://github.com/100mslive/100ms-react-native/actions/workflows/build.yml)
6
7
  [![license](https://img.shields.io/npm/l/@100mslive/react-native-hms)](https://www.100ms.live/)
7
8
  [![quality](https://img.shields.io/npms-io/quality-score/@100mslive/react-native-hms)](https://www.npmjs.com/package/@100mslive/react-native-hms)
8
9
  [![collaborators](https://img.shields.io/npm/collaborators/@100mslive/react-native-hms)](https://www.npmjs.com/package/@100mslive/react-native-hms)
@@ -21,10 +22,10 @@ With support for HLS and RTMP Live Streaming and Recording, Picture-in-Picture (
21
22
 
22
23
  📖 Read the Complete Documentation here: https://www.100ms.live/docs/react-native/v2/foundation/basics
23
24
 
24
- | Package | Version |
25
- | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
26
- | @100mslive/react-native-room-kit | [![npm](https://img.shields.io/npm/v/@100mslive/react-native-room-kit)](https://www.npmjs.com/package/@100mslive/react-native-room-kit) |
27
- | @100mslive/react-native-hms | [![npm](https://img.shields.io/npm/v/@100mslive/react-native-hms)](https://www.npmjs.com/package/@100mslive/react-native-hms) |
25
+ | Package | Version |
26
+ | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
27
+ | @100mslive/react-native-room-kit | [![npm](https://img.shields.io/npm/v/@100mslive/react-native-room-kit)](https://www.npmjs.com/package/@100mslive/react-native-room-kit) |
28
+ | @100mslive/react-native-hms | [![npm](https://img.shields.io/npm/v/@100mslive/react-native-hms)](https://www.npmjs.com/package/@100mslive/react-native-hms) |
28
29
 
29
30
  ## 🏃 Example App
30
31
 
@@ -1 +1,8 @@
1
- sdk.dir=/Users/yogesh/Library/Android/sdk
1
+ ## This file must *NOT* be checked into Version Control Systems,
2
+ # as it contains information specific to your local configuration.
3
+ #
4
+ # Location of the SDK. This is only used by Gradle.
5
+ # For customization when using a Version Control System, please read the
6
+ # header note.
7
+ #Mon Nov 14 20:51:00 IST 2022
8
+ sdk.dir=/Users/jatinnagar/Library/Android/sdk
@@ -340,6 +340,8 @@ object HMSDecoder {
340
340
  permissions.putBoolean("hlsStreaming", hmsPermissions.hlsStreaming)
341
341
  permissions.putBoolean("rtmpStreaming", hmsPermissions.rtmpStreaming)
342
342
  permissions.putBoolean("changeRole", hmsPermissions.changeRole)
343
+ permissions.putBoolean("pollRead", hmsPermissions.pollRead)
344
+ permissions.putBoolean("pollWrite", hmsPermissions.pollWrite)
343
345
  }
344
346
  return permissions
345
347
  }
@@ -12,6 +12,8 @@ import android.util.Rational
12
12
  import android.view.WindowManager
13
13
  import androidx.annotation.RequiresApi
14
14
  import androidx.core.app.NotificationManagerCompat
15
+ import androidx.core.view.WindowCompat
16
+ import androidx.core.view.WindowInsetsCompat
15
17
  import com.facebook.react.bridge.*
16
18
  import com.facebook.react.module.annotations.ReactModule
17
19
  import com.facebook.react.modules.core.DeviceEventManagerModule
@@ -686,7 +688,7 @@ class HMSManager(reactContext: ReactApplicationContext) :
686
688
  hms?.getAuthTokenByRoomCode(data, promise)
687
689
  }
688
690
 
689
- // region Person-In-Person Mode Action handing
691
+ // region Picture-In-Picture Mode Action handing
690
692
  private val pipReceiver by lazy {
691
693
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
692
694
  PipActionReceiver(
@@ -778,7 +780,9 @@ class HMSManager(reactContext: ReactApplicationContext) :
778
780
  PendingIntent.getBroadcast(
779
781
  reactApplicationContext,
780
782
  PipActionReceiver.PIPActions.localAudio.requestCode,
781
- Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(PipActionReceiver.PIPActions.localAudio.title, PipActionReceiver.PIPActions.localAudio.requestCode),
783
+ Intent(
784
+ PipActionReceiver.PIP_INTENT_ACTION,
785
+ ).putExtra(PipActionReceiver.PIPActions.localAudio.title, PipActionReceiver.PIPActions.localAudio.requestCode),
782
786
  PendingIntent.FLAG_IMMUTABLE,
783
787
  ),
784
788
  )
@@ -803,7 +807,9 @@ class HMSManager(reactContext: ReactApplicationContext) :
803
807
  PendingIntent.getBroadcast(
804
808
  reactApplicationContext,
805
809
  PipActionReceiver.PIPActions.localVideo.requestCode,
806
- Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(PipActionReceiver.PIPActions.localVideo.title, PipActionReceiver.PIPActions.localVideo.requestCode),
810
+ Intent(
811
+ PipActionReceiver.PIP_INTENT_ACTION,
812
+ ).putExtra(PipActionReceiver.PIPActions.localVideo.title, PipActionReceiver.PIPActions.localVideo.requestCode),
807
813
  PendingIntent.FLAG_IMMUTABLE,
808
814
  ),
809
815
  )
@@ -1298,6 +1304,35 @@ class HMSManager(reactContext: ReactApplicationContext) :
1298
1304
  return attributes.softInputMode
1299
1305
  }
1300
1306
 
1307
+ @ReactMethod
1308
+ fun hideSystemBars() {
1309
+ val window = reactApplicationContext?.currentActivity?.window
1310
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && window != null) {
1311
+ UiThreadUtil.runOnUiThread {
1312
+ window.attributes.layoutInDisplayCutoutMode =
1313
+ WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
1314
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
1315
+ window.insetsController?.hide(WindowInsetsCompat.Type.systemBars())
1316
+ }
1317
+ WindowCompat.setDecorFitsSystemWindows(window, false)
1318
+ }
1319
+ }
1320
+ }
1321
+
1322
+ @ReactMethod
1323
+ fun showSystemBars() {
1324
+ val window = reactApplicationContext?.currentActivity?.window
1325
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && window != null) {
1326
+ UiThreadUtil.runOnUiThread {
1327
+ window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT
1328
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
1329
+ window.insetsController?.show(WindowInsetsCompat.Type.systemBars())
1330
+ }
1331
+ WindowCompat.setDecorFitsSystemWindows(window, true)
1332
+ }
1333
+ }
1334
+ }
1335
+
1301
1336
  fun emitEvent(
1302
1337
  event: String,
1303
1338
  data: WritableMap,
@@ -1307,6 +1342,64 @@ class HMSManager(reactContext: ReactApplicationContext) :
1307
1342
  .emit(event, data)
1308
1343
  }
1309
1344
 
1345
+ // region Polls
1346
+ @ReactMethod
1347
+ fun quickStartPoll(
1348
+ data: ReadableMap,
1349
+ promise: Promise?,
1350
+ ) {
1351
+ val rnSDK = HMSHelper.getHms(data, hmsCollection)
1352
+ rnSDK?.let { sdk ->
1353
+ sdk.interactivityCenter?.let { center ->
1354
+ center.quickStartPoll(data, promise)
1355
+ return
1356
+ }
1357
+ }
1358
+ promise?.reject(
1359
+ "6004",
1360
+ "HMS SDK not initialized",
1361
+ )
1362
+ }
1363
+
1364
+ @ReactMethod
1365
+ fun addResponseOnPollQuestion(
1366
+ data: ReadableMap,
1367
+ promise: Promise?,
1368
+ ) {
1369
+ val rnSDK = HMSHelper.getHms(data, hmsCollection)
1370
+ rnSDK?.let { sdk ->
1371
+ sdk.interactivityCenter?.let { center ->
1372
+ center.addResponseOnPollQuestion(data, promise)
1373
+ return
1374
+ }
1375
+ }
1376
+ promise?.reject(
1377
+ "6004",
1378
+ "HMS SDK not initialized",
1379
+ )
1380
+ }
1381
+
1382
+ @ReactMethod
1383
+ fun stopPoll(
1384
+ data: ReadableMap,
1385
+ promise: Promise?,
1386
+ ) {
1387
+ val rnSDK = HMSHelper.getHms(data, hmsCollection)
1388
+ rnSDK?.let { sdk ->
1389
+ sdk.interactivityCenter?.let { center ->
1390
+ center.stop(data, promise)
1391
+ return
1392
+ }
1393
+ }
1394
+ promise?.reject(
1395
+ "6004",
1396
+ "HMS SDK not initialized",
1397
+ )
1398
+ }
1399
+ // endregion
1400
+
1401
+ // region ActivityLifecycleCallbacks
1402
+
1310
1403
  override fun onActivityCreated(
1311
1404
  activity: Activity,
1312
1405
  savedInstanceState: Bundle?,
@@ -1342,7 +1435,8 @@ class HMSManager(reactContext: ReactApplicationContext) :
1342
1435
  }
1343
1436
  }
1344
1437
  } catch (e: Exception) {
1345
- // Log.d("error", e.message)
1346
1438
  }
1347
1439
  }
1440
+
1441
+ // endregion
1348
1442
  }
@@ -49,12 +49,14 @@ class HMSRNSDK(
49
49
  private var audioMixingMode: AudioMixingMode = AudioMixingMode.TALK_AND_MUSIC
50
50
  private var id: String = sdkId
51
51
  private var self = this
52
- private var eventsEnableStatus = mutableMapOf<String, Boolean>()
52
+ var eventsEnableStatus = mutableMapOf<String, Boolean>()
53
53
  private var sessionStore: HmsSessionStore? = null
54
54
  private val keyChangeObservers = mutableMapOf<String, HMSKeyChangeListener?>()
55
55
  private val peerListIterators = mutableMapOf<String, PeerListIterator>()
56
56
  private var roomMutedLocally = false
57
57
 
58
+ var interactivityCenter: HMSRNInteractivityCenter? = null
59
+
58
60
  init {
59
61
  val builder = HMSSDK.Builder(reactApplicationContext)
60
62
  if (HMSHelper.areAllRequiredKeysAvailable(data, arrayOf(Pair("trackSettings", "Map")))) {
@@ -85,6 +87,10 @@ class HMSRNSDK(
85
87
  }
86
88
 
87
89
  this.hmsSDK = builder.build()
90
+
91
+ hmsSDK?.let {
92
+ interactivityCenter = HMSRNInteractivityCenter(it, this)
93
+ }
88
94
  }
89
95
 
90
96
  private fun emitCustomError(message: String) {
@@ -1692,21 +1698,22 @@ class HMSRNSDK(
1692
1698
  hmsSDK?.setAudioDeviceChangeListener(
1693
1699
  object : HMSAudioManager.AudioManagerDeviceChangeListener {
1694
1700
  override fun onAudioDeviceChanged(
1695
- device: HMSAudioManager.AudioDevice?,
1696
- audioDevicesList: Set<HMSAudioManager.AudioDevice>?,
1701
+ selectedAudioDevice: HMSAudioManager.AudioDevice,
1702
+ availableAudioDevices: Set<HMSAudioManager.AudioDevice>,
1697
1703
  ) {
1698
1704
  if (eventsEnableStatus["ON_AUDIO_DEVICE_CHANGED"] != true) {
1699
1705
  return
1700
1706
  }
1707
+
1701
1708
  val data: WritableMap = Arguments.createMap()
1702
- data.putString("device", device?.name)
1703
- data.putArray("audioDevicesList", HMSHelper.getAudioDevicesSet(audioDevicesList))
1709
+ data.putString("device", selectedAudioDevice.name)
1710
+ data.putArray("audioDevicesList", HMSHelper.getAudioDevicesSet(availableAudioDevices))
1704
1711
  data.putString("id", id)
1705
1712
  delegate.emitEvent("ON_AUDIO_DEVICE_CHANGED", data)
1706
1713
  }
1707
1714
 
1708
- override fun onError(error: HMSException) {
1709
- self.emitHMSError(error)
1715
+ override fun onError(e: HMSException) {
1716
+ self.emitHMSError(e)
1710
1717
  }
1711
1718
  },
1712
1719
  )
@@ -0,0 +1,328 @@
1
+ package com.reactnativehmssdk.Interactivity
2
+
3
+ import com.facebook.react.bridge.Arguments
4
+ import com.facebook.react.bridge.ReadableArray
5
+ import com.facebook.react.bridge.WritableArray
6
+ import com.facebook.react.bridge.WritableMap
7
+ import com.reactnativehmssdk.HMSDecoder
8
+ import live.hms.video.polls.models.*
9
+ import live.hms.video.polls.models.answer.HMSPollQuestionAnswer
10
+ import live.hms.video.polls.models.answer.HmsPollAnswer
11
+ import live.hms.video.polls.models.answer.PollAnswerItem
12
+ import live.hms.video.polls.models.answer.PollAnswerResponse
13
+ import live.hms.video.polls.models.question.HMSPollQuestion
14
+ import live.hms.video.polls.models.question.HMSPollQuestionOption
15
+ import live.hms.video.polls.network.PollResultsDisplay
16
+
17
+ object HMSInteractivityDecoder {
18
+ fun getPollUpdateType(hmsPollUpdateType: HMSPollUpdateType): Int {
19
+ return when (hmsPollUpdateType) {
20
+ HMSPollUpdateType.started -> 0
21
+ HMSPollUpdateType.resultsupdated -> 1
22
+ HMSPollUpdateType.stopped -> 2
23
+ else -> {
24
+ 0
25
+ }
26
+ }
27
+ }
28
+
29
+ fun getPoll(poll: HmsPoll): WritableMap {
30
+ val data = Arguments.createMap()
31
+
32
+ data.putBoolean("anonymous", poll.anonymous)
33
+ data.putInt("type", poll.category.ordinal)
34
+ poll.duration?.let { data.putDouble("duration", it.toDouble()) }
35
+ data.putString("pollId", poll.pollId)
36
+ data.putArray("rolesThatCanViewResponses", HMSDecoder.getAllRoles(poll.rolesThatCanViewResponses))
37
+ data.putArray("rolesThatCanVote", HMSDecoder.getAllRoles(poll.rolesThatCanVote))
38
+ data.putInt("state", getPollStateOrdinal(poll.state))
39
+ data.putString("title", poll.title)
40
+
41
+ poll.createdBy?.let {
42
+ data.putMap("createdBy", HMSDecoder.getHmsPeerSubset(it))
43
+ }
44
+
45
+ poll.mode?.let {
46
+ data.putInt("mode", getPollMode(poll))
47
+ }
48
+
49
+ poll.questionCount?.let {
50
+ data.putInt("questionCount", it)
51
+ }
52
+
53
+ poll.questions?.let {
54
+ data.putArray("questions", getPollQuestions(it))
55
+ }
56
+
57
+ poll.result?.let {
58
+ data.putMap("result", getPollResult(it))
59
+ }
60
+
61
+ data.putString("startedAt", poll.startedAt.toString())
62
+
63
+ poll.stoppedAt?.let {
64
+ data.putString("stoppedAt", it.toString())
65
+ }
66
+
67
+ poll.startedBy?.let {
68
+ data.putMap("startedBy", HMSDecoder.getHmsPeerSubset(it))
69
+ }
70
+
71
+ return data
72
+ }
73
+
74
+ private fun getPollStateOrdinal(pollState: HmsPollState): Int {
75
+ return when (pollState) {
76
+ HmsPollState.CREATED -> 0
77
+ HmsPollState.STARTED -> 1
78
+ HmsPollState.STOPPED -> 2
79
+ else -> 0
80
+ }
81
+ }
82
+
83
+ private fun getPollMode(poll: HmsPoll): Int {
84
+ return when (poll.mode) {
85
+ HmsPollUserTrackingMode.PEER_ID -> 0
86
+ HmsPollUserTrackingMode.USER_ID -> 1
87
+ HmsPollUserTrackingMode.USERNAME -> 2
88
+ else -> {
89
+ 0
90
+ }
91
+ }
92
+ }
93
+
94
+ private fun getPollQuestions(questions: List<HMSPollQuestion>): WritableArray {
95
+ val data = Arguments.createArray()
96
+
97
+ for (question in questions) {
98
+ data.pushMap(getPollQuestion(question))
99
+ }
100
+
101
+ return data
102
+ }
103
+
104
+ private fun getPollQuestion(question: HMSPollQuestion): WritableMap {
105
+ val data = Arguments.createMap()
106
+
107
+ data.putInt("index", question.questionID)
108
+
109
+ question.duration.let { data.putDouble("duration", it.toDouble()) }
110
+
111
+ question.myResponses.let {
112
+ data.putArray("myResponses", getPollAnswers(it))
113
+ }
114
+
115
+ data.putBoolean("skippable", question.canSkip)
116
+
117
+ data.putString("text", question.text)
118
+
119
+ data.putInt("type", question.type.ordinal)
120
+
121
+ data.putBoolean("voted", question.voted)
122
+
123
+ data.putInt("weight", question.weight)
124
+
125
+ question.correctAnswer?.let {
126
+ data.putMap("answer", getPollQuestionAnswer(it))
127
+ }
128
+
129
+ question.answerLongMinLength?.let {
130
+ data.putDouble("answerMaxLen", it.toDouble())
131
+ }
132
+
133
+ question.answerShortMinLength?.let {
134
+ data.putDouble("answerMinLen", it.toDouble())
135
+ }
136
+
137
+ question.options?.let {
138
+ data.putArray("options", getPollQuestionOptions(it))
139
+ }
140
+
141
+ return data
142
+ }
143
+
144
+ private fun getPollQuestionOptions(options: List<HMSPollQuestionOption>): WritableArray {
145
+ val data = Arguments.createArray()
146
+
147
+ for (option in options) {
148
+ data.pushMap(getPollQuestionOption(option))
149
+ }
150
+
151
+ return data
152
+ }
153
+
154
+ private fun getPollQuestionOption(option: HMSPollQuestionOption): WritableMap {
155
+ val data = Arguments.createMap()
156
+
157
+ data.putString("text", option.text)
158
+ data.putInt("index", option.index)
159
+ data.putInt("voteCount", option.voteCount.toInt())
160
+ option.weight?.let { data.putInt("weight", it) }
161
+
162
+ return data
163
+ }
164
+
165
+ private fun getPollQuestionAnswer(answer: HMSPollQuestionAnswer): WritableMap {
166
+ val data = Arguments.createMap()
167
+
168
+ answer.option?.let { data.putInt("option", it) }
169
+
170
+ answer.options?.let { data.putArray("options", convertListToReadableArray(it)) }
171
+
172
+ data.putBoolean("hidden", answer.hidden)
173
+
174
+ return data
175
+ }
176
+
177
+ private fun getPollAnswers(answers: List<HmsPollAnswer>): WritableArray {
178
+ val data = Arguments.createArray()
179
+
180
+ for (answer in answers) {
181
+ data.pushMap(getPollAnswer(answer))
182
+ }
183
+
184
+ return data
185
+ }
186
+
187
+ private fun getPollAnswer(answer: HmsPollAnswer): WritableMap {
188
+ val data = Arguments.createMap()
189
+
190
+ answer.durationMillis.let { data.putDouble("duration", (it * 1000).toDouble()) }
191
+
192
+ data.putInt("option", answer.selectedOption)
193
+
194
+ data.putInt("questionId", answer.questionId)
195
+
196
+ data.putBoolean("skipped", answer.skipped)
197
+
198
+ data.putString("text", answer.answerText)
199
+
200
+ data.putInt("type", answer.questionType.ordinal)
201
+
202
+ data.putBoolean("update", answer.update)
203
+
204
+ answer.selectedOptions?.let {
205
+ data.putArray("options", convertListToReadableArray(it))
206
+ }
207
+
208
+ return data
209
+ }
210
+
211
+ private fun getPollResult(result: PollResultsDisplay): WritableMap {
212
+ val data = Arguments.createMap()
213
+
214
+ result.totalResponses?.let {
215
+ data.putDouble("totalResponse", it.toDouble())
216
+ }
217
+
218
+ result.votingUsers?.let {
219
+ data.putDouble("userCount", it.toDouble())
220
+ }
221
+
222
+ result.totalDistinctUsers?.let {
223
+ data.putDouble("maxUserCount", it.toDouble())
224
+ }
225
+
226
+ result.questions.let {
227
+ data.putArray("questions", getPollStatsQuestion(it))
228
+ }
229
+
230
+ return data
231
+ }
232
+
233
+ private fun getPollStatsQuestion(questions: List<PollStatsQuestions>): WritableArray {
234
+ val data = Arguments.createArray()
235
+
236
+ for (question in questions) {
237
+ data.pushMap(getPollStatsQuestion(question))
238
+ }
239
+
240
+ return data
241
+ }
242
+
243
+ private fun getPollStatsQuestion(question: PollStatsQuestions): WritableMap {
244
+ val data = Arguments.createMap()
245
+
246
+ data.putInt("question", question.index)
247
+
248
+ data.putInt("type", question.questionType.ordinal)
249
+
250
+ question.correct?.let { data.putDouble("correctVotes", it.toDouble()) }
251
+
252
+ data.putDouble("skippedVotes", question.skipped.toDouble())
253
+
254
+ data.putInt("totalVotes", question.attemptedTimes)
255
+
256
+ question.options?.let {
257
+ data.putArray("optionVoteCounts", convertLongListToReadableArray(it))
258
+ }
259
+
260
+ return data
261
+ }
262
+
263
+ private fun convertLongListToReadableArray(list: List<Long>): ReadableArray {
264
+ val readableArray = Arguments.createArray()
265
+ list.forEach {
266
+ readableArray.pushInt(it.toInt())
267
+ }
268
+ return readableArray
269
+ }
270
+
271
+ private fun convertListToReadableArray(list: List<Int>): ReadableArray {
272
+ val readableArray = Arguments.createArray()
273
+ list.forEach {
274
+ readableArray.pushInt(it.toInt())
275
+ }
276
+ return readableArray
277
+ }
278
+
279
+ /*
280
+
281
+ static func getHMSPollQuestionResponseResults(_ hmsPollQuestionResponseResults: [HMSPollQuestionResponseResult]) -> [[String: AnyHashable]] {
282
+ var results = [[String: AnyHashable]]()
283
+
284
+ hmsPollQuestionResponseResults.forEach { result in
285
+ results.append(getHMSPollQuestionResponseResult(result))
286
+ }
287
+ return results
288
+ }
289
+
290
+ static func getHMSPollQuestionResponseResult(_ hmsPollQuestionResponseResult: HMSPollQuestionResponseResult) -> [String: AnyHashable] {
291
+ var result: [String: AnyHashable] = [
292
+ "question": hmsPollQuestionResponseResult.question
293
+ ]
294
+ if let correct = hmsPollQuestionResponseResult.correct {
295
+ result["correct"] = correct
296
+ }
297
+ if let error = hmsPollQuestionResponseResult.error {
298
+ result["error"] = error.localizedDescription
299
+ }
300
+ return result
301
+ }
302
+
303
+ */
304
+ fun getHMSPollQuestionResponseResults(hmsPollQuestionResponseResults: PollAnswerResponse): WritableArray {
305
+ val results = Arguments.createArray()
306
+
307
+ hmsPollQuestionResponseResults.result.forEach { result ->
308
+ results.pushMap(getHMSPollQuestionResponseResult(result))
309
+ }
310
+ return results
311
+ }
312
+
313
+ private fun getHMSPollQuestionResponseResult(hmsPollQuestionResponseResult: PollAnswerItem): WritableMap {
314
+ val result = Arguments.createMap()
315
+
316
+ result.putInt("question", hmsPollQuestionResponseResult.questionIndex)
317
+
318
+ hmsPollQuestionResponseResult.correct.let {
319
+ result.putBoolean("correct", it)
320
+ }
321
+
322
+ hmsPollQuestionResponseResult.error?.let {
323
+ result.putString("error", it.localizedMessage)
324
+ }
325
+
326
+ return result
327
+ }
328
+ }