Skip to content

Commit

Permalink
Keep screen awake on controller and editor screens
Browse files Browse the repository at this point in the history
  • Loading branch information
experiment322 committed Mar 10, 2019
1 parent c0389c9 commit c6f1ebf
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 7 deletions.
1 change: 1 addition & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -30,6 +31,7 @@ protected List<ReactPackage> getPackages() {
return Arrays.asList(
new MainReactPackage(),
new SvgPackage(),
new KCKeepAwakePackage(),
new VectorIconsPackage(),
new OrientationPackage(),
new RNGestureHandlerPackage(),
Expand Down
3 changes: 3 additions & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
3 changes: 3 additions & 0 deletions js/interface/screens/ControllerScreen.jsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -18,6 +19,7 @@ class ControllerScreen extends React.Component {
};

componentDidMount() {
KeepAwake.activate();
StatusBar.setHidden(true);
Orientation.lockToLandscape();
}
Expand All @@ -27,6 +29,7 @@ class ControllerScreen extends React.Component {
navigation.getParam('socketClose')();
Orientation.unlockAllOrientations();
StatusBar.setHidden(false);
KeepAwake.deactivate();
}

render() {
Expand Down
3 changes: 3 additions & 0 deletions js/interface/screens/EditorScreen.jsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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')]) });
Expand All @@ -67,6 +69,7 @@ class EditorScreen extends React.Component {
createLayout(navigation.getParam('editedLayout'), layout);
Orientation.unlockAllOrientations();
StatusBar.setHidden(false);
KeepAwake.deactivate();
}

openComponentPicker = () => {
Expand Down
11 changes: 8 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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",
Expand Down
11 changes: 8 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit c6f1ebf

Please sign in to comment.