You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bh...@apache.org on 2013/09/13 14:40:10 UTC
git commit: [CB-4592] [Blackberry10] Added beep support
Updated Branches:
refs/heads/dev f26bc0468 -> 888a12ba3
[CB-4592] [Blackberry10] Added beep support
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/commit/888a12ba
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/888a12ba
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/888a12ba
Branch: refs/heads/dev
Commit: 888a12ba3d54b6c64d75d6147fbf4d8f30c791d3
Parents: f26bc04
Author: Kristoffer Flores <kf...@blackberry.com>
Authored: Fri Aug 23 14:14:42 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri Sep 13 08:42:40 2013 -0400
----------------------------------------------------------------------
plugin.xml | 11 +++++++----
src/blackberry10/index.js | 4 ----
www/blackberry10/beep.js | 42 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 49 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/888a12ba/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index fb3184d..7cfabbf 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -20,18 +20,18 @@
<param name="android-package" value="org.apache.cordova.dialogs.Notification"/>
</feature>
</config-file>
-
+
<source-file src="src/android/Notification.java" target-dir="src/org/apache/cordova/dialogs" />
<!-- android specific notification apis -->
<js-module src="www/android/notification.js" name="notification_android">
<merges target="navigator.notification" />
</js-module>
-
+
</platform>
<!-- ios -->
- <platform name="ios">
+ <platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="Notification">
<param name="ios-package" value="CDVNotification"/>
@@ -40,7 +40,7 @@
<header-file src="src/ios/CDVNotification.h" />
<source-file src="src/ios/CDVNotification.m" />
<resource-file src="src/ios/CDVNotification.bundle" />
- <framework src="AudioToolbox.framework" weak="true" />
+ <framework src="AudioToolbox.framework" weak="true" />
</platform>
<!-- blackberry10 -->
@@ -49,6 +49,9 @@
<config-file target="www/config.xml" parent="/widget">
<feature name="Notification" value="Notification"/>
</config-file>
+ <js-module src="www/blackberry10/beep.js" name="beep">
+ <clobbers target="window.navigator.notification.beep" />
+ </js-module>
</platform>
<!-- wp7 -->
http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/888a12ba/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
index fad04f7..b218eab 100644
--- a/src/blackberry10/index.js
+++ b/src/blackberry10/index.js
@@ -83,9 +83,5 @@ module.exports = {
} else {
showDialog(args, "JavaScriptPrompt", result);
}
- },
- beep: function (success, fail, args, env) {
- var result = new PluginResult(args, env);
- result.error("Beep not supported");
}
};
http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/888a12ba/www/blackberry10/beep.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/beep.js b/www/blackberry10/beep.js
new file mode 100644
index 0000000..6d4a77a
--- /dev/null
+++ b/www/blackberry10/beep.js
@@ -0,0 +1,42 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+var beep,
+ count = 0,
+ beepObj = new Audio('file:///usr/share/sounds/notification_text_message_im_received.wav');
+
+beep = function (quantity) {
+ var callback = function () {
+ if (--count > 0) {
+ beepObj.play();
+ } else {
+ beepObj.removeEventListener("ended", callback);
+ delete beepObj;
+ }
+ };
+
+ count += quantity;
+ if (count === quantity) {
+ beepObj.addEventListener("ended", callback);
+ beepObj.play();
+ }
+};
+
+module.exports = beep;