Giter VIP home page Giter VIP logo

cordova-glass's Introduction

##Cordova Google Glass Plugin##

This plugin modifies the Android platform in your Cordova based application with Google Glass Compatibility. At its most basic usage it will allow you to launch your application via a voice trigger. Advanced usage allows for voice prompts to be captured during the launch process and sent into the application. By default the plugin will automatically dispatch touch events ('touchstart', 'touchend' and 'touchmove') and dispatch native gesture events on the document.

###Basic Usage###

Add plugin via Node

cordova plugin add https://github.com/aphex/cordova-glass

Modify Voice Trigger located in {app}/platforms/android/res/values/glass.xml

<string name="app_launch_voice_trigger">hello cordova</string>

###Voice Trigger Prompt###

A Voice Trigger prompt allows your application to ask the user for voice input before the application launches. An example of what this might sound like could be

  • 'Ok Glass' (wake up glass for voice input)
  • 'Open movie search' (launch your movie search application)
  • 'Goodfellas' (capture a voice trigger prompt from the user)

To use first uncomment the following line from {app}/platforms/android/res/xml/app_launch_voice_trigger.xml

<input prompt="@string/app_launch_voice_prompt"/>

Then modify Voice Trigger Prompt located in {app}/platforms/android/res/values/glass.xml

<string name="app_launch_voice_prompt">prompt question</string>

After your application has received a 'deviceready' event you will be able to retrieve the input from the user as shown in the follow where 'results' is a array.

rossgerbasi.glass.getLaunchParams(
	function(results) {
		console.log(results);
	},
	function () {
		console.log("Error getting launch Params");
	}
);

###Native Gestures### Add an event listener to the document of your web application

document.addEventListener('swiperight', 
	function() {
		console.log('Got that Swipe Right');
	}
);

For example to exit your application on swipe down you can use the following

document.addEventListener('swipedown', function() {
	if(navigator && navigator.app) {
		navigator.app.exitApp();
	} else {
		console.log("Exiting Application");
	}
})

####Basic Events####

  • tap
  • longpress
  • swipeup
  • swipedown
  • swipeleft
  • swiperight
  • twotap
  • twolongpress
  • twoswipeup
  • twoswipedown
  • twoswipeleft
  • twoswiperight
  • threetap
  • threelongpress

A helpful note here a swipe to the left is backwards on the glass touchpad (from your eye towards your ear) where a swipe to the right is from your ear towards your eye.

####Advanced Events#### Advanced events have data associated with them

  • scroll
  • twofingerscroll
  • fingercountchanged

####Advanced Examples####

// Data contains properties type, displacement, delta and velocity
document.addEventListener("scroll", function(data) {
	console.log("Got that scroll");
	console.log(data.displacement);
	console.log(data.delta);
	console.log(data.velocity);
})
// Data contains properties type, displacement, delta and velocity
document.addEventListener("twofingerscroll", function(data) {
	console.log("Got that two finger scroll");
	console.log(data.displacement);
	console.log(data.delta);
	console.log(data.velocity);
})
// Data contains properties type, from and to
document.addEventListener("fingercountchanged", function(data) {
	console.log("Fingers changed from " + data.from + " to " + data.to);
})

###Config### The following config.xml preferences are available via this plugin

####keepAwake####

<preference name="rossgerbasi.glass.keepAwake" value="false"/>

Setting this to true will force your application to always stay on, no screen dimming. A User will need to exit your application via a swipe down gesture to close it.

####touchDisabled####

<preference name="rossgerbasi.glass.touchDisabled" value="false"/>

Setting this to true will disable the translation of touch events from the touchpad to the web view. Essentially turning off 'touchstart', 'touched' and 'touchmove' events.

####gesturesDisabled####

<preference name="rossgerbasi.glass.gesturesDisabled" value="false"/>

Setting this to true will disable all native gesture events (swipe, long press, scroll, etc).

cordova-glass's People

Contributors

aphex avatar

Watchers

Lauriane Kayungu-N avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.