File tree 3 files changed +11
-12
lines changed
3 files changed +11
-12
lines changed Original file line number Diff line number Diff line change 10
10
[ twitter-image ] :https://img.shields.io/twitter/follow/eddyverbruggen.svg?style=social&label=Follow%20me
11
11
[ twitter-url ] :https://twitter.com/eddyverbruggen
12
12
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
+
13
15
## Demo app (Angular)
14
16
This plugin is part of the [ plugin showcase app] ( https://github.com/EddyVerbruggen/nativescript-pluginshowcase/tree/master/app/ar ) I built using Angular.
15
17
Original file line number Diff line number Diff line change 1
- var app = require ( "@nativescript/core/application " ) ;
1
+ var core = require ( "@nativescript/core" ) ;
2
2
3
3
exports . keepAwake = function ( ) {
4
4
var keepScreenOn = function ( ) {
5
- var activity = app . android . foregroundActivity || app . android . startActivity ;
5
+ var activity = core . Application . android . foregroundActivity || core . Application . android . startActivity ;
6
6
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 ) ;
10
8
} ;
11
9
12
10
return new Promise ( function ( resolve , reject ) {
13
11
try {
14
- if ( app . android . foregroundActivity || app . android . startActivity ) {
12
+ if ( core . Application . android . foregroundActivity || core . Application . android . startActivity ) {
15
13
keepScreenOn ( ) ;
16
14
resolve ( ) ;
17
15
} else {
18
- app . android . on ( "activityStarted" , function ( args ) {
16
+ core . Application . android . on ( "activityStarted" , function ( args ) {
19
17
keepScreenOn ( ) ;
20
18
resolve ( ) ;
21
19
} ) ;
@@ -30,8 +28,7 @@ exports.keepAwake = function () {
30
28
exports . allowSleepAgain = function ( ) {
31
29
return new Promise ( function ( resolve , reject ) {
32
30
try {
33
- var activity =
34
- app . android . foregroundActivity || app . android . startActivity ;
31
+ var activity = core . Application . android . foregroundActivity || core . Application . android . startActivity ;
35
32
var window = activity . getWindow ( ) ;
36
33
window . clearFlags (
37
34
android . view . WindowManager . LayoutParams . FLAG_KEEP_SCREEN_ON
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " nativescript-insomnia" ,
3
- "version" : " 1.2.3 " ,
3
+ "version" : " 2.0.0 " ,
4
4
"description" : " Make the screen not dim (and eventually lock the device) while Insomnia is active" ,
5
5
"main" : " insomnia" ,
6
6
"typings" : " index.d.ts" ,
7
7
"nativescript" : {
8
8
"platforms" : {
9
- "ios" : " 2.3 .0" ,
10
- "android" : " 2.3 .0"
9
+ "ios" : " 7.0 .0" ,
10
+ "android" : " 7.0 .0"
11
11
}
12
12
},
13
13
"repository" : {
You can’t perform that action at this time.
0 commit comments