mobile_template 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +28 -0
- data/Rakefile +3 -0
- data/bin/mobile_template +71 -0
- data/lib/mobile_template/version.rb +4 -0
- data/lib/mobile_template.rb +5 -0
- data/mobile_template.gemspec +21 -0
- data/templates/assets/Gemfile +4 -0
- data/templates/assets/config.rb +96 -0
- data/templates/assets/config.ru +4 -0
- data/templates/assets/source/images/vendor/ajax-loader.gif +0 -0
- data/templates/assets/source/images/vendor/ajax-loader.png +0 -0
- data/templates/assets/source/images/vendor/icons-18-black.png +0 -0
- data/templates/assets/source/images/vendor/icons-18-white.png +0 -0
- data/templates/assets/source/images/vendor/icons-36-black.png +0 -0
- data/templates/assets/source/images/vendor/icons-36-white.png +0 -0
- data/templates/assets/source/index.html.erb +2 -0
- data/templates/assets/source/javascripts/app/index.js.coffee +2 -0
- data/templates/assets/source/javascripts/application.js.coffee +5 -0
- data/templates/assets/source/javascripts/vendor/cordova.js +4841 -0
- data/templates/assets/source/javascripts/vendor/jquery.js +9267 -0
- data/templates/assets/source/javascripts/vendor/jquery.mobile.js +7410 -0
- data/templates/assets/source/layout.erb +24 -0
- data/templates/assets/source/stylesheets/application.css.scss +2 -0
- data/templates/assets/source/stylesheets/vendor/jquery.mobile.css.scss +1872 -0
- data/templates/cordova_android/.gitignore +18 -0
- data/templates/cordova_android/LICENSE +202 -0
- data/templates/cordova_android/NOTICE +5 -0
- data/templates/cordova_android/README.md +95 -0
- data/templates/cordova_android/VERSION +1 -0
- data/templates/cordova_android/bin/BOOM +4 -0
- data/templates/cordova_android/bin/autotest +2 -0
- data/templates/cordova_android/bin/bench +29 -0
- data/templates/cordova_android/bin/create +46 -0
- data/templates/cordova_android/bin/create.bat +1 -0
- data/templates/cordova_android/bin/create.js +88 -0
- data/templates/cordova_android/bin/create.xml +79 -0
- data/templates/cordova_android/bin/node_modules/.bin/cake +7 -0
- data/templates/cordova_android/bin/node_modules/.bin/coffee +7 -0
- data/templates/cordova_android/bin/node_modules/.bin/nodeunit +120 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/.npmignore +11 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/LICENSE +22 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/README +48 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/Rakefile +78 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/bin/cake +7 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/bin/coffee +7 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/extras/jsl.conf +44 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/browser.js +75 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/cake.js +76 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/coffee-script.js +135 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/command.js +301 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/grammar.js +591 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/helpers.js +66 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/index.js +8 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/lexer.js +656 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/nodes.js +2289 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/optparse.js +111 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/parser.js +676 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/repl.js +123 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/rewriter.js +363 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/scope.js +120 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/package.json +27 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/.gitignore +5 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/.npmignore +3 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/CONTRIBUTORS.md +60 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/LICENSE +19 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/Makefile +126 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/README.md +432 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit +120 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit.json +10 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/async.js +623 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/console.log.js +55 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/ejs.js +125 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/json2.js +483 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/nodeunit.js +1757 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite1.js +12 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite2.js +13 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/test.html +16 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/img/example_fail.png +0 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/img/example_pass.png +0 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/index.js +3 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/assert.js +316 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/core.js +260 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/nodeunit.js +82 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/browser.js +119 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/default.js +123 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/html.js +107 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/index.js +9 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/junit.js +183 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/minimal.js +112 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/skip_passed.js +105 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/track.js +48 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/types.js +187 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/utils.js +209 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/man1/nodeunit.1 +95 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/nodelint.cfg +4 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/package.json +56 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/junit.xml.ejs +19 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/license.js +11 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/nodeunit.css +70 -0
- data/templates/cordova_android/bin/templates/project/.cordova/android/readme.md +1 -0
- data/templates/cordova_android/bin/templates/project/.cordova/readme.md +3 -0
- data/templates/cordova_android/bin/templates/project/cordova/create +36 -0
- data/templates/cordova_android/bin/templates/project/cordova/debug +9 -0
- data/templates/cordova_android/bin/templates/project/cordova/emulate +12 -0
- data/templates/cordova_android/bin/templates/project/cordova/log +3 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/Activity.java +16 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/AndroidManifest.xml +50 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/index.html +42 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/main.js +146 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/master.css +96 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/drawable/icon.png +0 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/cordova.xml +5 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/plugins.xml +19 -0
- data/templates/cordova_android/bin/test +26 -0
- data/templates/cordova_android/bin/tests/autotest.coffee +4 -0
- data/templates/cordova_android/bin/tests/create.coffee +21 -0
- data/templates/cordova_android/bin/tests/debug.coffee +0 -0
- data/templates/cordova_android/bin/tests/test.coffee +0 -0
- data/templates/cordova_android/framework/.classpath +8 -0
- data/templates/cordova_android/framework/.project +33 -0
- data/templates/cordova_android/framework/AndroidManifest.xml +68 -0
- data/templates/cordova_android/framework/ant.properties +34 -0
- data/templates/cordova_android/framework/assets/js/accelerometer.js +137 -0
- data/templates/cordova_android/framework/assets/js/app.js +89 -0
- data/templates/cordova_android/framework/assets/js/battery.js +134 -0
- data/templates/cordova_android/framework/assets/js/camera.js +168 -0
- data/templates/cordova_android/framework/assets/js/capture.js +203 -0
- data/templates/cordova_android/framework/assets/js/compass.js +168 -0
- data/templates/cordova_android/framework/assets/js/contact.js +310 -0
- data/templates/cordova_android/framework/assets/js/cordova.android.js +4841 -0
- data/templates/cordova_android/framework/assets/js/cordova.js.base +924 -0
- data/templates/cordova_android/framework/assets/js/crypto.js +54 -0
- data/templates/cordova_android/framework/assets/js/device.js +83 -0
- data/templates/cordova_android/framework/assets/js/file.js +1082 -0
- data/templates/cordova_android/framework/assets/js/filetransfer.js +125 -0
- data/templates/cordova_android/framework/assets/js/geolocation.js +209 -0
- data/templates/cordova_android/framework/assets/js/header.txt +19 -0
- data/templates/cordova_android/framework/assets/js/media.js +233 -0
- data/templates/cordova_android/framework/assets/js/network.js +100 -0
- data/templates/cordova_android/framework/assets/js/notification.js +133 -0
- data/templates/cordova_android/framework/assets/js/position.js +100 -0
- data/templates/cordova_android/framework/assets/js/storage.js +439 -0
- data/templates/cordova_android/framework/assets/www/index.html +27 -0
- data/templates/cordova_android/framework/build.xml +216 -0
- data/templates/cordova_android/framework/libs/commons-codec-1.3.jar +0 -0
- data/templates/cordova_android/framework/proguard-project.txt +20 -0
- data/templates/cordova_android/framework/project.properties +14 -0
- data/templates/cordova_android/framework/res/drawable/icon.png +0 -0
- data/templates/cordova_android/framework/res/drawable/splash.png +0 -0
- data/templates/cordova_android/framework/res/layout/main.xml +29 -0
- data/templates/cordova_android/framework/res/values/strings.xml +23 -0
- data/templates/cordova_android/framework/res/xml/cordova.xml +37 -0
- data/templates/cordova_android/framework/res/xml/plugins.xml +37 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/IPlugin.java +27 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/LOG.java +28 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PhonegapActivity.java +28 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/Plugin.java +27 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PluginManager.java +35 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PluginResult.java +53 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AccelListener.java +311 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/App.java +198 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AudioHandler.java +364 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AudioPlayer.java +450 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AuthenticationToken.java +69 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/BatteryListener.java +156 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CallbackServer.java +431 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CameraLauncher.java +500 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Capture.java +400 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CompassListener.java +308 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessor.java +198 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessorSdk5.java +1934 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactManager.java +113 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CordovaChromeClient.java +314 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CordovaWebViewClient.java +306 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Device.java +219 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/DirectoryManager.java +161 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/DroidGap.java +1417 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ExifHelper.java +165 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileTransfer.java +458 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileUploadResult.java +63 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileUtils.java +1048 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GeoBroker.java +165 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GeoListener.java +133 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GpsListener.java +163 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/HttpHandler.java +80 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java +104 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/NetworkListener.java +153 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/NetworkManager.java +248 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Notification.java +366 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceNode.java +34 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceSet.java +62 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/StandAlone.java +35 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Storage.java +239 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/TempListener.java +112 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/CordovaInterface.java +145 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/IPlugin.java +116 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/LOG.java +234 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/Plugin.java +210 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginManager.java +359 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginResult.java +119 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/EncodingException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/FileExistsException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/InvalidModificationException.java +29 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/NoModificationAllowedException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/TypeMismatchException.java +29 -0
- data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceNodeTest.java +53 -0
- data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceSetTest.java +73 -0
- metadata +279 -0
@@ -0,0 +1,450 @@
|
|
1
|
+
/*
|
2
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
3
|
+
or more contributor license agreements. See the NOTICE file
|
4
|
+
distributed with this work for additional information
|
5
|
+
regarding copyright ownership. The ASF licenses this file
|
6
|
+
to you under the Apache License, Version 2.0 (the
|
7
|
+
"License"); you may not use this file except in compliance
|
8
|
+
with the License. You may obtain a copy of the License at
|
9
|
+
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
|
12
|
+
Unless required by applicable law or agreed to in writing,
|
13
|
+
software distributed under the License is distributed on an
|
14
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
KIND, either express or implied. See the License for the
|
16
|
+
specific language governing permissions and limitations
|
17
|
+
under the License.
|
18
|
+
*/
|
19
|
+
package org.apache.cordova;
|
20
|
+
|
21
|
+
import android.media.AudioManager;
|
22
|
+
import android.media.MediaPlayer;
|
23
|
+
import android.media.MediaPlayer.OnCompletionListener;
|
24
|
+
import android.media.MediaPlayer.OnErrorListener;
|
25
|
+
import android.media.MediaPlayer.OnPreparedListener;
|
26
|
+
import android.media.MediaRecorder;
|
27
|
+
import android.os.Environment;
|
28
|
+
import android.util.Log;
|
29
|
+
|
30
|
+
import java.io.File;
|
31
|
+
import java.io.IOException;
|
32
|
+
|
33
|
+
/**
|
34
|
+
* This class implements the audio playback and recording capabilities used by Cordova.
|
35
|
+
* It is called by the AudioHandler Cordova class.
|
36
|
+
* Only one file can be played or recorded per class instance.
|
37
|
+
*
|
38
|
+
* Local audio files must reside in one of two places:
|
39
|
+
* android_asset: file name must start with /android_asset/sound.mp3
|
40
|
+
* sdcard: file name is just sound.mp3
|
41
|
+
*/
|
42
|
+
public class AudioPlayer implements OnCompletionListener, OnPreparedListener, OnErrorListener {
|
43
|
+
|
44
|
+
private static final String LOG_TAG = "AudioPlayer";
|
45
|
+
|
46
|
+
// AudioPlayer states
|
47
|
+
public static int MEDIA_NONE = 0;
|
48
|
+
public static int MEDIA_STARTING = 1;
|
49
|
+
public static int MEDIA_RUNNING = 2;
|
50
|
+
public static int MEDIA_PAUSED = 3;
|
51
|
+
public static int MEDIA_STOPPED = 4;
|
52
|
+
|
53
|
+
// AudioPlayer message ids
|
54
|
+
private static int MEDIA_STATE = 1;
|
55
|
+
private static int MEDIA_DURATION = 2;
|
56
|
+
private static int MEDIA_POSITION = 3;
|
57
|
+
private static int MEDIA_ERROR = 9;
|
58
|
+
|
59
|
+
// Media error codes
|
60
|
+
private static int MEDIA_ERR_NONE_ACTIVE = 0;
|
61
|
+
private static int MEDIA_ERR_ABORTED = 1;
|
62
|
+
private static int MEDIA_ERR_NETWORK = 2;
|
63
|
+
private static int MEDIA_ERR_DECODE = 3;
|
64
|
+
private static int MEDIA_ERR_NONE_SUPPORTED = 4;
|
65
|
+
|
66
|
+
private AudioHandler handler; // The AudioHandler object
|
67
|
+
private String id; // The id of this player (used to identify Media object in JavaScript)
|
68
|
+
private int state = MEDIA_NONE; // State of recording or playback
|
69
|
+
private String audioFile = null; // File name to play or record to
|
70
|
+
private float duration = -1; // Duration of audio
|
71
|
+
|
72
|
+
private MediaRecorder recorder = null; // Audio recording object
|
73
|
+
private String tempFile = null; // Temporary recording file name
|
74
|
+
|
75
|
+
private MediaPlayer mPlayer = null; // Audio player object
|
76
|
+
private boolean prepareOnly = false;
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Constructor.
|
80
|
+
*
|
81
|
+
* @param handler The audio handler object
|
82
|
+
* @param id The id of this audio player
|
83
|
+
*/
|
84
|
+
public AudioPlayer(AudioHandler handler, String id) {
|
85
|
+
this.handler = handler;
|
86
|
+
this.id = id;
|
87
|
+
this.tempFile = Environment.getExternalStorageDirectory().getAbsolutePath() + "/tmprecording.mp3";
|
88
|
+
}
|
89
|
+
|
90
|
+
/**
|
91
|
+
* Destroy player and stop audio playing or recording.
|
92
|
+
*/
|
93
|
+
public void destroy() {
|
94
|
+
|
95
|
+
// Stop any play or record
|
96
|
+
if (this.mPlayer != null) {
|
97
|
+
if ((this.state == MEDIA_RUNNING) || (this.state == MEDIA_PAUSED)) {
|
98
|
+
this.mPlayer.stop();
|
99
|
+
this.setState(MEDIA_STOPPED);
|
100
|
+
}
|
101
|
+
this.mPlayer.release();
|
102
|
+
this.mPlayer = null;
|
103
|
+
}
|
104
|
+
if (this.recorder != null) {
|
105
|
+
this.stopRecording();
|
106
|
+
this.recorder.release();
|
107
|
+
this.recorder = null;
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
/**
|
112
|
+
* Start recording the specified file.
|
113
|
+
*
|
114
|
+
* @param file The name of the file
|
115
|
+
*/
|
116
|
+
public void startRecording(String file) {
|
117
|
+
if (this.mPlayer != null) {
|
118
|
+
Log.d(LOG_TAG, "AudioPlayer Error: Can't record in play mode.");
|
119
|
+
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
120
|
+
}
|
121
|
+
|
122
|
+
// Make sure we're not already recording
|
123
|
+
else if (this.recorder == null) {
|
124
|
+
this.audioFile = file;
|
125
|
+
this.recorder = new MediaRecorder();
|
126
|
+
this.recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
|
127
|
+
this.recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT); // THREE_GPP);
|
128
|
+
this.recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); //AMR_NB);
|
129
|
+
this.recorder.setOutputFile(this.tempFile);
|
130
|
+
try {
|
131
|
+
this.recorder.prepare();
|
132
|
+
this.recorder.start();
|
133
|
+
this.setState(MEDIA_RUNNING);
|
134
|
+
return;
|
135
|
+
} catch (IllegalStateException e) {
|
136
|
+
e.printStackTrace();
|
137
|
+
} catch (IOException e) {
|
138
|
+
e.printStackTrace();
|
139
|
+
}
|
140
|
+
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
141
|
+
}
|
142
|
+
else {
|
143
|
+
Log.d(LOG_TAG, "AudioPlayer Error: Already recording.");
|
144
|
+
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
/**
|
149
|
+
* Save temporary recorded file to specified name
|
150
|
+
*
|
151
|
+
* @param file
|
152
|
+
*/
|
153
|
+
public void moveFile(String file) {
|
154
|
+
|
155
|
+
/* this is a hack to save the file as the specified name */
|
156
|
+
File f = new File(this.tempFile);
|
157
|
+
f.renameTo(new File("/sdcard/" + file));
|
158
|
+
}
|
159
|
+
|
160
|
+
/**
|
161
|
+
* Stop recording and save to the file specified when recording started.
|
162
|
+
*/
|
163
|
+
public void stopRecording() {
|
164
|
+
if (this.recorder != null) {
|
165
|
+
try{
|
166
|
+
if (this.state == MEDIA_RUNNING) {
|
167
|
+
this.recorder.stop();
|
168
|
+
this.setState(MEDIA_STOPPED);
|
169
|
+
}
|
170
|
+
this.moveFile(this.audioFile);
|
171
|
+
}
|
172
|
+
catch (Exception e) {
|
173
|
+
e.printStackTrace();
|
174
|
+
}
|
175
|
+
}
|
176
|
+
}
|
177
|
+
|
178
|
+
/**
|
179
|
+
* Start or resume playing audio file.
|
180
|
+
*
|
181
|
+
* @param file The name of the audio file.
|
182
|
+
*/
|
183
|
+
public void startPlaying(String file) {
|
184
|
+
if (this.recorder != null) {
|
185
|
+
Log.d(LOG_TAG, "AudioPlayer Error: Can't play in record mode.");
|
186
|
+
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
187
|
+
}
|
188
|
+
|
189
|
+
// If this is a new request to play audio, or stopped
|
190
|
+
else if ((this.mPlayer == null) || (this.state == MEDIA_STOPPED)) {
|
191
|
+
try {
|
192
|
+
// If stopped, then reset player
|
193
|
+
if (this.mPlayer != null) {
|
194
|
+
this.mPlayer.reset();
|
195
|
+
}
|
196
|
+
// Otherwise, create a new one
|
197
|
+
else {
|
198
|
+
this.mPlayer = new MediaPlayer();
|
199
|
+
}
|
200
|
+
this.audioFile = file;
|
201
|
+
|
202
|
+
// If streaming file
|
203
|
+
if (this.isStreaming(file)) {
|
204
|
+
this.mPlayer.setDataSource(file);
|
205
|
+
this.mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
|
206
|
+
this.setState(MEDIA_STARTING);
|
207
|
+
this.mPlayer.setOnPreparedListener(this);
|
208
|
+
this.mPlayer.prepareAsync();
|
209
|
+
}
|
210
|
+
|
211
|
+
// If local file
|
212
|
+
else {
|
213
|
+
if (file.startsWith("/android_asset/")) {
|
214
|
+
String f = file.substring(15);
|
215
|
+
android.content.res.AssetFileDescriptor fd = this.handler.ctx.getBaseContext().getAssets().openFd(f);
|
216
|
+
this.mPlayer.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
|
217
|
+
}
|
218
|
+
else {
|
219
|
+
this.mPlayer.setDataSource("/sdcard/" + file);
|
220
|
+
}
|
221
|
+
this.setState(MEDIA_STARTING);
|
222
|
+
this.mPlayer.setOnPreparedListener(this);
|
223
|
+
this.mPlayer.prepare();
|
224
|
+
|
225
|
+
// Get duration
|
226
|
+
this.duration = getDurationInSeconds();
|
227
|
+
}
|
228
|
+
}
|
229
|
+
catch (Exception e) {
|
230
|
+
e.printStackTrace();
|
231
|
+
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
232
|
+
}
|
233
|
+
}
|
234
|
+
|
235
|
+
// If we have already have created an audio player
|
236
|
+
else {
|
237
|
+
|
238
|
+
// If player has been paused, then resume playback
|
239
|
+
if ((this.state == MEDIA_PAUSED) || (this.state == MEDIA_STARTING)) {
|
240
|
+
this.mPlayer.start();
|
241
|
+
this.setState(MEDIA_RUNNING);
|
242
|
+
}
|
243
|
+
else {
|
244
|
+
Log.d(LOG_TAG, "AudioPlayer Error: startPlaying() called during invalid state: "+this.state);
|
245
|
+
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
|
246
|
+
}
|
247
|
+
}
|
248
|
+
}
|
249
|
+
|
250
|
+
/**
|
251
|
+
* Seek or jump to a new time in the track.
|
252
|
+
*/
|
253
|
+
public void seekToPlaying(int milliseconds) {
|
254
|
+
if (this.mPlayer != null) {
|
255
|
+
this.mPlayer.seekTo(milliseconds);
|
256
|
+
Log.d(LOG_TAG, "Send a onStatus update for the new seek");
|
257
|
+
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_POSITION+", "+milliseconds/1000.0f+");");
|
258
|
+
}
|
259
|
+
}
|
260
|
+
|
261
|
+
/**
|
262
|
+
* Pause playing.
|
263
|
+
*/
|
264
|
+
public void pausePlaying() {
|
265
|
+
|
266
|
+
// If playing, then pause
|
267
|
+
if (this.state == MEDIA_RUNNING) {
|
268
|
+
this.mPlayer.pause();
|
269
|
+
this.setState(MEDIA_PAUSED);
|
270
|
+
}
|
271
|
+
else {
|
272
|
+
Log.d(LOG_TAG, "AudioPlayer Error: pausePlaying() called during invalid state: "+this.state);
|
273
|
+
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_NONE_ACTIVE+");");
|
274
|
+
}
|
275
|
+
}
|
276
|
+
|
277
|
+
/**
|
278
|
+
* Stop playing the audio file.
|
279
|
+
*/
|
280
|
+
public void stopPlaying() {
|
281
|
+
if ((this.state == MEDIA_RUNNING) || (this.state == MEDIA_PAUSED)) {
|
282
|
+
this.mPlayer.stop();
|
283
|
+
this.setState(MEDIA_STOPPED);
|
284
|
+
}
|
285
|
+
else {
|
286
|
+
Log.d(LOG_TAG, "AudioPlayer Error: stopPlaying() called during invalid state: "+this.state);
|
287
|
+
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_NONE_ACTIVE+");");
|
288
|
+
}
|
289
|
+
}
|
290
|
+
|
291
|
+
/**
|
292
|
+
* Callback to be invoked when playback of a media source has completed.
|
293
|
+
*
|
294
|
+
* @param mPlayer The MediaPlayer that reached the end of the file
|
295
|
+
*/
|
296
|
+
public void onCompletion(MediaPlayer mPlayer) {
|
297
|
+
this.setState(MEDIA_STOPPED);
|
298
|
+
}
|
299
|
+
|
300
|
+
/**
|
301
|
+
* Get current position of playback.
|
302
|
+
*
|
303
|
+
* @return position in msec or -1 if not playing
|
304
|
+
*/
|
305
|
+
public long getCurrentPosition() {
|
306
|
+
if ((this.state == MEDIA_RUNNING) || (this.state == MEDIA_PAUSED)) {
|
307
|
+
int curPos = this.mPlayer.getCurrentPosition();
|
308
|
+
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_POSITION+", "+curPos/1000.0f+");");
|
309
|
+
return curPos;
|
310
|
+
}
|
311
|
+
else {
|
312
|
+
return -1;
|
313
|
+
}
|
314
|
+
}
|
315
|
+
|
316
|
+
/**
|
317
|
+
* Determine if playback file is streaming or local.
|
318
|
+
* It is streaming if file name starts with "http://"
|
319
|
+
*
|
320
|
+
* @param file The file name
|
321
|
+
* @return T=streaming, F=local
|
322
|
+
*/
|
323
|
+
public boolean isStreaming(String file) {
|
324
|
+
if (file.contains("http://") || file.contains("https://")) {
|
325
|
+
return true;
|
326
|
+
}
|
327
|
+
else {
|
328
|
+
return false;
|
329
|
+
}
|
330
|
+
}
|
331
|
+
|
332
|
+
/**
|
333
|
+
* Get the duration of the audio file.
|
334
|
+
*
|
335
|
+
* @param file The name of the audio file.
|
336
|
+
* @return The duration in msec.
|
337
|
+
* -1=can't be determined
|
338
|
+
* -2=not allowed
|
339
|
+
*/
|
340
|
+
public float getDuration(String file) {
|
341
|
+
|
342
|
+
// Can't get duration of recording
|
343
|
+
if (this.recorder != null) {
|
344
|
+
return(-2); // not allowed
|
345
|
+
}
|
346
|
+
|
347
|
+
// If audio file already loaded and started, then return duration
|
348
|
+
if (this.mPlayer != null) {
|
349
|
+
return this.duration;
|
350
|
+
}
|
351
|
+
|
352
|
+
// If no player yet, then create one
|
353
|
+
else {
|
354
|
+
this.prepareOnly = true;
|
355
|
+
this.startPlaying(file);
|
356
|
+
|
357
|
+
// This will only return value for local, since streaming
|
358
|
+
// file hasn't been read yet.
|
359
|
+
return this.duration;
|
360
|
+
}
|
361
|
+
}
|
362
|
+
|
363
|
+
/**
|
364
|
+
* Callback to be invoked when the media source is ready for playback.
|
365
|
+
*
|
366
|
+
* @param mPlayer The MediaPlayer that is ready for playback
|
367
|
+
*/
|
368
|
+
public void onPrepared(MediaPlayer mPlayer) {
|
369
|
+
// Listen for playback completion
|
370
|
+
this.mPlayer.setOnCompletionListener(this);
|
371
|
+
|
372
|
+
// If start playing after prepared
|
373
|
+
if (!this.prepareOnly) {
|
374
|
+
|
375
|
+
// Start playing
|
376
|
+
this.mPlayer.start();
|
377
|
+
|
378
|
+
// Set player init flag
|
379
|
+
this.setState(MEDIA_RUNNING);
|
380
|
+
}
|
381
|
+
|
382
|
+
// Save off duration
|
383
|
+
this.duration = getDurationInSeconds();
|
384
|
+
this.prepareOnly = false;
|
385
|
+
|
386
|
+
// Send status notification to JavaScript
|
387
|
+
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_DURATION+","+this.duration+");");
|
388
|
+
|
389
|
+
}
|
390
|
+
|
391
|
+
/**
|
392
|
+
* By default Android returns the length of audio in mills but we want seconds
|
393
|
+
*
|
394
|
+
* @return length of clip in seconds
|
395
|
+
*/
|
396
|
+
private float getDurationInSeconds() {
|
397
|
+
return (this.mPlayer.getDuration() / 1000.0f);
|
398
|
+
}
|
399
|
+
|
400
|
+
/**
|
401
|
+
* Callback to be invoked when there has been an error during an asynchronous operation
|
402
|
+
* (other errors will throw exceptions at method call time).
|
403
|
+
*
|
404
|
+
* @param mPlayer the MediaPlayer the error pertains to
|
405
|
+
* @param arg1 the type of error that has occurred: (MEDIA_ERROR_UNKNOWN, MEDIA_ERROR_SERVER_DIED)
|
406
|
+
* @param arg2 an extra code, specific to the error.
|
407
|
+
*/
|
408
|
+
public boolean onError(MediaPlayer mPlayer, int arg1, int arg2) {
|
409
|
+
Log.d(LOG_TAG, "AudioPlayer.onError(" + arg1 + ", " + arg2+")");
|
410
|
+
|
411
|
+
// TODO: Not sure if this needs to be sent?
|
412
|
+
this.mPlayer.stop();
|
413
|
+
this.mPlayer.release();
|
414
|
+
|
415
|
+
// Send error notification to JavaScript
|
416
|
+
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+arg1+");");
|
417
|
+
return false;
|
418
|
+
}
|
419
|
+
|
420
|
+
/**
|
421
|
+
* Set the state and send it to JavaScript.
|
422
|
+
*
|
423
|
+
* @param state
|
424
|
+
*/
|
425
|
+
private void setState(int state) {
|
426
|
+
if (this.state != state) {
|
427
|
+
this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_STATE+", "+state+");");
|
428
|
+
}
|
429
|
+
|
430
|
+
this.state = state;
|
431
|
+
}
|
432
|
+
|
433
|
+
/**
|
434
|
+
* Get the audio state.
|
435
|
+
*
|
436
|
+
* @return int
|
437
|
+
*/
|
438
|
+
public int getState() {
|
439
|
+
return this.state;
|
440
|
+
}
|
441
|
+
|
442
|
+
/**
|
443
|
+
* Set the volume for audio player
|
444
|
+
*
|
445
|
+
* @param volume
|
446
|
+
*/
|
447
|
+
public void setVolume(float volume) {
|
448
|
+
this.mPlayer.setVolume(volume, volume);
|
449
|
+
}
|
450
|
+
}
|
@@ -0,0 +1,69 @@
|
|
1
|
+
/*
|
2
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
3
|
+
or more contributor license agreements. See the NOTICE file
|
4
|
+
distributed with this work for additional information
|
5
|
+
regarding copyright ownership. The ASF licenses this file
|
6
|
+
to you under the Apache License, Version 2.0 (the
|
7
|
+
"License"); you may not use this file except in compliance
|
8
|
+
with the License. You may obtain a copy of the License at
|
9
|
+
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
|
12
|
+
Unless required by applicable law or agreed to in writing,
|
13
|
+
software distributed under the License is distributed on an
|
14
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
KIND, either express or implied. See the License for the
|
16
|
+
specific language governing permissions and limitations
|
17
|
+
under the License.
|
18
|
+
*/
|
19
|
+
package org.apache.cordova;
|
20
|
+
|
21
|
+
/**
|
22
|
+
* The Class AuthenticationToken defines the userName and password to be used for authenticating a web resource
|
23
|
+
*/
|
24
|
+
public class AuthenticationToken {
|
25
|
+
private String userName;
|
26
|
+
private String password;
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Gets the user name.
|
30
|
+
*
|
31
|
+
* @return the user name
|
32
|
+
*/
|
33
|
+
public String getUserName() {
|
34
|
+
return userName;
|
35
|
+
}
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Sets the user name.
|
39
|
+
*
|
40
|
+
* @param userName
|
41
|
+
* the new user name
|
42
|
+
*/
|
43
|
+
public void setUserName(String userName) {
|
44
|
+
this.userName = userName;
|
45
|
+
}
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Gets the password.
|
49
|
+
*
|
50
|
+
* @return the password
|
51
|
+
*/
|
52
|
+
public String getPassword() {
|
53
|
+
return password;
|
54
|
+
}
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Sets the password.
|
58
|
+
*
|
59
|
+
* @param password
|
60
|
+
* the new password
|
61
|
+
*/
|
62
|
+
public void setPassword(String password) {
|
63
|
+
this.password = password;
|
64
|
+
}
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
}
|
@@ -0,0 +1,156 @@
|
|
1
|
+
/*
|
2
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
3
|
+
or more contributor license agreements. See the NOTICE file
|
4
|
+
distributed with this work for additional information
|
5
|
+
regarding copyright ownership. The ASF licenses this file
|
6
|
+
to you under the Apache License, Version 2.0 (the
|
7
|
+
"License"); you may not use this file except in compliance
|
8
|
+
with the License. You may obtain a copy of the License at
|
9
|
+
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
|
12
|
+
Unless required by applicable law or agreed to in writing,
|
13
|
+
software distributed under the License is distributed on an
|
14
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
KIND, either express or implied. See the License for the
|
16
|
+
specific language governing permissions and limitations
|
17
|
+
under the License.
|
18
|
+
*/
|
19
|
+
package org.apache.cordova;
|
20
|
+
|
21
|
+
import org.apache.cordova.api.Plugin;
|
22
|
+
import org.apache.cordova.api.PluginResult;
|
23
|
+
import org.json.JSONArray;
|
24
|
+
import org.json.JSONException;
|
25
|
+
import org.json.JSONObject;
|
26
|
+
|
27
|
+
|
28
|
+
import android.content.BroadcastReceiver;
|
29
|
+
import android.content.Context;
|
30
|
+
import android.content.Intent;
|
31
|
+
import android.content.IntentFilter;
|
32
|
+
import android.util.Log;
|
33
|
+
|
34
|
+
public class BatteryListener extends Plugin {
|
35
|
+
|
36
|
+
private static final String LOG_TAG = "BatteryManager";
|
37
|
+
|
38
|
+
BroadcastReceiver receiver;
|
39
|
+
|
40
|
+
private String batteryCallbackId = null;
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Constructor.
|
44
|
+
*/
|
45
|
+
public BatteryListener() {
|
46
|
+
this.receiver = null;
|
47
|
+
}
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Executes the request and returns PluginResult.
|
51
|
+
*
|
52
|
+
* @param action The action to execute.
|
53
|
+
* @param args JSONArry of arguments for the plugin.
|
54
|
+
* @param callbackId The callback id used when calling back into JavaScript.
|
55
|
+
* @return A PluginResult object with a status and message.
|
56
|
+
*/
|
57
|
+
public PluginResult execute(String action, JSONArray args, String callbackId) {
|
58
|
+
PluginResult.Status status = PluginResult.Status.INVALID_ACTION;
|
59
|
+
String result = "Unsupported Operation: " + action;
|
60
|
+
|
61
|
+
if (action.equals("start")) {
|
62
|
+
if (this.batteryCallbackId != null) {
|
63
|
+
return new PluginResult(PluginResult.Status.ERROR, "Battery listener already running.");
|
64
|
+
}
|
65
|
+
this.batteryCallbackId = callbackId;
|
66
|
+
|
67
|
+
// We need to listen to power events to update battery status
|
68
|
+
IntentFilter intentFilter = new IntentFilter() ;
|
69
|
+
intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
70
|
+
if (this.receiver == null) {
|
71
|
+
this.receiver = new BroadcastReceiver() {
|
72
|
+
@Override
|
73
|
+
public void onReceive(Context context, Intent intent) {
|
74
|
+
updateBatteryInfo(intent);
|
75
|
+
}
|
76
|
+
};
|
77
|
+
ctx.registerReceiver(this.receiver, intentFilter);
|
78
|
+
}
|
79
|
+
|
80
|
+
// Don't return any result now, since status results will be sent when events come in from broadcast receiver
|
81
|
+
PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT);
|
82
|
+
pluginResult.setKeepCallback(true);
|
83
|
+
return pluginResult;
|
84
|
+
}
|
85
|
+
|
86
|
+
else if (action.equals("stop")) {
|
87
|
+
removeBatteryListener();
|
88
|
+
this.sendUpdate(new JSONObject(), false); // release status callback in JS side
|
89
|
+
this.batteryCallbackId = null;
|
90
|
+
return new PluginResult(PluginResult.Status.OK);
|
91
|
+
}
|
92
|
+
|
93
|
+
return new PluginResult(status, result);
|
94
|
+
}
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Stop battery receiver.
|
98
|
+
*/
|
99
|
+
public void onDestroy() {
|
100
|
+
removeBatteryListener();
|
101
|
+
}
|
102
|
+
|
103
|
+
/**
|
104
|
+
* Stop the battery receiver and set it to null.
|
105
|
+
*/
|
106
|
+
private void removeBatteryListener() {
|
107
|
+
if (this.receiver != null) {
|
108
|
+
try {
|
109
|
+
this.ctx.unregisterReceiver(this.receiver);
|
110
|
+
this.receiver = null;
|
111
|
+
} catch (Exception e) {
|
112
|
+
Log.e(LOG_TAG, "Error unregistering battery receiver: " + e.getMessage(), e);
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
/**
|
118
|
+
* Creates a JSONObject with the current battery information
|
119
|
+
*
|
120
|
+
* @param batteryIntent the current battery information
|
121
|
+
* @return a JSONObject containing the battery status information
|
122
|
+
*/
|
123
|
+
private JSONObject getBatteryInfo(Intent batteryIntent) {
|
124
|
+
JSONObject obj = new JSONObject();
|
125
|
+
try {
|
126
|
+
obj.put("level", batteryIntent.getIntExtra(android.os.BatteryManager.EXTRA_LEVEL, 0));
|
127
|
+
obj.put("isPlugged", batteryIntent.getIntExtra(android.os.BatteryManager.EXTRA_PLUGGED, -1) > 0 ? true : false);
|
128
|
+
} catch (JSONException e) {
|
129
|
+
Log.e(LOG_TAG, e.getMessage(), e);
|
130
|
+
}
|
131
|
+
return obj;
|
132
|
+
}
|
133
|
+
|
134
|
+
/**
|
135
|
+
* Updates the JavaScript side whenever the battery changes
|
136
|
+
*
|
137
|
+
* @param batteryIntent the current battery information
|
138
|
+
* @return
|
139
|
+
*/
|
140
|
+
private void updateBatteryInfo(Intent batteryIntent) {
|
141
|
+
sendUpdate(this.getBatteryInfo(batteryIntent), true);
|
142
|
+
}
|
143
|
+
|
144
|
+
/**
|
145
|
+
* Create a new plugin result and send it back to JavaScript
|
146
|
+
*
|
147
|
+
* @param connection the network info to set as navigator.connection
|
148
|
+
*/
|
149
|
+
private void sendUpdate(JSONObject info, boolean keepCallback) {
|
150
|
+
if (this.batteryCallbackId != null) {
|
151
|
+
PluginResult result = new PluginResult(PluginResult.Status.OK, info);
|
152
|
+
result.setKeepCallback(keepCallback);
|
153
|
+
this.success(result, this.batteryCallbackId);
|
154
|
+
}
|
155
|
+
}
|
156
|
+
}
|