diff --git a/android/app/build.gradle b/android/app/build.gradle index 2030907..b2ae42d 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -146,6 +146,7 @@ android { dependencies { implementation project(':react-native-svg') + implementation project(':react-native-keep-awake') implementation project(':react-native-vector-icons') implementation project(':react-native-splash-screen') implementation project(':react-native-gesture-handler') diff --git a/android/app/src/main/java/com/controlloid/MainApplication.java b/android/app/src/main/java/com/controlloid/MainApplication.java index 320a1c0..f4081ec 100644 --- a/android/app/src/main/java/com/controlloid/MainApplication.java +++ b/android/app/src/main/java/com/controlloid/MainApplication.java @@ -2,6 +2,7 @@ import android.app.Application; +import com.corbt.keepawake.KCKeepAwakePackage; import com.facebook.react.ReactApplication; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; @@ -30,6 +31,7 @@ protected List getPackages() { return Arrays.asList( new MainReactPackage(), new SvgPackage(), + new KCKeepAwakePackage(), new VectorIconsPackage(), new OrientationPackage(), new RNGestureHandlerPackage(), diff --git a/android/settings.gradle b/android/settings.gradle index a0d9ada..fcf466a 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -3,6 +3,9 @@ rootProject.name = 'Controlloid' include ':react-native-svg' project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android') +include ':react-native-keep-awake' +project(':react-native-keep-awake').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-keep-awake/android') + include ':react-native-vector-icons' project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android') diff --git a/js/interface/screens/ControllerScreen.jsx b/js/interface/screens/ControllerScreen.jsx index 7da0e15..1413f4b 100644 --- a/js/interface/screens/ControllerScreen.jsx +++ b/js/interface/screens/ControllerScreen.jsx @@ -1,4 +1,5 @@ import React from 'react'; +import KeepAwake from 'react-native-keep-awake'; import Orientation from 'react-native-orientation-locker'; import { connect } from 'react-redux'; import { StatusBar } from 'react-native'; @@ -18,6 +19,7 @@ class ControllerScreen extends React.Component { }; componentDidMount() { + KeepAwake.activate(); StatusBar.setHidden(true); Orientation.lockToLandscape(); } @@ -27,6 +29,7 @@ class ControllerScreen extends React.Component { navigation.getParam('socketClose')(); Orientation.unlockAllOrientations(); StatusBar.setHidden(false); + KeepAwake.deactivate(); } render() { diff --git a/js/interface/screens/EditorScreen.jsx b/js/interface/screens/EditorScreen.jsx index 89c6143..26e4a33 100644 --- a/js/interface/screens/EditorScreen.jsx +++ b/js/interface/screens/EditorScreen.jsx @@ -1,5 +1,6 @@ import _ from 'lodash'; import React from 'react'; +import KeepAwake from 'react-native-keep-awake'; import Orientation from 'react-native-orientation-locker'; import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons'; import { connect } from 'react-redux'; @@ -56,6 +57,7 @@ class EditorScreen extends React.Component { componentDidMount() { const { layouts, navigation } = this.props; + KeepAwake.activate(); StatusBar.setHidden(true); Orientation.lockToLandscape(); this.setState({ layout: _.cloneDeep(layouts[navigation.getParam('editedLayout')]) }); @@ -67,6 +69,7 @@ class EditorScreen extends React.Component { createLayout(navigation.getParam('editedLayout'), layout); Orientation.unlockAllOrientations(); StatusBar.setHidden(false); + KeepAwake.deactivate(); } openComponentPicker = () => { diff --git a/package-lock.json b/package-lock.json index 9a579f3..fd88645 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2389,9 +2389,9 @@ "dev": true }, "@types/node": { - "version": "11.10.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-11.10.5.tgz", - "integrity": "sha512-DuIRlQbX4K+d5I+GMnv+UfnGh+ist0RdlvOp+JZ7ePJ6KQONCFQv/gKYSU1ZzbVdFSUCKZOltjmpFAGGv5MdYA==", + "version": "11.11.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-11.11.0.tgz", + "integrity": "sha512-D5Rt+HXgEywr3RQJcGlZUCTCx1qVbCZpVk3/tOOA6spLNZdGm8BU+zRgdRYDoF1pO3RuXLxADzMrF903JlQXqg==", "dev": true }, "@types/stack-utils": { @@ -10857,6 +10857,11 @@ "prop-types": "^15.5.10" } }, + "react-native-keep-awake": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/react-native-keep-awake/-/react-native-keep-awake-4.0.0.tgz", + "integrity": "sha512-0Fotox+eLXQooeibVs3P60yASYUWjtRw9MZNmbuHt5UZQrgUrAKsE4jm7gTr4tPU1m1RkwGzcgUFpcOkh/ec7g==" + }, "react-native-orientation-locker": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/react-native-orientation-locker/-/react-native-orientation-locker-1.1.3.tgz", diff --git a/package.json b/package.json index 1cc7618..a1a3c4d 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "version": "1.0.0-beta.1", "private": true, "scripts": { - "start": "node node_modules/react-native/local-cli/cli.js start", "test": "jest", + "start": "node node_modules/react-native/local-cli/cli.js start", "postversion": "react-native-version --target android" }, "dependencies": { @@ -14,6 +14,7 @@ "react": "16.6.3", "react-native": "0.58.6", "react-native-gesture-handler": "^1.1.0", + "react-native-keep-awake": "^4.0.0", "react-native-orientation-locker": "^1.1.3", "react-native-paper": "^2.12.0", "react-native-splash-screen": "^3.2.0", diff --git a/yarn.lock b/yarn.lock index 2436b11..b0b368e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -865,9 +865,9 @@ integrity sha512-ohkhb9LehJy+PA40rDtGAji61NCgdtKLAlFoYp4cnuuQEswwdK3vz9SOIkkyc3wrk8dzjphQApNs56yyXLStaQ== "@types/node@*": - version "11.10.5" - resolved "https://registry.yarnpkg.com/@types/node/-/node-11.10.5.tgz#fbaca34086bdc118011e1f05c47688d432f2d571" - integrity sha512-DuIRlQbX4K+d5I+GMnv+UfnGh+ist0RdlvOp+JZ7ePJ6KQONCFQv/gKYSU1ZzbVdFSUCKZOltjmpFAGGv5MdYA== + version "11.11.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-11.11.0.tgz#070e9ce7c90e727aca0e0c14e470f9a93ffe9390" + integrity sha512-D5Rt+HXgEywr3RQJcGlZUCTCx1qVbCZpVk3/tOOA6spLNZdGm8BU+zRgdRYDoF1pO3RuXLxADzMrF903JlQXqg== "@types/stack-utils@^1.0.1": version "1.0.1" @@ -5493,6 +5493,11 @@ react-native-gesture-handler@~1.0.14: invariant "^2.2.2" prop-types "^15.5.10" +react-native-keep-awake@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/react-native-keep-awake/-/react-native-keep-awake-4.0.0.tgz#d89fdc3fb60b3cffa979ef37dc5816196df998a2" + integrity sha512-0Fotox+eLXQooeibVs3P60yASYUWjtRw9MZNmbuHt5UZQrgUrAKsE4jm7gTr4tPU1m1RkwGzcgUFpcOkh/ec7g== + react-native-orientation-locker@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/react-native-orientation-locker/-/react-native-orientation-locker-1.1.3.tgz#c57a31181f0aa53256c8f6bddb76a175975b22db"