Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

phonegap-nfc-0.1.3 and phonegap-1.0.0

  • Loading branch information...
commit a2eb8239ecd0dc0d4eab11fb5e05bf47ba26c2bd 1 parent 944facb
@don authored
View
4 .classpath
@@ -3,7 +3,7 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="lib" path="lib/phonegap-1.0.0rc2.jar"/>
- <classpathentry kind="lib" path="lib/phonegap-nfc-0.1.0.jar"/>
+ <classpathentry kind="lib" path="lib/phonegap-1.0.0.jar"/>
+ <classpathentry kind="lib" path="lib/phonegap-nfc-0.1.3.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
View
4 .gitignore
@@ -1,4 +1,4 @@
bin/
gen/
-update.sh
-pg.sh
+*.iml
+.idea/
View
4 assets/www/index.html
@@ -5,8 +5,8 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Rock Paper Scissors</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" />
- <script type="text/javascript" charset="utf-8" src="phonegap-1.0.0rc2.js"></script>
- <script type="text/javascript" charset="utf-8" src="phonegap-nfc-0.1.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="phonegap-nfc-0.1.3.js"></script>
<script type="text/javascript" charset="utf-8" src="main.js"></script>
</head>
<body>
View
5 assets/www/main.js
@@ -13,8 +13,9 @@ function onNfc(nfcEvent) {
if (!listening) {
return;
}
-
- var records = nfcEvent.tagData,
+
+ var tag = nfcEvent.tag,
+ records = tag.ndefMessage,
opponentsChoice = Ndef.bytesToString(records[0].payload),
result;
View
61 assets/www/phonegap-1.0.0rc2.js → assets/www/phonegap-1.0.0.js
@@ -1063,6 +1063,7 @@ PhoneGap.addConstructor(function() {
if (!PhoneGap.hasResource("app")) {
PhoneGap.addResource("app");
+(function() {
/**
* Constructor
@@ -1134,8 +1135,9 @@ App.prototype.exitApp = function() {
};
PhoneGap.addConstructor(function() {
- navigator.app = window.app = new App();
+ navigator.app = new App();
});
+}());
}
@@ -1176,6 +1178,21 @@ Camera.DestinationType = {
Camera.prototype.DestinationType = Camera.DestinationType;
/**
+ * Encoding of image returned from getPicture.
+ *
+ * Example: navigator.camera.getPicture(success, fail,
+ * { quality: 80,
+ * destinationType: Camera.DestinationType.DATA_URL,
+ * sourceType: Camera.PictureSourceType.CAMERA,
+ * encodingType: Camera.EncodingType.PNG})
+*/
+Camera.EncodingType = {
+ JPEG: 0, // Return JPEG encoded image
+ PNG: 1 // Return PNG encoded image
+};
+Camera.prototype.EncodingType = Camera.EncodingType;
+
+/**
* Source to getPicture from.
*
* Example: navigator.camera.getPicture(success, fail,
@@ -1219,6 +1236,12 @@ Camera.prototype.getPicture = function(successCallback, errorCallback, options)
if (options.quality) {
quality = this.options.quality;
}
+
+ var maxResolution = 0;
+ if (options.maxResolution) {
+ maxResolution = this.options.maxResolution;
+ }
+
var destinationType = Camera.DestinationType.DATA_URL;
if (this.options.destinationType) {
destinationType = this.options.destinationType;
@@ -1227,7 +1250,32 @@ Camera.prototype.getPicture = function(successCallback, errorCallback, options)
if (typeof this.options.sourceType === "number") {
sourceType = this.options.sourceType;
}
- PhoneGap.exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType, sourceType]);
+ var encodingType = Camera.EncodingType.JPEG;
+ if (typeof options.encodingType == "number") {
+ encodingType = this.options.encodingType;
+ }
+
+ var targetWidth = -1;
+ if (typeof options.targetWidth == "number") {
+ targetWidth = options.targetWidth;
+ } else if (typeof options.targetWidth == "string") {
+ var width = new Number(options.targetWidth);
+ if (isNaN(width) === false) {
+ targetWidth = width.valueOf();
+ }
+ }
+
+ var targetHeight = -1;
+ if (typeof options.targetHeight == "number") {
+ targetHeight = options.targetHeight;
+ } else if (typeof options.targetHeight == "string") {
+ var height = new Number(options.targetHeight);
+ if (isNaN(height) === false) {
+ targetHeight = height.valueOf();
+ }
+ }
+
+ PhoneGap.exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType]);
};
PhoneGap.addConstructor(function() {
@@ -2189,7 +2237,7 @@ FileReader.prototype.abort = function() {
}
// If abort callback
if (typeof this.onabort === "function") {
- this.oneabort({"type":"abort", "target":this});
+ this.onabort({"type":"abort", "target":this});
}
// If load end callback
if (typeof this.onloadend === "function") {
@@ -2448,7 +2496,7 @@ FileWriter.prototype.abort = function() {
}
// If abort callback
if (typeof this.onabort === "function") {
- this.oneabort({"type":"abort", "target":this});
+ this.onabort({"type":"abort", "target":this});
}
this.readyState = FileWriter.DONE;
@@ -3437,6 +3485,7 @@ var Media = function(src, successCallback, errorCallback, statusCallback, positi
// Media messages
Media.MEDIA_STATE = 1;
Media.MEDIA_DURATION = 2;
+Media.MEDIA_POSITION = 3;
Media.MEDIA_ERROR = 9;
// Media states
@@ -3561,7 +3610,6 @@ PhoneGap.Media.getMediaObject = function(id) {
*/
PhoneGap.Media.onStatus = function(id, msg, value) {
var media = PhoneGap.mediaObjects[id];
-
// If state update
if (msg === Media.MEDIA_STATE) {
if (value === Media.MEDIA_STOPPED) {
@@ -3581,6 +3629,9 @@ PhoneGap.Media.onStatus = function(id, msg, value) {
media.errorCallback(value);
}
}
+ else if (msg == Media.MEDIA_POSITION) {
+ media._position = value;
+ }
};
}
View
30 assets/www/phonegap-nfc-0.1.0.js → assets/www/phonegap-nfc-0.1.3.js
@@ -1,5 +1,19 @@
/*global PhoneGap*/
+PhoneGap.addConstructor(
+ function () {
+ PhoneGap.exec(
+ function () {
+ console.log("Initialized the NdefPlugin");
+ },
+ function (reason) {
+ alert("Failed to initialize the NdefPlugin " + reason);
+ },
+ "NdefPlugin", "init", []
+ )
+ }
+);
+
var Ndef = {
// see android.nfc.NdefRecord for documentation about constants
// http://developer.android.com/reference/android/nfc/NdefRecord.html
@@ -131,9 +145,9 @@ navigator.nfc = {
PhoneGap.exec(win, fail, "NdefPlugin", "registerNdef", []);
},
- addNdefFormattableListener: function (callback, win, fail) {
- document.addEventListener("ndef-unformatted", callback, false);
- PhoneGap.exec(win, fail, "NdefPlugin", "registerNdefFormattable", []);
+ addNdefFormatableListener: function (callback, win, fail) {
+ document.addEventListener("ndef-formatable", callback, false);
+ PhoneGap.exec(win, fail, "NdefPlugin", "registerNdefFormatable", []);
},
writeTag: function (ndefMessage, win, fail) {
@@ -150,14 +164,6 @@ navigator.nfc = {
eraseTag: function (win, fail) {
PhoneGap.exec(win, fail, "NdefPlugin", "writeTag", [[]]);
- },
+ }
- // Java is responsible for calling this method
- // Type is ndef-mime, ndef, or ndef-unformatted
- fireEvent: function (type, tagData) {
- var e = document.createEvent('Events');
- e.initEvent(type);
- e.tagData = tagData;
- document.dispatchEvent(e);
- }
};
View
0  gen/.gitignore
No changes.
View
BIN  lib/phonegap-1.0.0rc2.jar → lib/phonegap-1.0.0.jar
Binary file not shown
View
BIN  lib/phonegap-nfc-0.1.0.jar
Binary file not shown
View
BIN  lib/phonegap-nfc-0.1.3.jar
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.