rhodes 7.4.1 → 7.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (305) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG +319 -0
  3. data/CREDITS +3 -1
  4. data/LICENSE +1 -1
  5. data/README.md +6 -16
  6. data/Rakefile +55 -43
  7. data/SECURITY.md +19 -0
  8. data/appveyor.yml +66 -8
  9. data/azure-pipelines.yml +67 -0
  10. data/bin/rhodes-setup +22 -8
  11. data/extensions/emdk3-manager/ext/platform/android/src/com/rho/emdk3/EMDK3Extension.java +14 -5
  12. data/extensions/instrumentation/ext/platform/android/src/com/rho/instrumentation/Instrumentation.java +29 -15
  13. data/extensions/rhoconnect-push/ext/rhoconnect-push/platform/android/src/com/rhomobile/rhoelements/ans/ANSManager.java +3 -3
  14. data/extensions/rhoelementsext/ext/rhoelementsext/platform/android/rhoelements_temp/src/com/rho/rhoelements/ElementsCore.java +12 -9
  15. data/extensions/rhoelementsext/ext/rhoelementsext/platform/android/rhoelements_temp/src/com/rho/rhoelements/graphics/BatteryIndicator.java +2 -2
  16. data/lib/commonAPI/barcode/ext/platform/android/AndroidManifest.xml +3 -1
  17. data/lib/commonAPI/barcode/ext/platform/android/src/com/google/barcodereader/BarcodeCaptureActivity.java +11 -13
  18. data/lib/commonAPI/barcode/ext/platform/android/src/com/google/barcodereader/BarcodeGraphicTracker.java +1 -1
  19. data/lib/commonAPI/barcode/ext/platform/android/src/com/google/barcodereader/ui/camera/CameraSource.java +3 -3
  20. data/lib/commonAPI/barcode/ext/platform/android/src/com/google/barcodereader/ui/camera/CameraSourcePreview.java +1 -1
  21. data/lib/commonAPI/barcode/ext/platform/qt/Barcode.pro +1 -1
  22. data/lib/commonAPI/barcode/ext/platform/qt/Barcode.pro.erb +2 -2
  23. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/QZXing.pri +9 -21
  24. data/lib/commonAPI/barcode/ext.yml +5 -8
  25. data/lib/commonAPI/bluetooth/ext/platform/qt/Bluetooth.pro +1 -1
  26. data/lib/commonAPI/bluetooth/ext/platform/qt/Bluetooth.pro.erb +1 -1
  27. data/lib/commonAPI/bluetooth/ext/platform/qt/src/bluetooth/bluetoothhelper.h +1 -1
  28. data/lib/commonAPI/coreapi/RhoSystemApi.rb +6 -0
  29. data/lib/commonAPI/coreapi/ext/Intent.xml +4 -0
  30. data/lib/commonAPI/coreapi/ext/platform/android/Rakefile +0 -12
  31. data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/intent/IntentSingleton.java +6 -0
  32. data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/notification/Notification.java +5 -2
  33. data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/notification/NotificationScheduler.java +4 -4
  34. data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/notification/NotificationSingleton.java +1 -1
  35. data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/webview/WebViewSingleton.java +40 -27
  36. data/lib/commonAPI/coreapi/ext/platform/iphone/cpp_based_impl/SystemImpl.mm +5 -6
  37. data/lib/commonAPI/coreapi/ext/platform/iphone/impl/Intent.h +1 -1
  38. data/lib/commonAPI/coreapi/ext/platform/iphone/impl/Intent.m +3 -1
  39. data/lib/commonAPI/coreapi/ext/platform/iphone/impl/NotificationSingleton.h +2 -1
  40. data/lib/commonAPI/coreapi/ext/platform/iphone/impl/NotificationSingleton.m +10 -0
  41. data/lib/commonAPI/coreapi/ext/platform/wm/src/IntentImpl.cpp +3 -0
  42. data/lib/commonAPI/coreapi/ext/push.xml +5 -2
  43. data/lib/commonAPI/coreapi/ext/shared/SystemImplBase.cpp +13 -0
  44. data/lib/commonAPI/coreapi/ext/shared/SystemImplBase.h +2 -0
  45. data/lib/commonAPI/coreapi/ext/system.xml +3 -0
  46. data/lib/commonAPI/mediacapture/ext/camera.xml +4 -9
  47. data/lib/commonAPI/mediacapture/ext/platform/android/ApplicationCameraActivity.erb +2 -2
  48. data/lib/commonAPI/mediacapture/ext/platform/android/ApplicationFileProvider.erb +1 -1
  49. data/lib/commonAPI/mediacapture/ext/platform/android/ext_java.files +2 -9
  50. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraExtension.java +0 -2
  51. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java +19 -24
  52. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraObject.java +322 -730
  53. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraRhoListener.java +247 -433
  54. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/{CameraSingletonObject.java → CameraSingleton.java} +68 -74
  55. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/mediacapture/RhoCameraFileProvider.java +6 -0
  56. data/lib/commonAPI/mediacapture/ext/platform/qt/MediaCapture.pro.erb +1 -1
  57. data/lib/commonAPI/mediacapture/ext/platform/qt/Mediacapture.pro +1 -1
  58. data/lib/commonAPI/printing_zebra/ext/platform/android/src/com/rhomobile/printing/zebra/impl/ZebraPrintingProviderImpl.java +2 -1
  59. data/lib/commonAPI/signature/ext/platform/iphone/impl/readme.txt +7 -0
  60. data/lib/commonAPI/signature/ext/platform/qt/Signature.pro +3 -10
  61. data/lib/commonAPI/signature/ext/platform/qt/Signature.pro.erb +2 -2
  62. data/lib/extensions/fcm-push/ext/android/ApplicationManifestAdds.erb +15 -17
  63. data/lib/extensions/fcm-push/ext/android/Rakefile +59 -34
  64. data/lib/extensions/fcm-push/ext/android/ext_java.files +0 -1
  65. data/lib/extensions/fcm-push/ext/android/src/com/rhomobile/rhodes/fcm/FCMFacade.java +13 -17
  66. data/lib/extensions/fcm-push/ext/android/src/com/rhomobile/rhodes/fcm/FCMIntentService.java +81 -80
  67. data/lib/extensions/fcm-push/ext/android/src/com/rhomobile/rhodes/fcm/FCMListener.java +0 -16
  68. data/lib/extensions/fcm-push/ext/iphone/Podfile +15 -2
  69. data/lib/extensions/fcm-push/ext/iphone/fcm-push.xcodeproj/project.pbxproj +6 -7
  70. data/lib/extensions/fcm-push/ext.yml +1 -1
  71. data/lib/extensions/gmaps/ext/platform/android/ApplicationManifestAdds.erb +1 -0
  72. data/lib/extensions/gmaps/ext/platform/android/src/com/rhomobile/rhodes/gmaps/GMapActivity.java +12 -4
  73. data/lib/extensions/gmaps/ext.yml +3 -1
  74. data/lib/extensions/nfc/ext/platform/android/src/com/rhomobile/nfc/Nfc.java +2 -1
  75. data/lib/extensions/serialport/ext/serialport.pro +1 -1
  76. data/platform/android/Rhodes/jni/include/rhodes/JNIRhodes.h +1 -0
  77. data/platform/android/Rhodes/jni/src/MethodResultJni.cpp +4 -0
  78. data/platform/android/Rhodes/jni/src/fileapi.cpp +4 -0
  79. data/platform/android/Rhodes/res/drawable/baseline_check_24.xml +5 -0
  80. data/platform/android/Rhodes/res/drawable/baseline_check_240.xml +5 -0
  81. data/platform/android/Rhodes/res/drawable/baseline_close_24.xml +5 -0
  82. data/platform/android/Rhodes/res/drawable/baseline_close_240.xml +5 -0
  83. data/platform/android/Rhodes/res/layout/overlay_layout.xml +39 -0
  84. data/platform/android/Rhodes/res/layout/perrmission_alert_dialog.xml +267 -0
  85. data/platform/android/Rhodes/src/com/rhomobile/rhodes/BaseActivity.java +183 -66
  86. data/platform/android/Rhodes/src/com/rhomobile/rhodes/LocalFileProvider.java +38 -6
  87. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoFileProvider.java +32 -0
  88. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +532 -92
  89. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +26 -4
  90. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +259 -163
  91. data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/StatusNotification.java +1 -1
  92. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/AbstractRhoExtension.java +14 -3
  93. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoExtManager.java +4 -0
  94. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoExtension.java +5 -4
  95. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/RhoExtManagerImpl.java +79 -38
  96. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocation.java +20 -15
  97. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +18 -9
  98. data/platform/android/Rhodes/src/com/rhomobile/rhodes/kioskservices/CallReceiver.java +22 -0
  99. data/platform/android/Rhodes/src/com/rhomobile/rhodes/kioskservices/IKioskMode.java +11 -0
  100. data/platform/android/Rhodes/src/com/rhomobile/rhodes/kioskservices/KioskManager.java +18 -0
  101. data/platform/android/Rhodes/src/com/rhomobile/rhodes/kioskservices/MyAccessibilityService.java +230 -0
  102. data/platform/android/Rhodes/src/com/rhomobile/rhodes/kioskservices/MyNotificationListenerService.java +16 -0
  103. data/platform/android/Rhodes/src/com/rhomobile/rhodes/kioskservices/MyOverlayService.java +197 -0
  104. data/platform/android/Rhodes/src/com/rhomobile/rhodes/kioskservices/PermissionManager.java +232 -0
  105. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +34 -8
  106. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality26.java +1 -1
  107. data/platform/android/Rhodes/src/com/rhomobile/rhodes/permissioncheck/CheckDrawable.java +53 -0
  108. data/platform/android/Rhodes/src/com/rhomobile/rhodes/permissioncheck/PermissionListGenerate.java +366 -0
  109. data/platform/android/Rhodes/src/com/rhomobile/rhodes/rhodes.iml +11 -0
  110. data/platform/android/Rhodes/src/com/rhomobile/rhodes/socket/SSLImpl.java +1 -0
  111. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/GoogleWebView.java +782 -41
  112. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoInputConnectionWrapper.java +146 -0
  113. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoInputListener.java +21 -0
  114. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebViewClient.java +92 -32
  115. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/TauWebViewOptions.java +118 -0
  116. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/WebSettingsProviderBase.java +18 -17
  117. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/WebSettingsProviderEclairMR1.java +4 -4
  118. data/platform/android/build/RhodesSRC_build.files +13 -0
  119. data/platform/android/build/{aab_builder.rb → aapt2_helper.rb} +94 -37
  120. data/platform/android/build/android-repack.rake +8 -1
  121. data/platform/android/build/android.rake +238 -238
  122. data/platform/android/build/android_tools.rb +10 -10
  123. data/platform/android/build/androidcommon.rb +31 -14
  124. data/platform/android/build/build_tools_finder.rb +46 -0
  125. data/platform/android/build/config.yml +8 -0
  126. data/platform/android/build/dex_builder.rb +88 -0
  127. data/platform/android/build/hostplatform.rb +9 -0
  128. data/platform/android/build/manifest_generator.rb +15 -10
  129. data/platform/android/build/maven_deps_extractor.rb +29 -22
  130. data/platform/android/build/ndkwrapper.rb +92 -51
  131. data/platform/android/proguard/proguard-base-rules.pro +5 -0
  132. data/platform/android/proguard/proguard.jar +0 -0
  133. data/platform/iphone/Classes/AppManager/AppManager.m +3 -1
  134. data/platform/iphone/Classes/Camera/PickImageDelegate.h +2 -0
  135. data/platform/iphone/Classes/Camera/PickImageDelegate.m +45 -23
  136. data/platform/iphone/Classes/CocoaServer/CCocoaServer.h +27 -0
  137. data/platform/iphone/Classes/CocoaServer/CCocoaServer.m +107 -0
  138. data/platform/iphone/Classes/CocoaServer/RhoHTTPConnection.h +16 -0
  139. data/platform/iphone/Classes/CocoaServer/RhoHTTPConnection.m +226 -0
  140. data/platform/iphone/Classes/RhoAppBaseLib-Bridging-Header.h +4 -0
  141. data/platform/iphone/Classes/RhoAppBaseStandaloneLib-Bridging-Header.h +4 -0
  142. data/platform/iphone/Classes/RhoCryptAESGCM.swift +105 -0
  143. data/platform/iphone/Classes/RhoUIWebView.h +1 -1
  144. data/platform/iphone/Classes/RhoUIWebView.m +1 -1
  145. data/platform/iphone/Classes/RhoWKWebView.h +1 -1
  146. data/platform/iphone/Classes/RhoWKWebView.mm +110 -15
  147. data/platform/iphone/Classes/RhoWebView.h +1 -1
  148. data/platform/iphone/Classes/RhoWebViewFabrique.m +13 -2
  149. data/platform/iphone/Classes/Rhodes.m +3 -0
  150. data/platform/iphone/Classes/SimpleMainView.m +5 -5
  151. data/platform/iphone/Classes/URLProtocol/CRhoURLProtocol.m +21 -10
  152. data/platform/iphone/Classes/rho/net/IPhoneNetRequest.mm +4 -0
  153. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDData.h +14 -0
  154. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDData.m +158 -0
  155. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDNumber.h +12 -0
  156. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDNumber.m +88 -0
  157. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDRange.h +56 -0
  158. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDRange.m +104 -0
  159. data/platform/iphone/CocoaHTTPServer/Core/HTTPAuthenticationRequest.h +45 -0
  160. data/platform/iphone/CocoaHTTPServer/Core/HTTPAuthenticationRequest.m +195 -0
  161. data/platform/iphone/CocoaHTTPServer/Core/HTTPConnection.h +120 -0
  162. data/platform/iphone/CocoaHTTPServer/Core/HTTPConnection.m +2708 -0
  163. data/platform/iphone/CocoaHTTPServer/Core/HTTPLogging.h +136 -0
  164. data/platform/iphone/CocoaHTTPServer/Core/HTTPMessage.h +48 -0
  165. data/platform/iphone/CocoaHTTPServer/Core/HTTPMessage.m +113 -0
  166. data/platform/iphone/CocoaHTTPServer/Core/HTTPResponse.h +149 -0
  167. data/platform/iphone/CocoaHTTPServer/Core/HTTPServer.h +205 -0
  168. data/platform/iphone/CocoaHTTPServer/Core/HTTPServer.m +772 -0
  169. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartFormDataParser.h +65 -0
  170. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartFormDataParser.m +529 -0
  171. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartMessageHeader.h +33 -0
  172. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartMessageHeader.m +86 -0
  173. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartMessageHeaderField.h +23 -0
  174. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartMessageHeaderField.m +211 -0
  175. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPAsyncFileResponse.h +75 -0
  176. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPAsyncFileResponse.m +405 -0
  177. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPDataResponse.h +13 -0
  178. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPDataResponse.m +79 -0
  179. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPDynamicFileResponse.h +52 -0
  180. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPDynamicFileResponse.m +292 -0
  181. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPErrorResponse.h +9 -0
  182. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPErrorResponse.m +38 -0
  183. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPFileResponse.h +25 -0
  184. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPFileResponse.m +237 -0
  185. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPRedirectResponse.h +12 -0
  186. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPRedirectResponse.m +73 -0
  187. data/platform/iphone/CocoaHTTPServer/Core/WebSocket.h +105 -0
  188. data/platform/iphone/CocoaHTTPServer/Core/WebSocket.m +791 -0
  189. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DAVConnection.h +7 -0
  190. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DAVConnection.m +160 -0
  191. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DAVResponse.h +11 -0
  192. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DAVResponse.m +372 -0
  193. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DELETEResponse.h +7 -0
  194. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DELETEResponse.m +49 -0
  195. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/PUTResponse.h +8 -0
  196. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/PUTResponse.m +69 -0
  197. data/platform/iphone/CocoaHTTPServer/LICENSE.txt +18 -0
  198. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaAsyncSocket/About.txt +4 -0
  199. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaAsyncSocket/GCDAsyncSocket.h +1226 -0
  200. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaAsyncSocket/GCDAsyncSocket.m +8528 -0
  201. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/About.txt +33 -0
  202. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDASLLogger.h +41 -0
  203. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDASLLogger.m +99 -0
  204. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
  205. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDAbstractDatabaseLogger.m +727 -0
  206. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDFileLogger.h +334 -0
  207. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDFileLogger.m +1353 -0
  208. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDLog.h +601 -0
  209. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDLog.m +1083 -0
  210. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDTTYLogger.h +167 -0
  211. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDTTYLogger.m +1479 -0
  212. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/ContextFilterLogFormatter.h +65 -0
  213. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/ContextFilterLogFormatter.m +191 -0
  214. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/DispatchQueueLogFormatter.h +116 -0
  215. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/DispatchQueueLogFormatter.m +251 -0
  216. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/README.txt +7 -0
  217. data/platform/iphone/Framework/RhoApplication/RhoApplication.xcodeproj/project.pbxproj +1 -1
  218. data/platform/iphone/Framework/Rhodes/Rhodes.xcodeproj/project.pbxproj +2 -2
  219. data/platform/iphone/RhoAppBaseLib/RhoAppBaseLib.xcodeproj/project.pbxproj +410 -1
  220. data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +1 -1
  221. data/platform/iphone/curl/curl.xcodeproj/project.pbxproj +4 -1
  222. data/platform/iphone/rbuild/iphone.rake +13 -8
  223. data/platform/iphone/rhoextlib/rhoextlib.xcodeproj/project.pbxproj +4 -1
  224. data/platform/iphone/rhorubylib/rhorubylib.xcodeproj/project.pbxproj +1 -1
  225. data/platform/iphone/rhosynclib/rhosynclib.xcodeproj/project.pbxproj +1 -1
  226. data/platform/osx/bin/RhoSimulator/RhoSimulator.app.zip +0 -0
  227. data/platform/sailfish/build/{harbour-SailfishRhodes.pro.erb → SailfishRhodes.pro.erb} +10 -17
  228. data/platform/sailfish/build/rhodes.pro.erb +7 -17
  229. data/platform/sailfish/build/rpm/SailfishRhodes.desktop.erb +12 -0
  230. data/platform/sailfish/build/rpm/SailfishRhodes.erb +2 -0
  231. data/platform/sailfish/build/rpm/SailfishRhodes.spec.erb +43 -0
  232. data/platform/sailfish/build/rubylib.pro.erb +29 -29
  233. data/platform/sailfish/build/sailfish.rake +188 -180
  234. data/platform/sailfish/keys/regular_cert.pem +14 -0
  235. data/platform/sailfish/keys/regular_key.pem +4 -0
  236. data/platform/shared/common/RhodesApp.cpp +59 -10
  237. data/platform/shared/common/iphone/RhoCryptImpl.mm +130 -54
  238. data/platform/shared/net/HttpServer.cpp +20 -0
  239. data/platform/shared/qt/RhoSimulator.pro +1 -1
  240. data/platform/shared/qt/rhodes/rhodes.pro +4 -11
  241. data/platform/shared/qt/sailfish/SailfishRhodes.desktop +3 -4
  242. data/platform/shared/qt/sailfish/SailfishRhodes.pro +9 -10
  243. data/platform/shared/qt/sailfish/icons/108x108/108x108.png +0 -0
  244. data/platform/shared/qt/sailfish/privileges/sailfishrhodes +2 -0
  245. data/platform/shared/qt/sailfish/qml/pages/FirstPageWK.qml +7 -11
  246. data/platform/shared/qt/sailfish/qml/{harbour-sailfishrhodes.qml → sailfishrhodes.qml} +1 -1
  247. data/platform/shared/qt/sailfish/rpm/sailfishrhodes.spec +80 -0
  248. data/platform/shared/qt/sailfish/rpm/{harbour-sailfishrhodes.yaml → sailfishrhodes.yaml} +2 -2
  249. data/platform/shared/qt/sailfish/src/QtMainWindow.cpp +1 -1
  250. data/platform/shared/qt/sailfish/src/QtMainWindow.h +1 -1
  251. data/platform/shared/qt/sailfish/src/main.cpp +6 -38
  252. data/platform/shared/qt/sailfish/src/rootdelegate.h +2 -14
  253. data/platform/shared/ruby/aurora/ruby/config.h +386 -0
  254. data/platform/shared/ruby/aurora/ruby/constdefs.c +5866 -0
  255. data/platform/shared/ruby/aurora/ruby/constdefs.h +1788 -0
  256. data/platform/shared/ruby/osx/ruby/config.h +2 -0
  257. data/platform/shared/ruby/win32/win32.c +10 -3
  258. data/platform/shared/sqlite/crypto.c +14 -0
  259. data/platform/win32/RhoSimulator/RhoSimulator.exe +0 -0
  260. data/platform/win32/build/rhodes.nsi +3 -3
  261. data/platform/win32/build/win32.rake +1 -1
  262. data/rakefile.rb +55 -43
  263. data/res/build-tools/RhoRuby.exe +0 -0
  264. data/res/build-tools/aapt2/linux/aapt2 +0 -0
  265. data/res/build-tools/aapt2/osx/aapt2 +0 -0
  266. data/res/build-tools/iphonesim/build/Release/iphonesim_8 +4 -4
  267. data/res/generators/templates/application/AndroidManifest.erb +28 -6
  268. data/res/generators/templates/application/build.yml +18 -11
  269. data/res/generators/templates/application/resources/android/res/xml/provider_paths.xml +4 -0
  270. data/res/generators/templates/application/rhoconfig.txt +15 -1
  271. data/res/generators/templates/iphone_project/Bremen8.xcodeproj/project.pbxproj +24 -1
  272. data/res/generators/templates/iphone_project/Classes/SimpleSwiftClass.swift +20 -0
  273. data/res/generators/templates/iphone_project/Classes/rhorunner-Bridging-Header.h +4 -0
  274. data/rhobuild.yml.example +4 -4
  275. data/rhodes.gemspec +4 -3
  276. data/version +1 -1
  277. metadata +157 -57
  278. data/lib/commonAPI/mediacapture/ext/platform/android/adds/res/drawable/camera_btn.xml +0 -14
  279. data/lib/commonAPI/mediacapture/ext/platform/android/adds/res/layout/camera_land.xml +0 -23
  280. data/lib/commonAPI/mediacapture/ext/platform/android/adds/res/layout/camera_port.xml +0 -23
  281. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraActivity.java +0 -156
  282. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraEclair.java +0 -227
  283. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraGingerbread.java +0 -152
  284. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraPreview.java +0 -183
  285. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraSingletonEclair.java +0 -14
  286. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraSingletonGingerbread.java +0 -60
  287. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/ICameraObject.java +0 -20
  288. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/ICameraSingletonObject.java +0 -8
  289. data/lib/extensions/fcm-push/ext/android/src/com/rhomobile/rhodes/fcm/FCMTokenRefresherService.java +0 -27
  290. data/platform/android/Rhodes/AndroidManifest.xml.erb +0 -89
  291. data/platform/sailfish/build/rho_build.cmd.erb +0 -14
  292. data/platform/sailfish/build/rho_clean.cmd.erb +0 -14
  293. data/platform/sailfish/build/rho_deploy.cmd.erb +0 -15
  294. data/platform/sailfish/build/rho_rpm.cmd.erb +0 -14
  295. data/platform/sailfish/build/rho_rpmvalidation.cmd.erb +0 -14
  296. data/platform/sailfish/build/rpm/harbour-SailfishRhodes.desktop.erb +0 -7
  297. data/platform/sailfish/build/rpm/harbour-SailfishRhodes.erb +0 -2
  298. data/platform/sailfish/build/rpm/harbour-SailfishRhodes.yaml.erb +0 -37
  299. data/platform/shared/qt/sailfish/harbour-sailfishrhodes.desktop +0 -6
  300. data/platform/shared/qt/sailfish/icons/108x108/harbour-sailfishrhodes.png +0 -0
  301. data/platform/shared/qt/sailfish/privileges/harbour-sailfishrhodes +0 -2
  302. data/platform/shared/qt/sailfish/qml/pages/FirstPageWE.qml +0 -236
  303. /data/platform/shared/qt/sailfish/icons/128x128/{harbour-sailfishrhodes.png → sailfishrhodes.png} +0 -0
  304. /data/platform/shared/qt/sailfish/icons/172x172/{harbour-sailfishrhodes.png → sailfishrhodes.png} +0 -0
  305. /data/platform/shared/qt/sailfish/icons/86x86/{harbour-sailfishrhodes.png → sailfishrhodes.png} +0 -0
@@ -13,7 +13,9 @@ import java.util.List;
13
13
  import java.util.Map;
14
14
  import java.util.concurrent.ExecutorService;
15
15
  import java.util.concurrent.Executors;
16
-
16
+ import java.util.ArrayList;
17
+ import java.util.UUID;
18
+
17
19
  import android.annotation.SuppressLint;
18
20
  import android.app.Activity;
19
21
  import android.content.ContentResolver;
@@ -24,15 +26,18 @@ import android.graphics.Bitmap;
24
26
  import android.graphics.BitmapFactory;
25
27
  import android.graphics.Matrix;
26
28
  import android.hardware.Camera;
27
- import android.media.MediaPlayer;
28
29
  import android.net.Uri;
29
30
  import android.os.Environment;
30
31
  import android.provider.MediaStore;
31
32
  import android.view.SurfaceHolder;
32
33
  import android.database.Cursor;
34
+ import android.content.pm.PackageManager;
35
+
36
+ import androidx.core.content.PermissionChecker;
37
+ import androidx.core.content.ContextCompat;
38
+ import android.Manifest;
33
39
 
34
- //import androidx.core.content.FileProvider;
35
- import android.support.v4.content.FileProvider;
40
+ import androidx.core.content.FileProvider;
36
41
 
37
42
  import com.rhomobile.rhodes.Base64;
38
43
  import com.rhomobile.rhodes.Logger;
@@ -41,640 +46,169 @@ import com.rhomobile.rhodes.api.IMethodResult;
41
46
  import com.rhomobile.rhodes.extmanager.RhoExtManager;
42
47
  import com.rhomobile.rhodes.file.RhoFileApi;
43
48
  import com.rhomobile.rhodes.util.ContextFactory;
49
+ import com.rho.camera.ICameraSingleton;
44
50
 
45
- public class CameraObject extends CameraBase implements ICameraObject {
51
+ public class CameraObject extends CameraBase implements ICamera{
46
52
  private static final String TAG = CameraObject.class.getSimpleName();
47
- public static boolean deprecated_take_pic;
48
- private Map<String, String> mActualPropertyMap;
49
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_hhmmss");
50
- void setActualPropertyMap(Map<String, String> props) { mActualPropertyMap = props; }
51
- Map<String, String> getActualPropertyMap() { return mActualPropertyMap; }
52
-
53
-
54
- private Camera mCamera;
55
- private int mCameraUsers;
56
- private Uri fileUri;
57
- String mCurrentPhotoPath = null;
58
- public static String userFilePath = null;
59
- private ContentValues values = null;
53
+ private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_hhmmss");
54
+
55
+ private Camera mCamera = null;
56
+ private int mCameraUsers;
60
57
  private File storageDir = null;
58
+ private List<Camera.Size> mSupportedPictureSizes;
61
59
 
62
60
  public static boolean CURRENT_SCREEN_AUTO_ROTATE_MODE;
63
61
  public static boolean CURRENT_FULL_SCREEN_MODE;
64
62
 
63
+ interface ISize {
64
+ int getWidth();
65
+ int getHeight();
66
+ int D2();
67
+ }
68
+
69
+ static class CameraSize implements ISize {
70
+ private Camera.Size mSize;
71
+ CameraSize(Camera.Size size) { mSize = size; }
72
+ @Override public int getWidth() { return mSize.width; }
73
+ @Override public int getHeight() { return mSize.height; }
74
+ @Override public int D2() { return mSize.width * mSize.width + mSize.height * mSize.height; }
75
+ @Override public String toString() { return "" + mSize.width + "X" + mSize.height; }
76
+ }
77
+
78
+ static class RawSize implements ISize {
79
+ private int width;
80
+ private int height;
81
+ RawSize(int width, int height) { this.width = width; this.height = height; }
82
+ @Override public int getWidth() { return this.width; }
83
+ @Override public int getHeight() { return this.height; }
84
+ @Override public int D2() { return width * width + height * height; }
85
+ @Override public String toString() { return "" + width + "X" + height; }
86
+ }
87
+
65
88
  int getCameraIndex() {
66
- return CameraSingletonObject.getCameraIndex(getId());
89
+ return CameraSingleton.getCameraIndex(getId());
67
90
  }
91
+
68
92
  @Override
69
93
  public void setProperties(Map<String, String> propertyMap, IMethodResult result) {
70
- // TODO Auto-generated method stub
71
- Map<String, String> temp=getPropertiesMap();
72
- temp.putAll(propertyMap);
94
+ getPropertiesMap().putAll(propertyMap);
73
95
  result.set(true);
74
96
  }
97
+
75
98
  @Override
76
99
  public void getProperties(List<String> arrayofNames, IMethodResult result) {
77
-
78
- //super.getProperties(arrayofNames, result);
79
100
  Map<String, Object> props = new HashMap<String, Object>();
80
101
  for (String name: arrayofNames)
81
102
  {
82
103
  props.put(name, cameraPropGet(name));
83
104
  }
84
105
  result.set(props);
85
-
86
106
  }
87
107
 
88
108
  private String cameraPropGet(String name)
89
109
  {
90
- String propValue="";
91
- Map<String, String> temp=getPropertiesMap();
92
- if(temp.containsKey(name))
93
- {
94
-
95
- try{
96
- propValue=String.valueOf(temp.get(name));
97
- }
98
- catch(Exception ex)
99
- {
100
-
101
- }
102
- }
103
- return propValue;
104
- }
105
-
106
- static class CameraSize implements ICameraObject.ISize {
107
- private Camera.Size mSize;
108
- CameraSize(Camera.Size size) { mSize = size; }
109
- @Override public int getWidth() { return mSize.width; }
110
- @Override public int getHeight() { return mSize.height; }
111
- @Override public int D2() { return mSize.width * mSize.width + mSize.height * mSize.height; }
112
- @Override public String toString() { return "" + mSize.width + "X" + mSize.height; }
110
+ return getPropertiesMap().getOrDefault(name, "");
113
111
  }
114
112
 
115
- static class RawSize implements ICameraObject.ISize {
116
- private int width;
117
- private int height;
118
- RawSize(int width, int height) { this.width = width; this.height = height; }
119
- @Override public int getWidth() { return this.width; }
120
- @Override public int getHeight() { return this.height; }
121
- @Override public int D2() { return width * width + height * height; }
122
- @Override public String toString() { return "" + width + "X" + height; }
123
- }
124
-
125
- @Override
113
+ @Override
126
114
  public void getAllProperties(IMethodResult result) {
127
- // TODO Auto-generated method stub
128
115
  Map<String, Object> props = new HashMap<String, Object>();
129
116
  for (String key: getPropertiesMap().keySet()) {
130
117
  props.put(key, cameraPropGet(key));
131
118
  }
132
119
  result.set(props);
133
120
  }
134
-
135
- protected class TakePictureCallback implements Camera.PictureCallback {
136
- private Activity mPreviewActivity;
137
- MediaPlayer mp;
138
- Bitmap bitmap = null;
139
- TakePictureCallback(Activity previewActivity) {
140
- mPreviewActivity = previewActivity;
141
- }
142
- @Override
143
- public void onPictureTaken(byte[] data, Camera camera) {
144
- Logger.T(TAG, "onPictureTaken: entering the function");
145
-
146
- Intent intent = new Intent();
147
- OutputStream stream = null;
148
- try {
149
-
150
- final Map<String, String> propertyMap = getActualPropertyMap();
151
- if (propertyMap == null) {
152
- throw new RuntimeException("Camera property map is undefined");
153
- }
154
-
155
- String outputFormat = propertyMap.get("outputFormat");
156
- if(propertyMap.get("deprecated") == null || propertyMap.get("deprecated").equalsIgnoreCase("false")){
157
- propertyMap.put("deprecated", "false");
158
- deprecated_take_pic = false;
159
- }
160
- else
161
- deprecated_take_pic = true;
162
- if(propertyMap.containsKey("captureSound")){
163
- Runnable music= new Runnable(){
164
- public void run() {
165
- playMusic(propertyMap.get("captureSound"));
166
- }
167
- };
168
- ExecutorService exec = Executors.newSingleThreadExecutor();
169
- exec.submit(music);
170
- }
171
-
172
- String filePath = null;
173
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_hhmmss");
174
- if(!propertyMap.containsKey("fileName")){
175
- filePath = "/sdcard/DCIM/Camera/IMG_"+ dateFormat.format(new Date(System.currentTimeMillis()));
176
- userFilePath = filePath;
177
- }
178
- else{
179
- filePath = propertyMap.get("fileName");
180
- userFilePath = filePath;
181
- if(filePath.contains("\\")){
182
- intent.putExtra("error", "Invalid file path");
183
- }
184
- }
185
- try {
186
- String folderPath = filePath.substring(0,filePath.lastIndexOf("/"));
187
- File folderFile = new File(folderPath);
188
- if (!folderFile.exists()) {
189
- folderFile.mkdirs();
190
- }
191
- }
192
- catch (Exception e) {
193
- e.printStackTrace();
194
- }
195
- Uri resultUri = null;
196
- BitmapFactory.Options options=new BitmapFactory.Options();
197
- options.inPurgeable = true;
198
- bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, options);
199
- Matrix m = new Matrix();
200
- android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo();
201
- android.hardware.Camera.getCameraInfo(getCameraIndex(), info);
202
- if (info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT && OrientationListnerService.mRotation == 90) {
203
- m.postRotate(270);
204
- }else if(info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT && OrientationListnerService.mRotation == 270){
205
- m.postRotate(90);
206
- }else{
207
- m.postRotate(OrientationListnerService.mRotation);
208
- }
209
- if (!Boolean.parseBoolean(getActualPropertyMap().get("useSystemViewfinder"))) {
210
- bitmap = Bitmap.createBitmap(bitmap , 0, 0, bitmap.getWidth(), bitmap.getHeight(), m, true);
211
- }
212
- if (outputFormat.equalsIgnoreCase("dataUri")) {
213
- Logger.T(TAG, "outputFormat: " + outputFormat);
214
- // filePath = getTemporaryPath(filePath)+ ".jpg";
215
- if (Boolean.parseBoolean(propertyMap.get("saveToDeviceGallery")))
216
- {
217
-
218
- ContentResolver contentResolver = ContextFactory.getContext().getContentResolver();
219
- Logger.T(TAG, "Image size: " + bitmap.getWidth() + "X" + bitmap.getHeight());
220
- propertyMap.put("DeviceGallery_Key", "DeviceGallery_Value");
221
- String strUri = null;
222
- if (!propertyMap.containsKey("fileName")) {
223
- strUri = MediaStore.Images.Media.insertImage(contentResolver, bitmap, "IMG_"+ dateFormat.format(new Date(System.currentTimeMillis())), "Camera");
224
- }
225
- else{
226
- strUri = MediaStore.Images.Media.insertImage(contentResolver, bitmap, new File(propertyMap.get("fileName")).getName(), "Camera");
227
- }
228
- if (strUri != null) {
229
- resultUri = Uri.parse(strUri);
230
- } else {
231
- throw new RuntimeException("Failed to save camera image to Gallery");
232
- }
233
- }
234
- else
235
- {
236
- if(userFilePath.contains("sdcard")){
237
-
238
- Boolean isSDPresent = android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
239
-
240
-
241
- if(isSDPresent)
242
- {
243
- byte[] byteArray = null;
244
- int lastIndex = userFilePath.lastIndexOf("/");
245
-
246
- String subfolderName = userFilePath.replaceAll("/sdcard", "");
247
- String folderName = subfolderName.substring(subfolderName.indexOf("/")+1,subfolderName.lastIndexOf("/"));
248
-
249
- String file_name= userFilePath.substring(lastIndex+1, userFilePath.length());
250
-
251
-
252
- File directory = new File(Environment.getExternalStorageDirectory()+File.separator + folderName);
253
- boolean flag = directory.mkdirs();
254
-
255
- stream = new FileOutputStream(directory +File.separator + file_name+".jpg");
256
- resultUri = Uri.fromFile(new File(directory +File.separator + file_name+".jpg"));
257
- if(bitmap != null){
258
- if (!Boolean.parseBoolean(getActualPropertyMap().get("useSystemViewfinder"))) {
259
- ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
260
- bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytestream);
261
- byteArray = bytestream.toByteArray();
262
- stream.write(byteArray);
263
- }
264
- else {
265
- stream.write(data);
266
- }
267
- stream.flush();
268
- stream.close();
269
- }
270
- }
271
- }else{
272
- stream = new FileOutputStream(filePath);
273
- resultUri = Uri.fromFile(new File(filePath));
274
- byte[] byteArray = null;
275
- if(bitmap != null){
276
- if (!Boolean.parseBoolean(getActualPropertyMap().get("useSystemViewfinder"))) {
277
- ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
278
- bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytestream);
279
- byteArray = bytestream.toByteArray();
280
- stream.write(byteArray);
281
- }
282
- else {
283
- stream.write(data);
284
- }
285
- stream.flush();
286
- stream.close();
287
- }
288
- }
289
- //CameraRhoListener.getInstance().copyImgAsUserChoice(filePath);
290
-
291
- }
292
- byte[] byteArray = null;
293
- stream = new FileOutputStream(filePath);
294
- if(bitmap != null){
295
- if (!Boolean.parseBoolean(getActualPropertyMap().get("useSystemViewfinder"))) {
296
- ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
297
- bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytestream);
298
- byteArray = bytestream.toByteArray();
299
- stream.write(byteArray);
300
- stream.flush();
301
- stream.close();
302
- }
303
- }
304
- StringBuilder dataBuilder = new StringBuilder();
305
- dataBuilder.append("data:image/jpeg;base64,");
306
- if (!Boolean.parseBoolean(getActualPropertyMap().get("useSystemViewfinder"))) {
307
- dataBuilder.append(Base64.encodeToString(byteArray, false));
308
- }
309
- else {
310
- dataBuilder.append(Base64.encodeToString(data, false));
311
- }
312
- propertyMap.put("captureUri", dataBuilder.toString());
313
- propertyMap.put("dataURI", "datauri_value");
314
- Logger.T(TAG, dataBuilder.toString());
315
- intent.putExtra("IMAGE_WIDTH", bitmap.getWidth());
316
- intent.putExtra("IMAGE_HEIGHT", bitmap.getHeight());
317
- mPreviewActivity.setResult(Activity.RESULT_OK, intent);
318
- } else
319
- if (outputFormat.equalsIgnoreCase("image")) {
320
- // filePath = getTemporaryPath(filePath)+ ".jpg";
321
- Logger.T(TAG, "outputFormat: " + outputFormat + ", path: " + filePath);
322
- if (Boolean.parseBoolean(propertyMap.get("saveToDeviceGallery")))
323
- {
324
- ContentResolver contentResolver = ContextFactory.getContext().getContentResolver();
325
- Logger.T(TAG, "Image size: " + bitmap.getWidth() + "X" + bitmap.getHeight());
326
- propertyMap.put("DeviceGallery_Key", "DeviceGallery_Value");
327
- String strUri = null;
328
- if (!propertyMap.containsKey("fileName"))
329
- strUri = MediaStore.Images.Media.insertImage(contentResolver, bitmap, "IMG_"+ dateFormat.format(new Date(System.currentTimeMillis())), "Camera");
330
- else
331
- strUri = MediaStore.Images.Media.insertImage(contentResolver, bitmap, new File(propertyMap.get("fileName")).getName(), "Camera");
332
- if (strUri != null) {
333
- resultUri = Uri.parse(strUri);
334
- } else {
335
- throw new RuntimeException("Failed to save camera image to Gallery");
336
- }
337
- }
338
- else
339
- {
340
- stream = new FileOutputStream(filePath);
341
- resultUri = Uri.fromFile(new File(filePath));
342
- byte[] byteArray = null;
343
- if(bitmap != null){
344
- if (!Boolean.parseBoolean(getActualPropertyMap().get("useSystemViewfinder"))) {
345
- ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
346
- bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytestream);
347
- byteArray = bytestream.toByteArray();
348
- stream.write(byteArray);
349
- }
350
- else {
351
- stream.write(data);
352
- }
353
- stream.flush();
354
- stream.close();
355
- }
356
- }
357
-
358
- intent.putExtra(MediaStore.EXTRA_OUTPUT, resultUri);
359
- intent.putExtra("IMAGE_WIDTH", bitmap.getWidth());
360
- intent.putExtra("IMAGE_HEIGHT", bitmap.getHeight());
361
- mPreviewActivity.setResult(Activity.RESULT_OK, intent);
362
- }
363
-
364
- } catch (Throwable e) {
365
- Logger.E(TAG, e);
366
- if (stream != null) {
367
- try {
368
- stream.close();
369
- } catch (Throwable e1) {
370
- //Do nothing
371
- }
372
- }
373
- intent.putExtra("error", e.getMessage());
374
- mPreviewActivity.setResult(Activity.RESULT_CANCELED, intent);
375
- }
376
- if(bitmap != null){
377
- bitmap.recycle();
378
- bitmap = null;
379
- System.gc();
380
- }
381
- mPreviewActivity.finish();
382
- }
383
- private void playMusic(String musicPath) {
384
- mp = new MediaPlayer();
385
- try {
386
- mp.setDataSource(RhoFileApi.openFd(musicPath));
387
- } catch (IllegalArgumentException e) {
388
- // TODO Auto-generated catch block
389
- e.printStackTrace();
390
- } catch (IllegalStateException e) {
391
- // TODO Auto-generated catch block
392
- e.printStackTrace();
393
- } catch (IOException e) {
394
- // TODO Auto-generated catch block
395
- e.printStackTrace();
396
- }
397
- try {
398
- mp.prepare();
399
- } catch (IllegalStateException e) {
400
- // TODO Auto-generated catch block
401
- e.printStackTrace();
402
- } catch (IOException e) {
403
- // TODO Auto-generated catch block
404
- e.printStackTrace();
405
- }
406
- mp.start();
407
- try {
408
- Thread.sleep(3000);
409
- } catch (InterruptedException e) {
410
- // TODO Auto-generated catch block
411
- e.printStackTrace();
412
- }
413
- mp.stop();
414
- clearMediaPlayerResources();
415
- }
416
-
417
- private void clearMediaPlayerResources() {
418
- // TODO Auto-generated method stub
419
- if(mp != null){
420
- mp.release();
421
- mp = null;
422
- }
423
- }
424
- }
425
-
426
-
427
-
121
+
428
122
  protected Camera getCamera() { return mCamera; }
429
123
  protected void setCamera(Camera camera) { mCamera = camera; }
430
124
 
431
- synchronized protected void openCamera() {
432
- if (mCameraUsers == 0) {
433
- setCamera(android.hardware.Camera.open());
434
- }
435
- mCameraUsers++;
436
- }
437
- synchronized protected void closeCamera() {
438
- mCameraUsers--;
439
- if (mCameraUsers == 0) {
440
- getCamera().release();
441
- }
442
- }
443
-
444
125
  CameraObject(String id) {
445
126
  super(id);
446
127
 
447
128
  getPropertiesMap().put("ChoosePicture_Key", "");
448
- getPropertiesMap().put("cameraType", "back");
449
- getPropertiesMap().put("compressionFormat", "jpg");
450
- getPropertiesMap().put("outputFormat", "image");
451
- getPropertiesMap().put("colorModel", "rgb");
452
- getPropertiesMap().put("useSystemViewfinder", "true");
453
- getPropertiesMap().put("useRealBitmapResize", "true");
454
- getPropertiesMap().put("useRotationBitmapByEXIF", "true");
455
- getPropertiesMap().put("saveToDeviceGallery", "false");
456
- if (hasPermission()) {
457
- openCamera();
458
- Camera.Parameters params = getCamera().getParameters();
459
- closeCamera();
460
-
461
- getPropertiesMap().put("maxWidth", String.valueOf(params.getPictureSize().width));
462
- getPropertiesMap().put("maxHeight", String.valueOf(params.getPictureSize().height));
463
-
464
- // default desired size not specified in documentation and XML !!!
465
- //getPropertiesMap().put("desiredWidth", "640");
466
- //getPropertiesMap().put("desiredHeight", "480");
467
- }
468
- else {
469
- Logger.E(TAG, "Application has no permission to Camera access !!!");
470
- getPropertiesMap().put("maxWidth", String.valueOf(0));
471
- getPropertiesMap().put("maxHeight", String.valueOf(0));
472
- }
473
- getPropertiesMap().put("desiredWidth", "0");
474
- getPropertiesMap().put("desiredHeight", "0");
129
+ getPropertiesMap().put(ICameraSingleton.PROPERTY_COMPRESSION_FORMAT, ICameraSingleton.COMPRESSION_FORMAT_JPG);
130
+ getPropertiesMap().put(ICameraSingleton.PROPERTY_OUTPUT_FORMAT, ICameraSingleton.OUTPUT_FORMAT_IMAGE);
131
+ getPropertiesMap().put(ICameraSingleton.PROPERTY_COLOR_MODEL, ICameraSingleton.COLOR_MODEL_RGB);
132
+ getPropertiesMap().put(ICameraSingleton.PROPERTY_USE_REAL_BITMAP_RESIZE, "true");
133
+ getPropertiesMap().put(ICameraSingleton.PROPERTY_USE_ROTATION_BITMAP_BY_EXIF, "true");
134
+ getPropertiesMap().put(ICameraSingleton.PROPERTY_SAVE_TO_DEVICE_GALLERY, "false");
475
135
 
476
136
  storageDir = new File(Environment.getExternalStorageDirectory(), "RhoImages");
477
137
  createRhoCacheFolder();
478
138
 
479
- }
480
-
481
- public void createRhoCacheFolder(){
482
- storageDir.mkdirs();
483
- try{
484
- //File nomediaFile = new File(storageDir, ".nomedia");
485
- //if (!nomediaFile.exists()) {nomediaFile.createNewFile();}
486
- }catch (Exception e){
487
-
139
+ android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo();
140
+ android.hardware.Camera.getCameraInfo(getCameraIndex(), info);
141
+ switch (info.facing) {
142
+ case android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK:
143
+ getPropertiesMap().put(ICameraSingleton.PROPERTY_CAMERA_TYPE, ICameraSingleton.CAMERA_TYPE_BACK);
144
+ break;
145
+ case android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT:
146
+ getPropertiesMap().put(ICameraSingleton.PROPERTY_CAMERA_TYPE, ICameraSingleton.CAMERA_TYPE_FRONT);
147
+ break;
148
+ default:
149
+ getPropertiesMap().put(ICameraSingleton.PROPERTY_CAMERA_TYPE, "unknown");
150
+ break;
488
151
  }
489
- }
490
152
 
491
- @Override
492
- public void startPreview(SurfaceHolder surfaceHolder) {
493
- try {
153
+ if (hasPermission()) {
494
154
  openCamera();
495
- getCamera().setPreviewDisplay(surfaceHolder);
496
- getCamera().startPreview();
497
- } catch (Throwable e) {
498
- Logger.E(TAG, e);
499
- return;
500
- }
501
- }
155
+ Camera.Parameters params = getCamera().getParameters();
156
+ closeCamera();
502
157
 
503
- @Override
504
- public void stopPreview() {
505
- // Surface will be destroyed when we return, so stop the preview.
506
- if (getCamera() != null) {
507
- try {
508
- getCamera().stopPreview();
509
- getCamera().setPreviewDisplay(null);
510
- closeCamera();
511
- } catch (Throwable e) {
512
- Logger.E(TAG, e);
513
- return;
158
+ mSupportedPictureSizes = params.getSupportedPictureSizes();
159
+ ISize maxSize = null;
160
+ for(android.hardware.Camera.Size curSize: mSupportedPictureSizes) {
161
+ Logger.D(TAG, "Possible picture size: " + curSize.width + "X" + curSize.height);
162
+ if ((maxSize == null) || (curSize.width > maxSize.getWidth())) {
163
+ maxSize = new CameraSize(curSize);
164
+ }
514
165
  }
515
- }
516
- }
517
166
 
518
- @SuppressWarnings("deprecation")
519
- @SuppressLint("NewApi")
520
- @Override
521
- public ISize setPreviewSize(int width, int height) {
522
- Camera camera = getCamera();
523
- Camera.Parameters parameters = camera.getParameters();
524
- List<android.hardware.Camera.Size> sizes = camera.getParameters().getSupportedPictureSizes();
525
- android.hardware.Camera.Size maxSize=sizes.get(0);
526
- if((getActualPropertyMap().containsKey("desiredWidth") || getActualPropertyMap().containsKey("desiredHeight")) &&
527
- (!Boolean.parseBoolean(getActualPropertyMap().get("useRealBitmapResize")))){
528
- int desired_width = Integer.parseInt(getActualPropertyMap().get("desiredWidth"));
529
- int desired_height = Integer.parseInt(getActualPropertyMap().get("desiredHeight"));
530
- if(desired_width > 0 && desired_width <= maxSize.width && desired_height > 0 && desired_height <= maxSize.height){
531
- Camera.Size previewSize = getOptimalPreviewSize(parameters.getSupportedPictureSizes(), desired_width, desired_height);
532
- Logger.T(TAG, "Selected size: " + previewSize.width + "x" + previewSize.height);
533
- parameters.setPreviewSize(previewSize.width, previewSize.height);
534
- }
535
- else if(desired_width > maxSize.width || desired_height > maxSize.height){
536
- final Camera.Parameters newParam=parameters;
537
- final android.hardware.Camera.Size newMaxSize = sizes.get(0);
538
- RhodesActivity.safeGetInstance().runOnUiThread(new Runnable() {
539
-
540
- @Override
541
- public void run() {
542
- // TODO Auto-generated method stub
543
- newParam.setPreviewSize(newMaxSize.width , newMaxSize.height);
544
- }
545
- });
546
- }
547
- else{
548
- parameters.setPreviewSize(320, 240);
549
- }
167
+ getPropertiesMap().put(ICameraSingleton.PROPERTY_MAX_WIDTH, String.valueOf(maxSize.getWidth()));
168
+ getPropertiesMap().put(ICameraSingleton.PROPERTY_MAX_HEIGHT, String.valueOf(maxSize.getHeight()));
550
169
  }
551
- else{
552
- Camera.Size previewSize = getOptimalPreviewSize(parameters.getSupportedPictureSizes(), width, height);
553
- Logger.T(TAG, "Selected size: " + previewSize.width + "x" + previewSize.height);
554
- parameters.setPreviewSize(previewSize.width, previewSize.height);
555
- }
556
- camera.stopPreview();
557
- try{
558
- camera.setParameters(parameters);
559
- }
560
- catch(RuntimeException e){
561
- e.printStackTrace();
170
+ else {
171
+ Logger.E(TAG, "Application has no permission to Camera access !!!");
172
+ getPropertiesMap().put(ICameraSingleton.PROPERTY_MAX_WIDTH, String.valueOf(0));
173
+ getPropertiesMap().put(ICameraSingleton.PROPERTY_MAX_HEIGHT, String.valueOf(0));
562
174
  }
563
- camera.startPreview();
564
175
 
565
- return new CameraSize(camera.getParameters().getPreviewSize());
176
+ getPropertiesMap().put(ICameraSingleton.PROPERTY_DESIRED_WIDTH, "0");
177
+ getPropertiesMap().put(ICameraSingleton.PROPERTY_DESIRED_HEIGHT, "0");
566
178
  }
567
179
 
568
- private Camera.Size getOptimalPreviewSize(List<Camera.Size> sizes, int w, int h) {
569
- final double ASPECT_TOLERANCE = 0.2;
570
- final double SCALE_TOLERANCE = 0.2;
571
- double targetRatio = (double) w / h;
572
- if (sizes == null) return null;
573
-
574
- Camera.Size optimalSize = null;
575
- double minDiff = Double.MAX_VALUE;
576
-
577
- int targetHeight = h;
578
-
579
- // Try to find an size match aspect ratio and size
580
- for (Camera.Size size : sizes) {
581
- Logger.T(TAG, "Size: " + size.width + "x" + size.height);
582
-
583
- double scale = (double) size.width / w;
584
- double ratio = (double) size.width / size.height;
585
-
586
- Logger.T(TAG, "Target ratio: " + targetRatio + ", ratio: " + ratio + ", scale: " + scale);
587
-
588
- if (size.width > w || size.height > h) continue;
589
- if (Math.abs(1 - scale) > SCALE_TOLERANCE) continue;
590
- if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue;
591
-
592
- Logger.T(TAG, "Try size: " + size.width + "x" + size.height);
593
-
594
- if (Math.abs(size.height - targetHeight) < minDiff) {
595
- optimalSize = size;
596
- minDiff = Math.abs(size.height - targetHeight);
597
- }
598
- }
599
-
600
- // Cannot find the one match the aspect ratio, ignore the requirement
601
- if (optimalSize == null) {
602
- Logger.T(TAG, "There is no match for preview size!");
603
- minDiff = Double.MAX_VALUE;
604
- for (Camera.Size size : sizes) {
605
- if (size.width > w || size.height > h) continue;
606
-
607
- Logger.T(TAG, "Try size: " + size.width + "x" + size.height);
608
-
609
- if (Math.abs(size.height - targetHeight) < minDiff) {
610
- optimalSize = size;
611
- minDiff = Math.abs(size.height - targetHeight);
612
- }
613
- }
614
- }
615
- if(optimalSize == null)
616
- return getCamera().getParameters().getPictureSize();
617
- return optimalSize;
180
+ public void createRhoCacheFolder(){
181
+ storageDir.mkdirs();
618
182
  }
619
183
 
184
+
620
185
  @Override
621
186
  public void setCompressionFormat(String compressionFormat, IMethodResult result) {
622
- if (!compressionFormat.equalsIgnoreCase("jpg")) {
187
+ if (!compressionFormat.equalsIgnoreCase(ICameraSingleton.COMPRESSION_FORMAT_JPG)) {
623
188
  Logger.E(TAG, "Android does not support the compression format: " + compressionFormat);
624
189
  result.setError("Android does not support the compression format: " + compressionFormat);
625
190
  }
626
191
  }
627
192
 
628
- @Override
629
- public void getPreviewLeft(IMethodResult result) {
630
- //WM only
631
- }
632
-
633
- @Override
634
- public void setPreviewLeft(int previewLeft, IMethodResult result) {
635
- //WM only
636
- }
637
-
638
- @Override
639
- public void getPreviewTop(IMethodResult result) {
640
- //WM only
641
- }
642
-
643
- @Override
644
- public void setPreviewTop(int previewTop, IMethodResult result) {
645
- //WM only
193
+ public static String createFileName(){
194
+ return dateFormat.format(new Date(System.currentTimeMillis())) + "_" + UUID.randomUUID().toString();
646
195
  }
647
196
 
648
-
649
-
650
- String currentPhotoPath;
651
-
652
197
  private File createImageFile() throws IOException {
653
- // Create an image file name
654
- String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date(System.currentTimeMillis()));
655
- String imageFileName = "JPEG_" + timeStamp + "_";
198
+ String imageFileName = "JPEG_" + createFileName() + "_";
656
199
  File storageDir = RhodesActivity.getContext().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
657
- File image = File.createTempFile(
658
- imageFileName, /* prefix */
659
- ".jpg", /* suffix */
660
- storageDir /* directory */
661
- );
662
-
663
- // Save a file: path for use with ACTION_VIEW intents
664
- currentPhotoPath = image.getAbsolutePath();
200
+ File image = File.createTempFile(imageFileName, ".jpg", storageDir);
665
201
  return image;
666
202
  }
667
203
 
668
204
 
669
-
670
-
671
205
  @Override
672
206
  public void takePicture(Map<String, String> propertyMap, IMethodResult result) {
673
207
  if (!hasPermission()) {
674
208
  Logger.E(TAG, "Application has no permission to Camera access !!!");
675
209
  HashMap<String, Object> inResultMap = new HashMap<String,Object>();
676
- inResultMap.put("message", "No CAMERA permission !");
677
- inResultMap.put("status", "error");
210
+ inResultMap.put(ICameraSingleton.HK_MESSAGE, "No CAMERA permission !");
211
+ inResultMap.put(ICameraSingleton.HK_STATUS, ICameraSingleton.STATUS_ERROR);
678
212
  result.set(inResultMap);
679
213
  return;
680
214
  }
@@ -682,235 +216,293 @@ public class CameraObject extends CameraBase implements ICameraObject {
682
216
  CURRENT_SCREEN_AUTO_ROTATE_MODE = RhodesActivity.safeGetInstance().getScreenAutoRotateMode();
683
217
  CURRENT_FULL_SCREEN_MODE = RhodesActivity.safeGetInstance().getFullScreenMode();
684
218
 
685
- CameraSingletonObject.deprecated_choose_pic = false;
686
- deprecated_take_pic = false;
687
-
688
219
  Logger.T(TAG, "takePicture");
689
220
  try {
690
221
  Map<String, String> actualPropertyMap = new HashMap<String, String>();
691
222
  actualPropertyMap.putAll(getPropertiesMap());
692
223
  actualPropertyMap.putAll(propertyMap);
693
- setActualPropertyMap(actualPropertyMap);
694
224
 
695
- if (Boolean.parseBoolean(actualPropertyMap.get("deprecated"))) {
696
- deprecated_take_pic = true;
697
- }
698
- String outputFormat = actualPropertyMap.get("outputFormat");
699
- String filePath = null;
700
-
701
- String fdir = "/sdcard/DCIM/Camera/";
702
- fdir = storageDir.getAbsolutePath();
703
- String fname = actualPropertyMap.get("fileName");
704
-
705
- //if(!actualPropertyMap.containsKey("fileName")){
706
- fname = "IMG_"+ dateFormat.format(new Date(System.currentTimeMillis()));
707
- //}
708
-
709
- filePath = fdir + "/" + fname + ".jpg";
710
-
711
- /*
712
- //TODO: in all cases it is image, so think, why we need this parameter
713
- if (outputFormat.equalsIgnoreCase("image")) {
714
- filePath = actualPropertyMap.get("fileName") + ".jpg";
715
- Logger.T(TAG, "outputFormat: " + outputFormat + ", path: " + filePath);
716
- } else if (outputFormat.equalsIgnoreCase("dataUri")) {
717
- Logger.T(TAG, "outputFormat: " + outputFormat);
718
- } else {
719
- throw new RuntimeException("Unknown 'outputFormat' value: " + outputFormat);
720
- }
721
- */
722
-
723
- /*Logger.T(TAG, "Output file real path from URI: " + getRealPathFromURI(RhodesActivity.getContext(),
724
- MediaStore.Images.Media.EXTERNAL_CONTENT_URI));*/
725
- /*File image = null;
726
- try{
727
- image = File.createTempFile(fname, ".jpg", new File(storageDir));
728
- }catch(IOException e){
729
-
730
- }*/
731
-
732
- Intent intent = null;
733
- if (Boolean.parseBoolean(actualPropertyMap.get("useSystemViewfinder"))) {
734
- intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
735
- if (outputFormat.equalsIgnoreCase("image")) {
736
- ContentValues values = new ContentValues();
737
- if (!Boolean.parseBoolean(propertyMap.get("saveToDeviceGallery"))) {
738
- values.put( MediaStore.Images.ImageColumns.DATA, filePath);
739
- Logger.T(TAG, "Output filePath: " + filePath);
740
- }
741
-
742
- //fileUri = RhodesActivity.getContext().getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
743
-
744
-
745
-
746
-
747
- File photoFile = null;
748
- try {
749
- photoFile = createImageFile();
750
- } catch (IOException ex) {
751
- // Error occurred while creating the File
752
- Logger.E(TAG, "$$$ Failed to create temporary file !!!");
753
- }
754
- // Continue only if the File was successfully created
755
- if (photoFile != null) {
756
- fileUri = FileProvider.getUriForFile(RhodesActivity.getContext(),
757
- RhodesActivity.getContext().getPackageName() + ".fileprovider",
758
- photoFile);
759
- intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
760
- //startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
761
- }
225
+ String outputFormat = actualPropertyMap.get(ICameraSingleton.PROPERTY_OUTPUT_FORMAT);
762
226
 
227
+ String fileDir = storageDir.getAbsolutePath();
228
+ String fileName = actualPropertyMap.get(ICameraSingleton.PROPERTY_FILE_NAME);
229
+ if (fileName == null || fileName.isEmpty()){
230
+ fileName = "IMG_" + createFileName();
231
+ }
232
+ String filePath = fileDir + "/" + fileName + ".jpg";
233
+
234
+ Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
235
+ if (outputFormat.equalsIgnoreCase(ICameraSingleton.OUTPUT_FORMAT_IMAGE)) {
236
+ ContentValues values = new ContentValues();
237
+ if (!Boolean.parseBoolean(propertyMap.get(ICameraSingleton.PROPERTY_SAVE_TO_DEVICE_GALLERY))) {
238
+ values.put( MediaStore.Images.ImageColumns.DATA, filePath);
239
+ Logger.T(TAG, "Output filePath: " + filePath);
240
+ }
763
241
 
242
+ File photoFile = null;
243
+ try {
244
+ photoFile = createImageFile();
245
+ } catch (IOException ex) {
246
+ Logger.E(TAG, "$$$ Failed to create temporary file !!!");
247
+ }
248
+
249
+ if (photoFile != null) {
250
+ Uri fileUri = FileProvider.getUriForFile(RhodesActivity.getContext(),
251
+ RhodesActivity.getContext().getPackageName() + ".fileprovider", photoFile);
252
+ intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
764
253
  actualPropertyMap.put("captureUri", fileUri.toString());
765
- actualPropertyMap.put("captureUriFilePath", currentPhotoPath);
766
- propertyMap.put("dataURI", "");
767
254
  Logger.T(TAG, "Output fileUri: " + fileUri.toString());
255
+ actualPropertyMap.put("captureUriFilePath", photoFile.getAbsolutePath());
256
+ }
768
257
 
769
- // intent is null with MediaStore.EXTRA_OUTPUT so adding fileuri to map and get it with same key
770
- // if instead of MediaStore.EXTRA_OUTPUT any other key is used then the bitmap is null though the file is getting created
771
-
772
-
773
-
774
-
775
- //Uri fff = Uri.fromFile(new File(filePath));
776
- //intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
777
- //intent.putExtra(MediaStore.EXTRA_OUTPUT, fff);
778
-
258
+ propertyMap.put(ICameraSingleton.OUTPUT_FORMAT_DATAURI, "");
259
+
260
+ intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
261
+ } else if (outputFormat.equalsIgnoreCase(ICameraSingleton.OUTPUT_FORMAT_DATAURI)) {}
779
262
 
780
263
 
781
- intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
782
- } else if (outputFormat.equalsIgnoreCase("dataUri")) {}
783
- } else {
784
- intent = new Intent(ContextFactory.getUiContext(), CameraActivity.class);
785
- intent.putExtra(CameraExtension.INTENT_EXTRA_PREFIX + "CAMERA_ID", getId());
786
- }
787
-
788
264
  ((CameraFactory)CameraFactorySingleton.getInstance()).getRhoListener().setMethodResult(result);
789
265
  ((CameraFactory)CameraFactorySingleton.getInstance()).getRhoListener().setActualPropertyMap(actualPropertyMap);
790
266
 
791
- RhodesActivity.safeGetInstance().startActivityForResult(intent, RhoExtManager.getInstance().getActivityResultNextRequestCode(CameraRhoListener.getInstance()));
267
+ RhodesActivity.safeGetInstance().startActivityForResult(intent,
268
+ RhoExtManager.getInstance().getActivityResultNextRequestCode(CameraRhoListener.getInstance()));
792
269
  } catch (RuntimeException e) {
793
270
  Logger.E(TAG, e);
794
271
  result.setError(e.getMessage());
795
272
  }
796
273
  }
797
274
 
275
+ @Override
276
+ public void getSupportedSizeList(IMethodResult result) {
277
+ List<Object> res = new ArrayList<Object>();
278
+ for(Camera.Size size: mSupportedPictureSizes) {
279
+ Map<String, Integer> resSize = new HashMap<String, Integer>();
280
+ resSize.put(ICameraSingleton.HK_WIDTH, Integer.valueOf(size.width));
281
+ resSize.put(ICameraSingleton.HK_HEIGHT, Integer.valueOf(size.height));
282
+ res.add(resSize);
283
+ }
284
+ result.set(res);
285
+ }
286
+
287
+ public void finalize() {
288
+ if (getCamera() != null) {
289
+ getCamera().release();
290
+ }
291
+ }
798
292
 
799
293
 
800
- /*public String getRealPathFromURI(Context context, Uri contentUri) {
801
- Cursor cursor = null;
802
- try {
803
- String[] proj = { MediaStore.Images.Media.DATA };
804
- cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
805
- int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
806
- cursor.moveToFirst();
807
- return cursor.getString(column_index);
808
- } finally {
809
- if (cursor != null) {
810
- cursor.close();
811
- }
294
+ public boolean hasPermission() {
295
+ boolean res = (PermissionChecker.checkSelfPermission(RhodesActivity.getContext(), Manifest.permission.CAMERA) ==
296
+ PackageManager.PERMISSION_GRANTED);
297
+ if (!res) {
298
+ Logger.E(TAG, "Application has no permission to Camera access !!!");
299
+ }
300
+ return res;
301
+ }
302
+
303
+ protected ISize getDesiredSize() {
304
+ String strDesiredWidth = getPropertiesMap().get(ICameraSingleton.PROPERTY_DESIRED_WIDTH);
305
+ String strDesiredHeight = getPropertiesMap().get(ICameraSingleton.PROPERTY_DESIRED_HEIGHT);
306
+
307
+ if (Boolean.parseBoolean(getPropertiesMap().get(ICameraSingleton.PROPERTY_USE_REAL_BITMAP_RESIZE))) {
308
+ return null;
812
309
  }
813
- }*/
814
-
815
- protected String getTemporaryPath(String targetPath) {
816
- if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
817
- File externalRoot = Environment.getExternalStorageDirectory();
818
- if (! externalRoot.exists()){
819
- if (! externalRoot.mkdirs()){
820
- Logger.E(TAG, "Failed to create directory: " + externalRoot);
821
- return null;
310
+
311
+ if (Integer.valueOf(strDesiredWidth) <= 0) {
312
+ strDesiredWidth = null;
313
+ }
314
+ if (Integer.valueOf(strDesiredHeight) <= 0) {
315
+ strDesiredHeight = null;
316
+ }
317
+
318
+ int minDiff = Integer.MAX_VALUE;
319
+ ISize selectedSize = null;
320
+
321
+ if (strDesiredWidth != null && strDesiredHeight != null) {
322
+ ISize desiredSize = new RawSize(Integer.valueOf(strDesiredWidth),
323
+ Integer.valueOf(strDesiredHeight));
324
+ Logger.T(TAG, "Desired picture size: " + desiredSize);
325
+ for(Camera.Size size: mSupportedPictureSizes) {
326
+ ISize curSize = new CameraSize(size);
327
+ int curDiff = Math.abs(curSize.D2() - desiredSize.D2());
328
+ if (curDiff < minDiff) {
329
+ minDiff = curDiff;
330
+ selectedSize = curSize;
331
+ }
332
+ }
333
+ } else if (strDesiredWidth != null) {
334
+ int desiredWidth = Integer.valueOf(strDesiredWidth);
335
+ Logger.T(TAG, "Desired picture width: " + desiredWidth);
336
+ for(Camera.Size size: mSupportedPictureSizes) {
337
+ int curDiff = Math.abs(size.width - desiredWidth);
338
+ if (curDiff < minDiff) {
339
+ minDiff = curDiff;
340
+ selectedSize = new CameraSize(size);
341
+ }
342
+ }
343
+ } else if (strDesiredHeight != null) {
344
+ int desiredHeight = Integer.valueOf(strDesiredHeight);
345
+ Logger.T(TAG, "Desired picture width: " + desiredHeight);
346
+ for(Camera.Size size: mSupportedPictureSizes) {
347
+ int curDiff = Math.abs(size.height - desiredHeight);
348
+ if (curDiff < minDiff) {
349
+ minDiff = curDiff;
350
+ selectedSize = new CameraSize(size);
822
351
  }
823
352
  }
824
- String filename = new File(targetPath).getName();
825
- return new File(externalRoot, filename).getAbsolutePath();
826
- } else {
827
- return null;
828
353
  }
354
+ Logger.T(TAG, "Selected picture size: " + selectedSize);
355
+ return selectedSize;
829
356
  }
830
357
 
831
- @Override
832
- public void getSupportedSizeList(IMethodResult result) {
358
+ protected boolean hasAutoFocus() {
359
+ if (!hasPermission()) {
360
+ Logger.D(TAG, "Application has no permission to Camera access !!!");
361
+ return false;
362
+ }
363
+ String focusMode = getCamera().getParameters().getFocusMode();
364
+ boolean supported = false;
365
+ if (focusMode != null) {
366
+ supported = (focusMode.equals(android.hardware.Camera.Parameters.FOCUS_MODE_AUTO)) || (focusMode.equals(android.hardware.Camera.Parameters.FOCUS_MODE_MACRO));
367
+ }
368
+ return supported;
369
+
833
370
  }
834
371
 
835
- @SuppressLint("NewApi")
836
- @Override
837
- public void doTakePicture(Activity previewActivity, int rotation) {
838
- Logger.T(TAG, "doTakePicture: rotation: " + rotation);
839
- openCamera();
840
- Camera.Parameters params = getCamera().getParameters();
841
- params.setRotation((90 + rotation) % 360);
842
- getCamera().setParameters(params);
843
- getCamera().takePicture(null, null, new TakePictureCallback(previewActivity));
844
- closeCamera();
372
+ protected String getFlashMode() {
373
+ String flashParam = getPropertiesMap().get(ICameraSingleton.PROPERTY_FLASH_MODE);
374
+ String flashMode = Camera.Parameters.FLASH_MODE_AUTO;
375
+ if (flashParam != null) {
376
+ if (flashParam.equals(ICameraSingleton.FLASH_ON)) {
377
+ flashMode = Camera.Parameters.FLASH_MODE_ON;
378
+ } else
379
+ if (flashParam.equals(ICameraSingleton.FLASH_OFF)) {
380
+ flashMode = Camera.Parameters.FLASH_MODE_OFF;
381
+ } else
382
+ if (flashParam.equals(ICameraSingleton.FLASH_RED_EYE)) {
383
+ flashMode = Camera.Parameters.FLASH_MODE_RED_EYE;
384
+ } else
385
+ if (flashParam.equals(ICameraSingleton.FLASH_TORCH)) {
386
+ flashMode = Camera.Parameters.FLASH_MODE_TORCH;
387
+ }
388
+ }
389
+ Logger.T(TAG, "Flash mode: " + flashMode);
390
+ return flashMode;
845
391
  }
846
392
 
847
- public void finalize() {
848
- if (getCamera() != null) {
849
- getCamera().release();
393
+ protected String getColorMode() {
394
+ String colorParam = getPropertiesMap().get(ICameraSingleton.PROPERTY_COLOR_MODEL);
395
+ String colorMode = Camera.Parameters.EFFECT_NONE;
396
+ if (colorParam != null) {
397
+ if (colorParam.equals(ICameraSingleton.COLOR_MODEL_GRAYSCALE)) {
398
+ colorMode = Camera.Parameters.EFFECT_MONO;
399
+ }
400
+ }
401
+ Logger.T(TAG, "Color effect: " + colorMode);
402
+ return colorMode;
403
+ }
404
+
405
+ synchronized protected void openCamera() {
406
+ if (hasPermission()) {
407
+ if (mCameraUsers == 0) {
408
+ setCamera(Camera.open(getCameraIndex()));
409
+ }
410
+ mCameraUsers++;
411
+ }
412
+ }
413
+
414
+ synchronized protected void closeCamera() {
415
+ if (hasPermission()) {
416
+ mCameraUsers--;
417
+ if (mCameraUsers == 0) {
418
+ getCamera().release();
419
+
420
+ }
850
421
  }
851
422
  }
423
+
424
+
425
+ /* Here comes the stubs */
426
+
427
+ void notSupported(IMethodResult result){
428
+ result.setError("Not supported");
429
+ }
430
+
852
431
  @Override
853
- public void showPreview(Map<String, String> propertyMap,
854
- IMethodResult result) {
855
- // TODO Auto-generated method stub
432
+ public void capture(IMethodResult result){
433
+ notSupported(result);
434
+ }
856
435
 
436
+ @Override
437
+ public void showPreview(Map<String, String> propertyMap, IMethodResult result){
438
+ notSupported(result);
857
439
  }
440
+
858
441
  @Override
859
- public void hidePreview(IMethodResult result) {
860
- // TODO Auto-generated method stub
442
+ public void hidePreview(IMethodResult result){
443
+ notSupported(result);
444
+ }
861
445
 
446
+ @Override
447
+ public void getEnableEditing(IMethodResult result){
448
+ notSupported(result);
862
449
  }
450
+
863
451
  @Override
864
- public void capture(IMethodResult result) {
865
- // TODO Auto-generated method stub
452
+ public void setEnableEditing(boolean enableEditing, IMethodResult result){
453
+ notSupported(result);
454
+ }
866
455
 
456
+ @Override
457
+ public void getPreviewWidth(IMethodResult result){
458
+ notSupported(result);
867
459
  }
868
460
 
869
461
  @Override
870
- public void setDisplayOrientation(int rotate) {
871
- Camera camera = getCamera();
872
- camera.setDisplayOrientation(rotate);
462
+ public void setPreviewWidth(int previewWidth, IMethodResult result){
463
+ notSupported(result);
873
464
  }
874
465
 
466
+ @Override
467
+ public void getPreviewHeight(IMethodResult result){
468
+ notSupported(result);
469
+ }
875
470
 
876
- /**
877
- * Checks the device if it has
878
- * auto focus feature and sets auto focus
879
- * @param Preview Activity
880
- *
881
- */
471
+ @Override
472
+ public void setPreviewHeight(int previewHeight, IMethodResult result){
473
+ notSupported(result);
474
+ }
475
+
476
+ @Override
477
+ public void getAimMode(IMethodResult result){
478
+ notSupported(result);
479
+ }
882
480
 
883
481
  @Override
884
- public void setFocus(final Activity preview) {
885
- openCamera();
886
- if (hasAutoFocus()) {
887
- getCamera().autoFocus(new Camera.AutoFocusCallback() {
888
- public void onAutoFocus(boolean success, Camera camera) {
889
- }
890
- });
482
+ public void setAimMode(String aimMode, IMethodResult result){
483
+ notSupported(result);
484
+ }
891
485
 
892
- }
893
- closeCamera();
486
+ @Override
487
+ public void getPreviewLeft(IMethodResult result) {
488
+ notSupported(result);
894
489
  }
895
490
 
896
- private boolean hasAutoFocus() {
897
- if (!hasPermission()) {
898
- Logger.E(TAG, "Application has no permission to Camera access !!!");
899
- return false;
900
- }
901
- String focusMode = getCamera().getParameters().getFocusMode();
902
- boolean supported = false;
903
- if (focusMode != null) {
904
- supported = (focusMode.equals(android.hardware.Camera.Parameters.FOCUS_MODE_AUTO)) || (focusMode.equals(android.hardware.Camera.Parameters.FOCUS_MODE_MACRO));
905
- }
906
- return supported;
491
+ @Override
492
+ public void setPreviewLeft(int previewLeft, IMethodResult result) {
493
+ notSupported(result);
494
+ }
907
495
 
496
+ @Override
497
+ public void getPreviewTop(IMethodResult result) {
498
+ notSupported(result);
908
499
  }
909
500
 
910
- public boolean hasPermission() {
911
- //Logger.E(TAG, "Application has permission to Camera access DAFAULT !!!");
912
- return true;
501
+ @Override
502
+ public void setPreviewTop(int previewTop, IMethodResult result) {
503
+ notSupported(result);
913
504
  }
914
505
 
506
+
915
507
 
916
508
  }