From f109e4872ccb68c983a8d1fafeda6b97df3bae3e Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Sun, 12 Aug 2018 11:34:32 +0100 Subject: [PATCH] Use redux-persist-filesystem-storage engine due to AsyncStorage size limitation on Android --- app/package-lock.json | 37 +++++++++++++++++++ app/package.json | 2 + app/src/index.js | 24 ++++++------ .../lbry/build/templates/build.tmpl.gradle | 12 ++++++ .../lbry/build/templates/settings.tmpl.gradle | 2 + .../java/io/lbry/browser/MainActivity.java | 2 + 6 files changed, 66 insertions(+), 13 deletions(-) diff --git a/app/package-lock.json b/app/package-lock.json index 038cb751..61801120 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -2076,6 +2076,11 @@ } } }, + "base-64": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz", + "integrity": "sha1-eAqZyE59YAJgNhURxId2E78k9rs=" + }, "base64-js": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", @@ -5175,6 +5180,30 @@ "react-native-drawer-layout": "1.3.2" } }, + "react-native-fetch-blob": { + "version": "0.10.8", + "resolved": "https://registry.npmjs.org/react-native-fetch-blob/-/react-native-fetch-blob-0.10.8.tgz", + "integrity": "sha1-T8JWq64MtfEOfEHyjBGz/zMNcqk=", + "requires": { + "base-64": "0.1.0", + "glob": "7.0.6" + }, + "dependencies": { + "glob": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.0.6.tgz", + "integrity": "sha1-IRuvr0nlJbjNkyYNFKsTYVKz9Xo=", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.2", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } + } + }, "react-native-image-pan-zoom": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/react-native-image-pan-zoom/-/react-native-image-pan-zoom-2.1.3.tgz", @@ -5364,6 +5393,14 @@ "lodash-es": "^4.17.4" } }, + "redux-persist-filesystem-storage": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/redux-persist-filesystem-storage/-/redux-persist-filesystem-storage-1.2.0.tgz", + "integrity": "sha512-cFenkZN9h29WaerxmnHamc7EW1+voYE9H3iAJYI6JMWcnFJGue+RYjxYCoHk9B4LWVfYAkmiBsz3oTAA7NIcAQ==", + "requires": { + "react-native-fetch-blob": "^0.10.0" + } + }, "redux-persist-transform-compress": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/redux-persist-transform-compress/-/redux-persist-transform-compress-4.2.0.tgz", diff --git a/app/package.json b/app/package.json index ed29a78d..16f2b6b2 100644 --- a/app/package.json +++ b/app/package.json @@ -10,6 +10,7 @@ "moment": "^2.22.1", "react": "16.2.0", "react-native": "0.55.3", + "react-native-fetch-blob": "^0.10.8", "react-native-image-zoom-viewer": "^2.2.5", "react-native-vector-icons": "^5.0.0", "react-native-video": "lbryio/react-native-video#exoplayer-lbry-android", @@ -19,6 +20,7 @@ "redux": "^3.6.0", "redux-logger": "3.0.6", "redux-persist": "^4.8.0", + "redux-persist-filesystem-storage": "^1.2.0", "redux-persist-transform-compress": "^4.2.0", "redux-persist-transform-filter": "0.0.10", "redux-thunk": "^2.2.0" diff --git a/app/src/index.js b/app/src/index.js index 8e3f74ef..4a2c93b5 100644 --- a/app/src/index.js +++ b/app/src/index.js @@ -1,6 +1,5 @@ import React from 'react'; import { Provider, connect } from 'react-redux'; -import DiscoverPage from './page/discover'; import { AppRegistry, AppState, @@ -9,16 +8,6 @@ import { View, NativeModules } from 'react-native'; -import { createStore, applyMiddleware, compose, combineReducers } from 'redux'; -import { - StackNavigator, addNavigationHelpers -} from 'react-navigation'; -import { AppNavigator } from './component/AppNavigator'; -import AppWithNavigationState from './component/AppNavigator'; -import { persistStore, autoRehydrate } from 'redux-persist'; -import createCompressor from 'redux-persist-transform-compress'; -import createFilter from 'redux-persist-transform-filter'; -import thunk from 'redux-thunk'; import { Lbry, claimsReducer, @@ -28,9 +17,18 @@ import { searchReducer, walletReducer } from 'lbry-redux'; +import { createStore, applyMiddleware, compose, combineReducers } from 'redux'; +import { StackNavigator, addNavigationHelpers } from 'react-navigation'; +import { AppNavigator } from './component/AppNavigator'; +import { persistStore, autoRehydrate } from 'redux-persist'; +import { reactNavigationMiddleware } from './utils/redux'; +import AppWithNavigationState from './component/AppNavigator'; +import FilesystemStorage from 'redux-persist-filesystem-storage'; +import createCompressor from 'redux-persist-transform-compress'; +import createFilter from 'redux-persist-transform-filter'; +import thunk from 'redux-thunk'; import settingsReducer from './redux/reducers/settings'; import moment from 'moment'; -import { reactNavigationMiddleware } from './utils/redux'; function isFunction(object) { return typeof object === 'function'; @@ -106,7 +104,7 @@ const persistOptions = { // read the data transforms: [saveClaimsFilter, subscriptionsFilter, settingsFilter, walletFilter, compressor], debounce: 10000, - storage: AsyncStorage + storage: FilesystemStorage }; persistStore(store, persistOptions, err => { diff --git a/p4a/pythonforandroid/bootstraps/lbry/build/templates/build.tmpl.gradle b/p4a/pythonforandroid/bootstraps/lbry/build/templates/build.tmpl.gradle index 67bba558..acb74d2a 100644 --- a/p4a/pythonforandroid/bootstraps/lbry/build/templates/build.tmpl.gradle +++ b/p4a/pythonforandroid/bootstraps/lbry/build/templates/build.tmpl.gradle @@ -68,8 +68,20 @@ android { } } +subprojects { + afterEvaluate {project -> + if (project.hasProperty("android")) { + android { + compileSdkVersion {{ android_api }} + buildToolsVersion '{{ build_tools_version }}' + } + } + } +} + dependencies { compile project(':react-native-video') + compile project(':react-native-fetch-blob') {%- for aar in aars %} compile(name: '{{ aar }}', ext: 'aar') {%- endfor -%} diff --git a/p4a/pythonforandroid/bootstraps/lbry/build/templates/settings.tmpl.gradle b/p4a/pythonforandroid/bootstraps/lbry/build/templates/settings.tmpl.gradle index c566f677..33372a15 100644 --- a/p4a/pythonforandroid/bootstraps/lbry/build/templates/settings.tmpl.gradle +++ b/p4a/pythonforandroid/bootstraps/lbry/build/templates/settings.tmpl.gradle @@ -1,3 +1,5 @@ rootProject.name = 'browser' include ':react-native-video' project(':react-native-video').projectDir = new File(rootProject.projectDir, './react/node_modules/react-native-video/android-exoplayer') +include ':react-native-fetch-blob' +project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir, './react/node_modules/react-native-fetch-blob/android') diff --git a/src/main/java/io/lbry/browser/MainActivity.java b/src/main/java/io/lbry/browser/MainActivity.java index 3095cba3..9bca57bf 100644 --- a/src/main/java/io/lbry/browser/MainActivity.java +++ b/src/main/java/io/lbry/browser/MainActivity.java @@ -23,6 +23,7 @@ import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; import com.facebook.react.ReactRootView; import com.facebook.react.ReactInstanceManager; import com.facebook.react.shell.MainReactPackage; +import com.RNFetchBlob.RNFetchBlobPackage; import io.lbry.browser.reactpackages.LbryReactPackage; import io.lbry.browser.reactmodules.DownloadManagerModule; @@ -88,6 +89,7 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand .setJSMainModulePath("index") .addPackage(new MainReactPackage()) .addPackage(new ReactVideoPackage()) + .addPackage(new RNFetchBlobPackage()) .addPackage(new LbryReactPackage()) .setUseDeveloperSupport(true) .setInitialLifecycleState(LifecycleState.RESUMED)