Skip to content

Commit e8f55c6

Browse files
{N} 7
1 parent 3110f07 commit e8f55c6

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
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)
1416
This plugin is part of the [plugin showcase app](https://github.com/EddyVerbruggen/nativescript-pluginshowcase/tree/master/app/ar) I built using Angular.
1517

insomnia.android.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
var app = require("@nativescript/core/application");
1+
var core = require("@nativescript/core");
22

33
exports.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 () {
3028
exports.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

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
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": {

0 commit comments

Comments
 (0)