Skip to content

Commit

Permalink
{N} 7
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Sep 16, 2020
1 parent 3110f07 commit e8f55c6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -10,6 +10,8 @@
[twitter-image]:https://img.shields.io/twitter/follow/eddyverbruggen.svg?style=social&label=Follow%20me
[twitter-url]:https://twitter.com/eddyverbruggen

> 💡 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.
## Demo app (Angular)
This plugin is part of the [plugin showcase app](https://github.com/EddyVerbruggen/nativescript-pluginshowcase/tree/master/app/ar) I built using Angular.

Expand Down
15 changes: 6 additions & 9 deletions insomnia.android.js
@@ -1,21 +1,19 @@
var app = require("@nativescript/core/application");
var core = require("@nativescript/core");

exports.keepAwake = function () {
var keepScreenOn = function () {
var activity = app.android.foregroundActivity || app.android.startActivity;
var activity = core.Application.android.foregroundActivity || core.Application.android.startActivity;
var window = activity.getWindow();
window.addFlags(
android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
);
window.addFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
};

return new Promise(function (resolve, reject) {
try {
if (app.android.foregroundActivity || app.android.startActivity) {
if (core.Application.android.foregroundActivity || core.Application.android.startActivity) {
keepScreenOn();
resolve();
} else {
app.android.on("activityStarted", function (args) {
core.Application.android.on("activityStarted", function (args) {
keepScreenOn();
resolve();
});
Expand All @@ -30,8 +28,7 @@ exports.keepAwake = function () {
exports.allowSleepAgain = function () {
return new Promise(function (resolve, reject) {
try {
var activity =
app.android.foregroundActivity || app.android.startActivity;
var activity = core.Application.android.foregroundActivity || core.Application.android.startActivity;
var window = activity.getWindow();
window.clearFlags(
android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
Expand Down
6 changes: 3 additions & 3 deletions package.json
@@ -1,13 +1,13 @@
{
"name": "nativescript-insomnia",
"version": "1.2.3",
"version": "2.0.0",
"description": "Make the screen not dim (and eventually lock the device) while Insomnia is active",
"main": "insomnia",
"typings": "index.d.ts",
"nativescript": {
"platforms": {
"ios": "2.3.0",
"android": "2.3.0"
"ios": "7.0.0",
"android": "7.0.0"
}
},
"repository": {
Expand Down

0 comments on commit e8f55c6

Please sign in to comment.