Skip to content

Commit

Permalink
feat(power-management): add power management support (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
ihadeed committed Aug 27, 2016
1 parent 00d87db commit cd82a53
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import { OneSignal } from './plugins/onesignal';
import { PhotoViewer } from './plugins/photo-viewer';
import { ScreenOrientation } from './plugins/screen-orientation';
import { PinDialog } from './plugins/pin-dialog';
import { PowerManagement } from './plugins/power-management';
import { Printer } from './plugins/printer';
import { Push } from './plugins/push';
import { SafariViewController } from './plugins/safari-view-controller';
Expand Down Expand Up @@ -178,6 +179,7 @@ OneSignal,
PhotoViewer,
ScreenOrientation,
PinDialog,
PowerManagement,
Screenshot,
SecureStorage,
Shake,
Expand Down Expand Up @@ -266,6 +268,7 @@ window['IonicNative'] = {
PhotoViewer: PhotoViewer,
ScreenOrientation: ScreenOrientation,
PinDialog: PinDialog,
PowerManagement: PowerManagement,
SafariViewController: SafariViewController,
Screenshot: Screenshot,
SecureStorage: SecureStorage,
Expand Down
49 changes: 49 additions & 0 deletions src/plugins/power-management.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import {Plugin, Cordova} from './plugin';
/**
* @name PowerManagement
* @description
* The PowerManagement plugin offers access to the devices power-management functionality.
* It should be used for applications which keep running for a long time without any user interaction.
*
* @usage
* ```
* import {PowerManagement} from 'ionic-native';
*
* PowerManagement.acquire()
* .then(onSuccess)
* .catch(onError);
*
* ```
*/
@Plugin({
plugin: 'cordova-plugin-powermanagement-orig',
pluginRef: 'https://github.com/Viras-/cordova-plugin-powermanagement',
repo: 'powerManagement'
})
export class PowerManagement {
/**
* Acquire a wakelock by calling this.
*/
@Cordova()
static acquire(): Promise<any> {return; }

/**
* This acquires a partial wakelock, allowing the screen to be dimmed.
*/
@Cordova()
static dim(): Promise<any> {return; }

/**
* Release the wakelock. It's important to do this when you're finished with the wakelock, to avoid unnecessary battery drain.
*/
@Cordova()
static release(): Promise<any> {return; }

/**
* By default, the plugin will automatically release a wakelock when your app is paused (e.g. when the screen is turned off, or the user switches to another app).
* It will reacquire the wakelock upon app resume. If you would prefer to disable this behaviour, you can use this function.
* @param set {boolean}
*/
@Cordova()
static setReleaseOnPause(set: boolean): Promise<any> {return; }
}

0 comments on commit cd82a53

Please sign in to comment.