File tree Expand file tree Collapse file tree 3 files changed +11
-12
lines changed
Expand file tree Collapse file tree 3 files changed +11
-12
lines changed Original file line number Diff line number Diff line change 1010[ twitter-image ] :https://img.shields.io/twitter/follow/eddyverbruggen.svg?style=social&label=Follow%20me
1111[ twitter-url ] :https://twitter.com/eddyverbruggen
1212
13+ > 💡 Plugin version 2.0.0+ is compatible with NativeScript 7+. If you need to target older NativeScript versions, please stick to plugin version 1.2.3.
14+
1315## Demo app (Angular)
1416This plugin is part of the [ plugin showcase app] ( https://github.com/EddyVerbruggen/nativescript-pluginshowcase/tree/master/app/ar ) I built using Angular.
1517
Original file line number Diff line number Diff line change 1- var app = require ( "@nativescript/core/application " ) ;
1+ var core = require ( "@nativescript/core" ) ;
22
33exports . keepAwake = function ( ) {
44 var keepScreenOn = function ( ) {
5- var activity = app . android . foregroundActivity || app . android . startActivity ;
5+ var activity = core . Application . android . foregroundActivity || core . Application . android . startActivity ;
66 var window = activity . getWindow ( ) ;
7- window . addFlags (
8- android . view . WindowManager . LayoutParams . FLAG_KEEP_SCREEN_ON
9- ) ;
7+ window . addFlags ( android . view . WindowManager . LayoutParams . FLAG_KEEP_SCREEN_ON ) ;
108 } ;
119
1210 return new Promise ( function ( resolve , reject ) {
1311 try {
14- if ( app . android . foregroundActivity || app . android . startActivity ) {
12+ if ( core . Application . android . foregroundActivity || core . Application . android . startActivity ) {
1513 keepScreenOn ( ) ;
1614 resolve ( ) ;
1715 } else {
18- app . android . on ( "activityStarted" , function ( args ) {
16+ core . Application . android . on ( "activityStarted" , function ( args ) {
1917 keepScreenOn ( ) ;
2018 resolve ( ) ;
2119 } ) ;
@@ -30,8 +28,7 @@ exports.keepAwake = function () {
3028exports . allowSleepAgain = function ( ) {
3129 return new Promise ( function ( resolve , reject ) {
3230 try {
33- var activity =
34- app . android . foregroundActivity || app . android . startActivity ;
31+ var activity = core . Application . android . foregroundActivity || core . Application . android . startActivity ;
3532 var window = activity . getWindow ( ) ;
3633 window . clearFlags (
3734 android . view . WindowManager . LayoutParams . FLAG_KEEP_SCREEN_ON
Original file line number Diff line number Diff line change 11{
22 "name" : " nativescript-insomnia" ,
3- "version" : " 1.2.3 " ,
3+ "version" : " 2.0.0 " ,
44 "description" : " Make the screen not dim (and eventually lock the device) while Insomnia is active" ,
55 "main" : " insomnia" ,
66 "typings" : " index.d.ts" ,
77 "nativescript" : {
88 "platforms" : {
9- "ios" : " 2.3 .0" ,
10- "android" : " 2.3 .0"
9+ "ios" : " 7.0 .0" ,
10+ "android" : " 7.0 .0"
1111 }
1212 },
1313 "repository" : {
You can’t perform that action at this time.
0 commit comments