From 34f355563413b2c37f1ea7e105f3640181b92689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Fri, 28 Jul 2017 15:37:50 +0200 Subject: [PATCH 01/26] Introducing share button, we have errors, incl "At least one of message,url" --- src/auricle/events.cljs | 11 +++++++++++ src/auricle/ui.cljs | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/src/auricle/events.cljs b/src/auricle/events.cljs index 8ffa22c..2fdc89e 100644 --- a/src/auricle/events.cljs +++ b/src/auricle/events.cljs @@ -10,6 +10,9 @@ [day8.re-frame.http-fx] [auricle.async-storage-fx :as async-storage-fx])) +(def ReactNative (js/require "react-native")) +(def share-class (r/adapt-react-class (.-Share ReactNative))) +(defn share [content] (.share share-class content {})) ;; -- Interceptors ------------------------------------------------------------ ;; @@ -134,6 +137,14 @@ (fn [db [_ new-name]] (assoc db :api-key-input new-name))) +(reg-event-fx + :share-data + validate-spec + (fn + [{:keys [db]} [_]] + {:db (assoc db :sharing-status-whatever (share {:message (str (:speakers db))})) + })) + (reg-event-fx :export-data validate-spec diff --git a/src/auricle/ui.cljs b/src/auricle/ui.cljs index 5ecfecf..72d2f44 100644 --- a/src/auricle/ui.cljs +++ b/src/auricle/ui.cljs @@ -74,6 +74,10 @@ [touchable-highlight {:on-press #(dispatch [:export-data])} [text {:style {:padding 10 :background-color "#FFDD67" :margin-bottom 10} } "Export to Paste.ee"]]) +(defn share-button [] + [touchable-highlight {:on-press #(dispatch [:share-data])} + [text {:style {:padding 10 :background-color "#999999" :margin-bottom 10}} "Share with sharing"]]) + (defn new-speaker [] (let [speakers (subscribe [:speakers]) api-key (subscribe [:api-key])] @@ -86,6 +90,7 @@ :autoCorrect false :style {:flex 1}}] [speaker-list @speakers] + (share-button) (if-not @api-key [view {:flex 1 :flex-direction "row"} [text-input {:onChangeText #(dispatch [:api-key-input-changed %]) From 49cbfbd3c11c277c11f5ab8f91dbffd66e47fd20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Fri, 28 Jul 2017 15:47:07 +0200 Subject: [PATCH 02/26] share-button react square brackets, string: Share-~ with sharing~ --- src/auricle/ui.cljs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/auricle/ui.cljs b/src/auricle/ui.cljs index 72d2f44..4d6c6a3 100644 --- a/src/auricle/ui.cljs +++ b/src/auricle/ui.cljs @@ -76,7 +76,7 @@ (defn share-button [] [touchable-highlight {:on-press #(dispatch [:share-data])} - [text {:style {:padding 10 :background-color "#999999" :margin-bottom 10}} "Share with sharing"]]) + [text {:style {:padding 10 :background-color "#999999" :margin-bottom 10}} "Share"]]) (defn new-speaker [] (let [speakers (subscribe [:speakers]) @@ -90,7 +90,7 @@ :autoCorrect false :style {:flex 1}}] [speaker-list @speakers] - (share-button) + [share-button] (if-not @api-key [view {:flex 1 :flex-direction "row"} [text-input {:onChangeText #(dispatch [:api-key-input-changed %]) From 82ea7bedcb45abfffabe012d98c097f5825024f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Fri, 28 Jul 2017 16:34:38 +0200 Subject: [PATCH 03/26] properly referred to adapt-react-class in share-class --- src/auricle/events.cljs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/auricle/events.cljs b/src/auricle/events.cljs index 2fdc89e..607ddac 100644 --- a/src/auricle/events.cljs +++ b/src/auricle/events.cljs @@ -1,5 +1,6 @@ (ns auricle.events (:require + [reagent.core :refer [adapt-react-class]] [re-frame.core :as r :refer [reg-event-db after reg-event-fx dispatch]] [cljs.spec.alpha :as s] [auricle.db :as db :refer [app-db]] @@ -11,7 +12,7 @@ [auricle.async-storage-fx :as async-storage-fx])) (def ReactNative (js/require "react-native")) -(def share-class (r/adapt-react-class (.-Share ReactNative))) +(def share-class (adapt-react-class (.-Share ReactNative))) (defn share [content] (.share share-class content {})) ;; -- Interceptors ------------------------------------------------------------ From 79dc171e5fee3617c18c0733220fa05667bd546a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Fri, 28 Jul 2017 16:38:45 +0200 Subject: [PATCH 04/26] Unwrapped adapt-react-class Share --- src/auricle/events.cljs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/auricle/events.cljs b/src/auricle/events.cljs index 607ddac..44566e7 100644 --- a/src/auricle/events.cljs +++ b/src/auricle/events.cljs @@ -1,6 +1,5 @@ (ns auricle.events (:require - [reagent.core :refer [adapt-react-class]] [re-frame.core :as r :refer [reg-event-db after reg-event-fx dispatch]] [cljs.spec.alpha :as s] [auricle.db :as db :refer [app-db]] @@ -12,7 +11,7 @@ [auricle.async-storage-fx :as async-storage-fx])) (def ReactNative (js/require "react-native")) -(def share-class (adapt-react-class (.-Share ReactNative))) +(def share-class (.-Share ReactNative)) (defn share [content] (.share share-class content {})) ;; -- Interceptors ------------------------------------------------------------ From b7c61daa0fe4bc0ab807119bb27e9c68c75470a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Fri, 28 Jul 2017 17:05:40 +0200 Subject: [PATCH 05/26] Moved share to ui --- src/auricle/events.cljs | 11 ----------- src/auricle/ui.cljs | 10 +++++++--- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/auricle/events.cljs b/src/auricle/events.cljs index 44566e7..074dae4 100644 --- a/src/auricle/events.cljs +++ b/src/auricle/events.cljs @@ -10,10 +10,6 @@ [day8.re-frame.http-fx] [auricle.async-storage-fx :as async-storage-fx])) -(def ReactNative (js/require "react-native")) -(def share-class (.-Share ReactNative)) -(defn share [content] (.share share-class content {})) - ;; -- Interceptors ------------------------------------------------------------ ;; ;; See https://github.com/Day8/re-frame/blob/master/docs/Interceptors.md @@ -137,13 +133,6 @@ (fn [db [_ new-name]] (assoc db :api-key-input new-name))) -(reg-event-fx - :share-data - validate-spec - (fn - [{:keys [db]} [_]] - {:db (assoc db :sharing-status-whatever (share {:message (str (:speakers db))})) - })) (reg-event-fx :export-data diff --git a/src/auricle/ui.cljs b/src/auricle/ui.cljs index 4d6c6a3..1f87fa3 100644 --- a/src/auricle/ui.cljs +++ b/src/auricle/ui.cljs @@ -74,8 +74,12 @@ [touchable-highlight {:on-press #(dispatch [:export-data])} [text {:style {:padding 10 :background-color "#FFDD67" :margin-bottom 10} } "Export to Paste.ee"]]) -(defn share-button [] - [touchable-highlight {:on-press #(dispatch [:share-data])} +(def share-class (.-Share ReactNative)) +(defn share [content] (.share share-class content {})) +(defn share-speakers [speakers] (share {:message (str speakers)})) + +(defn share-button [speakers] + [touchable-highlight {:on-press #(share-speakers speakers)} [text {:style {:padding 10 :background-color "#999999" :margin-bottom 10}} "Share"]]) (defn new-speaker [] @@ -90,7 +94,7 @@ :autoCorrect false :style {:flex 1}}] [speaker-list @speakers] - [share-button] + [share-button @speakers] (if-not @api-key [view {:flex 1 :flex-direction "row"} [text-input {:onChangeText #(dispatch [:api-key-input-changed %]) From a8a31c091dbc1f954b674ca2e7ef06c260a24f98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Fri, 28 Jul 2017 17:10:19 +0200 Subject: [PATCH 06/26] share: clj->js content --- src/auricle/ui.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auricle/ui.cljs b/src/auricle/ui.cljs index 1f87fa3..03ff45f 100644 --- a/src/auricle/ui.cljs +++ b/src/auricle/ui.cljs @@ -75,7 +75,7 @@ [text {:style {:padding 10 :background-color "#FFDD67" :margin-bottom 10} } "Export to Paste.ee"]]) (def share-class (.-Share ReactNative)) -(defn share [content] (.share share-class content {})) +(defn share [content] (.share share-class (clj->js content) {})) (defn share-speakers [speakers] (share {:message (str speakers)})) (defn share-button [speakers] From 1677d7d5a242fb0e7ae775d8531fc3f2d1d42038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Mon, 31 Jul 2017 13:53:54 +0200 Subject: [PATCH 07/26] Added react-native-fs --- android/app/build.gradle | 1 + .../java/com/auricle/MainApplication.java | 4 +- android/settings.gradle | 2 + ios/auricle.xcodeproj/project.pbxproj | 24 +++++++++- package.json | 45 ++++++++++--------- 5 files changed, 51 insertions(+), 25 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 529c5ac..3b5427a 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -131,6 +131,7 @@ android { } dependencies { + compile project(':react-native-fs') compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:23.0.1" compile "com.facebook.react:react-native:+" // From node_modules diff --git a/android/app/src/main/java/com/auricle/MainApplication.java b/android/app/src/main/java/com/auricle/MainApplication.java index 8aac811..b06d462 100644 --- a/android/app/src/main/java/com/auricle/MainApplication.java +++ b/android/app/src/main/java/com/auricle/MainApplication.java @@ -3,6 +3,7 @@ import android.app.Application; import com.facebook.react.ReactApplication; +import com.rnfs.RNFSPackage; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; @@ -22,7 +23,8 @@ public boolean getUseDeveloperSupport() { @Override protected List getPackages() { return Arrays.asList( - new MainReactPackage() + new MainReactPackage(), + new RNFSPackage() ); } }; diff --git a/android/settings.gradle b/android/settings.gradle index db3d6ff..2f01d80 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,3 +1,5 @@ rootProject.name = 'auricle' +include ':react-native-fs' +project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android') include ':app' diff --git a/ios/auricle.xcodeproj/project.pbxproj b/ios/auricle.xcodeproj/project.pbxproj index 604d85b..8767fdc 100644 --- a/ios/auricle.xcodeproj/project.pbxproj +++ b/ios/auricle.xcodeproj/project.pbxproj @@ -5,7 +5,6 @@ }; objectVersion = 46; objects = { - /* Begin PBXBuildFile section */ 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; }; 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; }; @@ -22,6 +21,7 @@ 146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; 5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; }; 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; + B0314355B1B543DE84BD37CA /* libRNFS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 905F022AC5954080A6F57D3A /* libRNFS.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -224,6 +224,8 @@ 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = ""; }; 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; }; 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; }; + 1CD3E61BDF09456FAF06EECE /* RNFS.xcodeproj */ = {isa = PBXFileReference; name = "RNFS.xcodeproj"; path = "../node_modules/react-native-fs/RNFS.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; + 905F022AC5954080A6F57D3A /* libRNFS.a */ = {isa = PBXFileReference; name = "libRNFS.a"; path = "libRNFS.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -242,6 +244,7 @@ 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */, 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */, 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */, + B0314355B1B543DE84BD37CA /* libRNFS.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -386,6 +389,7 @@ 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */, 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */, 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */, + 1CD3E61BDF09456FAF06EECE /* RNFS.xcodeproj */, ); name = Libraries; sourceTree = ""; @@ -446,7 +450,7 @@ 83CBB9F71A601CBA00E9B192 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0610; + LastUpgradeCheck = 610; ORGANIZATIONNAME = Facebook; TargetAttributes = { 13B07F861A680F5B00A75B9A = { @@ -767,6 +771,14 @@ PRODUCT_NAME = auricle; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/auricle\"", + ); + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)/../node_modules/react-native-fs/**", + ); }; name = Debug; }; @@ -786,6 +798,14 @@ PRODUCT_NAME = auricle; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/auricle\"", + ); + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)/../node_modules/react-native-fs/**", + ); }; name = Release; }; diff --git a/package.json b/package.json index d1799cd..837da0d 100644 --- a/package.json +++ b/package.json @@ -1,23 +1,24 @@ { - "name": "auricle", - "version": "0.0.1", - "private": true, - "scripts": { - "start": "node node_modules/react-native/local-cli/cli.js start", - "test": "jest" - }, - "dependencies": { - "babel-plugin-transform-es2015-block-scoping": "6.15.0", - "react": "16.0.0-alpha.12", - "react-native": "0.46.1" - }, - "devDependencies": { - "babel-jest": "20.0.3", - "babel-preset-react-native": "2.1.0", - "jest": "20.0.4", - "react-test-renderer": "16.0.0-alpha.12" - }, - "jest": { - "preset": "react-native" - } -} \ No newline at end of file + "name": "auricle", + "version": "0.0.1", + "private": true, + "scripts": { + "start": "node node_modules/react-native/local-cli/cli.js start", + "test": "jest" + }, + "dependencies": { + "babel-plugin-transform-es2015-block-scoping": "6.15.0", + "react": "16.0.0-alpha.12", + "react-native": "0.46.1", + "react-native-fs": "^2.3.3" + }, + "devDependencies": { + "babel-jest": "20.0.3", + "babel-preset-react-native": "2.1.0", + "jest": "20.0.4", + "react-test-renderer": "16.0.0-alpha.12" + }, + "jest": { + "preset": "react-native" + } +} From 34e175d85484c002fdd24b32c84dc6c6e8c64497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Mon, 31 Jul 2017 14:55:36 +0200 Subject: [PATCH 08/26] Added react-native-fs to .re-natal modules --- .re-natal | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.re-natal b/.re-natal index f98c607..20b485f 100644 --- a/.re-natal +++ b/.re-natal @@ -5,7 +5,9 @@ "dev": "env/dev", "prod": "env/prod" }, - "modules": [], + "modules": [ + "react-native-fs" + ], "imageDirs": [ "images" ], From 7a7adeb1673e1133eec7c009c0bdb4f40cf78bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Mon, 31 Jul 2017 15:32:54 +0200 Subject: [PATCH 09/26] Added Write to file button with its functionality without using react-native-file-opener yet --- src/auricle/ui.cljs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/auricle/ui.cljs b/src/auricle/ui.cljs index 03ff45f..12f10ab 100644 --- a/src/auricle/ui.cljs +++ b/src/auricle/ui.cljs @@ -78,9 +78,21 @@ (defn share [content] (.share share-class (clj->js content) {})) (defn share-speakers [speakers] (share {:message (str speakers)})) -(defn share-button [speakers] - [touchable-highlight {:on-press #(share-speakers speakers)} - [text {:style {:padding 10 :background-color "#999999" :margin-bottom 10}} "Share"]]) +(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 share-button [speakers] (a-share-button "Share msg" share-speakers speakers)) + +(def RNFS (js/require "react-native-fs")) +(def the-file-path (str (.-DocumentDirectoryPath RNFS) "/thefilepath.txt")) +(defn rnfs-write-to-file [speakers] (.writeFile RNFS the-file-path (str speakers) "utf8")) +(defn write-to-file [speakers] (-> speakers + rnfs-write-to-file + (.then #(js/console.log (str "suc " (pr-str %)))) + (.catch #(js/console.log (str "err " (pr-str %)))))) + +(defn write-to-file-button [speakers] (a-share-button "Write to file" write-to-file speakers)) (defn new-speaker [] (let [speakers (subscribe [:speakers]) @@ -94,7 +106,9 @@ :autoCorrect false :style {:flex 1}}] [speaker-list @speakers] - [share-button @speakers] + [view {:flex 1 :flex-direction "row" :justify-content "space-between"} + [share-button @speakers] + [write-to-file-button @speakers]] (if-not @api-key [view {:flex 1 :flex-direction "row"} [text-input {:onChangeText #(dispatch [:api-key-input-changed %]) From 3475cbf135676e28bfa176c7fc901ae2f46379e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Mon, 31 Jul 2017 15:45:05 +0200 Subject: [PATCH 10/26] Added react-native-file-opener --- .re-natal | 3 ++- android/app/build.gradle | 1 + .../app/src/main/java/com/auricle/MainApplication.java | 2 ++ android/settings.gradle | 2 ++ ios/auricle.xcodeproj/project.pbxproj | 9 +++++++++ package.json | 1 + 6 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.re-natal b/.re-natal index 20b485f..8074378 100644 --- a/.re-natal +++ b/.re-natal @@ -6,7 +6,8 @@ "prod": "env/prod" }, "modules": [ - "react-native-fs" + "react-native-fs", + "react-native-file-opener" ], "imageDirs": [ "images" diff --git a/android/app/build.gradle b/android/app/build.gradle index 3b5427a..26dd834 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -131,6 +131,7 @@ android { } dependencies { + compile project(':react-native-file-opener') compile project(':react-native-fs') compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:23.0.1" diff --git a/android/app/src/main/java/com/auricle/MainApplication.java b/android/app/src/main/java/com/auricle/MainApplication.java index b06d462..e913d11 100644 --- a/android/app/src/main/java/com/auricle/MainApplication.java +++ b/android/app/src/main/java/com/auricle/MainApplication.java @@ -3,6 +3,7 @@ import android.app.Application; import com.facebook.react.ReactApplication; +import com.fileopener.FileOpenerPackage; import com.rnfs.RNFSPackage; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; @@ -24,6 +25,7 @@ public boolean getUseDeveloperSupport() { protected List getPackages() { return Arrays.asList( new MainReactPackage(), + new FileOpenerPackage(), new RNFSPackage() ); } diff --git a/android/settings.gradle b/android/settings.gradle index 2f01d80..9b9c77e 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,4 +1,6 @@ rootProject.name = 'auricle' +include ':react-native-file-opener' +project(':react-native-file-opener').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-file-opener/android') include ':react-native-fs' project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android') diff --git a/ios/auricle.xcodeproj/project.pbxproj b/ios/auricle.xcodeproj/project.pbxproj index 8767fdc..9b92c72 100644 --- a/ios/auricle.xcodeproj/project.pbxproj +++ b/ios/auricle.xcodeproj/project.pbxproj @@ -22,6 +22,7 @@ 5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; }; 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; B0314355B1B543DE84BD37CA /* libRNFS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 905F022AC5954080A6F57D3A /* libRNFS.a */; }; + 5D27088B9FEC4B67B653FF2E /* libRNFileOpener.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C81A53B17B14784A6FA1693 /* libRNFileOpener.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -226,6 +227,8 @@ 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; }; 1CD3E61BDF09456FAF06EECE /* RNFS.xcodeproj */ = {isa = PBXFileReference; name = "RNFS.xcodeproj"; path = "../node_modules/react-native-fs/RNFS.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; 905F022AC5954080A6F57D3A /* libRNFS.a */ = {isa = PBXFileReference; name = "libRNFS.a"; path = "libRNFS.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; + F0C062B9A31A46A5964A72D9 /* RNFileOpener.xcodeproj */ = {isa = PBXFileReference; name = "RNFileOpener.xcodeproj"; path = "../node_modules/react-native-file-opener/ios/RNFileOpener.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; + 8C81A53B17B14784A6FA1693 /* libRNFileOpener.a */ = {isa = PBXFileReference; name = "libRNFileOpener.a"; path = "libRNFileOpener.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -245,6 +248,7 @@ 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */, 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */, B0314355B1B543DE84BD37CA /* libRNFS.a in Frameworks */, + 5D27088B9FEC4B67B653FF2E /* libRNFileOpener.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -390,6 +394,7 @@ 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */, 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */, 1CD3E61BDF09456FAF06EECE /* RNFS.xcodeproj */, + F0C062B9A31A46A5964A72D9 /* RNFileOpener.xcodeproj */, ); name = Libraries; sourceTree = ""; @@ -774,10 +779,12 @@ LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/auricle\"", + "\"$(SRCROOT)/auricle\"", ); HEADER_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../node_modules/react-native-fs/**", + "$(SRCROOT)/../node_modules/react-native-file-opener/ios/RNFileOpener", ); }; name = Debug; @@ -801,10 +808,12 @@ LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/auricle\"", + "\"$(SRCROOT)/auricle\"", ); HEADER_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../node_modules/react-native-fs/**", + "$(SRCROOT)/../node_modules/react-native-file-opener/ios/RNFileOpener", ); }; name = Release; diff --git a/package.json b/package.json index 837da0d..8de67b0 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "babel-plugin-transform-es2015-block-scoping": "6.15.0", "react": "16.0.0-alpha.12", "react-native": "0.46.1", + "react-native-file-opener": "^0.2.0", "react-native-fs": "^2.3.3" }, "devDependencies": { From 4ea5965027627ac462c22bb9744c8d712be12ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Mon, 31 Jul 2017 16:09:28 +0200 Subject: [PATCH 11/26] Added file opening --- src/auricle/ui.cljs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/auricle/ui.cljs b/src/auricle/ui.cljs index 12f10ab..770f31b 100644 --- a/src/auricle/ui.cljs +++ b/src/auricle/ui.cljs @@ -85,11 +85,18 @@ (defn share-button [speakers] (a-share-button "Share msg" share-speakers speakers)) (def RNFS (js/require "react-native-fs")) -(def the-file-path (str (.-DocumentDirectoryPath RNFS) "/thefilepath.txt")) +(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 + :android (.-ExternalDirectoryPath RNFS) + :ios (.-LibraryDirectoryPath RNFS)) "/" the-relative-file-path)) (defn rnfs-write-to-file [speakers] (.writeFile RNFS the-file-path (str speakers) "utf8")) +(def rn-file-opener (js/require "react-native-file-opener")) +(defn open-opener [] (.open rn-file-opener the-file-path "text/plain")) (defn write-to-file [speakers] (-> speakers rnfs-write-to-file - (.then #(js/console.log (str "suc " (pr-str %)))) + (.then #(do (js/console.log (str "suc " (pr-str %))) + (open-opener))) (.catch #(js/console.log (str "err " (pr-str %)))))) (defn write-to-file-button [speakers] (a-share-button "Write to file" write-to-file speakers)) From bb6116c2bb1538813c2ebdfbbb8f28bc4f4bac6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Mon, 31 Jul 2017 16:58:57 +0200 Subject: [PATCH 12/26] Added file sharing which doesn't work (at least on Android) --- src/auricle/ui.cljs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/auricle/ui.cljs b/src/auricle/ui.cljs index 770f31b..e9ed120 100644 --- a/src/auricle/ui.cljs +++ b/src/auricle/ui.cljs @@ -93,13 +93,17 @@ (defn rnfs-write-to-file [speakers] (.writeFile RNFS the-file-path (str speakers) "utf8")) (def rn-file-opener (js/require "react-native-file-opener")) (defn open-opener [] (.open rn-file-opener the-file-path "text/plain")) -(defn write-to-file [speakers] (-> speakers +(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 %))) - (open-opener))) - (.catch #(js/console.log (str "err " (pr-str %)))))) - -(defn write-to-file-button [speakers] (a-share-button "Write to file" write-to-file speakers)) + (.then #(do (js/console.log (str "suc " (pr-str %) "|" the-file-path)) + (what-then-fn))) + (.catch #(js/console.log (str "err " (pr-str %))))))) +(def write-to-file-and-open (write-to-file-fn open-opener)) +(defn write-to-file-and-open-button [speakers] (a-share-button "Write to file &open" write-to-file-and-open speakers)) +(defn share-filepath [] (share {:url the-file-path})) +(def write-to-file-and-share (write-to-file-fn share-filepath)) +(defn write-to-file-and-share-button [speakers] (a-share-button "Write to file &share" write-to-file-and-share speakers)) (defn new-speaker [] (let [speakers (subscribe [:speakers]) @@ -115,7 +119,8 @@ [speaker-list @speakers] [view {:flex 1 :flex-direction "row" :justify-content "space-between"} [share-button @speakers] - [write-to-file-button @speakers]] + [write-to-file-and-open-button @speakers] + [write-to-file-and-share-button @speakers]] (if-not @api-key [view {:flex 1 :flex-direction "row"} [text-input {:onChangeText #(dispatch [:api-key-input-changed %]) From 2a6801c407b97ffee3eb49ba16cbfbd61306da00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Mon, 31 Jul 2017 17:18:02 +0200 Subject: [PATCH 13/26] Added react-native-share --- android/app/build.gradle | 1 + .../app/src/main/java/com/auricle/MainApplication.java | 2 ++ android/settings.gradle | 2 ++ ios/auricle.xcodeproj/project.pbxproj | 9 +++++++++ package.json | 3 ++- 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 26dd834..ea875ae 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -131,6 +131,7 @@ android { } dependencies { + compile project(':react-native-share') compile project(':react-native-file-opener') compile project(':react-native-fs') compile fileTree(dir: "libs", include: ["*.jar"]) diff --git a/android/app/src/main/java/com/auricle/MainApplication.java b/android/app/src/main/java/com/auricle/MainApplication.java index e913d11..ca29f92 100644 --- a/android/app/src/main/java/com/auricle/MainApplication.java +++ b/android/app/src/main/java/com/auricle/MainApplication.java @@ -3,6 +3,7 @@ import android.app.Application; import com.facebook.react.ReactApplication; +import cl.json.RNSharePackage; import com.fileopener.FileOpenerPackage; import com.rnfs.RNFSPackage; import com.facebook.react.ReactNativeHost; @@ -25,6 +26,7 @@ public boolean getUseDeveloperSupport() { protected List getPackages() { return Arrays.asList( new MainReactPackage(), + new RNSharePackage(), new FileOpenerPackage(), new RNFSPackage() ); diff --git a/android/settings.gradle b/android/settings.gradle index 9b9c77e..7e8f43d 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,4 +1,6 @@ rootProject.name = 'auricle' +include ':react-native-share' +project(':react-native-share').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-share/android') include ':react-native-file-opener' project(':react-native-file-opener').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-file-opener/android') include ':react-native-fs' diff --git a/ios/auricle.xcodeproj/project.pbxproj b/ios/auricle.xcodeproj/project.pbxproj index 9b92c72..dd05b8f 100644 --- a/ios/auricle.xcodeproj/project.pbxproj +++ b/ios/auricle.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; B0314355B1B543DE84BD37CA /* libRNFS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 905F022AC5954080A6F57D3A /* libRNFS.a */; }; 5D27088B9FEC4B67B653FF2E /* libRNFileOpener.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C81A53B17B14784A6FA1693 /* libRNFileOpener.a */; }; + 904A0798CB1B4D9EA0D492AC /* libRNShare.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4F79A6A13FE9439B9A907FB8 /* libRNShare.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -229,6 +230,8 @@ 905F022AC5954080A6F57D3A /* libRNFS.a */ = {isa = PBXFileReference; name = "libRNFS.a"; path = "libRNFS.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; F0C062B9A31A46A5964A72D9 /* RNFileOpener.xcodeproj */ = {isa = PBXFileReference; name = "RNFileOpener.xcodeproj"; path = "../node_modules/react-native-file-opener/ios/RNFileOpener.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; 8C81A53B17B14784A6FA1693 /* libRNFileOpener.a */ = {isa = PBXFileReference; name = "libRNFileOpener.a"; path = "libRNFileOpener.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; + AE36A50852844F9AA3CD5FEA /* RNShare.xcodeproj */ = {isa = PBXFileReference; name = "RNShare.xcodeproj"; path = "../node_modules/react-native-share/ios/RNShare.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; + 4F79A6A13FE9439B9A907FB8 /* libRNShare.a */ = {isa = PBXFileReference; name = "libRNShare.a"; path = "libRNShare.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -249,6 +252,7 @@ 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */, B0314355B1B543DE84BD37CA /* libRNFS.a in Frameworks */, 5D27088B9FEC4B67B653FF2E /* libRNFileOpener.a in Frameworks */, + 904A0798CB1B4D9EA0D492AC /* libRNShare.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -395,6 +399,7 @@ 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */, 1CD3E61BDF09456FAF06EECE /* RNFS.xcodeproj */, F0C062B9A31A46A5964A72D9 /* RNFileOpener.xcodeproj */, + AE36A50852844F9AA3CD5FEA /* RNShare.xcodeproj */, ); name = Libraries; sourceTree = ""; @@ -780,11 +785,13 @@ "$(inherited)", "\"$(SRCROOT)/auricle\"", "\"$(SRCROOT)/auricle\"", + "\"$(SRCROOT)/auricle\"", ); HEADER_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../node_modules/react-native-fs/**", "$(SRCROOT)/../node_modules/react-native-file-opener/ios/RNFileOpener", + "$(SRCROOT)/../node_modules/react-native-share/ios", ); }; name = Debug; @@ -809,11 +816,13 @@ "$(inherited)", "\"$(SRCROOT)/auricle\"", "\"$(SRCROOT)/auricle\"", + "\"$(SRCROOT)/auricle\"", ); HEADER_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../node_modules/react-native-fs/**", "$(SRCROOT)/../node_modules/react-native-file-opener/ios/RNFileOpener", + "$(SRCROOT)/../node_modules/react-native-share/ios", ); }; name = Release; diff --git a/package.json b/package.json index 8de67b0..8c58ece 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "react": "16.0.0-alpha.12", "react-native": "0.46.1", "react-native-file-opener": "^0.2.0", - "react-native-fs": "^2.3.3" + "react-native-fs": "^2.3.3", + "react-native-share": "^1.0.20" }, "devDependencies": { "babel-jest": "20.0.3", From a147d86df9cd1519404b37de601f83f62a9f0483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Mon, 31 Jul 2017 17:25:21 +0200 Subject: [PATCH 14/26] Added react-native-share to .re-natal --- .re-natal | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.re-natal b/.re-natal index 8074378..eb00268 100644 --- a/.re-natal +++ b/.re-natal @@ -7,7 +7,8 @@ }, "modules": [ "react-native-fs", - "react-native-file-opener" + "react-native-file-opener", + "react-native-share" ], "imageDirs": [ "images" From ab3abd3d5ba85a5c6989b1d23d0cc4c92d4f68f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Mon, 31 Jul 2017 17:53:07 +0200 Subject: [PATCH 15/26] Added file sharing which works, at least on Android with the most important apps like GDrive or GMail --- src/auricle/ui.cljs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/auricle/ui.cljs b/src/auricle/ui.cljs index e9ed120..9e15d46 100644 --- a/src/auricle/ui.cljs +++ b/src/auricle/ui.cljs @@ -101,7 +101,13 @@ (.catch #(js/console.log (str "err " (pr-str %))))))) (def write-to-file-and-open (write-to-file-fn open-opener)) (defn write-to-file-and-open-button [speakers] (a-share-button "Write to file &open" write-to-file-and-open speakers)) -(defn share-filepath [] (share {:url the-file-path})) +(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" + ;;:title "Auricle saved data" + ;;:subject "Auricle saved data" + ;;:message "This is the file" + }))) (def write-to-file-and-share (write-to-file-fn share-filepath)) (defn write-to-file-and-share-button [speakers] (a-share-button "Write to file &share" write-to-file-and-share speakers)) From f14ed31f4062876d131ad8eba4579f58f5403cec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Mon, 31 Jul 2017 19:15:23 +0200 Subject: [PATCH 16/26] Removed paste.ee export and everything related --- src/auricle/events.cljs | 51 ----------------------------------------- src/auricle/subs.cljs | 4 ---- src/auricle/ui.cljs | 18 ++------------- 3 files changed, 2 insertions(+), 71 deletions(-) diff --git a/src/auricle/events.cljs b/src/auricle/events.cljs index 074dae4..3184817 100644 --- a/src/auricle/events.cljs +++ b/src/auricle/events.cljs @@ -118,54 +118,3 @@ validate-spec (fn [db [_ reason]] (assoc db :fail reason))) - -(reg-event-fx - :save-api-key - validate-spec - (fn [{:keys [db]} [_]] - (let [api-key (:api-key-input db)] - {:db (assoc db :api-key api-key) - :async-storage-fx/set-item (format-item :api-key api-key)}))) - -(reg-event-db - :api-key-input-changed - validate-spec - (fn [db [_ new-name]] - (assoc db :api-key-input new-name))) - - -(reg-event-fx - :export-data - validate-spec - (fn - [{:keys [db]} [_]] - {:db (assoc db :loading true) - :http-xhrio {:method :post - :uri "https://api.paste.ee/v1/pastes" - :timeout 10000 - :format (ajax/json-request-format) - :response-format (ajax/json-response-format {:keywords? true}) - :params {:key (:api-key db) - :description "Auricle export" - :sections [{:name "Speakers" - :contents (str (:speakers db))}]} - :on-failure [:export-data-failure] - :on-success [:export-data-success]}})) - - -(reg-event-db - :export-data-failure - validate-spec - (fn [db [_ reason]] - (assoc db :export-fail reason - :loading false))) - - -(reg-event-db - :export-data-success - validate-spec - (fn [db [_ response]] - (assoc db :export-success response - :loading false))) - - diff --git a/src/auricle/subs.cljs b/src/auricle/subs.cljs index 8de999e..6d927af 100644 --- a/src/auricle/subs.cljs +++ b/src/auricle/subs.cljs @@ -42,7 +42,3 @@ (fn [db _] (:next-time db))) -(reg-sub - :api-key - (fn [db _] - (:api-key db))) diff --git a/src/auricle/ui.cljs b/src/auricle/ui.cljs index 9e15d46..f3882d5 100644 --- a/src/auricle/ui.cljs +++ b/src/auricle/ui.cljs @@ -70,10 +70,6 @@ :render-row #(r/as-element [speaker-item %]) :enableEmptySections true}]) -(defn export-button [] - [touchable-highlight {:on-press #(dispatch [:export-data])} - [text {:style {:padding 10 :background-color "#FFDD67" :margin-bottom 10} } "Export to Paste.ee"]]) - (def share-class (.-Share ReactNative)) (defn share [content] (.share share-class (clj->js content) {})) (defn share-speakers [speakers] (share {:message (str speakers)})) @@ -112,8 +108,7 @@ (defn write-to-file-and-share-button [speakers] (a-share-button "Write to file &share" write-to-file-and-share speakers)) (defn new-speaker [] - (let [speakers (subscribe [:speakers]) - api-key (subscribe [:api-key])] + (let [speakers (subscribe [:speakers])] (fn [] [view {:style {:flex 1 :flex-direction "column" :justify-content "space-between" :align-items "stretch" :margin-left 20 :margin-right 20}} [text-input {:onChangeText #(dispatch [:speaker-input-changed %]) @@ -127,16 +122,7 @@ [share-button @speakers] [write-to-file-and-open-button @speakers] [write-to-file-and-share-button @speakers]] - (if-not @api-key - [view {:flex 1 :flex-direction "row"} - [text-input {:onChangeText #(dispatch [:api-key-input-changed %]) - :onSubmitEditing #(dispatch [:save-api-key]) - :placeholder "Paste.ee api key" - :autoCorrect false - :style {:flex 1}}] - [touchable-highlight {:on-press #(dispatch [:load-data :api-key])} - [text "Load api-key"]]] - [export-button])]))) + ]))) (defn pages [] (let [current-speaker (subscribe [:current-speaker]) From eefcdca96c778ff3a0b3de58795aa9610e6089b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Mon, 31 Jul 2017 19:17:37 +0200 Subject: [PATCH 17/26] Removed Write file & open --- src/auricle/ui.cljs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/auricle/ui.cljs b/src/auricle/ui.cljs index f3882d5..6ba40da 100644 --- a/src/auricle/ui.cljs +++ b/src/auricle/ui.cljs @@ -87,16 +87,12 @@ :android (.-ExternalDirectoryPath RNFS) :ios (.-LibraryDirectoryPath RNFS)) "/" the-relative-file-path)) (defn rnfs-write-to-file [speakers] (.writeFile RNFS the-file-path (str speakers) "utf8")) -(def rn-file-opener (js/require "react-native-file-opener")) -(defn open-opener [] (.open rn-file-opener the-file-path "text/plain")) (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)) (what-then-fn))) (.catch #(js/console.log (str "err " (pr-str %))))))) -(def write-to-file-and-open (write-to-file-fn open-opener)) -(defn write-to-file-and-open-button [speakers] (a-share-button "Write to file &open" write-to-file-and-open speakers)) (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" @@ -120,7 +116,6 @@ [speaker-list @speakers] [view {:flex 1 :flex-direction "row" :justify-content "space-between"} [share-button @speakers] - [write-to-file-and-open-button @speakers] [write-to-file-and-share-button @speakers]] ]))) From a762acc1bc691be2a4316864fbc6bf3e6b34e530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Mon, 31 Jul 2017 19:27:41 +0200 Subject: [PATCH 18/26] Removed react-native-file-opener --- .re-natal | 1 - android/app/build.gradle | 1 - .../app/src/main/java/com/auricle/MainApplication.java | 2 -- android/settings.gradle | 2 -- ios/auricle.xcodeproj/project.pbxproj | 9 --------- package.json | 1 - 6 files changed, 16 deletions(-) diff --git a/.re-natal b/.re-natal index eb00268..622d497 100644 --- a/.re-natal +++ b/.re-natal @@ -7,7 +7,6 @@ }, "modules": [ "react-native-fs", - "react-native-file-opener", "react-native-share" ], "imageDirs": [ diff --git a/android/app/build.gradle b/android/app/build.gradle index ea875ae..03cdb10 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -132,7 +132,6 @@ android { dependencies { compile project(':react-native-share') - compile project(':react-native-file-opener') compile project(':react-native-fs') compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:23.0.1" diff --git a/android/app/src/main/java/com/auricle/MainApplication.java b/android/app/src/main/java/com/auricle/MainApplication.java index ca29f92..e7ba03f 100644 --- a/android/app/src/main/java/com/auricle/MainApplication.java +++ b/android/app/src/main/java/com/auricle/MainApplication.java @@ -4,7 +4,6 @@ import com.facebook.react.ReactApplication; import cl.json.RNSharePackage; -import com.fileopener.FileOpenerPackage; import com.rnfs.RNFSPackage; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; @@ -27,7 +26,6 @@ protected List getPackages() { return Arrays.asList( new MainReactPackage(), new RNSharePackage(), - new FileOpenerPackage(), new RNFSPackage() ); } diff --git a/android/settings.gradle b/android/settings.gradle index 7e8f43d..63b076c 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,8 +1,6 @@ rootProject.name = 'auricle' include ':react-native-share' project(':react-native-share').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-share/android') -include ':react-native-file-opener' -project(':react-native-file-opener').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-file-opener/android') include ':react-native-fs' project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android') diff --git a/ios/auricle.xcodeproj/project.pbxproj b/ios/auricle.xcodeproj/project.pbxproj index dd05b8f..566accf 100644 --- a/ios/auricle.xcodeproj/project.pbxproj +++ b/ios/auricle.xcodeproj/project.pbxproj @@ -22,7 +22,6 @@ 5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; }; 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; B0314355B1B543DE84BD37CA /* libRNFS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 905F022AC5954080A6F57D3A /* libRNFS.a */; }; - 5D27088B9FEC4B67B653FF2E /* libRNFileOpener.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C81A53B17B14784A6FA1693 /* libRNFileOpener.a */; }; 904A0798CB1B4D9EA0D492AC /* libRNShare.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4F79A6A13FE9439B9A907FB8 /* libRNShare.a */; }; /* End PBXBuildFile section */ @@ -228,8 +227,6 @@ 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; }; 1CD3E61BDF09456FAF06EECE /* RNFS.xcodeproj */ = {isa = PBXFileReference; name = "RNFS.xcodeproj"; path = "../node_modules/react-native-fs/RNFS.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; 905F022AC5954080A6F57D3A /* libRNFS.a */ = {isa = PBXFileReference; name = "libRNFS.a"; path = "libRNFS.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; - F0C062B9A31A46A5964A72D9 /* RNFileOpener.xcodeproj */ = {isa = PBXFileReference; name = "RNFileOpener.xcodeproj"; path = "../node_modules/react-native-file-opener/ios/RNFileOpener.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; - 8C81A53B17B14784A6FA1693 /* libRNFileOpener.a */ = {isa = PBXFileReference; name = "libRNFileOpener.a"; path = "libRNFileOpener.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; AE36A50852844F9AA3CD5FEA /* RNShare.xcodeproj */ = {isa = PBXFileReference; name = "RNShare.xcodeproj"; path = "../node_modules/react-native-share/ios/RNShare.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; 4F79A6A13FE9439B9A907FB8 /* libRNShare.a */ = {isa = PBXFileReference; name = "libRNShare.a"; path = "libRNShare.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; /* End PBXFileReference section */ @@ -251,7 +248,6 @@ 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */, 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */, B0314355B1B543DE84BD37CA /* libRNFS.a in Frameworks */, - 5D27088B9FEC4B67B653FF2E /* libRNFileOpener.a in Frameworks */, 904A0798CB1B4D9EA0D492AC /* libRNShare.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -398,7 +394,6 @@ 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */, 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */, 1CD3E61BDF09456FAF06EECE /* RNFS.xcodeproj */, - F0C062B9A31A46A5964A72D9 /* RNFileOpener.xcodeproj */, AE36A50852844F9AA3CD5FEA /* RNShare.xcodeproj */, ); name = Libraries; @@ -785,12 +780,10 @@ "$(inherited)", "\"$(SRCROOT)/auricle\"", "\"$(SRCROOT)/auricle\"", - "\"$(SRCROOT)/auricle\"", ); HEADER_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../node_modules/react-native-fs/**", - "$(SRCROOT)/../node_modules/react-native-file-opener/ios/RNFileOpener", "$(SRCROOT)/../node_modules/react-native-share/ios", ); }; @@ -816,12 +809,10 @@ "$(inherited)", "\"$(SRCROOT)/auricle\"", "\"$(SRCROOT)/auricle\"", - "\"$(SRCROOT)/auricle\"", ); HEADER_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../node_modules/react-native-fs/**", - "$(SRCROOT)/../node_modules/react-native-file-opener/ios/RNFileOpener", "$(SRCROOT)/../node_modules/react-native-share/ios", ); }; diff --git a/package.json b/package.json index 8c58ece..2ae27e4 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,6 @@ "babel-plugin-transform-es2015-block-scoping": "6.15.0", "react": "16.0.0-alpha.12", "react-native": "0.46.1", - "react-native-file-opener": "^0.2.0", "react-native-fs": "^2.3.3", "react-native-share": "^1.0.20" }, From a542ab696c0c1499bc86e9edbc3c63b52f9b3486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Mon, 31 Jul 2017 19:38:16 +0200 Subject: [PATCH 19/26] Removed msg sharing --- src/auricle/ui.cljs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/auricle/ui.cljs b/src/auricle/ui.cljs index 6ba40da..b7d9419 100644 --- a/src/auricle/ui.cljs +++ b/src/auricle/ui.cljs @@ -70,16 +70,9 @@ :render-row #(r/as-element [speaker-item %]) :enableEmptySections true}]) -(def share-class (.-Share ReactNative)) -(defn share [content] (.share share-class (clj->js content) {})) -(defn share-speakers [speakers] (share {:message (str speakers)})) - (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 share-button [speakers] (a-share-button "Share msg" share-speakers speakers)) - (def RNFS (js/require "react-native-fs")) (def what-platform (keyword (str (.-OS (.-Platform ReactNative))))) (def the-relative-file-path "auricle-saved.txt") @@ -115,7 +108,6 @@ :style {:flex 1}}] [speaker-list @speakers] [view {:flex 1 :flex-direction "row" :justify-content "space-between"} - [share-button @speakers] [write-to-file-and-share-button @speakers]] ]))) From 2b86b5ddc56f771046b17a22785c555e25304d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Mon, 31 Jul 2017 19:49:49 +0200 Subject: [PATCH 20/26] Moved a-share-button defn down to before write-to-file-and-share-button --- src/auricle/ui.cljs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/auricle/ui.cljs b/src/auricle/ui.cljs index b7d9419..23da84b 100644 --- a/src/auricle/ui.cljs +++ b/src/auricle/ui.cljs @@ -70,9 +70,6 @@ :render-row #(r/as-element [speaker-item %]) :enableEmptySections true}]) -(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]]) (def RNFS (js/require "react-native-fs")) (def what-platform (keyword (str (.-OS (.-Platform ReactNative))))) (def the-relative-file-path "auricle-saved.txt") @@ -94,6 +91,9 @@ ;;: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] + [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 "Write to file &share" write-to-file-and-share speakers)) (defn new-speaker [] From baa0972f8d92e2bd6d45707b480af91855d727b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Tue, 1 Aug 2017 13:58:08 +0200 Subject: [PATCH 21/26] =?UTF-8?q?Renamed=20button:=20"Write=20to=20file=20?= =?UTF-8?q?&share"=20=E2=86=92=20"Export"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/auricle/ui.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auricle/ui.cljs b/src/auricle/ui.cljs index 23da84b..ed8e07d 100644 --- a/src/auricle/ui.cljs +++ b/src/auricle/ui.cljs @@ -94,7 +94,7 @@ (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 "Write to file &share" write-to-file-and-share speakers)) +(defn write-to-file-and-share-button [speakers] (a-share-button "Export" write-to-file-and-share speakers)) (defn new-speaker [] (let [speakers (subscribe [:speakers])] From d4e4760c255b6e41e6f3b1d49829f8285c70f220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Tue, 1 Aug 2017 18:53:11 +0200 Subject: [PATCH 22/26] =?UTF-8?q?Replaced=20write=20console=20logging=20wi?= =?UTF-8?q?th=20catch=E2=86=92alert=20as=20I=20don't=20know=20how=20to=20u?= =?UTF-8?q?se=20goog.debug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/auricle/ui.cljs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/auricle/ui.cljs b/src/auricle/ui.cljs index ed8e07d..d677ce3 100644 --- a/src/auricle/ui.cljs +++ b/src/auricle/ui.cljs @@ -77,12 +77,17 @@ :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) + "Writing to file failed" + (str "There was an error writing to file: " e + " →the path: " the-file-path) + (clj->js + [{:text "Too bad" :onPress #(do)}]))) (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)) - (what-then-fn))) - (.catch #(js/console.log (str "err " (pr-str %))))))) + (.then (what-then-fn)) + (.catch #(alert-about-write-failed %))))) (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" From 742c1dde7adddf5ba2669fab9d0d067d8f3b3c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Tue, 1 Aug 2017 21:24:04 +0200 Subject: [PATCH 23/26] Changed the comment about :subject or :title to be more humane --- src/auricle/ui.cljs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/auricle/ui.cljs b/src/auricle/ui.cljs index d677ce3..fedb931 100644 --- a/src/auricle/ui.cljs +++ b/src/auricle/ui.cljs @@ -89,12 +89,10 @@ (.then (what-then-fn)) (.catch #(alert-about-write-failed %))))) (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" - ;;:title "Auricle saved data" - ;;:subject "Auricle saved data" - ;;:message "This is the file" - }))) +(defn share-filepath [] (.open esteban-share + (clj->js {:url (str "file://" the-file-path) + ;;maybe setting :title or :subject (not :message) would prevent crashes + }))) (def write-to-file-and-share (write-to-file-fn share-filepath)) (defn a-share-button [text-on on-press-func speakers] [touchable-highlight {:on-press #(on-press-func speakers)} From 982bef525c00e33c9dacc21d32a4f63cfb1749f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Tue, 1 Aug 2017 21:28:49 +0200 Subject: [PATCH 24/26] Renamed to share-button/3 & export-button/1; centered export button. --- src/auricle/ui.cljs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/auricle/ui.cljs b/src/auricle/ui.cljs index fedb931..89b8c23 100644 --- a/src/auricle/ui.cljs +++ b/src/auricle/ui.cljs @@ -94,10 +94,10 @@ ;;maybe setting :title or :subject (not :message) would prevent crashes }))) (def write-to-file-and-share (write-to-file-fn share-filepath)) -(defn a-share-button [text-on on-press-func speakers] +(defn 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)) +(defn export-button [speakers] (share-button "Export" write-to-file-and-share speakers)) (defn new-speaker [] (let [speakers (subscribe [:speakers])] @@ -110,8 +110,8 @@ :autoCorrect false :style {:flex 1}}] [speaker-list @speakers] - [view {:flex 1 :flex-direction "row" :justify-content "space-between"} - [write-to-file-and-share-button @speakers]] + [view {:flex 1 :flex-direction "row" :justify-content "center" :align-items "center"} + [export-button @speakers]] ]))) (defn pages [] From 1759390f556f6c5b4811b12a5c12964afa2a7d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Wed, 2 Aug 2017 12:26:56 +0200 Subject: [PATCH 25/26] Made the comment about .-DocumentDirectoryPath more humane --- src/auricle/ui.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auricle/ui.cljs b/src/auricle/ui.cljs index 89b8c23..2d13baf 100644 --- a/src/auricle/ui.cljs +++ b/src/auricle/ui.cljs @@ -73,7 +73,7 @@ (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 +(def the-file-path (str (case what-platform ;;maybe could have used .-DocumentDirectoryPath here :android (.-ExternalDirectoryPath RNFS) :ios (.-LibraryDirectoryPath RNFS)) "/" the-relative-file-path)) (defn rnfs-write-to-file [speakers] (.writeFile RNFS the-file-path (str speakers) "utf8")) From 46ee82d5b05fc901e2a32629d48afce7f0a786f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Wed, 2 Aug 2017 13:26:48 +0200 Subject: [PATCH 26/26] Abstracted out alert function --- src/auricle/ui.cljs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/auricle/ui.cljs b/src/auricle/ui.cljs index 2d13baf..6cd1032 100644 --- a/src/auricle/ui.cljs +++ b/src/auricle/ui.cljs @@ -77,12 +77,24 @@ :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) - "Writing to file failed" - (str "There was an error writing to file: " e - " →the path: " the-file-path) - (clj->js - [{:text "Too bad" :onPress #(do)}]))) +(def alert-class (.-Alert ReactNative)) +(defn alert-buttons-constructor [input] + (loop [input input] + (if (or (string? input) (map? input)) (recur [input]) + (mapv #(loop [input %] (cond (map? input) input + (string? input) {:text input})) input)))) +(defn alert + ([title message buttons] + (alert title message buttons {} )) + ([title message buttons options] + (.alert alert-class (str title) (str message) + (clj->js (alert-buttons-constructor buttons)) + (clj->js options))) + ) +(defn alert-about-write-failed [e] (alert "Writing to file failed" + (str "There was an error writing to file: " e + " →the path: " the-file-path) + "Too bad")) (defn write-to-file-fn [what-then-fn] (fn write-to-file [speakers] (-> speakers rnfs-write-to-file