[#5650] Blank page when accessing .pdf files from Android app browser

Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
Andrey Shovkoplyas 2018-12-18 12:02:02 +01:00
parent 67a47fac56
commit b4e2654b74
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
2 changed files with 18 additions and 0 deletions

View File

@ -193,6 +193,11 @@
(update-browser-option :error? true)
(update-browser-option :loading? false)))
(fx/defn handle-pdf
[_ url]
(when (and platform/android? (string/ends-with? url ".pdf"))
{:browser/show-web-browser-selection url}))
(fx/defn update-browser-on-nav-change
[cofx browser url loading? error?]
(let [options (get-in cofx [:db :browser/options])
@ -202,6 +207,7 @@
resolved-url (if resolved-ens (string/replace url (second resolved-ens) (first resolved-ens)) url)]
(fx/merge cofx
(update-browser-history browser resolved-url)
(handle-pdf url)
(resolve-url {:error? error? :resolved-url (when resolved-ens url)}))))))
(fx/defn navigation-state-changed
@ -374,3 +380,9 @@
:browser/show-browser-selection
(fn [link]
(list-selection/browse link)))
(re-frame/reg-fx
:browser/show-web-browser-selection
(fn [link]
(list-selection/browse-in-web-browser link)))

View File

@ -38,6 +38,12 @@
:action #(.openURL react/linking (http/normalize-url link))}]
:cancel-text (i18n/label :t/browsing-cancel)}))
(defn browse-in-web-browser [link]
(show {:title (i18n/label :t/browsing-title)
:options [{:label (i18n/label :t/browsing-open-in-web-browser)
:action #(.openURL react/linking (http/normalize-url link))}]
:cancel-text (i18n/label :t/browsing-cancel)}))
(defn browse-dapp [link]
(show {:title (i18n/label :t/browsing-title)
:options [{:label (i18n/label :t/browsing-open-in-status)