Skip to content

aborovsky/phonegap-plugin-brightness

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 

Repository files navigation

phonegap-plugin-brightness

A phonegap 3.x plugin for brightness control within android and ios. Also recently I have added the function for keep screen on.

Installing

You may use phonegap CLI as follows:

➜ phonegap local plugin add https://github.com/fiscal-cliff/phonegap-plugin-brightness.git
[phonegap] adding the plugin: https://github.com/fiscal-cliff/phonegap-plugin-brightness.git
[phonegap] successfully added the plugin

Using

The code below can be placed into script tag.

		document.addEventListener('deviceready', onDeviceReady);
		function onDeviceReady() {
			window.brightness = cordova.require("cordova.plugin.Brightness.Brightness");
		}
		function setBrightness(value) {
			// value should be float in range from 0 to 1.
			brightness.setBrightness(value, win, fail);
		}
		function getBrightness() {
			// win([-1,0-1]) float 0-1 is a brightness level, -1 represents a system default
			brightness.getBrightness( win, fail);
		}
		function win(status) {
			alert('Message: ' + status);
		}
		function fail(status) {
			alert('Error: ' + status);
		}

You may also prevent a sleep (or keep screen on).

		// prevents sleep
		brightness.setKeepScreenOn(true);
		// returns normal behavior
		pluginService.brightness.setKeepScreenOn(false);

How to build for build.phonegap.com

Modify your config.xml to include the following tag:

<plugin spec="https://github.com/fiscal-cliff/phonegap-plugin-brightness.git" source="git" />

About

A phonegap 3.x plugin for brightness control within android and ios

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 66.1%
  • Objective-C 23.8%
  • JavaScript 10.1%