@fishjam-cloud/react-native-client 0.24.0 → 0.25.0-rc.2

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 (260) hide show
  1. package/README.md +56 -15
  2. package/dist/index.d.ts +13 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +19 -0
  5. package/dist/overrides/RTCPeerConnection.d.ts +8 -0
  6. package/dist/overrides/RTCPeerConnection.d.ts.map +1 -0
  7. package/dist/overrides/RTCPeerConnection.js +16 -0
  8. package/dist/overrides/RTCView.d.ts +11 -0
  9. package/dist/overrides/RTCView.d.ts.map +1 -0
  10. package/dist/overrides/RTCView.js +21 -0
  11. package/dist/polyfills/local-storage.d.ts +10 -0
  12. package/dist/polyfills/local-storage.d.ts.map +1 -0
  13. package/dist/polyfills/local-storage.js +24 -0
  14. package/{build/hooks → dist}/useForegroundService.d.ts +10 -10
  15. package/dist/useForegroundService.d.ts.map +1 -0
  16. package/dist/useForegroundService.js +10 -0
  17. package/dist/webrtc-polyfill.d.ts +2 -0
  18. package/dist/webrtc-polyfill.d.ts.map +1 -0
  19. package/dist/webrtc-polyfill.js +14 -0
  20. package/package.json +45 -92
  21. package/plugin/broadcastExtensionFiles/Atomic.swift +37 -0
  22. package/plugin/broadcastExtensionFiles/DarwinNotificationCenter.swift +29 -0
  23. package/plugin/broadcastExtensionFiles/Info.plist +1 -1
  24. package/plugin/broadcastExtensionFiles/SampleHandler.swift +104 -0
  25. package/plugin/broadcastExtensionFiles/SampleUploader.swift +146 -0
  26. package/plugin/broadcastExtensionFiles/SocketConnection.swift +198 -0
  27. package/plugin/build/types.d.ts +5 -4
  28. package/plugin/build/withFishjam.d.ts +31 -2
  29. package/plugin/build/withFishjam.js +31 -5
  30. package/plugin/build/withFishjamAndroid.d.ts +2 -2
  31. package/plugin/build/withFishjamAndroid.js +48 -40
  32. package/plugin/build/withFishjamIos.d.ts +3 -8
  33. package/plugin/build/withFishjamIos.js +52 -72
  34. package/LICENSE.txt +0 -201
  35. package/android/build.gradle +0 -95
  36. package/android/src/main/AndroidManifest.xml +0 -2
  37. package/android/src/main/java/io/fishjam/reactnative/AudioDeviceKind.kt +0 -34
  38. package/android/src/main/java/io/fishjam/reactnative/AudioSwitchManager.kt +0 -61
  39. package/android/src/main/java/io/fishjam/reactnative/EmitableEvents.kt +0 -126
  40. package/android/src/main/java/io/fishjam/reactnative/Errors.kt +0 -31
  41. package/android/src/main/java/io/fishjam/reactnative/PipContainerView.kt +0 -282
  42. package/android/src/main/java/io/fishjam/reactnative/PipContainerViewModule.kt +0 -41
  43. package/android/src/main/java/io/fishjam/reactnative/PipTrackSelector.kt +0 -98
  44. package/android/src/main/java/io/fishjam/reactnative/PipViewFactory.kt +0 -186
  45. package/android/src/main/java/io/fishjam/reactnative/RNFishjamClient.kt +0 -1001
  46. package/android/src/main/java/io/fishjam/reactnative/RNFishjamClientModule.kt +0 -358
  47. package/android/src/main/java/io/fishjam/reactnative/Utils.kt +0 -11
  48. package/android/src/main/java/io/fishjam/reactnative/VideoPreviewView.kt +0 -40
  49. package/android/src/main/java/io/fishjam/reactnative/VideoPreviewViewModule.kt +0 -22
  50. package/android/src/main/java/io/fishjam/reactnative/VideoRendererView.kt +0 -76
  51. package/android/src/main/java/io/fishjam/reactnative/VideoRendererViewModule.kt +0 -33
  52. package/android/src/main/java/io/fishjam/reactnative/VideoView.kt +0 -257
  53. package/android/src/main/java/io/fishjam/reactnative/extensions/CaptureDevice.kt +0 -17
  54. package/android/src/main/java/io/fishjam/reactnative/foregroundService/FishjamForegroundService.kt +0 -101
  55. package/android/src/main/java/io/fishjam/reactnative/foregroundService/ForegroundServiceManager.kt +0 -118
  56. package/android/src/main/java/io/fishjam/reactnative/foregroundService/ForegroundServiceState.kt +0 -46
  57. package/android/src/main/java/io/fishjam/reactnative/helpers/PictureInPictureHelperFragment.kt +0 -20
  58. package/android/src/main/java/io/fishjam/reactnative/managers/ListenerManager.kt +0 -24
  59. package/android/src/main/java/io/fishjam/reactnative/managers/LocalCameraTracksChangedListenersManager.kt +0 -8
  60. package/android/src/main/java/io/fishjam/reactnative/managers/LocalTracksSwitchListenersManager.kt +0 -17
  61. package/android/src/main/java/io/fishjam/reactnative/managers/TracksUpdateListenersManager.kt +0 -7
  62. package/android/src/main/java/io/fishjam/reactnative/utils/PermissionUtils.kt +0 -45
  63. package/build/RNFishjamClientModule.d.ts +0 -106
  64. package/build/RNFishjamClientModule.d.ts.map +0 -1
  65. package/build/RNFishjamClientModule.js +0 -21
  66. package/build/RNFishjamClientModule.js.map +0 -1
  67. package/build/common/metadata.d.ts +0 -9
  68. package/build/common/metadata.d.ts.map +0 -1
  69. package/build/common/metadata.js +0 -11
  70. package/build/common/metadata.js.map +0 -1
  71. package/build/components/FishjamRoom/GridTrackItem.d.ts +0 -12
  72. package/build/components/FishjamRoom/GridTrackItem.d.ts.map +0 -1
  73. package/build/components/FishjamRoom/GridTrackItem.js +0 -56
  74. package/build/components/FishjamRoom/GridTrackItem.js.map +0 -1
  75. package/build/components/FishjamRoom/VideosGrid.d.ts +0 -3
  76. package/build/components/FishjamRoom/VideosGrid.d.ts.map +0 -1
  77. package/build/components/FishjamRoom/VideosGrid.js +0 -20
  78. package/build/components/FishjamRoom/VideosGrid.js.map +0 -1
  79. package/build/components/FishjamRoom/index.d.ts +0 -33
  80. package/build/components/FishjamRoom/index.d.ts.map +0 -1
  81. package/build/components/FishjamRoom/index.js +0 -52
  82. package/build/components/FishjamRoom/index.js.map +0 -1
  83. package/build/components/FishjamRoom/parsePeersToTracks.d.ts +0 -4
  84. package/build/components/FishjamRoom/parsePeersToTracks.d.ts.map +0 -1
  85. package/build/components/FishjamRoom/parsePeersToTracks.js +0 -37
  86. package/build/components/FishjamRoom/parsePeersToTracks.js.map +0 -1
  87. package/build/components/PipContainerView.d.ts +0 -48
  88. package/build/components/PipContainerView.d.ts.map +0 -1
  89. package/build/components/PipContainerView.js +0 -34
  90. package/build/components/PipContainerView.js.map +0 -1
  91. package/build/components/VideoPreviewView.d.ts +0 -28
  92. package/build/components/VideoPreviewView.d.ts.map +0 -1
  93. package/build/components/VideoPreviewView.js +0 -17
  94. package/build/components/VideoPreviewView.js.map +0 -1
  95. package/build/components/VideoRendererView.d.ts +0 -39
  96. package/build/components/VideoRendererView.d.ts.map +0 -1
  97. package/build/components/VideoRendererView.js +0 -25
  98. package/build/components/VideoRendererView.js.map +0 -1
  99. package/build/consts/index.d.ts +0 -5
  100. package/build/consts/index.d.ts.map +0 -1
  101. package/build/consts/index.js +0 -8
  102. package/build/consts/index.js.map +0 -1
  103. package/build/debug/common/webRTC.d.ts +0 -9
  104. package/build/debug/common/webRTC.d.ts.map +0 -1
  105. package/build/debug/common/webRTC.js +0 -11
  106. package/build/debug/common/webRTC.js.map +0 -1
  107. package/build/debug/index.d.ts +0 -4
  108. package/build/debug/index.d.ts.map +0 -1
  109. package/build/debug/index.js +0 -3
  110. package/build/debug/index.js.map +0 -1
  111. package/build/debug/stats/types.d.ts +0 -55
  112. package/build/debug/stats/types.d.ts.map +0 -1
  113. package/build/debug/stats/types.js +0 -2
  114. package/build/debug/stats/types.js.map +0 -1
  115. package/build/debug/stats/useRTCStatistics.d.ts +0 -9
  116. package/build/debug/stats/useRTCStatistics.d.ts.map +0 -1
  117. package/build/debug/stats/useRTCStatistics.js +0 -79
  118. package/build/debug/stats/useRTCStatistics.js.map +0 -1
  119. package/build/hooks/internal/useFishjamEvent.d.ts +0 -4
  120. package/build/hooks/internal/useFishjamEvent.d.ts.map +0 -1
  121. package/build/hooks/internal/useFishjamEvent.js +0 -38
  122. package/build/hooks/internal/useFishjamEvent.js.map +0 -1
  123. package/build/hooks/internal/useFishjamEventState.d.ts +0 -3
  124. package/build/hooks/internal/useFishjamEventState.d.ts.map +0 -1
  125. package/build/hooks/internal/useFishjamEventState.js +0 -18
  126. package/build/hooks/internal/useFishjamEventState.js.map +0 -1
  127. package/build/hooks/useAppScreenShare.d.ts +0 -18
  128. package/build/hooks/useAppScreenShare.d.ts.map +0 -1
  129. package/build/hooks/useAppScreenShare.js +0 -46
  130. package/build/hooks/useAppScreenShare.js.map +0 -1
  131. package/build/hooks/useAudioSettings.d.ts +0 -49
  132. package/build/hooks/useAudioSettings.d.ts.map +0 -1
  133. package/build/hooks/useAudioSettings.js +0 -70
  134. package/build/hooks/useAudioSettings.js.map +0 -1
  135. package/build/hooks/useBandwidthEstimation.d.ts +0 -14
  136. package/build/hooks/useBandwidthEstimation.d.ts.map +0 -1
  137. package/build/hooks/useBandwidthEstimation.js +0 -19
  138. package/build/hooks/useBandwidthEstimation.js.map +0 -1
  139. package/build/hooks/useCallKit.d.ts +0 -121
  140. package/build/hooks/useCallKit.d.ts.map +0 -1
  141. package/build/hooks/useCallKit.js +0 -142
  142. package/build/hooks/useCallKit.js.map +0 -1
  143. package/build/hooks/useCamera.d.ts +0 -113
  144. package/build/hooks/useCamera.d.ts.map +0 -1
  145. package/build/hooks/useCamera.js +0 -93
  146. package/build/hooks/useCamera.js.map +0 -1
  147. package/build/hooks/useConnection.d.ts +0 -73
  148. package/build/hooks/useConnection.d.ts.map +0 -1
  149. package/build/hooks/useConnection.js +0 -46
  150. package/build/hooks/useConnection.js.map +0 -1
  151. package/build/hooks/useForegroundService.d.ts.map +0 -1
  152. package/build/hooks/useForegroundService.js +0 -66
  153. package/build/hooks/useForegroundService.js.map +0 -1
  154. package/build/hooks/useMicrophone.d.ts +0 -16
  155. package/build/hooks/useMicrophone.d.ts.map +0 -1
  156. package/build/hooks/useMicrophone.js +0 -31
  157. package/build/hooks/useMicrophone.js.map +0 -1
  158. package/build/hooks/usePeerStatus.d.ts +0 -10
  159. package/build/hooks/usePeerStatus.d.ts.map +0 -1
  160. package/build/hooks/usePeerStatus.js +0 -13
  161. package/build/hooks/usePeerStatus.js.map +0 -1
  162. package/build/hooks/usePeers.d.ts +0 -98
  163. package/build/hooks/usePeers.d.ts.map +0 -1
  164. package/build/hooks/usePeers.js +0 -81
  165. package/build/hooks/usePeers.js.map +0 -1
  166. package/build/hooks/usePermissions.d.ts +0 -24
  167. package/build/hooks/usePermissions.d.ts.map +0 -1
  168. package/build/hooks/usePermissions.js +0 -61
  169. package/build/hooks/usePermissions.js.map +0 -1
  170. package/build/hooks/useReconnection.d.ts +0 -11
  171. package/build/hooks/useReconnection.d.ts.map +0 -1
  172. package/build/hooks/useReconnection.js +0 -14
  173. package/build/hooks/useReconnection.js.map +0 -1
  174. package/build/hooks/useSandbox.d.ts +0 -20
  175. package/build/hooks/useSandbox.d.ts.map +0 -1
  176. package/build/hooks/useSandbox.js +0 -54
  177. package/build/hooks/useSandbox.js.map +0 -1
  178. package/build/hooks/useScreenShare.d.ts +0 -36
  179. package/build/hooks/useScreenShare.d.ts.map +0 -1
  180. package/build/hooks/useScreenShare.js +0 -45
  181. package/build/hooks/useScreenShare.js.map +0 -1
  182. package/build/hooks/useUpdatePeerMetadata.d.ts +0 -15
  183. package/build/hooks/useUpdatePeerMetadata.d.ts.map +0 -1
  184. package/build/hooks/useUpdatePeerMetadata.js +0 -21
  185. package/build/hooks/useUpdatePeerMetadata.js.map +0 -1
  186. package/build/index.d.ts +0 -36
  187. package/build/index.d.ts.map +0 -1
  188. package/build/index.js +0 -30
  189. package/build/index.js.map +0 -1
  190. package/build/livestream/components/LivestreamStreamer.d.ts +0 -24
  191. package/build/livestream/components/LivestreamStreamer.d.ts.map +0 -1
  192. package/build/livestream/components/LivestreamStreamer.js +0 -12
  193. package/build/livestream/components/LivestreamStreamer.js.map +0 -1
  194. package/build/livestream/components/LivestreamViewer.d.ts +0 -46
  195. package/build/livestream/components/LivestreamViewer.d.ts.map +0 -1
  196. package/build/livestream/components/LivestreamViewer.js +0 -10
  197. package/build/livestream/components/LivestreamViewer.js.map +0 -1
  198. package/build/livestream/hooks/useLivestreamScreenSharingStreamer.d.ts +0 -49
  199. package/build/livestream/hooks/useLivestreamScreenSharingStreamer.d.ts.map +0 -1
  200. package/build/livestream/hooks/useLivestreamScreenSharingStreamer.js +0 -58
  201. package/build/livestream/hooks/useLivestreamScreenSharingStreamer.js.map +0 -1
  202. package/build/livestream/hooks/useLivestreamStreamer.d.ts +0 -65
  203. package/build/livestream/hooks/useLivestreamStreamer.d.ts.map +0 -1
  204. package/build/livestream/hooks/useLivestreamStreamer.js +0 -71
  205. package/build/livestream/hooks/useLivestreamStreamer.js.map +0 -1
  206. package/build/livestream/hooks/useLivestreamViewer.d.ts +0 -36
  207. package/build/livestream/hooks/useLivestreamViewer.d.ts.map +0 -1
  208. package/build/livestream/hooks/useLivestreamViewer.js +0 -73
  209. package/build/livestream/hooks/useLivestreamViewer.js.map +0 -1
  210. package/build/livestream/index.d.ts +0 -12
  211. package/build/livestream/index.d.ts.map +0 -1
  212. package/build/livestream/index.js +0 -7
  213. package/build/livestream/index.js.map +0 -1
  214. package/build/protos/fishjam/peer_notifications.d.ts +0 -63
  215. package/build/protos/fishjam/peer_notifications.d.ts.map +0 -1
  216. package/build/protos/fishjam/peer_notifications.js +0 -235
  217. package/build/protos/fishjam/peer_notifications.js.map +0 -1
  218. package/build/types.d.ts +0 -34
  219. package/build/types.d.ts.map +0 -1
  220. package/build/types.js +0 -2
  221. package/build/types.js.map +0 -1
  222. package/build/utils/config.d.ts +0 -6
  223. package/build/utils/config.d.ts.map +0 -1
  224. package/build/utils/config.js +0 -10
  225. package/build/utils/config.js.map +0 -1
  226. package/build/utils/errorListener.d.ts +0 -2
  227. package/build/utils/errorListener.d.ts.map +0 -1
  228. package/build/utils/errorListener.js +0 -15
  229. package/build/utils/errorListener.js.map +0 -1
  230. package/build/utils/eventPayloadValidator.d.ts +0 -3
  231. package/build/utils/eventPayloadValidator.d.ts.map +0 -1
  232. package/build/utils/eventPayloadValidator.js +0 -86
  233. package/build/utils/eventPayloadValidator.js.map +0 -1
  234. package/build/utils/getFishjamUrl.d.ts +0 -2
  235. package/build/utils/getFishjamUrl.d.ts.map +0 -1
  236. package/build/utils/getFishjamUrl.js +0 -10
  237. package/build/utils/getFishjamUrl.js.map +0 -1
  238. package/debug/package.json +0 -4
  239. package/expo-module.config.json +0 -19
  240. package/ios/CameraPermissionsRequester.swift +0 -117
  241. package/ios/Events.swift +0 -152
  242. package/ios/PictureInPictureManager.swift +0 -215
  243. package/ios/PipContainerView.swift +0 -56
  244. package/ios/PipContainerViewModule.swift +0 -48
  245. package/ios/RNFishjamClient.podspec +0 -30
  246. package/ios/RNFishjamClient.swift +0 -995
  247. package/ios/RNFishjamClientModule.swift +0 -289
  248. package/ios/RNFishjamProxy.swift +0 -12
  249. package/ios/Utils/PermissionUtils.swift +0 -16
  250. package/ios/Utils.swift +0 -23
  251. package/ios/VideoPreviewView.swift +0 -54
  252. package/ios/VideoPreviewViewModule.swift +0 -21
  253. package/ios/VideoRendererView.swift +0 -98
  254. package/ios/VideoRendererViewModule.swift +0 -23
  255. package/ios/extensions/AVCaptureDevice.swift +0 -20
  256. package/ios/managers/LocalCameraTracksChangedListenersManager.swift +0 -23
  257. package/ios/managers/TracksUpdateListenersManager.swift +0 -21
  258. package/livestream/package.json +0 -4
  259. package/plugin/broadcastExtensionFiles/FishjamBroadcastSampleHandler.swift +0 -50
  260. /package/plugin/broadcastExtensionFiles/{FishjamScreenBroadcastExtension.entitlements → ScreenBroadcastExtension.entitlements} +0 -0
@@ -1,186 +0,0 @@
1
- package io.fishjam.reactnative
2
-
3
- import android.content.Context
4
- import android.graphics.Color
5
- import android.graphics.drawable.GradientDrawable
6
- import android.text.TextUtils
7
- import android.util.TypedValue
8
- import android.view.Gravity
9
- import android.view.View
10
- import android.view.ViewGroup
11
- import android.widget.FrameLayout
12
- import android.widget.LinearLayout
13
- import android.widget.RelativeLayout
14
- import android.widget.TextView
15
- import expo.modules.kotlin.AppContext
16
-
17
- data class PipViewContainer(
18
- val splitScreenContainer: LinearLayout,
19
- val primaryContainer: RelativeLayout,
20
- val secondaryContainer: RelativeLayout,
21
- val primaryVideoView: VideoRendererView,
22
- val secondaryVideoView: VideoRendererView,
23
- val primaryPlaceholder: TextView,
24
- val secondaryPlaceholder: TextView,
25
- val secondaryNameOverlay: TextView
26
- )
27
-
28
- class PipViewFactory(
29
- private val context: Context,
30
- private val appContext: AppContext
31
- ) {
32
- companion object {
33
- private const val PLACEHOLDER_COLOR = "#000000"
34
- private const val PLACEHOLDER_TEXT_COLOR = Color.WHITE
35
- private const val PLACEHOLDER_TEXT_SIZE_SP = 16f
36
- private const val VIDEO_LAYOUT_MODE = "FILL"
37
-
38
- private const val NAME_OVERLAY_TEXT_SIZE_SP = 12f
39
- private const val NAME_OVERLAY_PADDING_DP = 5
40
- private const val NAME_OVERLAY_MAX_WIDTH_DP = 80
41
- private const val NAME_OVERLAY_BG_COLOR = 0x4D000000
42
- private const val NAME_OVERLAY_CORNER_RADIUS_DP = 5f
43
- }
44
-
45
- fun createPipViews(
46
- primaryPlaceholderText: String,
47
- secondaryPlaceholderText: String
48
- ): PipViewContainer {
49
- val primaryContainer = createRelativeLayoutContainer()
50
- val secondaryContainer = createRelativeLayoutContainer()
51
-
52
- val primaryPlaceholder = createPlaceholderTextView(primaryPlaceholderText)
53
- val secondaryPlaceholder = createPlaceholderTextView(secondaryPlaceholderText)
54
-
55
- val primaryVideoView = createVideoView()
56
- val secondaryVideoView = createVideoView()
57
-
58
- val secondaryNameOverlay = createNameOverlayTextView()
59
-
60
- primaryContainer.apply {
61
- addView(primaryPlaceholder, createMatchParentLayoutParams())
62
- addView(primaryVideoView, createCenteredLayoutParams())
63
- }
64
-
65
- secondaryContainer.apply {
66
- addView(secondaryPlaceholder, createMatchParentLayoutParams())
67
- addView(secondaryVideoView, createCenteredLayoutParams())
68
- addView(secondaryNameOverlay, createNameOverlayLayoutParams())
69
- }
70
-
71
- val splitScreenContainer = createSplitScreenContainer().apply {
72
- addView(primaryContainer)
73
- addView(secondaryContainer)
74
- }
75
-
76
- return PipViewContainer(
77
- splitScreenContainer = splitScreenContainer,
78
- primaryContainer = primaryContainer,
79
- secondaryContainer = secondaryContainer,
80
- primaryVideoView = primaryVideoView,
81
- secondaryVideoView = secondaryVideoView,
82
- primaryPlaceholder = primaryPlaceholder,
83
- secondaryPlaceholder = secondaryPlaceholder,
84
- secondaryNameOverlay = secondaryNameOverlay
85
- )
86
- }
87
-
88
- private fun createPlaceholderTextView(text: String): TextView {
89
- return TextView(context).apply {
90
- this.text = text
91
- setTextColor(PLACEHOLDER_TEXT_COLOR)
92
- gravity = Gravity.CENTER
93
- setTextSize(TypedValue.COMPLEX_UNIT_SP, PLACEHOLDER_TEXT_SIZE_SP)
94
- setBackgroundColor(Color.parseColor(PLACEHOLDER_COLOR))
95
- }
96
- }
97
-
98
- private fun createVideoView(): VideoRendererView {
99
- return VideoRendererView(context, appContext).apply {
100
- setVideoLayout(VIDEO_LAYOUT_MODE)
101
- visibility = View.GONE
102
- }
103
- }
104
-
105
- private fun createSplitScreenContainer(): LinearLayout {
106
- return LinearLayout(context).apply {
107
- orientation = LinearLayout.HORIZONTAL
108
- layoutParams = FrameLayout.LayoutParams(
109
- ViewGroup.LayoutParams.MATCH_PARENT,
110
- ViewGroup.LayoutParams.MATCH_PARENT
111
- )
112
- }
113
- }
114
-
115
- private fun createRelativeLayoutContainer(): RelativeLayout {
116
- return RelativeLayout(context).apply {
117
- layoutParams = LinearLayout.LayoutParams(
118
- 0,
119
- ViewGroup.LayoutParams.MATCH_PARENT,
120
- 1f
121
- )
122
- }
123
- }
124
-
125
- private fun createMatchParentLayoutParams(): RelativeLayout.LayoutParams {
126
- return RelativeLayout.LayoutParams(
127
- ViewGroup.LayoutParams.MATCH_PARENT,
128
- ViewGroup.LayoutParams.MATCH_PARENT
129
- )
130
- }
131
-
132
- private fun createCenteredLayoutParams(): RelativeLayout.LayoutParams {
133
- return RelativeLayout.LayoutParams(
134
- ViewGroup.LayoutParams.MATCH_PARENT,
135
- ViewGroup.LayoutParams.MATCH_PARENT
136
- ).apply {
137
- addRule(RelativeLayout.CENTER_IN_PARENT)
138
- }
139
- }
140
-
141
- private fun createNameOverlayTextView(): TextView {
142
- val paddingPx = dpToPx(NAME_OVERLAY_PADDING_DP)
143
- val maxWidthPx = dpToPx(NAME_OVERLAY_MAX_WIDTH_DP)
144
- val cornerRadiusPx = dpToPx(NAME_OVERLAY_CORNER_RADIUS_DP.toInt()).toFloat()
145
-
146
- val background = GradientDrawable().apply {
147
- setColor(NAME_OVERLAY_BG_COLOR.toInt())
148
- cornerRadii = floatArrayOf(
149
- cornerRadiusPx, cornerRadiusPx,
150
- 0f, 0f,
151
- 0f, 0f,
152
- 0f, 0f
153
- )
154
- }
155
-
156
- return TextView(context).apply {
157
- setTextColor(PLACEHOLDER_TEXT_COLOR)
158
- setTextSize(TypedValue.COMPLEX_UNIT_SP, NAME_OVERLAY_TEXT_SIZE_SP)
159
- setPadding(paddingPx, paddingPx, paddingPx, paddingPx)
160
- maxWidth = maxWidthPx
161
- maxLines = 1
162
- ellipsize = TextUtils.TruncateAt.END
163
- setBackground(background)
164
- visibility = View.GONE
165
- }
166
- }
167
-
168
- private fun createNameOverlayLayoutParams(): RelativeLayout.LayoutParams {
169
- return RelativeLayout.LayoutParams(
170
- ViewGroup.LayoutParams.WRAP_CONTENT,
171
- ViewGroup.LayoutParams.WRAP_CONTENT
172
- ).apply {
173
- addRule(RelativeLayout.ALIGN_PARENT_BOTTOM)
174
- addRule(RelativeLayout.ALIGN_PARENT_END)
175
- }
176
- }
177
-
178
- private fun dpToPx(dp: Int): Int {
179
- return TypedValue.applyDimension(
180
- TypedValue.COMPLEX_UNIT_DIP,
181
- dp.toFloat(),
182
- context.resources.displayMetrics
183
- ).toInt()
184
- }
185
- }
186
-