theta-client-react-native 1.1.0 → 1.3.0

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 (233) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/AndroidManifest.xml +1 -1
  3. package/android/src/main/java/com/ricoh360/thetaclientreactnative/Converter.kt +647 -0
  4. package/android/src/main/java/com/ricoh360/thetaclientreactnative/ThetaClientSdkModule.kt +487 -85
  5. package/ios/ThetaClientReactNative.h +6 -0
  6. package/ios/ThetaClientReactNative.mm +1675 -181
  7. package/ios/ThetaClientReactNative.xcodeproj/project.pbxproj +2 -2
  8. package/lib/commonjs/capture/index.js +11 -0
  9. package/lib/commonjs/capture/index.js.map +1 -1
  10. package/lib/commonjs/capture/notify.js +12 -0
  11. package/lib/commonjs/capture/notify.js.map +1 -0
  12. package/lib/commonjs/capture/time-shift-capture.js +135 -0
  13. package/lib/commonjs/capture/time-shift-capture.js.map +1 -0
  14. package/lib/commonjs/theta-repository/access-point.js.map +1 -1
  15. package/lib/commonjs/theta-repository/digest-auth.js +2 -0
  16. package/lib/commonjs/theta-repository/digest-auth.js.map +1 -0
  17. package/lib/commonjs/theta-repository/index.js +37 -4
  18. package/lib/commonjs/theta-repository/index.js.map +1 -1
  19. package/lib/commonjs/theta-repository/options/index.js +198 -0
  20. package/lib/commonjs/theta-repository/options/index.js.map +1 -1
  21. package/lib/commonjs/theta-repository/options/option-ai-auto-thumbnail.js +17 -0
  22. package/lib/commonjs/theta-repository/options/option-ai-auto-thumbnail.js.map +1 -0
  23. package/lib/commonjs/theta-repository/options/option-bitrate.js +64 -0
  24. package/lib/commonjs/theta-repository/options/option-bitrate.js.map +1 -0
  25. package/lib/commonjs/theta-repository/options/option-burst-mode.js +23 -0
  26. package/lib/commonjs/theta-repository/options/option-burst-mode.js.map +1 -0
  27. package/lib/commonjs/theta-repository/options/option-burst-option.js +140 -0
  28. package/lib/commonjs/theta-repository/options/option-burst-option.js.map +1 -0
  29. package/lib/commonjs/theta-repository/options/option-camera-control-source.js +29 -0
  30. package/lib/commonjs/theta-repository/options/option-camera-control-source.js.map +1 -0
  31. package/lib/commonjs/theta-repository/options/option-camera-mode.js +26 -0
  32. package/lib/commonjs/theta-repository/options/option-camera-mode.js.map +1 -0
  33. package/lib/commonjs/theta-repository/options/option-capture-mode.js +30 -0
  34. package/lib/commonjs/theta-repository/options/option-capture-mode.js.map +1 -0
  35. package/lib/commonjs/theta-repository/options/option-continuous-number.js +71 -0
  36. package/lib/commonjs/theta-repository/options/option-continuous-number.js.map +1 -0
  37. package/lib/commonjs/theta-repository/options/option-filter.js +32 -0
  38. package/lib/commonjs/theta-repository/options/option-filter.js.map +1 -0
  39. package/lib/commonjs/theta-repository/options/option-network-type.js +26 -0
  40. package/lib/commonjs/theta-repository/options/option-network-type.js.map +1 -0
  41. package/lib/commonjs/theta-repository/options/option-power-saving.js +24 -0
  42. package/lib/commonjs/theta-repository/options/option-power-saving.js.map +1 -0
  43. package/lib/commonjs/theta-repository/options/option-preset.js +26 -0
  44. package/lib/commonjs/theta-repository/options/option-preset.js.map +1 -0
  45. package/lib/commonjs/theta-repository/options/option-preview-format.js +32 -0
  46. package/lib/commonjs/theta-repository/options/option-preview-format.js.map +1 -0
  47. package/lib/commonjs/theta-repository/options/option-proxy.js +2 -0
  48. package/lib/commonjs/theta-repository/options/option-proxy.js.map +1 -0
  49. package/lib/commonjs/theta-repository/options/option-shooting-method.js +41 -0
  50. package/lib/commonjs/theta-repository/options/option-shooting-method.js.map +1 -0
  51. package/lib/commonjs/theta-repository/options/option-shutter-speed.js +302 -0
  52. package/lib/commonjs/theta-repository/options/option-shutter-speed.js.map +1 -0
  53. package/lib/commonjs/theta-repository/options/option-time-shift.js +43 -0
  54. package/lib/commonjs/theta-repository/options/option-time-shift.js.map +1 -0
  55. package/lib/commonjs/theta-repository/options/option-wlan-frequency.js +22 -0
  56. package/lib/commonjs/theta-repository/options/option-wlan-frequency.js.map +1 -0
  57. package/lib/commonjs/theta-repository/options/options.js +52 -26
  58. package/lib/commonjs/theta-repository/options/options.js.map +1 -1
  59. package/lib/commonjs/theta-repository/theta-config.js +6 -0
  60. package/lib/commonjs/theta-repository/theta-config.js.map +1 -0
  61. package/lib/commonjs/theta-repository/theta-files.js +33 -1
  62. package/lib/commonjs/theta-repository/theta-files.js.map +1 -1
  63. package/lib/commonjs/theta-repository/theta-info.js +29 -0
  64. package/lib/commonjs/theta-repository/theta-info.js.map +1 -1
  65. package/lib/commonjs/theta-repository/theta-repository.js +56 -8
  66. package/lib/commonjs/theta-repository/theta-repository.js.map +1 -1
  67. package/lib/commonjs/theta-repository/theta-timeout.js +2 -0
  68. package/lib/commonjs/theta-repository/theta-timeout.js.map +1 -0
  69. package/lib/module/capture/index.js +1 -0
  70. package/lib/module/capture/index.js.map +1 -1
  71. package/lib/module/capture/notify.js +6 -0
  72. package/lib/module/capture/notify.js.map +1 -0
  73. package/lib/module/capture/time-shift-capture.js +127 -0
  74. package/lib/module/capture/time-shift-capture.js.map +1 -0
  75. package/lib/module/theta-repository/access-point.js.map +1 -1
  76. package/lib/module/theta-repository/digest-auth.js +2 -0
  77. package/lib/module/theta-repository/digest-auth.js.map +1 -0
  78. package/lib/module/theta-repository/index.js +4 -1
  79. package/lib/module/theta-repository/index.js.map +1 -1
  80. package/lib/module/theta-repository/options/index.js +18 -0
  81. package/lib/module/theta-repository/options/index.js.map +1 -1
  82. package/lib/module/theta-repository/options/option-ai-auto-thumbnail.js +10 -0
  83. package/lib/module/theta-repository/options/option-ai-auto-thumbnail.js.map +1 -0
  84. package/lib/module/theta-repository/options/option-bitrate.js +57 -0
  85. package/lib/module/theta-repository/options/option-bitrate.js.map +1 -0
  86. package/lib/module/theta-repository/options/option-burst-mode.js +16 -0
  87. package/lib/module/theta-repository/options/option-burst-mode.js.map +1 -0
  88. package/lib/module/theta-repository/options/option-burst-option.js +133 -0
  89. package/lib/module/theta-repository/options/option-burst-option.js.map +1 -0
  90. package/lib/module/theta-repository/options/option-camera-control-source.js +22 -0
  91. package/lib/module/theta-repository/options/option-camera-control-source.js.map +1 -0
  92. package/lib/module/theta-repository/options/option-camera-mode.js +19 -0
  93. package/lib/module/theta-repository/options/option-camera-mode.js.map +1 -0
  94. package/lib/module/theta-repository/options/option-capture-mode.js +23 -0
  95. package/lib/module/theta-repository/options/option-capture-mode.js.map +1 -0
  96. package/lib/module/theta-repository/options/option-continuous-number.js +64 -0
  97. package/lib/module/theta-repository/options/option-continuous-number.js.map +1 -0
  98. package/lib/module/theta-repository/options/option-filter.js +25 -0
  99. package/lib/module/theta-repository/options/option-filter.js.map +1 -0
  100. package/lib/module/theta-repository/options/option-network-type.js +19 -0
  101. package/lib/module/theta-repository/options/option-network-type.js.map +1 -0
  102. package/lib/module/theta-repository/options/option-power-saving.js +17 -0
  103. package/lib/module/theta-repository/options/option-power-saving.js.map +1 -0
  104. package/lib/module/theta-repository/options/option-preset.js +19 -0
  105. package/lib/module/theta-repository/options/option-preset.js.map +1 -0
  106. package/lib/module/theta-repository/options/option-preview-format.js +25 -0
  107. package/lib/module/theta-repository/options/option-preview-format.js.map +1 -0
  108. package/lib/module/theta-repository/options/option-proxy.js +2 -0
  109. package/lib/module/theta-repository/options/option-proxy.js.map +1 -0
  110. package/lib/module/theta-repository/options/option-shooting-method.js +34 -0
  111. package/lib/module/theta-repository/options/option-shooting-method.js.map +1 -0
  112. package/lib/module/theta-repository/options/option-shutter-speed.js +295 -0
  113. package/lib/module/theta-repository/options/option-shutter-speed.js.map +1 -0
  114. package/lib/module/theta-repository/options/option-time-shift.js +36 -0
  115. package/lib/module/theta-repository/options/option-time-shift.js.map +1 -0
  116. package/lib/module/theta-repository/options/option-wlan-frequency.js +15 -0
  117. package/lib/module/theta-repository/options/option-wlan-frequency.js.map +1 -0
  118. package/lib/module/theta-repository/options/options.js +50 -24
  119. package/lib/module/theta-repository/options/options.js.map +1 -1
  120. package/lib/module/theta-repository/theta-config.js +2 -0
  121. package/lib/module/theta-repository/theta-config.js.map +1 -0
  122. package/lib/module/theta-repository/theta-files.js +32 -0
  123. package/lib/module/theta-repository/theta-files.js.map +1 -1
  124. package/lib/module/theta-repository/theta-info.js +22 -0
  125. package/lib/module/theta-repository/theta-info.js.map +1 -1
  126. package/lib/module/theta-repository/theta-repository.js +54 -9
  127. package/lib/module/theta-repository/theta-repository.js.map +1 -1
  128. package/lib/module/theta-repository/theta-timeout.js +2 -0
  129. package/lib/module/theta-repository/theta-timeout.js.map +1 -0
  130. package/lib/typescript/capture/capture.d.ts +1 -1
  131. package/lib/typescript/capture/capture.d.ts.map +1 -1
  132. package/lib/typescript/capture/index.d.ts +1 -0
  133. package/lib/typescript/capture/index.d.ts.map +1 -1
  134. package/lib/typescript/capture/notify.d.ts +13 -0
  135. package/lib/typescript/capture/notify.d.ts.map +1 -0
  136. package/lib/typescript/capture/time-shift-capture.d.ts +64 -0
  137. package/lib/typescript/capture/time-shift-capture.d.ts.map +1 -0
  138. package/lib/typescript/theta-repository/access-point.d.ts +4 -1
  139. package/lib/typescript/theta-repository/access-point.d.ts.map +1 -1
  140. package/lib/typescript/theta-repository/digest-auth.d.ts +17 -0
  141. package/lib/typescript/theta-repository/digest-auth.d.ts.map +1 -0
  142. package/lib/typescript/theta-repository/index.d.ts +4 -1
  143. package/lib/typescript/theta-repository/index.d.ts.map +1 -1
  144. package/lib/typescript/theta-repository/options/index.d.ts +18 -0
  145. package/lib/typescript/theta-repository/options/index.d.ts.map +1 -1
  146. package/lib/typescript/theta-repository/options/option-ai-auto-thumbnail.d.ts +10 -0
  147. package/lib/typescript/theta-repository/options/option-ai-auto-thumbnail.d.ts.map +1 -0
  148. package/lib/typescript/theta-repository/options/option-bitrate.d.ts +57 -0
  149. package/lib/typescript/theta-repository/options/option-bitrate.d.ts.map +1 -0
  150. package/lib/typescript/theta-repository/options/option-burst-mode.d.ts +16 -0
  151. package/lib/typescript/theta-repository/options/option-burst-mode.d.ts.map +1 -0
  152. package/lib/typescript/theta-repository/options/option-burst-option.d.ts +153 -0
  153. package/lib/typescript/theta-repository/options/option-burst-option.d.ts.map +1 -0
  154. package/lib/typescript/theta-repository/options/option-camera-control-source.d.ts +22 -0
  155. package/lib/typescript/theta-repository/options/option-camera-control-source.d.ts.map +1 -0
  156. package/lib/typescript/theta-repository/options/option-camera-mode.d.ts +19 -0
  157. package/lib/typescript/theta-repository/options/option-camera-mode.d.ts.map +1 -0
  158. package/lib/typescript/theta-repository/options/option-capture-mode.d.ts +23 -0
  159. package/lib/typescript/theta-repository/options/option-capture-mode.d.ts.map +1 -0
  160. package/lib/typescript/theta-repository/options/option-continuous-number.d.ts +64 -0
  161. package/lib/typescript/theta-repository/options/option-continuous-number.d.ts.map +1 -0
  162. package/lib/typescript/theta-repository/options/option-filter.d.ts +25 -0
  163. package/lib/typescript/theta-repository/options/option-filter.d.ts.map +1 -0
  164. package/lib/typescript/theta-repository/options/option-network-type.d.ts +19 -0
  165. package/lib/typescript/theta-repository/options/option-network-type.d.ts.map +1 -0
  166. package/lib/typescript/theta-repository/options/option-power-saving.d.ts +16 -0
  167. package/lib/typescript/theta-repository/options/option-power-saving.d.ts.map +1 -0
  168. package/lib/typescript/theta-repository/options/option-preset.d.ts +18 -0
  169. package/lib/typescript/theta-repository/options/option-preset.d.ts.map +1 -0
  170. package/lib/typescript/theta-repository/options/option-preview-format.d.ts +25 -0
  171. package/lib/typescript/theta-repository/options/option-preview-format.d.ts.map +1 -0
  172. package/lib/typescript/theta-repository/options/option-proxy.d.ts +23 -0
  173. package/lib/typescript/theta-repository/options/option-proxy.d.ts.map +1 -0
  174. package/lib/typescript/theta-repository/options/option-shooting-method.d.ts +33 -0
  175. package/lib/typescript/theta-repository/options/option-shooting-method.d.ts.map +1 -0
  176. package/lib/typescript/theta-repository/options/option-shutter-speed.d.ts +295 -0
  177. package/lib/typescript/theta-repository/options/option-shutter-speed.d.ts.map +1 -0
  178. package/lib/typescript/theta-repository/options/option-time-shift.d.ts +54 -0
  179. package/lib/typescript/theta-repository/options/option-time-shift.d.ts.map +1 -0
  180. package/lib/typescript/theta-repository/options/option-white-balance-auto-strength.d.ts +1 -1
  181. package/lib/typescript/theta-repository/options/option-white-balance-auto-strength.d.ts.map +1 -1
  182. package/lib/typescript/theta-repository/options/option-wlan-frequency.d.ts +15 -0
  183. package/lib/typescript/theta-repository/options/option-wlan-frequency.d.ts.map +1 -0
  184. package/lib/typescript/theta-repository/options/options.d.ts +187 -41
  185. package/lib/typescript/theta-repository/options/options.d.ts.map +1 -1
  186. package/lib/typescript/theta-repository/theta-config.d.ts +20 -0
  187. package/lib/typescript/theta-repository/theta-config.d.ts.map +1 -0
  188. package/lib/typescript/theta-repository/theta-files.d.ts +66 -3
  189. package/lib/typescript/theta-repository/theta-files.d.ts.map +1 -1
  190. package/lib/typescript/theta-repository/theta-info.d.ts +21 -0
  191. package/lib/typescript/theta-repository/theta-info.d.ts.map +1 -1
  192. package/lib/typescript/theta-repository/theta-repository.d.ts +36 -8
  193. package/lib/typescript/theta-repository/theta-repository.d.ts.map +1 -1
  194. package/lib/typescript/theta-repository/theta-state.d.ts +5 -5
  195. package/lib/typescript/theta-repository/theta-state.d.ts.map +1 -1
  196. package/lib/typescript/theta-repository/theta-timeout.d.ts +22 -0
  197. package/lib/typescript/theta-repository/theta-timeout.d.ts.map +1 -0
  198. package/package.json +1 -1
  199. package/src/capture/capture.ts +1 -1
  200. package/src/capture/index.ts +1 -0
  201. package/src/capture/notify.ts +27 -0
  202. package/src/capture/time-shift-capture.ts +145 -0
  203. package/src/theta-repository/access-point.ts +5 -1
  204. package/src/theta-repository/digest-auth.ts +16 -0
  205. package/src/theta-repository/index.ts +4 -1
  206. package/src/theta-repository/options/index.ts +18 -0
  207. package/src/theta-repository/options/option-ai-auto-thumbnail.ts +11 -0
  208. package/src/theta-repository/options/option-bitrate.ts +59 -0
  209. package/src/theta-repository/options/option-burst-mode.ts +16 -0
  210. package/src/theta-repository/options/option-burst-option.ts +175 -0
  211. package/src/theta-repository/options/option-camera-control-source.ts +24 -0
  212. package/src/theta-repository/options/option-camera-mode.ts +20 -0
  213. package/src/theta-repository/options/option-capture-mode.ts +24 -0
  214. package/src/theta-repository/options/option-continuous-number.ts +65 -0
  215. package/src/theta-repository/options/option-filter.ts +25 -0
  216. package/src/theta-repository/options/option-network-type.ts +20 -0
  217. package/src/theta-repository/options/option-power-saving.ts +18 -0
  218. package/src/theta-repository/options/option-preset.ts +19 -0
  219. package/src/theta-repository/options/option-preview-format.ts +26 -0
  220. package/src/theta-repository/options/option-proxy.ts +22 -0
  221. package/src/theta-repository/options/option-shooting-method.ts +35 -0
  222. package/src/theta-repository/options/option-shutter-speed.ts +360 -0
  223. package/src/theta-repository/options/option-time-shift.ts +59 -0
  224. package/src/theta-repository/options/option-white-balance-auto-strength.ts +1 -1
  225. package/src/theta-repository/options/option-wlan-frequency.ts +16 -0
  226. package/src/theta-repository/options/options.ts +188 -46
  227. package/src/theta-repository/theta-config.ts +20 -0
  228. package/src/theta-repository/theta-files.ts +73 -3
  229. package/src/theta-repository/theta-info.ts +23 -0
  230. package/src/theta-repository/theta-repository.ts +87 -18
  231. package/src/theta-repository/theta-state.ts +5 -5
  232. package/src/theta-repository/theta-timeout.ts +21 -0
  233. package/theta-client-react-native.podspec +1 -1
@@ -3,14 +3,11 @@ package com.ricoh360.thetaclientreactnative
3
3
  import com.facebook.react.bridge.*
4
4
  import com.facebook.react.modules.core.DeviceEventManagerModule
5
5
  import com.ricoh360.thetaclient.ThetaRepository
6
- import com.ricoh360.thetaclient.capture.PhotoCapture
7
- import com.ricoh360.thetaclient.capture.VideoCapture
8
- import com.ricoh360.thetaclient.capture.VideoCapturing
6
+ import com.ricoh360.thetaclient.capture.*
9
7
  import io.ktor.utils.io.core.*
10
8
  import kotlinx.coroutines.*
11
- import java.io.ByteArrayOutputStream
12
- import kotlin.coroutines.*
13
9
  import java.util.*
10
+ import kotlin.coroutines.*
14
11
  import kotlin.text.String
15
12
 
16
13
  class ThetaClientReactNativeModule(
@@ -26,12 +23,17 @@ class ThetaClientReactNativeModule(
26
23
  var previewing: Boolean = false
27
24
  var photoCaptureBuilder: PhotoCapture.Builder? = null
28
25
  var photoCapture: PhotoCapture? = null
26
+ var timeShiftCaptureBuilder: TimeShiftCapture.Builder? = null
27
+ var timeShiftCapture: TimeShiftCapture? = null
28
+ var timeShiftCapturing: TimeShiftCapturing? = null
29
29
  var videoCaptureBuilder: VideoCapture.Builder? = null
30
30
  var videoCapture: VideoCapture? = null
31
31
  var videoCapturing: VideoCapturing? = null
32
- lateinit var theta: ThetaRepository
32
+ var theta: ThetaRepository? = null
33
33
  var listenerCount: Int = 0
34
34
 
35
+ val messageNotInit: String = "Not initialized."
36
+
35
37
  /**
36
38
  * add event listener for [eventName]
37
39
  */
@@ -52,6 +54,12 @@ class ThetaClientReactNativeModule(
52
54
  listenerCount -= count
53
55
  }
54
56
 
57
+ fun sendNotifyEvent(param: WritableMap) {
58
+ reactApplicationContext
59
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
60
+ .emit(EVENT_NOTIFY, param)
61
+ }
62
+
55
63
  /**
56
64
  * retreive constant
57
65
  */
@@ -64,10 +72,25 @@ class ThetaClientReactNativeModule(
64
72
  * @param promise promise to set initialize result
65
73
  */
66
74
  @ReactMethod
67
- fun initialize(endpoint: String, promise: Promise) {
75
+ fun initialize(endpoint: String, config: ReadableMap?, timeout: ReadableMap?, promise: Promise) {
68
76
  launch {
69
77
  try {
70
- theta = ThetaRepository.newInstance(endpoint)
78
+ theta = null
79
+ previewing = false
80
+ photoCaptureBuilder = null
81
+ photoCapture = null
82
+ timeShiftCaptureBuilder = null
83
+ timeShiftCapture = null
84
+ timeShiftCapturing = null
85
+ videoCaptureBuilder = null
86
+ videoCapture = null
87
+ videoCapturing = null
88
+
89
+ theta = ThetaRepository.newInstance(
90
+ endpoint,
91
+ config?.let { configToTheta(it) },
92
+ timeout?.let { timeoutToTheta(it) }
93
+ )
71
94
  promise.resolve(true)
72
95
  } catch (t: Throwable) {
73
96
  promise.reject(t)
@@ -75,12 +98,40 @@ class ThetaClientReactNativeModule(
75
98
  }
76
99
  }
77
100
 
101
+ /**
102
+ * Returns whether it is initialized or not.
103
+ * @param promise promise to set result
104
+ */
105
+ @ReactMethod
106
+ fun isInitialized(promise: Promise) {
107
+ promise.resolve(theta != null)
108
+ }
109
+
110
+ /**
111
+ * getThetaModel - Returns the connected THETA model
112
+ * @param promise promise to set result
113
+ */
114
+ @ReactMethod
115
+ fun getThetaModel(promise: Promise) {
116
+ val theta = theta
117
+ if (theta == null) {
118
+ promise.reject(Exception(messageNotInit))
119
+ return
120
+ }
121
+ promise.resolve(theta.cameraModel?.name)
122
+ }
123
+
78
124
  /**
79
125
  * getThetaInfo - retrieve ThetaInfo from THETA via repository
80
126
  * @param promise promise to set result
81
127
  */
82
128
  @ReactMethod
83
129
  fun getThetaInfo(promise: Promise) {
130
+ val theta = theta
131
+ if (theta == null) {
132
+ promise.reject(Exception(messageNotInit))
133
+ return
134
+ }
84
135
  launch {
85
136
  try {
86
137
  val info = theta.getThetaInfo()
@@ -105,6 +156,9 @@ class ThetaClientReactNativeModule(
105
156
  ep.putInt("httpUpdatesPort", info.endpoints.httpUpdatesPort)
106
157
  result.putMap("endpoints", ep)
107
158
  result.putArray("apiLevel", Arguments.fromList(info.apiLevel))
159
+ theta.cameraModel?.let {
160
+ result.putString("thetaModel", it.name)
161
+ }
108
162
  promise.resolve(result)
109
163
  } catch (t: Throwable) {
110
164
  promise.reject(t)
@@ -118,6 +172,11 @@ class ThetaClientReactNativeModule(
118
172
  */
119
173
  @ReactMethod
120
174
  fun getThetaState(promise: Promise) {
175
+ val theta = theta
176
+ if (theta == null) {
177
+ promise.reject(Exception(messageNotInit))
178
+ return
179
+ }
121
180
  launch {
122
181
  try {
123
182
  val state = theta.getThetaState()
@@ -170,31 +229,32 @@ class ThetaClientReactNativeModule(
170
229
  * @param fileType file type to retrieve
171
230
  * @param startPosition start position to retrieve
172
231
  * @param entryCount count to retrieve
232
+ * @param storage Desired storage
173
233
  * @param promise promise to set result
174
234
  */
175
235
  @ReactMethod
176
- fun listFiles(fileType: String, startPosition: Int, entryCount: Int, promise: Promise) {
236
+ fun listFiles(fileType: String, startPosition: Int, entryCount: Int, storage: String?, promise: Promise) {
237
+ val theta = theta
238
+ if (theta == null) {
239
+ promise.reject(Exception(messageNotInit))
240
+ return
241
+ }
177
242
  launch {
178
243
  try {
179
244
  val (fileList, totalEntries) = theta.listFiles(
180
245
  ThetaRepository.FileTypeEnum.valueOf(fileType),
181
246
  startPosition,
182
- entryCount
247
+ entryCount,
248
+ storage?.let { ThetaRepository.StorageEnum.valueOf(it) },
183
249
  )
184
- val resultlist = Arguments.createArray()
250
+ val resultList = Arguments.createArray()
185
251
  fileList.forEach {
186
- val result = Arguments.createMap()
187
- result.putString("name", it.name)
188
- result.putDouble("size", it.size.toDouble())
189
- result.putString("dateTime", it.dateTime)
190
- result.putString("thumbnailUrl", it.thumbnailUrl)
191
- result.putString("fileUrl", it.fileUrl)
192
- resultlist.pushMap(result)
252
+ resultList.pushMap(fileInfoFromTheta(it))
193
253
  }
194
- val resultmap = Arguments.createMap()
195
- resultmap.putArray("fileList", resultlist)
196
- resultmap.putInt("totalEntries", totalEntries)
197
- promise.resolve(resultmap)
254
+ val resultMap = Arguments.createMap()
255
+ resultMap.putArray("fileList", resultList)
256
+ resultMap.putInt("totalEntries", totalEntries)
257
+ promise.resolve(resultMap)
198
258
  } catch (t: Throwable) {
199
259
  promise.reject(t)
200
260
  }
@@ -208,6 +268,11 @@ class ThetaClientReactNativeModule(
208
268
  */
209
269
  @ReactMethod
210
270
  fun deleteFiles(fileUrls: ReadableArray, promise: Promise) {
271
+ val theta = theta
272
+ if (theta == null) {
273
+ promise.reject(Exception(messageNotInit))
274
+ return
275
+ }
211
276
  val fileList = mutableListOf<String>()
212
277
  for (index in 0..(fileUrls.size() - 1)) {
213
278
  fileList.add(fileUrls.getString(index))
@@ -228,6 +293,11 @@ class ThetaClientReactNativeModule(
228
293
  */
229
294
  @ReactMethod
230
295
  fun deleteAllFiles(promise: Promise) {
296
+ val theta = theta
297
+ if (theta == null) {
298
+ promise.reject(Exception(messageNotInit))
299
+ return
300
+ }
231
301
  launch {
232
302
  try {
233
303
  theta.deleteAllFiles()
@@ -244,6 +314,11 @@ class ThetaClientReactNativeModule(
244
314
  */
245
315
  @ReactMethod
246
316
  fun deleteAllImageFiles(promise: Promise) {
317
+ val theta = theta
318
+ if (theta == null) {
319
+ promise.reject(Exception(messageNotInit))
320
+ return
321
+ }
247
322
  launch {
248
323
  try {
249
324
  theta.deleteAllImageFiles()
@@ -260,6 +335,11 @@ class ThetaClientReactNativeModule(
260
335
  */
261
336
  @ReactMethod
262
337
  fun deleteAllVideoFiles(promise: Promise) {
338
+ val theta = theta
339
+ if (theta == null) {
340
+ promise.reject(Exception(messageNotInit))
341
+ return
342
+ }
263
343
  launch {
264
344
  try {
265
345
  theta.deleteAllVideoFiles()
@@ -272,10 +352,21 @@ class ThetaClientReactNativeModule(
272
352
 
273
353
  /** option converter */
274
354
  private val converters = mapOf(
355
+ "aiAutoThumbnail" to AiAutoThumbnailConverter(),
275
356
  "aperture" to ApertureConverter(),
357
+ "bitrate" to BitrateConverter(),
276
358
  "bluetoothPower" to BluetoothPowerConverter(),
359
+ "burstMode" to BurstModeConverter(),
360
+ "burstOption" to BurstOptionConverter(),
361
+ "cameraControlSource" to CameraControlSourceConverter(),
362
+ "cameraMode" to CameraModeConverter(),
363
+ "captureInterval" to CaptureIntervalConverter(),
277
364
  "captureMode" to CaptureModeConverter(),
365
+ "captureNumber" to CaptureNumberConverter(),
278
366
  "colorTemperature" to ColorTemperatureConverter(),
367
+ "compositeShootingOutputInterval" to CompositeShootingOutputIntervalConverter(),
368
+ "compositeShootingTime" to CompositeShootingTimeConverter(),
369
+ "continuousNumber" to ContinuousNumberConverter(),
279
370
  "dateTimeZone" to DateTimeZoneConverter(),
280
371
  "exposureCompensation" to ExposureCompensationConverter(),
281
372
  "exposureDelay" to ExposureDelayConverter(),
@@ -288,24 +379,46 @@ class ThetaClientReactNativeModule(
288
379
  "isoAutoHighLimit" to IsoAutoHighLimitConverter(),
289
380
  "language" to LanguageConverter(),
290
381
  "maxRecordableTime" to MaxRecordableTimeConverter(),
382
+ "networkType" to NetworkTypeConverter(),
291
383
  "offDelay" to OffDelayConverter(),
292
- "sleepDelay" to SleepDelayConverter(),
384
+ "password" to PasswordConverter(),
385
+ "powerSaving" to PowerSavingConverter(),
386
+ "preset" to PresetConverter(),
387
+ "previewFormat" to PreviewFormatConverter(),
388
+ "proxy" to ProxyConverter(),
293
389
  "remainingPictures" to RemainingPicturesConverter(),
294
390
  "remainingVideoSeconds" to RemainingVideoSecondsConverter(),
295
391
  "remainingSpace" to RemainingSpaceConverter(),
296
- "totalSpace" to TotalSpaceConverter(),
392
+ "shootingMethod" to ShootingMethodConverter(),
393
+ "shutterSpeed" to ShutterSpeedConverter(),
297
394
  "shutterVolume" to ShutterVolumeConverter(),
395
+ "sleepDelay" to SleepDelayConverter(),
396
+ "timeShift" to TimeShiftConverter(),
397
+ "totalSpace" to TotalSpaceConverter(),
398
+ "username" to UsernameConverter(),
298
399
  "whiteBalance" to WhiteBalanceConverter(),
299
400
  "whiteBalanceAutoStrength" to WhiteBalanceAutoStrengthConverter(),
401
+ "wlanFrequency" to WlanFrequencyConverter(),
300
402
  "_gpsTagRecording" to GpsTagRecordingConverter(),
301
403
  )
302
404
 
303
405
  /** OptionNameEnum to option */
304
406
  private val optionEnumToOption = mapOf(
407
+ "AiAutoThumbnail" to "aiAutoThumbnail",
305
408
  "Aperture" to "aperture",
409
+ "Bitrate" to "bitrate",
306
410
  "BluetoothPower" to "bluetoothPower",
411
+ "BurstMode" to "burstMode",
412
+ "BurstOption" to "burstOption",
413
+ "CameraControlSource" to "cameraControlSource",
414
+ "CameraMode" to "cameraMode",
415
+ "CaptureInterval" to "captureInterval",
307
416
  "CaptureMode" to "captureMode",
417
+ "CaptureNumber" to "captureNumber",
308
418
  "ColorTemperature" to "colorTemperature",
419
+ "CompositeShootingOutputInterval" to "compositeShootingOutputInterval",
420
+ "CompositeShootingTime" to "compositeShootingTime",
421
+ "ContinuousNumber" to "continuousNumber",
309
422
  "DateTimeZone" to "dateTimeZone",
310
423
  "ExposureCompensation" to "exposureCompensation",
311
424
  "ExposureDelay" to "exposureDelay",
@@ -318,15 +431,26 @@ class ThetaClientReactNativeModule(
318
431
  "IsoAutoHighLimit" to "isoAutoHighLimit",
319
432
  "Language" to "language",
320
433
  "MaxRecordableTime" to "maxRecordableTime",
434
+ "NetworkType" to "networkType",
321
435
  "OffDelay" to "offDelay",
322
- "SleepDelay" to "sleepDelay",
436
+ "Password" to "password",
437
+ "PowerSaving" to "powerSaving",
438
+ "Preset" to "preset",
439
+ "PreviewFormat" to "previewFormat",
440
+ "Proxy" to "proxy",
323
441
  "RemainingPictures" to "remainingPictures",
324
442
  "RemainingVideoSeconds" to "remainingVideoSeconds",
325
443
  "RemainingSpace" to "remainingSpace",
326
- "TotalSpace" to "totalSpace",
444
+ "ShootingMethod" to "shootingMethod",
445
+ "ShutterSpeed" to "shutterSpeed",
327
446
  "ShutterVolume" to "shutterVolume",
447
+ "SleepDelay" to "sleepDelay",
448
+ "TimeShift" to "timeShift",
449
+ "TotalSpace" to "totalSpace",
450
+ "Username" to "username",
328
451
  "WhiteBalance" to "whiteBalance",
329
452
  "WhiteBalanceAutoStrength" to "whiteBalanceAutoStrength",
453
+ "WlanFrequency" to "wlanFrequency",
330
454
  )
331
455
 
332
456
  /**
@@ -336,6 +460,11 @@ class ThetaClientReactNativeModule(
336
460
  */
337
461
  @ReactMethod
338
462
  fun getOptions(optionNames: ReadableArray, promise: Promise) {
463
+ val theta = theta
464
+ if (theta == null) {
465
+ promise.reject(Exception(messageNotInit))
466
+ return
467
+ }
339
468
  launch {
340
469
  try {
341
470
  val optionNameList = mutableListOf<ThetaRepository.OptionNameEnum>()
@@ -365,6 +494,11 @@ class ThetaClientReactNativeModule(
365
494
  */
366
495
  @ReactMethod
367
496
  fun setOptions(options: ReadableMap, promise: Promise) {
497
+ val theta = theta
498
+ if (theta == null) {
499
+ promise.reject(Exception(messageNotInit))
500
+ return
501
+ }
368
502
  launch {
369
503
  try {
370
504
  val thetaOptions = ThetaRepository.Options()
@@ -388,6 +522,11 @@ class ThetaClientReactNativeModule(
388
522
  */
389
523
  @ReactMethod
390
524
  fun getLivePreview(promise: Promise) {
525
+ val theta = theta
526
+ if (theta == null) {
527
+ promise.reject(Exception(messageNotInit))
528
+ return
529
+ }
391
530
  fun ByteArray.toBase64(): String = String(Base64.getEncoder().encode(this))
392
531
  suspend fun callFrameHandler(packet: Pair<ByteArray, Int>): Boolean {
393
532
  if (listenerCount == 0) {
@@ -420,6 +559,9 @@ class ThetaClientReactNativeModule(
420
559
  */
421
560
  @ReactMethod
422
561
  fun stopLivePreview() {
562
+ if (theta == null) {
563
+ throw Exception(messageNotInit)
564
+ }
423
565
  previewing = false
424
566
  }
425
567
 
@@ -428,6 +570,7 @@ class ThetaClientReactNativeModule(
428
570
  */
429
571
  @ReactMethod
430
572
  fun getPhotoCaptureBuilder() {
573
+ val theta = theta ?: throw Exception(messageNotInit)
431
574
  photoCaptureBuilder = theta.getPhotoCaptureBuilder()
432
575
  }
433
576
 
@@ -439,6 +582,9 @@ class ThetaClientReactNativeModule(
439
582
  */
440
583
  @ReactMethod
441
584
  fun buildPhotoCapture(options: ReadableMap, promise: Promise) {
585
+ if (theta == null) {
586
+ throw Exception(messageNotInit)
587
+ }
442
588
  if (photoCaptureBuilder == null) {
443
589
  promise.reject(Exception("no photoCaptureBuilder"))
444
590
  return
@@ -467,6 +613,10 @@ class ThetaClientReactNativeModule(
467
613
  */
468
614
  @ReactMethod
469
615
  fun takePicture(promise: Promise) {
616
+ if (theta == null) {
617
+ promise.reject(Exception(messageNotInit))
618
+ return
619
+ }
470
620
  if (photoCapture == null) {
471
621
  promise.reject(Exception("no photoCapture"))
472
622
  return
@@ -487,11 +637,107 @@ class ThetaClientReactNativeModule(
487
637
  }
488
638
  }
489
639
 
640
+ /**
641
+ * getTimeShiftCaptureBuilder - get time-shift builder from repository
642
+ */
643
+ @ReactMethod
644
+ fun getTimeShiftCaptureBuilder() {
645
+ val theta = theta ?: throw Exception(messageNotInit)
646
+ timeShiftCaptureBuilder = theta.getTimeShiftCaptureBuilder()
647
+ }
648
+
649
+ /**
650
+ * buildTimeShiftCapture - build time-shift
651
+ * @param options option to execute time-shift
652
+ * @param interval interval of checking time-shift status
653
+ * @param promise Promise for buildTimeShiftCapture
654
+ */
655
+ @ReactMethod
656
+ fun buildTimeShiftCapture(options: ReadableMap, interval: Int, promise: Promise) {
657
+ if (theta == null) {
658
+ promise.reject(Exception(messageNotInit))
659
+ return
660
+ }
661
+
662
+ timeShiftCaptureBuilder?.let { builder ->
663
+ launch {
664
+ try {
665
+ val iterator = options.keySetIterator()
666
+ while (iterator.hasNextKey()) {
667
+ val key = iterator.nextKey()
668
+ val cvt = converters[key]
669
+ cvt?.setTimeShiftOption(options, builder)
670
+ }
671
+
672
+ if (interval >= 0) {
673
+ builder.setCheckStatusCommandInterval(interval.toLong())
674
+ }
675
+
676
+ timeShiftCapture = builder.build()
677
+ promise.resolve(true)
678
+ timeShiftCaptureBuilder = null
679
+ } catch (t: Throwable) {
680
+ promise.reject(t)
681
+ timeShiftCaptureBuilder = null
682
+ }
683
+ }
684
+ } ?: run {
685
+ promise.reject(Exception("no timeShiftCaptureBuilder"))
686
+ }
687
+ }
688
+
689
+ /**
690
+ * startTimeShiftCapture - start time-shift
691
+ * @param promise promise for startTimeShiftCapture
692
+ */
693
+ @ReactMethod
694
+ fun startTimeShiftCapture(promise: Promise) {
695
+ if (theta == null) {
696
+ promise.reject(Exception(messageNotInit))
697
+ return
698
+ }
699
+ timeShiftCapture?.let { capture ->
700
+ class StartCaptureCallback : TimeShiftCapture.StartCaptureCallback {
701
+ override fun onSuccess(fileUrl: String?) {
702
+ promise.resolve(fileUrl)
703
+ timeShiftCapture = null
704
+ }
705
+
706
+ override fun onProgress(completion: Float) {
707
+ sendNotifyEvent(
708
+ toNotify("TIME-SHIFT-PROGRESS", toCaptureProgressNotifyParam(value = completion))
709
+ )
710
+ }
711
+
712
+ override fun onError(exception: ThetaRepository.ThetaRepositoryException) {
713
+ promise.reject(exception)
714
+ timeShiftCapture = null
715
+ }
716
+ }
717
+ timeShiftCapturing = capture.startCapture(StartCaptureCallback())
718
+ } ?: run {
719
+ promise.reject(Exception("no timeShiftCapture"))
720
+ }
721
+ }
722
+
723
+ /**
724
+ * cancelTimeShiftCapture - stop time-shift
725
+ * @param promise promise for stopTimeShiftCapture
726
+ */
727
+ @ReactMethod
728
+ fun cancelTimeShiftCapture(promise: Promise) {
729
+ if (theta == null) {
730
+ throw Exception(messageNotInit)
731
+ }
732
+ timeShiftCapturing?.cancelCapture()
733
+ }
734
+
490
735
  /**
491
736
  * getVideoCaptureBuilder - get video capture builder
492
737
  */
493
738
  @ReactMethod
494
739
  fun getVideoCaptureBuilder() {
740
+ val theta = theta ?: throw Exception(messageNotInit)
495
741
  videoCaptureBuilder = theta.getVideoCaptureBuilder()
496
742
  }
497
743
 
@@ -502,6 +748,10 @@ class ThetaClientReactNativeModule(
502
748
  */
503
749
  @ReactMethod
504
750
  fun buildVideoCapture(options: ReadableMap, promise: Promise) {
751
+ if (theta == null) {
752
+ promise.reject(Exception(messageNotInit))
753
+ return
754
+ }
505
755
  if (videoCaptureBuilder == null) {
506
756
  promise.reject(Exception("no videoCaptureBuilder"))
507
757
  return
@@ -530,6 +780,10 @@ class ThetaClientReactNativeModule(
530
780
  */
531
781
  @ReactMethod
532
782
  fun startCapture(promise: Promise) {
783
+ if (theta == null) {
784
+ promise.reject(Exception(messageNotInit))
785
+ return
786
+ }
533
787
  if (videoCapture == null) {
534
788
  promise.reject(Exception("no videoCapture"))
535
789
  return
@@ -555,6 +809,9 @@ class ThetaClientReactNativeModule(
555
809
  */
556
810
  @ReactMethod
557
811
  fun stopCapture() {
812
+ if (theta == null) {
813
+ throw Exception(messageNotInit)
814
+ }
558
815
  videoCapturing?.stopCapture()
559
816
  }
560
817
 
@@ -564,6 +821,11 @@ class ThetaClientReactNativeModule(
564
821
  */
565
822
  @ReactMethod
566
823
  fun getMetadata(fileUrl: String, promise: Promise) {
824
+ val theta = theta
825
+ if (theta == null) {
826
+ promise.reject(Exception(messageNotInit))
827
+ return
828
+ }
567
829
  launch {
568
830
  try {
569
831
  val metaData = theta.getMetadata(fileUrl)
@@ -598,6 +860,11 @@ class ThetaClientReactNativeModule(
598
860
  */
599
861
  @ReactMethod
600
862
  fun reset(promise: Promise) {
863
+ val theta = theta
864
+ if (theta == null) {
865
+ promise.reject(Exception(messageNotInit))
866
+ return
867
+ }
601
868
  launch {
602
869
  try {
603
870
  theta.reset()
@@ -614,6 +881,11 @@ class ThetaClientReactNativeModule(
614
881
  */
615
882
  @ReactMethod
616
883
  fun restoreSettings(promise: Promise) {
884
+ val theta = theta
885
+ if (theta == null) {
886
+ promise.reject(Exception(messageNotInit))
887
+ return
888
+ }
617
889
  launch {
618
890
  try {
619
891
  theta.restoreSettings()
@@ -630,6 +902,11 @@ class ThetaClientReactNativeModule(
630
902
  */
631
903
  @ReactMethod
632
904
  fun stopSelfTimer(promise: Promise) {
905
+ val theta = theta
906
+ if (theta == null) {
907
+ promise.reject(Exception(messageNotInit))
908
+ return
909
+ }
633
910
  launch {
634
911
  try {
635
912
  theta.stopSelfTimer()
@@ -654,6 +931,11 @@ class ThetaClientReactNativeModule(
654
931
  applyTopBottomCorrection: Boolean,
655
932
  promise: Promise,
656
933
  ) {
934
+ val theta = theta
935
+ if (theta == null) {
936
+ promise.reject(Exception(messageNotInit))
937
+ return
938
+ }
657
939
  launch {
658
940
  try {
659
941
  val convertedUrl = theta.convertVideoFormats(fileUrl, is4k, applyTopBottomCorrection)
@@ -671,6 +953,11 @@ class ThetaClientReactNativeModule(
671
953
  */
672
954
  @ReactMethod
673
955
  fun cancelVideoConvert(promise: Promise) {
956
+ val theta = theta
957
+ if (theta == null) {
958
+ promise.reject(Exception(messageNotInit))
959
+ return
960
+ }
674
961
  launch {
675
962
  try {
676
963
  theta.cancelVideoConvert()
@@ -687,6 +974,11 @@ class ThetaClientReactNativeModule(
687
974
  */
688
975
  @ReactMethod
689
976
  fun finishWlan(promise: Promise) {
977
+ val theta = theta
978
+ if (theta == null) {
979
+ promise.reject(Exception(messageNotInit))
980
+ return
981
+ }
690
982
  launch {
691
983
  try {
692
984
  theta.finishWlan()
@@ -703,6 +995,11 @@ class ThetaClientReactNativeModule(
703
995
  */
704
996
  @ReactMethod
705
997
  fun listAccessPoints(promise: Promise) {
998
+ val theta = theta
999
+ if (theta == null) {
1000
+ promise.reject(Exception(messageNotInit))
1001
+ return
1002
+ }
706
1003
  launch {
707
1004
  try {
708
1005
  val result = Arguments.createArray()
@@ -716,6 +1013,15 @@ class ThetaClientReactNativeModule(
716
1013
  apinfo.putString("ipAddress", it.ipAddress)
717
1014
  apinfo.putString("subnetMask", it.subnetMask)
718
1015
  apinfo.putString("defaultGateway", it.defaultGateway)
1016
+
1017
+ it.proxy?.let { proxy ->
1018
+ var options = ThetaRepository.Options(proxy = proxy)
1019
+ val optionsMap = Arguments.createMap()
1020
+ val cvt = converters["proxy"]
1021
+ cvt?.setFromTheta(options, optionsMap)
1022
+ apinfo.putMap("proxy", optionsMap.getMap("proxy"))
1023
+ }
1024
+
719
1025
  result.pushMap(apinfo)
720
1026
  }
721
1027
  promise.resolve(result)
@@ -732,6 +1038,7 @@ class ThetaClientReactNativeModule(
732
1038
  * @param authMode auth mode to connect
733
1039
  * @param password password to connect with auth
734
1040
  * @param connectionPriority connection priority
1041
+ * @param proxy Proxy information to be used for the access point.
735
1042
  * @param promise promise to set result
736
1043
  */
737
1044
  @ReactMethod
@@ -741,8 +1048,14 @@ class ThetaClientReactNativeModule(
741
1048
  authMode: String,
742
1049
  password: String,
743
1050
  connectionPriority: Int,
1051
+ proxy: ReadableMap?,
744
1052
  promise: Promise
745
1053
  ) {
1054
+ val theta = theta
1055
+ if (theta == null) {
1056
+ promise.reject(Exception(messageNotInit))
1057
+ return
1058
+ }
746
1059
  launch {
747
1060
  try {
748
1061
  theta.setAccessPointDynamically(
@@ -750,7 +1063,8 @@ class ThetaClientReactNativeModule(
750
1063
  ssidStealth,
751
1064
  ThetaRepository.AuthModeEnum.valueOf(authMode),
752
1065
  password,
753
- connectionPriority
1066
+ connectionPriority,
1067
+ convertMapToProxy(proxyMap = proxy)
754
1068
  )
755
1069
  promise.resolve(true)
756
1070
  } catch (t: Throwable) {
@@ -770,6 +1084,7 @@ class ThetaClientReactNativeModule(
770
1084
  * @param subnetMask subnet mask for ip address
771
1085
  * @param defaultGateway default gateway address
772
1086
  * @param promise promise to set result
1087
+ * @param proxy Proxy information to be used for the access point.
773
1088
  */
774
1089
  @ReactMethod
775
1090
  fun setAccessPointStatically(
@@ -781,8 +1096,14 @@ class ThetaClientReactNativeModule(
781
1096
  ipAddress: String,
782
1097
  subnetMask: String,
783
1098
  defaultGateway: String,
1099
+ proxy: ReadableMap?,
784
1100
  promise: Promise
785
1101
  ) {
1102
+ val theta = theta
1103
+ if (theta == null) {
1104
+ promise.reject(Exception(messageNotInit))
1105
+ return
1106
+ }
786
1107
  launch {
787
1108
  try {
788
1109
  theta.setAccessPointStatically(
@@ -794,6 +1115,7 @@ class ThetaClientReactNativeModule(
794
1115
  ipAddress,
795
1116
  subnetMask,
796
1117
  defaultGateway,
1118
+ convertMapToProxy(proxyMap = proxy)
797
1119
  )
798
1120
  promise.resolve(true)
799
1121
  } catch (t: Throwable) {
@@ -809,6 +1131,11 @@ class ThetaClientReactNativeModule(
809
1131
  */
810
1132
  @ReactMethod
811
1133
  fun deleteAccessPoint(ssid: String, promise: Promise) {
1134
+ val theta = theta
1135
+ if (theta == null) {
1136
+ promise.reject(Exception(messageNotInit))
1137
+ return
1138
+ }
812
1139
  launch {
813
1140
  try {
814
1141
  theta.deleteAccessPoint(ssid)
@@ -819,6 +1146,20 @@ class ThetaClientReactNativeModule(
819
1146
  }
820
1147
  }
821
1148
 
1149
+ /**
1150
+ * convert ReadableMap to ThetaRepository.Proxy
1151
+ */
1152
+ private fun convertMapToProxy(proxyMap: ReadableMap?): ThetaRepository.Proxy? {
1153
+ return proxyMap?.let {
1154
+ var options = ThetaRepository.Options()
1155
+ val optionsMap = Arguments.createMap()
1156
+ optionsMap.putMap("proxy", it)
1157
+ val cvt = converters["proxy"]
1158
+ cvt?.setToTheta(options, optionsMap)
1159
+ options.proxy
1160
+ } ?: null
1161
+ }
1162
+
822
1163
  /**
823
1164
  * setBluetoothDevice - register uuid of a BLE device
824
1165
  * @param uuid uuid to set
@@ -826,6 +1167,11 @@ class ThetaClientReactNativeModule(
826
1167
  */
827
1168
  @ReactMethod
828
1169
  fun setBluetoothDevice(uuid: String, promise: Promise) {
1170
+ val theta = theta
1171
+ if (theta == null) {
1172
+ promise.reject(Exception(messageNotInit))
1173
+ return
1174
+ }
829
1175
  launch {
830
1176
  try {
831
1177
  val deviceName = theta.setBluetoothDevice(uuid)
@@ -841,9 +1187,14 @@ class ThetaClientReactNativeModule(
841
1187
  * Just for Theta V and later
842
1188
  * @param captureMode The target shooting mode
843
1189
  * @param promise promise to set result
844
- */
1190
+ */
845
1191
  @ReactMethod
846
1192
  fun getMySetting(captureMode: String, promise: Promise) {
1193
+ val theta = theta
1194
+ if (theta == null) {
1195
+ promise.reject(Exception(messageNotInit))
1196
+ return
1197
+ }
847
1198
  launch {
848
1199
  try {
849
1200
  val options = theta.getMySetting(ThetaRepository.CaptureModeEnum.valueOf(captureMode))
@@ -865,8 +1216,13 @@ class ThetaClientReactNativeModule(
865
1216
  * @param optionNames The target shooting mode
866
1217
  * @param promise promise to set result
867
1218
  */
868
- @ReactMethod
869
- fun getMySettingFromOldModel(optionNames: ReadableArray, promise: Promise) {
1219
+ @ReactMethod
1220
+ fun getMySettingFromOldModel(optionNames: ReadableArray, promise: Promise) {
1221
+ val theta = theta
1222
+ if (theta == null) {
1223
+ promise.reject(Exception(messageNotInit))
1224
+ return
1225
+ }
870
1226
  launch {
871
1227
  try {
872
1228
  val optionNameList = mutableListOf<ThetaRepository.OptionNameEnum>()
@@ -896,6 +1252,11 @@ class ThetaClientReactNativeModule(
896
1252
  */
897
1253
  @ReactMethod
898
1254
  fun setMySetting(captureMode: String, options: ReadableMap, promise: Promise) {
1255
+ val theta = theta
1256
+ if (theta == null) {
1257
+ promise.reject(Exception(messageNotInit))
1258
+ return
1259
+ }
899
1260
  launch {
900
1261
  try {
901
1262
  val thetaOptions = ThetaRepository.Options()
@@ -920,6 +1281,11 @@ class ThetaClientReactNativeModule(
920
1281
  */
921
1282
  @ReactMethod
922
1283
  fun deleteMySetting(captureMode: String, promise: Promise) {
1284
+ val theta = theta
1285
+ if (theta == null) {
1286
+ promise.reject(Exception(messageNotInit))
1287
+ return
1288
+ }
923
1289
  launch {
924
1290
  try {
925
1291
  theta.deleteMySetting(ThetaRepository.CaptureModeEnum.valueOf(captureMode))
@@ -934,8 +1300,13 @@ class ThetaClientReactNativeModule(
934
1300
  * listPlugins - acquires a list of installed plugins
935
1301
  * @param promise promise to set result
936
1302
  */
937
- @ReactMethod
938
- fun listPlugins(promise: Promise) {
1303
+ @ReactMethod
1304
+ fun listPlugins(promise: Promise) {
1305
+ val theta = theta
1306
+ if (theta == null) {
1307
+ promise.reject(Exception(messageNotInit))
1308
+ return
1309
+ }
939
1310
  launch {
940
1311
  try {
941
1312
  val result = Arguments.createArray()
@@ -958,103 +1329,133 @@ class ThetaClientReactNativeModule(
958
1329
  promise.reject(t)
959
1330
  }
960
1331
  }
961
- }
1332
+ }
962
1333
 
963
- /**
964
- * setPlugin - sets the installed plugin for boot. Supported just by Theta V.
965
- * @param packageName Package name of the target plugin.
966
- * @param promise promise to set result
967
- */
968
- @ReactMethod
969
- fun setPlugin(packageName: String, promise: Promise) {
970
- launch {
1334
+ /**
1335
+ * setPlugin - sets the installed plugin for boot. Supported just by Theta V.
1336
+ * @param packageName Package name of the target plugin.
1337
+ * @param promise promise to set result
1338
+ */
1339
+ @ReactMethod
1340
+ fun setPlugin(packageName: String, promise: Promise) {
1341
+ val theta = theta
1342
+ if (theta == null) {
1343
+ promise.reject(Exception(messageNotInit))
1344
+ return
1345
+ }
1346
+ launch {
971
1347
  try {
972
1348
  theta.setPlugin(packageName)
973
1349
  promise.resolve(true)
974
1350
  } catch (t: Throwable) {
975
1351
  promise.reject(t)
976
1352
  }
977
- }
978
1353
  }
1354
+ }
979
1355
 
980
- /**
981
- * startPlugin - start the plugin specified by the [packageName].
982
- * @param packageName Package name of the target plugin.
983
- * @param promise promise to set result
984
- */
985
- @ReactMethod
986
- fun startPlugin(packageName: String, promise: Promise) {
987
- launch {
1356
+ /**
1357
+ * startPlugin - start the plugin specified by the [packageName].
1358
+ * @param packageName Package name of the target plugin.
1359
+ * @param promise promise to set result
1360
+ */
1361
+ @ReactMethod
1362
+ fun startPlugin(packageName: String, promise: Promise) {
1363
+ val theta = theta
1364
+ if (theta == null) {
1365
+ promise.reject(Exception(messageNotInit))
1366
+ return
1367
+ }
1368
+ launch {
988
1369
  try {
989
1370
  theta.startPlugin(packageName)
990
1371
  promise.resolve(true)
991
1372
  } catch (t: Throwable) {
992
1373
  promise.reject(t)
993
1374
  }
994
- }
995
1375
  }
1376
+ }
996
1377
 
997
1378
  /**
998
- * stopPlugin - Stop the running plugin.
999
- * @param promise promise to set result
1000
- */
1001
- @ReactMethod
1002
- fun stopPlugin(promise: Promise) {
1003
- launch {
1379
+ * stopPlugin - Stop the running plugin.
1380
+ * @param promise promise to set result
1381
+ */
1382
+ @ReactMethod
1383
+ fun stopPlugin(promise: Promise) {
1384
+ val theta = theta
1385
+ if (theta == null) {
1386
+ promise.reject(Exception(messageNotInit))
1387
+ return
1388
+ }
1389
+ launch {
1004
1390
  try {
1005
1391
  theta.stopPlugin()
1006
1392
  promise.resolve(true)
1007
1393
  } catch (t: Throwable) {
1008
1394
  promise.reject(t)
1009
1395
  }
1010
- }
1011
1396
  }
1397
+ }
1012
1398
 
1013
1399
  /**
1014
- * getPluginLicense - acquires the license for the installed plugin.
1015
- * @param packageName Package name of the target plugin.
1016
- * @param promise promise to set result
1017
- */
1018
- @ReactMethod
1019
- fun getPluginLicense(packageName: String, promise: Promise) {
1020
- launch {
1400
+ * getPluginLicense - acquires the license for the installed plugin.
1401
+ * @param packageName Package name of the target plugin.
1402
+ * @param promise promise to set result
1403
+ */
1404
+ @ReactMethod
1405
+ fun getPluginLicense(packageName: String, promise: Promise) {
1406
+ val theta = theta
1407
+ if (theta == null) {
1408
+ promise.reject(Exception(messageNotInit))
1409
+ return
1410
+ }
1411
+ launch {
1021
1412
  try {
1022
1413
  val result = theta.getPluginLicense(packageName)
1023
1414
  promise.resolve(result)
1024
1415
  } catch (t: Throwable) {
1025
1416
  promise.reject(t)
1026
1417
  }
1027
- }
1028
1418
  }
1419
+ }
1029
1420
 
1030
1421
  /**
1031
- * getPluginOrders - Return the plugin orders. Supported just by Theta X and Z1..
1032
- * @param promise promise to set result, list of package names of plugins.
1033
- */
1034
- @ReactMethod
1035
- fun getPluginOrders(promise: Promise) {
1036
- launch {
1422
+ * getPluginOrders - Return the plugin orders. Supported just by Theta X and Z1..
1423
+ * @param promise promise to set result, list of package names of plugins.
1424
+ */
1425
+ @ReactMethod
1426
+ fun getPluginOrders(promise: Promise) {
1427
+ val theta = theta
1428
+ if (theta == null) {
1429
+ promise.reject(Exception(messageNotInit))
1430
+ return
1431
+ }
1432
+ launch {
1037
1433
  try {
1038
1434
  val result = theta.getPluginOrders()
1039
1435
  promise.resolve(Arguments.fromList(result))
1040
1436
  } catch (t: Throwable) {
1041
1437
  promise.reject(t)
1042
1438
  }
1043
- }
1044
1439
  }
1440
+ }
1045
1441
 
1046
1442
  /**
1047
- * setPluginOrders - Return the plugin orders. Supported just by Theta X and Z1.
1048
- * @param plugins list of package names of plugins
1049
- * For Z1, list size must be three. No restrictions for the size for X.
1050
- * When not specifying, set an empty string.
1051
- * If an empty string is placed mid-way, it will be moved to the front.
1052
- * Specifying zero package name will result in an error.
1053
- * @param promise promise to set result
1054
- */
1055
- @ReactMethod
1056
- fun setPluginOrders(plugins: ReadableArray, promise: Promise) {
1057
- launch {
1443
+ * setPluginOrders - Return the plugin orders. Supported just by Theta X and Z1.
1444
+ * @param plugins list of package names of plugins
1445
+ * For Z1, list size must be three. No restrictions for the size for X.
1446
+ * When not specifying, set an empty string.
1447
+ * If an empty string is placed mid-way, it will be moved to the front.
1448
+ * Specifying zero package name will result in an error.
1449
+ * @param promise promise to set result
1450
+ */
1451
+ @ReactMethod
1452
+ fun setPluginOrders(plugins: ReadableArray, promise: Promise) {
1453
+ val theta = theta
1454
+ if (theta == null) {
1455
+ promise.reject(Exception(messageNotInit))
1456
+ return
1457
+ }
1458
+ launch {
1058
1459
  try {
1059
1460
  val pluginList = mutableListOf<String>()
1060
1461
  for (index in 0..(plugins.size() - 1)) {
@@ -1066,11 +1467,12 @@ class ThetaClientReactNativeModule(
1066
1467
  } catch (t: Throwable) {
1067
1468
  promise.reject(t)
1068
1469
  }
1069
- }
1070
1470
  }
1471
+ }
1071
1472
 
1072
1473
  companion object {
1073
1474
  const val NAME = "ThetaClientReactNative"
1074
1475
  const val EVENT_NAME = "ThetaFrameEvent"
1476
+ const val EVENT_NOTIFY = "ThetaNotify"
1075
1477
  }
1076
1478
  }