Skip to content

Commit

Permalink
Camera fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy Vlasov committed Sep 2, 2019
1 parent debce38 commit fd0dfeb
Show file tree
Hide file tree
Showing 9 changed files with 414 additions and 779 deletions.
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# $keytool -genkey -v -keystore ./status-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias status

# Version requirements used throughout the Gradle scripts
minSdkVersion=18
minSdkVersion=23
compileSdkVersion=28
targetSdkVersion=28
buildToolsVersion=28.0.3
Expand Down
1 change: 1 addition & 0 deletions externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ var TopLevel = {
"SyncInstallation" : function () {},
"SyncInstallationHandler" : function () {},
"t" : function () {},
"takePictureAsync" : function () {},
"Text" : function () {},
"text" : function () {},
"TextEncoder" : function () {},
Expand Down
5 changes: 3 additions & 2 deletions mobile_files/package.json.orig
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"react-dom": "16.4.2",
"react-native": "0.60.5",
"react-native-background-timer": "2.1.0-alpha.6",
"react-native-camera": "3.0.1",
"react-native-camera": "3.3.0",
"react-native-config": "git+https://github.com/status-im/react-native-config.git#0.11.2-1",
"react-native-crypto": "2.1.1",
"react-native-dialogs": "1.0.4",
Expand All @@ -58,7 +58,8 @@
"react-native-svg-transformer": "^0.12.1",
"react-native-touch-id": "^4.4.1",
"react-native-udp": "2.6.1",
"react-native-webview-bridge": "git+https://github.com/status-im/react-native-webview-bridge.git#community-webview",
"react-native-webview": "^6.11.1",
"react-native-webview-bridge": "git+https://github.com/status-im/react-native-webview-bridge.git#fix/community-webview",
"react-navigation": "^3.11.0",
"string_decoder": "0.10.31",
"text-encoding": "^0.6.4",
Expand Down
1,154 changes: 395 additions & 759 deletions mobile_files/yarn.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
(defn fs [] (js/require "react-native-fs"))
(defn http-bridge [] (js/require "react-native-http-bridge"))
(defn keychain [] (js/require "react-native-keychain"))
(def qr-code (js-require/js-require "qrcode"))
(def qr-code (js/require "qrcode"))
(def react-native (js/require "react-native"))
(defn status-keycard [] (js/require "react-native-status-keycard"))
(defn webview-bridge [] (js/require "react-native-webview-bridge"))
Expand Down
22 changes: 11 additions & 11 deletions src/status_im/ui/components/camera.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@

(defn default-camera [] (.-RNCamera (js-dependencies/camera)))

; (defn constants [t]
; (-> (default-camera)
; (object/get "Constants")
; (object/get t)
; (js->clj)
; (walk/keywordize-keys)))
(defn constants [t]
(-> (default-camera)
(object/get "Constants")
(object/get t)
(js->clj)
(walk/keywordize-keys)))

; (def aspects (constants "Orientation"))
; (def capture-targets (constants "CaptureTarget"))
;(def torch-modes (constants "FlashMode"))
(def aspects (constants "Orientation"))
(def capture-targets (constants "CaptureTarget"))
(def torch-modes (constants "FlashMode"))

; (defn set-torch [state]
; (set! (.-flashMode (default-camera)) (get torch-modes state)))
(defn set-torch [state]
(set! (.-flashMode (default-camera)) (get torch-modes state)))

(defn request-access-ios [then else]
(-> (.checkVideoAuthorizationStatus (default-camera))
Expand Down
4 changes: 2 additions & 2 deletions src/status_im/ui/screens/profile/photo_capture/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[status-im.ui.components.icons.vector-icons :as icons]))

(defn image-captured [data]
(let [path (.-path data)
(let [path (.-uri data)
_ (log/debug "Captured image: " path)
on-success (fn [base64]
(log/debug "Captured success: " base64)
Expand All @@ -39,7 +39,7 @@
[react/view styles/button
[react/touchable-highlight {:on-press (fn []
(let [camera @camera-ref]
(-> (.capture camera)
(-> (.takePictureAsync camera)
(.then image-captured)
(.catch #(log/debug "Error capturing image: " %)))))}
[react/view
Expand Down
1 change: 0 additions & 1 deletion src/status_im/ui/screens/qr_scanner/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
(do (reset! barcode-read? true)
(on-barcode-read identifier %))))
:ref #(reset! camera-initialized? true)
:captureAudio false
:style styles/barcode-scanner}])
[react/view styles/rectangle-container
[react/view styles/rectangle
Expand Down
2 changes: 0 additions & 2 deletions src/status_im/ui/screens/wallet/choose_recipient/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@
[react/with-activity-indicator
{}
[camera/camera {:style styles/preview
:aspect :fill
:captureAudio false
;:torchMode (camera/set-torch camera-flashlight)
:onBarCodeRead #(when-not @read-once?
(reset! read-once? true)
Expand Down

0 comments on commit fd0dfeb

Please sign in to comment.