Replaced paste.ee export with Android file sharing#2
Open
mkf wants to merge 26 commits intokapware:masterfrom
Open
Replaced paste.ee export with Android file sharing#2mkf wants to merge 26 commits intokapware:masterfrom
mkf wants to merge 26 commits intokapware:masterfrom
Conversation
…-native-file-opener yet
…ortant apps like GDrive or GMail
kapware
reviewed
Aug 1, 2017
src/auricle/ui.cljs
Outdated
| (.catch #(js/console.log (str "err " (pr-str %))))))) | ||
| (def esteban-share (js/require "react-native-share")) | ||
| (defn share-filepath [] (.open esteban-share (clj->js {:url (str "file://" the-file-path) | ||
| ;;:type "text/plain" |
src/auricle/ui.cljs
Outdated
| (defn a-share-button [text-on on-press-func speakers] | ||
| [touchable-highlight {:on-press #(on-press-func speakers)} | ||
| [text {:style {:padding 10 :background-color "#999999" :margin-bottom 10}} text-on]]) | ||
| (defn write-to-file-and-share-button [speakers] (a-share-button "Export" write-to-file-and-share speakers)) |
Owner
There was a problem hiding this comment.
Consider renaming to share-button.
src/auricle/ui.cljs
Outdated
| ;;:message "This is the file" | ||
| }))) | ||
| (def write-to-file-and-share (write-to-file-fn share-filepath)) | ||
| (defn a-share-button [text-on on-press-func speakers] |
src/auricle/ui.cljs
Outdated
| (defn write-to-file-fn [what-then-fn] | ||
| (fn write-to-file [speakers] (-> speakers | ||
| rnfs-write-to-file | ||
| (.then #(do (js/console.log (str "suc " (pr-str %) "|" the-file-path)) |
Owner
There was a problem hiding this comment.
Remove console log(s) or wrap it with goog.debug flag.
kapware
reviewed
Aug 2, 2017
src/auricle/ui.cljs
Outdated
| (def RNFS (js/require "react-native-fs")) | ||
| (def what-platform (keyword (str (.-OS (.-Platform ReactNative))))) | ||
| (def the-relative-file-path "auricle-saved.txt") | ||
| (def the-file-path (str (case what-platform ;;.-DocumentDirectoryPath |
src/auricle/ui.cljs
Outdated
| (str "There was an error writing to file: " e | ||
| " →the path: " the-file-path) | ||
| (clj->js | ||
| [{:text "Too bad" :onPress #(do)}]))) |
Owner
There was a problem hiding this comment.
Why do you even need :onPress here? Alert button wouldn't be enough?
src/auricle/ui.cljs
Outdated
| :android (.-ExternalDirectoryPath RNFS) | ||
| :ios (.-LibraryDirectoryPath RNFS)) "/" the-relative-file-path)) | ||
| (defn rnfs-write-to-file [speakers] (.writeFile RNFS the-file-path (str speakers) "utf8")) | ||
| (defn alert-about-write-failed [e] (.alert (.-Alert ReactNative) |
Owner
There was a problem hiding this comment.
Alerts are typically used in the app, consider abstracting it out in a convenient function.
| (def esteban-share (js/require "react-native-share")) | ||
| (defn share-filepath [] (.open esteban-share | ||
| (clj->js {:url (str "file://" the-file-path) | ||
| ;;maybe setting :title or :subject (not :message) would prevent crashes |
Owner
There was a problem hiding this comment.
Consider removing redundant comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.