cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [53/53] android commit: removed core plugins not needed to build pluginless cordova project
Date Tue, 30 Apr 2013 21:36:09 GMT
removed core plugins not needed to build pluginless cordova project


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/701dfb3b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/701dfb3b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/701dfb3b

Branch: refs/heads/3.0.0
Commit: 701dfb3baf842c7380803ff3a49cf8879f4ce1e6
Parents: b9b14e6
Author: Steven Gill <stevengill97@gmail.com>
Authored: Tue Apr 30 14:34:18 2013 -0700
Committer: Steven Gill <stevengill97@gmail.com>
Committed: Tue Apr 30 14:34:18 2013 -0700

----------------------------------------------------------------------
 bin/templates/project/assets/www/index.html        |    2 +-
 framework/assets/www/index.html                    |    2 +-
 framework/src/org/apache/cordova/core/App.java     |  221 --
 .../src/org/apache/cordova/core/AudioHandler.java  |  358 ---
 .../src/org/apache/cordova/core/AudioPlayer.java   |  553 ----
 .../org/apache/cordova/core/BatteryListener.java   |  163 --
 .../org/apache/cordova/core/CameraLauncher.java    |  795 ------
 framework/src/org/apache/cordova/core/Capture.java |  447 ---
 .../org/apache/cordova/core/CompassListener.java   |  296 --
 .../org/apache/cordova/core/ContactAccessor.java   |  198 --
 .../apache/cordova/core/ContactAccessorSdk5.java   | 2174 ---------------
 .../org/apache/cordova/core/ContactManager.java    |  122 -
 .../cordova/core/CordovaLocationListener.java      |  207 --
 framework/src/org/apache/cordova/core/Echo.java    |   49 -
 .../src/org/apache/cordova/core/ExifHelper.java    |  185 --
 .../apache/cordova/core/FileProgressResult.java    |   63 -
 .../src/org/apache/cordova/core/FileTransfer.java  |  878 ------
 .../org/apache/cordova/core/FileUploadResult.java  |   73 -
 .../src/org/apache/cordova/core/FileUtils.java     | 1188 --------
 .../src/org/apache/cordova/core/GPSListener.java   |   51 -
 .../src/org/apache/cordova/core/GeoBroker.java     |  204 --
 .../src/org/apache/cordova/core/Globalization.java |  577 ----
 .../apache/cordova/core/GlobalizationError.java    |  108 -
 .../src/org/apache/cordova/core/HttpHandler.java   |   86 -
 .../src/org/apache/cordova/core/InAppBrowser.java  |  668 -----
 .../org/apache/cordova/core/NetworkListener.java   |   33 -
 .../org/apache/cordova/core/NetworkManager.java    |  249 --
 .../src/org/apache/cordova/core/Notification.java  |  341 ---
 .../src/org/apache/cordova/core/SplashScreen.java  |   43 -
 framework/src/org/apache/cordova/core/Storage.java |  244 --
 30 files changed, 2 insertions(+), 10576 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/701dfb3b/bin/templates/project/assets/www/index.html
----------------------------------------------------------------------
diff --git a/bin/templates/project/assets/www/index.html b/bin/templates/project/assets/www/index.html
index 4d39cf3..ce767eb 100644
--- a/bin/templates/project/assets/www/index.html
+++ b/bin/templates/project/assets/www/index.html
@@ -33,7 +33,7 @@
                 <p class="event received">Device is Ready</p>
             </div>
         </div>
-        <script type="text/javascript" src="cordova-2.6.0.js"></script>
+        <script type="text/javascript" src="cordova-dev.js"></script>
         <script type="text/javascript" src="js/index.js"></script>
         <script type="text/javascript">
             app.initialize();

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/701dfb3b/framework/assets/www/index.html
----------------------------------------------------------------------
diff --git a/framework/assets/www/index.html b/framework/assets/www/index.html
index 1caeb8a..3678285 100644
--- a/framework/assets/www/index.html
+++ b/framework/assets/www/index.html
@@ -19,7 +19,7 @@
 <html>
   <head>
     <title></title>
-    <script src="cordova-2.6.0.js"></script>
+    <script src="cordova-dev.js"></script>
   </head>
   <body>
 

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/701dfb3b/framework/src/org/apache/cordova/core/App.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/core/App.java b/framework/src/org/apache/cordova/core/App.java
deleted file mode 100755
index 45b683f..0000000
--- a/framework/src/org/apache/cordova/core/App.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
-       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.
-*/
-
-package org.apache.cordova.core;
-
-import org.apache.cordova.api.CallbackContext;
-import org.apache.cordova.api.CordovaPlugin;
-import org.apache.cordova.api.LOG;
-import org.apache.cordova.api.PluginResult;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.util.HashMap;
-
-/**
- * This class exposes methods in DroidGap that can be called from JavaScript.
- */
-public class App extends CordovaPlugin {
-
-    /**
-     * Executes the request and returns PluginResult.
-     *
-     * @param action            The action to execute.
-     * @param args              JSONArry of arguments for the plugin.
-     * @param callbackContext   The callback context from which we were invoked.
-     * @return                  A PluginResult object with a status and message.
-     */
-    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
-        PluginResult.Status status = PluginResult.Status.OK;
-        String result = "";
-
-        try {
-            if (action.equals("clearCache")) {
-                this.clearCache();
-            }
-            else if (action.equals("show")) {
-                // This gets called from JavaScript onCordovaReady to show the webview.
-                // I recommend we change the name of the Message as spinner/stop is not
-                // indicative of what this actually does (shows the webview).
-                cordova.getActivity().runOnUiThread(new Runnable() {
-                    public void run() {
-                        webView.postMessage("spinner", "stop");
-                    }
-                });
-            }
-            else if (action.equals("loadUrl")) {
-                this.loadUrl(args.getString(0), args.optJSONObject(1));
-            }
-            else if (action.equals("cancelLoadUrl")) {
-                //this.cancelLoadUrl();
-            }
-            else if (action.equals("clearHistory")) {
-                this.clearHistory();
-            }
-            else if (action.equals("backHistory")) {
-                this.backHistory();
-            }
-            else if (action.equals("overrideButton")) {
-                this.overrideButton(args.getString(0), args.getBoolean(1));
-            }
-            else if (action.equals("overrideBackbutton")) {
-                this.overrideBackbutton(args.getBoolean(0));
-            }
-            else if (action.equals("exitApp")) {
-                this.exitApp();
-            }
-            callbackContext.sendPluginResult(new PluginResult(status, result));
-            return true;
-        } catch (JSONException e) {
-            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
-            return false;
-        }
-    }
-
-    //--------------------------------------------------------------------------
-    // LOCAL METHODS
-    //--------------------------------------------------------------------------
-
-    /**
-     * Clear the resource cache.
-     */
-    public void clearCache() {
-        this.webView.clearCache(true);
-    }
-
-    /**
-     * Load the url into the webview.
-     *
-     * @param url
-     * @param props			Properties that can be passed in to the DroidGap activity (i.e. loadingDialog, wait, ...)
-     * @throws JSONException
-     */
-    public void loadUrl(String url, JSONObject props) throws JSONException {
-        LOG.d("App", "App.loadUrl("+url+","+props+")");
-        int wait = 0;
-        boolean openExternal = false;
-        boolean clearHistory = false;
-
-        // If there are properties, then set them on the Activity
-        HashMap<String, Object> params = new HashMap<String, Object>();
-        if (props != null) {
-            JSONArray keys = props.names();
-            for (int i = 0; i < keys.length(); i++) {
-                String key = keys.getString(i);
-                if (key.equals("wait")) {
-                    wait = props.getInt(key);
-                }
-                else if (key.equalsIgnoreCase("openexternal")) {
-                    openExternal = props.getBoolean(key);
-                }
-                else if (key.equalsIgnoreCase("clearhistory")) {
-                    clearHistory = props.getBoolean(key);
-                }
-                else {
-                    Object value = props.get(key);
-                    if (value == null) {
-
-                    }
-                    else if (value.getClass().equals(String.class)) {
-                        params.put(key, (String)value);
-                    }
-                    else if (value.getClass().equals(Boolean.class)) {
-                        params.put(key, (Boolean)value);
-                    }
-                    else if (value.getClass().equals(Integer.class)) {
-                        params.put(key, (Integer)value);
-                    }
-                }
-            }
-        }
-
-        // If wait property, then delay loading
-
-        if (wait > 0) {
-            try {
-                synchronized(this) {
-                    this.wait(wait);
-                }
-            } catch (InterruptedException e) {
-                e.printStackTrace();
-            }
-        }
-        this.webView.showWebPage(url, openExternal, clearHistory, params);
-    }
-
-    /**
-     * Clear page history for the app.
-     */
-    public void clearHistory() {
-        this.webView.clearHistory();
-    }
-
-    /**
-     * Go to previous page displayed.
-     * This is the same as pressing the backbutton on Android device.
-     */
-    public void backHistory() {
-        cordova.getActivity().runOnUiThread(new Runnable() {
-            public void run() {
-                webView.backHistory();
-            }
-        });
-    }
-
-    /**
-     * Override the default behavior of the Android back button.
-     * If overridden, when the back button is pressed, the "backKeyDown" JavaScript event will be fired.
-     *
-     * @param override		T=override, F=cancel override
-     */
-    public void overrideBackbutton(boolean override) {
-        LOG.i("App", "WARNING: Back Button Default Behaviour will be overridden.  The backbutton event will be fired!");
-        webView.bindButton(override);
-    }
-
-    /**
-     * Override the default behavior of the Android volume buttons.
-     * If overridden, when the volume button is pressed, the "volume[up|down]button" JavaScript event will be fired.
-     *
-     * @param button        volumeup, volumedown
-     * @param override      T=override, F=cancel override
-     */
-    public void overrideButton(String button, boolean override) {
-        LOG.i("DroidGap", "WARNING: Volume Button Default Behaviour will be overridden.  The volume event will be fired!");
-        webView.bindButton(button, override);
-    }
-
-    /**
-     * Return whether the Android back button is overridden by the user.
-     *
-     * @return boolean
-     */
-    public boolean isBackbuttonOverridden() {
-        return webView.isBackButtonBound();
-    }
-
-    /**
-     * Exit the Android application.
-     */
-    public void exitApp() {
-        this.webView.postMessage("exit", null);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/701dfb3b/framework/src/org/apache/cordova/core/AudioHandler.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/core/AudioHandler.java b/framework/src/org/apache/cordova/core/AudioHandler.java
deleted file mode 100644
index 05725c0..0000000
--- a/framework/src/org/apache/cordova/core/AudioHandler.java
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
-       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.
-*/
-package org.apache.cordova.core;
-
-import org.apache.cordova.FileHelper;
-import org.apache.cordova.api.CallbackContext;
-import org.apache.cordova.api.CordovaPlugin;
-
-import android.content.Context;
-import android.media.AudioManager;
-
-import java.util.ArrayList;
-
-import org.apache.cordova.api.PluginResult;
-import org.json.JSONArray;
-import org.json.JSONException;
-import java.util.HashMap;
-
-/**
- * This class called by CordovaActivity to play and record audio.
- * The file can be local or over a network using http.
- *
- * Audio formats supported (tested):
- * 	.mp3, .wav
- *
- * Local audio files must reside in one of two places:
- * 		android_asset: 		file name must start with /android_asset/sound.mp3
- * 		sdcard:				file name is just sound.mp3
- */
-public class AudioHandler extends CordovaPlugin {
-
-    public static String TAG = "AudioHandler";
-    HashMap<String, AudioPlayer> players;	// Audio player object
-    ArrayList<AudioPlayer> pausedForPhone;     // Audio players that were paused when phone call came in
-
-    /**
-     * Constructor.
-     */
-    public AudioHandler() {
-        this.players = new HashMap<String, AudioPlayer>();
-        this.pausedForPhone = new ArrayList<AudioPlayer>();
-    }
-
-    /**
-     * Executes the request and returns PluginResult.
-     * @param action 		The action to execute.
-     * @param args 			JSONArry of arguments for the plugin.
-     * @param callbackContext		The callback context used when calling back into JavaScript.
-     * @return 				A PluginResult object with a status and message.
-     */
-    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
-        PluginResult.Status status = PluginResult.Status.OK;
-        String result = "";
-
-        if (action.equals("startRecordingAudio")) {
-            this.startRecordingAudio(args.getString(0), FileUtils.stripFileProtocol(args.getString(1)));
-        }
-        else if (action.equals("stopRecordingAudio")) {
-            this.stopRecordingAudio(args.getString(0));
-        }
-        else if (action.equals("startPlayingAudio")) {
-            this.startPlayingAudio(args.getString(0), FileUtils.stripFileProtocol(args.getString(1)));
-        }
-        else if (action.equals("seekToAudio")) {
-            this.seekToAudio(args.getString(0), args.getInt(1));
-        }
-        else if (action.equals("pausePlayingAudio")) {
-            this.pausePlayingAudio(args.getString(0));
-        }
-        else if (action.equals("stopPlayingAudio")) {
-            this.stopPlayingAudio(args.getString(0));
-        } else if (action.equals("setVolume")) {
-           try {
-               this.setVolume(args.getString(0), Float.parseFloat(args.getString(1)));
-           } catch (NumberFormatException nfe) {
-               //no-op
-           }
-        } else if (action.equals("getCurrentPositionAudio")) {
-            float f = this.getCurrentPositionAudio(args.getString(0));
-            callbackContext.sendPluginResult(new PluginResult(status, f));
-            return true;
-        }
-        else if (action.equals("getDurationAudio")) {
-            float f = this.getDurationAudio(args.getString(0), args.getString(1));
-            callbackContext.sendPluginResult(new PluginResult(status, f));
-            return true;
-        }
-        else if (action.equals("create")) {
-            String id = args.getString(0);
-            String src = FileUtils.stripFileProtocol(args.getString(1));
-            AudioPlayer audio = new AudioPlayer(this, id, src);
-            this.players.put(id, audio);
-        }
-        else if (action.equals("release")) {
-            boolean b = this.release(args.getString(0));
-            callbackContext.sendPluginResult(new PluginResult(status, b));
-            return true;
-        }
-        else { // Unrecognized action.
-            return false;
-        }
-
-        callbackContext.sendPluginResult(new PluginResult(status, result));
-
-        return true;
-    }
-
-    /**
-     * Stop all audio players and recorders.
-     */
-    public void onDestroy() {
-        for (AudioPlayer audio : this.players.values()) {
-            audio.destroy();
-        }
-        this.players.clear();
-    }
-
-    /**
-     * Stop all audio players and recorders on navigate.
-     */
-    @Override
-    public void onReset() {
-        onDestroy();
-    }
-
-    /**
-     * Called when a message is sent to plugin.
-     *
-     * @param id            The message id
-     * @param data          The message data
-     * @return              Object to stop propagation or null
-     */
-    public Object onMessage(String id, Object data) {
-
-        // If phone message
-        if (id.equals("telephone")) {
-
-            // If phone ringing, then pause playing
-            if ("ringing".equals(data) || "offhook".equals(data)) {
-
-                // Get all audio players and pause them
-                for (AudioPlayer audio : this.players.values()) {
-                    if (audio.getState() == AudioPlayer.STATE.MEDIA_RUNNING.ordinal()) {
-                        this.pausedForPhone.add(audio);
-                        audio.pausePlaying();
-                    }
-                }
-
-            }
-
-            // If phone idle, then resume playing those players we paused
-            else if ("idle".equals(data)) {
-                for (AudioPlayer audio : this.pausedForPhone) {
-                    audio.startPlaying(null);
-                }
-                this.pausedForPhone.clear();
-            }
-        }
-        return null;
-    }
-
-    //--------------------------------------------------------------------------
-    // LOCAL METHODS
-    //--------------------------------------------------------------------------
-
-    /**
-     * Release the audio player instance to save memory.
-     * @param id				The id of the audio player
-     */
-    private boolean release(String id) {
-        if (!this.players.containsKey(id)) {
-            return false;
-        }
-        AudioPlayer audio = this.players.get(id);
-        this.players.remove(id);
-        audio.destroy();
-        return true;
-    }
-
-    /**
-     * Start recording and save the specified file.
-     * @param id				The id of the audio player
-     * @param file				The name of the file
-     */
-    public void startRecordingAudio(String id, String file) {
-        AudioPlayer audio = this.players.get(id);
-        if ( audio == null) {
-            audio = new AudioPlayer(this, id, file);
-            this.players.put(id, audio);
-        }
-        audio.startRecording(file);
-    }
-
-    /**
-     * Stop recording and save to the file specified when recording started.
-     * @param id				The id of the audio player
-     */
-    public void stopRecordingAudio(String id) {
-        AudioPlayer audio = this.players.get(id);
-        if (audio != null) {
-            audio.stopRecording();
-        }
-    }
-
-    /**
-     * Start or resume playing audio file.
-     * @param id				The id of the audio player
-     * @param file				The name of the audio file.
-     */
-    public void startPlayingAudio(String id, String file) {
-        AudioPlayer audio = this.players.get(id);
-        if (audio == null) {
-            audio = new AudioPlayer(this, id, file);
-            this.players.put(id, audio);
-        }
-        audio.startPlaying(file);
-    }
-
-    /**
-     * Seek to a location.
-     * @param id				The id of the audio player
-     * @param milliseconds		int: number of milliseconds to skip 1000 = 1 second
-     */
-    public void seekToAudio(String id, int milliseconds) {
-        AudioPlayer audio = this.players.get(id);
-        if (audio != null) {
-            audio.seekToPlaying(milliseconds);
-        }
-    }
-
-    /**
-     * Pause playing.
-     * @param id				The id of the audio player
-     */
-    public void pausePlayingAudio(String id) {
-        AudioPlayer audio = this.players.get(id);
-        if (audio != null) {
-            audio.pausePlaying();
-        }
-    }
-
-    /**
-     * Stop playing the audio file.
-     * @param id				The id of the audio player
-     */
-    public void stopPlayingAudio(String id) {
-        AudioPlayer audio = this.players.get(id);
-        if (audio != null) {
-            audio.stopPlaying();
-            //audio.destroy();
-            //this.players.remove(id);
-        }
-    }
-
-    /**
-     * Get current position of playback.
-     * @param id				The id of the audio player
-     * @return 					position in msec
-     */
-    public float getCurrentPositionAudio(String id) {
-        AudioPlayer audio = this.players.get(id);
-        if (audio != null) {
-            return (audio.getCurrentPosition() / 1000.0f);
-        }
-        return -1;
-    }
-
-    /**
-     * Get the duration of the audio file.
-     * @param id				The id of the audio player
-     * @param file				The name of the audio file.
-     * @return					The duration in msec.
-     */
-    public float getDurationAudio(String id, String file) {
-
-        // Get audio file
-        AudioPlayer audio = this.players.get(id);
-        if (audio != null) {
-            return (audio.getDuration(file));
-        }
-
-        // If not already open, then open the file
-        else {
-            audio = new AudioPlayer(this, id, file);
-            this.players.put(id, audio);
-            return (audio.getDuration(file));
-        }
-    }
-
-    /**
-     * Set the audio device to be used for playback.
-     *
-     * @param output			1=earpiece, 2=speaker
-     */
-    @SuppressWarnings("deprecation")
-    public void setAudioOutputDevice(int output) {
-        AudioManager audiMgr = (AudioManager) this.cordova.getActivity().getSystemService(Context.AUDIO_SERVICE);
-        if (output == 2) {
-            audiMgr.setRouting(AudioManager.MODE_NORMAL, AudioManager.ROUTE_SPEAKER, AudioManager.ROUTE_ALL);
-        }
-        else if (output == 1) {
-            audiMgr.setRouting(AudioManager.MODE_NORMAL, AudioManager.ROUTE_EARPIECE, AudioManager.ROUTE_ALL);
-        }
-        else {
-            System.out.println("AudioHandler.setAudioOutputDevice() Error: Unknown output device.");
-        }
-    }
-
-    /**
-     * Get the audio device to be used for playback.
-     *
-     * @return					1=earpiece, 2=speaker
-     */
-    @SuppressWarnings("deprecation")
-    public int getAudioOutputDevice() {
-        AudioManager audiMgr = (AudioManager) this.cordova.getActivity().getSystemService(Context.AUDIO_SERVICE);
-        if (audiMgr.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_EARPIECE) {
-            return 1;
-        }
-        else if (audiMgr.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_SPEAKER) {
-            return 2;
-        }
-        else {
-            return -1;
-        }
-    }
-
-    /**
-     * Set the volume for an audio device
-     *
-     * @param id				The id of the audio player
-     * @param volume            Volume to adjust to 0.0f - 1.0f
-     */
-    public void setVolume(String id, float volume) {
-        AudioPlayer audio = this.players.get(id);
-        if (audio != null) {
-            audio.setVolume(volume);
-        } else {
-            System.out.println("AudioHandler.setVolume() Error: Unknown Audio Player " + id);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/701dfb3b/framework/src/org/apache/cordova/core/AudioPlayer.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/core/AudioPlayer.java b/framework/src/org/apache/cordova/core/AudioPlayer.java
deleted file mode 100644
index 271dfa3..0000000
--- a/framework/src/org/apache/cordova/core/AudioPlayer.java
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
-       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.
-*/
-package org.apache.cordova.core;
-
-import android.media.AudioManager;
-import android.media.MediaPlayer;
-import android.media.MediaPlayer.OnCompletionListener;
-import android.media.MediaPlayer.OnErrorListener;
-import android.media.MediaPlayer.OnPreparedListener;
-import android.media.MediaRecorder;
-import android.os.Environment;
-import android.util.Log;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-/**
- * This class implements the audio playback and recording capabilities used by Cordova.
- * It is called by the AudioHandler Cordova class.
- * Only one file can be played or recorded per class instance.
- *
- * Local audio files must reside in one of two places:
- *      android_asset:      file name must start with /android_asset/sound.mp3
- *      sdcard:             file name is just sound.mp3
- */
-public class AudioPlayer implements OnCompletionListener, OnPreparedListener, OnErrorListener {
-
-    // AudioPlayer modes
-    public enum MODE { NONE, PLAY, RECORD };
-
-    // AudioPlayer states
-    public enum STATE { MEDIA_NONE,
-                        MEDIA_STARTING,
-                        MEDIA_RUNNING,
-                        MEDIA_PAUSED,
-                        MEDIA_STOPPED,
-                        MEDIA_LOADING
-                      };
-
-    private static final String LOG_TAG = "AudioPlayer";
-
-    // AudioPlayer message ids
-    private static int MEDIA_STATE = 1;
-    private static int MEDIA_DURATION = 2;
-    private static int MEDIA_POSITION = 3;
-    private static int MEDIA_ERROR = 9;
-
-    // Media error codes
-    private static int MEDIA_ERR_NONE_ACTIVE    = 0;
-    private static int MEDIA_ERR_ABORTED        = 1;
-    private static int MEDIA_ERR_NETWORK        = 2;
-    private static int MEDIA_ERR_DECODE         = 3;
-    private static int MEDIA_ERR_NONE_SUPPORTED = 4;
-
-    private AudioHandler handler;           // The AudioHandler object
-    private String id;                      // The id of this player (used to identify Media object in JavaScript)
-    private MODE mode = MODE.NONE;          // Playback or Recording mode
-    private STATE state = STATE.MEDIA_NONE; // State of recording or playback
-
-    private String audioFile = null;        // File name to play or record to
-    private float duration = -1;            // Duration of audio
-
-    private MediaRecorder recorder = null;  // Audio recording object
-    private String tempFile = null;         // Temporary recording file name
-
-    private MediaPlayer player = null;      // Audio player object
-    private boolean prepareOnly = true;     // playback after file prepare flag
-    private int seekOnPrepared = 0;     // seek to this location once media is prepared
-
-    /**
-     * Constructor.
-     *
-     * @param handler           The audio handler object
-     * @param id                The id of this audio player
-     */
-    public AudioPlayer(AudioHandler handler, String id, String file) {
-        this.handler = handler;
-        this.id = id;
-        this.audioFile = file;
-        this.recorder = new MediaRecorder();
-
-        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
-            this.tempFile = Environment.getExternalStorageDirectory().getAbsolutePath() + "/tmprecording.3gp";
-        } else {
-            this.tempFile = "/data/data/" + handler.cordova.getActivity().getPackageName() + "/cache/tmprecording.3gp";
-        }
-
-    }
-
-    /**
-     * Destroy player and stop audio playing or recording.
-     */
-    public void destroy() {
-        // Stop any play or record
-        if (this.player != null) {
-            if ((this.state == STATE.MEDIA_RUNNING) || (this.state == STATE.MEDIA_PAUSED)) {
-                this.player.stop();
-                this.setState(STATE.MEDIA_STOPPED);
-            }
-            this.player.release();
-            this.player = null;
-        }
-        if (this.recorder != null) {
-            this.stopRecording();
-            this.recorder.release();
-            this.recorder = null;
-        }
-    }
-
-    /**
-     * Start recording the specified file.
-     *
-     * @param file              The name of the file
-     */
-    public void startRecording(String file) {
-        switch (this.mode) {
-        case PLAY:
-            Log.d(LOG_TAG, "AudioPlayer Error: Can't record in play mode.");
-            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
-            break;
-        case NONE:
-            this.audioFile = file;
-            this.recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
-            this.recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT); // THREE_GPP);
-            this.recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); //AMR_NB);
-            this.recorder.setOutputFile(this.tempFile);
-            try {
-                this.recorder.prepare();
-                this.recorder.start();
-                this.setState(STATE.MEDIA_RUNNING);
-                return;
-            } catch (IllegalStateException e) {
-                e.printStackTrace();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
-            break;
-        case RECORD:
-            Log.d(LOG_TAG, "AudioPlayer Error: Already recording.");
-            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
-        }
-    }
-
-    /**
-     * Save temporary recorded file to specified name
-     *
-     * @param file
-     */
-    public void moveFile(String file) {
-        /* this is a hack to save the file as the specified name */
-        File f = new File(this.tempFile);
-
-        if (!file.startsWith("/")) {
-            if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
-                file = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + file;
-            } else {
-                file = "/data/data/" + handler.cordova.getActivity().getPackageName() + "/cache/" + file;
-            }
-        }
-
-        String logMsg = "renaming " + this.tempFile + " to " + file;
-        Log.d(LOG_TAG, logMsg);
-        if (!f.renameTo(new File(file))) Log.e(LOG_TAG, "FAILED " + logMsg);
-    }
-
-    /**
-     * Stop recording and save to the file specified when recording started.
-     */
-    public void stopRecording() {
-        if (this.recorder != null) {
-            try{
-                if (this.state == STATE.MEDIA_RUNNING) {
-                    this.recorder.stop();
-                    this.setState(STATE.MEDIA_STOPPED);
-                }
-                this.recorder.reset();
-                this.moveFile(this.audioFile);
-            }
-            catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    //==========================================================================
-    // Playback
-    //==========================================================================
-
-    /**
-     * Start or resume playing audio file.
-     *
-     * @param file              The name of the audio file.
-     */
-    public void startPlaying(String file) {
-        if (this.readyPlayer(file) && this.player != null) {
-            this.player.start();
-            this.setState(STATE.MEDIA_RUNNING);
-            this.seekOnPrepared = 0; //insures this is always reset
-        } else {
-            this.prepareOnly = false;
-        }
-    }
-
-    /**
-     * Seek or jump to a new time in the track.
-     */
-    public void seekToPlaying(int milliseconds) {
-        if (this.readyPlayer(this.audioFile)) {
-            this.player.seekTo(milliseconds);
-            Log.d(LOG_TAG, "Send a onStatus update for the new seek");
-            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_POSITION + ", " + milliseconds / 1000.0f + ");");
-        }
-        else {
-            this.seekOnPrepared = milliseconds;
-        }
-    }
-
-    /**
-     * Pause playing.
-     */
-    public void pausePlaying() {
-
-        // If playing, then pause
-        if (this.state == STATE.MEDIA_RUNNING && this.player != null) {
-            this.player.pause();
-            this.setState(STATE.MEDIA_PAUSED);
-        }
-        else {
-            Log.d(LOG_TAG, "AudioPlayer Error: pausePlaying() called during invalid state: " + this.state.ordinal());
-            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_NONE_ACTIVE + "});");
-        }
-    }
-
-    /**
-     * Stop playing the audio file.
-     */
-    public void stopPlaying() {
-        if ((this.state == STATE.MEDIA_RUNNING) || (this.state == STATE.MEDIA_PAUSED)) {
-            this.player.pause();
-            this.player.seekTo(0);
-            Log.d(LOG_TAG, "stopPlaying is calling stopped");
-            this.setState(STATE.MEDIA_STOPPED);
-        }
-        else {
-            Log.d(LOG_TAG, "AudioPlayer Error: stopPlaying() called during invalid state: " + this.state.ordinal());
-            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_NONE_ACTIVE + "});");
-        }
-    }
-
-    /**
-     * Callback to be invoked when playback of a media source has completed.
-     *
-     * @param player           The MediaPlayer that reached the end of the file
-     */
-    public void onCompletion(MediaPlayer player) {
-        Log.d(LOG_TAG, "on completion is calling stopped");
-        this.setState(STATE.MEDIA_STOPPED);
-    }
-
-    /**
-     * Get current position of playback.
-     *
-     * @return                  position in msec or -1 if not playing
-     */
-    public long getCurrentPosition() {
-        if ((this.state == STATE.MEDIA_RUNNING) || (this.state == STATE.MEDIA_PAUSED)) {
-            int curPos = this.player.getCurrentPosition();
-            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_POSITION + ", " + curPos / 1000.0f + ");");
-            return curPos;
-        }
-        else {
-            return -1;
-        }
-    }
-
-    /**
-     * Determine if playback file is streaming or local.
-     * It is streaming if file name starts with "http://"
-     *
-     * @param file              The file name
-     * @return                  T=streaming, F=local
-     */
-    public boolean isStreaming(String file) {
-        if (file.contains("http://") || file.contains("https://")) {
-            return true;
-        }
-        else {
-            return false;
-        }
-    }
-
-    /**
-      * Get the duration of the audio file.
-      *
-      * @param file             The name of the audio file.
-      * @return                 The duration in msec.
-      *                             -1=can't be determined
-      *                             -2=not allowed
-      */
-    public float getDuration(String file) {
-
-        // Can't get duration of recording
-        if (this.recorder != null) {
-            return (-2); // not allowed
-        }
-
-        // If audio file already loaded and started, then return duration
-        if (this.player != null) {
-            return this.duration;
-        }
-
-        // If no player yet, then create one
-        else {
-            this.prepareOnly = true;
-            this.startPlaying(file);
-
-            // This will only return value for local, since streaming
-            // file hasn't been read yet.
-            return this.duration;
-        }
-    }
-
-    /**
-     * Callback to be invoked when the media source is ready for playback.
-     *
-     * @param player           The MediaPlayer that is ready for playback
-     */
-    public void onPrepared(MediaPlayer player) {
-        // Listen for playback completion
-        this.player.setOnCompletionListener(this);
-        // seek to any location received while not prepared
-        this.seekToPlaying(this.seekOnPrepared);
-        // If start playing after prepared
-        if (!this.prepareOnly) {
-            this.player.start();
-            this.setState(STATE.MEDIA_RUNNING);
-            this.seekOnPrepared = 0; //reset only when played
-        } else {
-            this.setState(STATE.MEDIA_STARTING);
-        }
-        // Save off duration
-        this.duration = getDurationInSeconds();
-        // reset prepare only flag
-        this.prepareOnly = true;
-
-        // Send status notification to JavaScript
-        this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_DURATION + "," + this.duration + ");");
-    }
-
-    /**
-     * By default Android returns the length of audio in mills but we want seconds
-     *
-     * @return length of clip in seconds
-     */
-    private float getDurationInSeconds() {
-        return (this.player.getDuration() / 1000.0f);
-    }
-
-    /**
-     * Callback to be invoked when there has been an error during an asynchronous operation
-     *  (other errors will throw exceptions at method call time).
-     *
-     * @param player           the MediaPlayer the error pertains to
-     * @param arg1              the type of error that has occurred: (MEDIA_ERROR_UNKNOWN, MEDIA_ERROR_SERVER_DIED)
-     * @param arg2              an extra code, specific to the error.
-     */
-    public boolean onError(MediaPlayer player, int arg1, int arg2) {
-        Log.d(LOG_TAG, "AudioPlayer.onError(" + arg1 + ", " + arg2 + ")");
-
-        // TODO: Not sure if this needs to be sent?
-        this.player.stop();
-        this.player.release();
-
-        // Send error notification to JavaScript
-        this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', { \"code\":" + arg1 + "});");
-        return false;
-    }
-
-    /**
-     * Set the state and send it to JavaScript.
-     *
-     * @param state
-     */
-    private void setState(STATE state) {
-        if (this.state != state) {
-            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_STATE + ", " + state.ordinal() + ");");
-        }
-        this.state = state;
-    }
-
-    /**
-     * Set the mode and send it to JavaScript.
-     *
-     * @param state
-     */
-    private void setMode(MODE mode) {
-        if (this.mode != mode) {
-            //mode is not part of the expected behavior, so no notification
-            //this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_STATE + ", " + mode + ");");
-        }
-        this.mode = mode;
-    }
-
-    /**
-     * Get the audio state.
-     *
-     * @return int
-     */
-    public int getState() {
-        return this.state.ordinal();
-    }
-
-    /**
-     * Set the volume for audio player
-     *
-     * @param volume
-     */
-    public void setVolume(float volume) {
-        this.player.setVolume(volume, volume);
-    }
-
-    /**
-     * attempts to put the player in play mode
-     * @return true if in playmode, false otherwise
-     */
-    private boolean playMode() {
-        switch(this.mode) {
-        case NONE:
-            this.setMode(MODE.PLAY);
-            break;
-        case PLAY:
-            break;
-        case RECORD:
-            Log.d(LOG_TAG, "AudioPlayer Error: Can't play in record mode.");
-            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_ABORTED + "});");
-            return false; //player is not ready
-        }
-        return true;
-    }
-
-    /**
-     * attempts to initialize the media player for playback
-     * @param file the file to play
-     * @return false if player not ready, reports if in wrong mode or state
-     */
-    private boolean readyPlayer(String file) {
-        if (playMode()) {
-            switch (this.state) {
-                case MEDIA_NONE:
-                    if (this.player == null) {
-                        this.player = new MediaPlayer();
-                    }
-                    try {
-                        this.loadAudioFile(file);
-                    } catch (Exception e) {
-                        this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
-                    }
-                    return false;
-                case MEDIA_LOADING:
-                    //cordova js is not aware of MEDIA_LOADING, so we send MEDIA_STARTING instead
-                    Log.d(LOG_TAG, "AudioPlayer Loading: startPlaying() called during media preparation: " + STATE.MEDIA_STARTING.ordinal());
-                    this.prepareOnly = false;
-                    return false;
-                case MEDIA_STARTING:
-                case MEDIA_RUNNING:
-                case MEDIA_PAUSED:
-                    return true;
-                case MEDIA_STOPPED:
-                    //if we are readying the same file
-                    if (this.audioFile.compareTo(file) == 0) {
-                        //reset the audio file
-                        player.seekTo(0);
-                        player.pause();
-                        return true;
-                    } else {
-                        //reset the player
-                        this.player.reset();
-                        try {
-                            this.loadAudioFile(file);
-                        } catch (Exception e) {
-                            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_ABORTED + "});");
-                        }
-                        //if we had to prepare= the file, we won't be in the correct state for playback
-                        return false;
-                    }
-                default:
-                    Log.d(LOG_TAG, "AudioPlayer Error: startPlaying() called during invalid state: " + this.state);
-                    this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_ABORTED + "});");
-            }
-        }
-        return false;
-    }
-
-    /**
-     * load audio file
-     * @throws IOException
-     * @throws IllegalStateException
-     * @throws SecurityException
-     * @throws IllegalArgumentException
-     */
-    private void loadAudioFile(String file) throws IllegalArgumentException, SecurityException, IllegalStateException, IOException {
-        if (this.isStreaming(file)) {
-            this.player.setDataSource(file);
-            this.player.setAudioStreamType(AudioManager.STREAM_MUSIC);
-            //if it's a streaming file, play mode is implied
-            this.setMode(MODE.PLAY);
-            this.setState(STATE.MEDIA_STARTING);
-            this.player.setOnPreparedListener(this);
-            this.player.prepareAsync();
-        }
-        else {
-            if (file.startsWith("/android_asset/")) {
-                String f = file.substring(15);
-                android.content.res.AssetFileDescriptor fd = this.handler.cordova.getActivity().getAssets().openFd(f);
-                this.player.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
-            }
-            else {
-                File fp = new File(file);
-                if (fp.exists()) {
-                    FileInputStream fileInputStream = new FileInputStream(file);
-                    this.player.setDataSource(fileInputStream.getFD());
-                }
-                else {
-                    this.player.setDataSource("/sdcard/" + file);
-                }
-            }
-                this.setState(STATE.MEDIA_STARTING);
-                this.player.setOnPreparedListener(this);
-                this.player.prepare();
-
-                // Get duration
-                this.duration = getDurationInSeconds();
-            }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/701dfb3b/framework/src/org/apache/cordova/core/BatteryListener.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/core/BatteryListener.java b/framework/src/org/apache/cordova/core/BatteryListener.java
deleted file mode 100755
index 67dfdd1..0000000
--- a/framework/src/org/apache/cordova/core/BatteryListener.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
-       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.
-*/
-package org.apache.cordova.core;
-
-import org.apache.cordova.api.CallbackContext;
-import org.apache.cordova.api.CordovaPlugin;
-import org.apache.cordova.api.PluginResult;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.util.Log;
-
-public class BatteryListener extends CordovaPlugin {
-
-    private static final String LOG_TAG = "BatteryManager";
-
-    BroadcastReceiver receiver;
-
-    private CallbackContext batteryCallbackContext = null;
-
-    /**
-     * Constructor.
-     */
-    public BatteryListener() {
-        this.receiver = null;
-    }
-
-    /**
-     * Executes the request.
-     *
-     * @param action        	The action to execute.
-     * @param args          	JSONArry of arguments for the plugin.
-     * @param callbackContext 	The callback context used when calling back into JavaScript.
-     * @return              	True if the action was valid, false if not.
-     */
-    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
-        if (action.equals("start")) {
-            if (this.batteryCallbackContext != null) {
-                callbackContext.error( "Battery listener already running.");
-                return true;
-            }
-            this.batteryCallbackContext = callbackContext;
-
-            // We need to listen to power events to update battery status
-            IntentFilter intentFilter = new IntentFilter();
-            intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
-            if (this.receiver == null) {
-                this.receiver = new BroadcastReceiver() {
-                    @Override
-                    public void onReceive(Context context, Intent intent) {
-                        updateBatteryInfo(intent);
-                    }
-                };
-                cordova.getActivity().registerReceiver(this.receiver, intentFilter);
-            }
-
-            // Don't return any result now, since status results will be sent when events come in from broadcast receiver
-            PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT);
-            pluginResult.setKeepCallback(true);
-            callbackContext.sendPluginResult(pluginResult);
-            return true;
-        }
-
-        else if (action.equals("stop")) {
-            removeBatteryListener();
-            this.sendUpdate(new JSONObject(), false); // release status callback in JS side
-            this.batteryCallbackContext = null;
-            callbackContext.success();
-            return true;
-        }
-
-        return false;
-    }
-
-    /**
-     * Stop battery receiver.
-     */
-    public void onDestroy() {
-        removeBatteryListener();
-    }
-
-    /**
-     * Stop battery receiver.
-     */
-    public void onReset() {
-        removeBatteryListener();
-    }
-
-    /**
-     * Stop the battery receiver and set it to null.
-     */
-    private void removeBatteryListener() {
-        if (this.receiver != null) {
-            try {
-                this.cordova.getActivity().unregisterReceiver(this.receiver);
-                this.receiver = null;
-            } catch (Exception e) {
-                Log.e(LOG_TAG, "Error unregistering battery receiver: " + e.getMessage(), e);
-            }
-        }
-    }
-
-    /**
-     * Creates a JSONObject with the current battery information
-     *
-     * @param batteryIntent the current battery information
-     * @return a JSONObject containing the battery status information
-     */
-    private JSONObject getBatteryInfo(Intent batteryIntent) {
-        JSONObject obj = new JSONObject();
-        try {
-            obj.put("level", batteryIntent.getIntExtra(android.os.BatteryManager.EXTRA_LEVEL, 0));
-            obj.put("isPlugged", batteryIntent.getIntExtra(android.os.BatteryManager.EXTRA_PLUGGED, -1) > 0 ? true : false);
-        } catch (JSONException e) {
-            Log.e(LOG_TAG, e.getMessage(), e);
-        }
-        return obj;
-    }
-
-    /**
-     * Updates the JavaScript side whenever the battery changes
-     *
-     * @param batteryIntent the current battery information
-     * @return
-     */
-    private void updateBatteryInfo(Intent batteryIntent) {
-        sendUpdate(this.getBatteryInfo(batteryIntent), true);
-    }
-
-    /**
-     * Create a new plugin result and send it back to JavaScript
-     *
-     * @param connection the network info to set as navigator.connection
-     */
-    private void sendUpdate(JSONObject info, boolean keepCallback) {
-        if (this.batteryCallbackContext != null) {
-            PluginResult result = new PluginResult(PluginResult.Status.OK, info);
-            result.setKeepCallback(keepCallback);
-            this.batteryCallbackContext.sendPluginResult(result);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/701dfb3b/framework/src/org/apache/cordova/core/CameraLauncher.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/core/CameraLauncher.java b/framework/src/org/apache/cordova/core/CameraLauncher.java
deleted file mode 100755
index 2fe3056..0000000
--- a/framework/src/org/apache/cordova/core/CameraLauncher.java
+++ /dev/null
@@ -1,795 +0,0 @@
-/*
-       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.
-*/
-package org.apache.cordova.core;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.cordova.DirectoryManager;
-import org.apache.cordova.FileHelper;
-import org.apache.cordova.api.CallbackContext;
-import org.apache.cordova.api.CordovaPlugin;
-import org.apache.cordova.api.LOG;
-import org.apache.cordova.api.PluginResult;
-import org.json.JSONArray;
-import org.json.JSONException;
-
-import android.app.Activity;
-import android.content.ContentValues;
-import android.content.Intent;
-import android.database.Cursor;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Matrix;
-import android.graphics.Bitmap.CompressFormat;
-import android.media.MediaScannerConnection;
-import android.media.MediaScannerConnection.MediaScannerConnectionClient;
-import android.net.Uri;
-import android.os.Environment;
-import android.provider.MediaStore;
-import android.util.Log;
-
-/**
- * This class launches the camera view, allows the user to take a picture, closes the camera view,
- * and returns the captured image.  When the camera view is closed, the screen displayed before
- * the camera view was shown is redisplayed.
- */
-public class CameraLauncher extends CordovaPlugin implements MediaScannerConnectionClient {
-
-    private static final int DATA_URL = 0;              // Return base64 encoded string
-    private static final int FILE_URI = 1;              // Return file uri (content://media/external/images/media/2 for Android)
-    private static final int NATIVE_URI = 2;			// On Android, this is the same as FILE_URI
-
-    private static final int PHOTOLIBRARY = 0;          // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
-    private static final int CAMERA = 1;                // Take picture from camera
-    private static final int SAVEDPHOTOALBUM = 2;       // Choose image from picture library (same as PHOTOLIBRARY for Android)
-
-    private static final int PICTURE = 0;               // allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType
-    private static final int VIDEO = 1;                 // allow selection of video only, ONLY RETURNS URL
-    private static final int ALLMEDIA = 2;              // allow selection from all media types
-
-    private static final int JPEG = 0;                  // Take a picture of type JPEG
-    private static final int PNG = 1;                   // Take a picture of type PNG
-    private static final String GET_PICTURE = "Get Picture";
-    private static final String GET_VIDEO = "Get Video";
-    private static final String GET_All = "Get All";
-
-    private static final String LOG_TAG = "CameraLauncher";
-
-    private int mQuality;                   // Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality)
-    private int targetWidth;                // desired width of the image
-    private int targetHeight;               // desired height of the image
-    private Uri imageUri;                   // Uri of captured image
-    private int encodingType;               // Type of encoding to use
-    private int mediaType;                  // What type of media to retrieve
-    private boolean saveToPhotoAlbum;       // Should the picture be saved to the device's photo album
-    private boolean correctOrientation;     // Should the pictures orientation be corrected
-    //private boolean allowEdit;              // Should we allow the user to crop the image. UNUSED.
-
-    public CallbackContext callbackContext;
-    private int numPics;
-
-    private MediaScannerConnection conn;    // Used to update gallery app with newly-written files
-    private Uri scanMe;                     // Uri of image to be added to content store
-
-    //This should never be null!
-    //private CordovaInterface cordova;
-
-    /**
-     * Constructor.
-     */
-    public CameraLauncher() {
-    }
-
-//    public void setContext(CordovaInterface mCtx) {
-//        super.setContext(mCtx);
-//        if (CordovaInterface.class.isInstance(mCtx))
-//            cordova = (CordovaInterface) mCtx;
-//        else
-//            LOG.d(LOG_TAG, "ERROR: You must use the CordovaInterface for this to work correctly. Please implement it in your activity");
-//    }
-
-    /**
-     * Executes the request and returns PluginResult.
-     *
-     * @param action        	The action to execute.
-     * @param args          	JSONArry of arguments for the plugin.
-     * @param callbackContext   The callback id used when calling back into JavaScript.
-     * @return              	A PluginResult object with a status and message.
-     */
-    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
-        this.callbackContext = callbackContext;
-
-        if (action.equals("takePicture")) {
-            int srcType = CAMERA;
-            int destType = FILE_URI;
-            this.saveToPhotoAlbum = false;
-            this.targetHeight = 0;
-            this.targetWidth = 0;
-            this.encodingType = JPEG;
-            this.mediaType = PICTURE;
-            this.mQuality = 80;
-
-            this.mQuality = args.getInt(0);
-            destType = args.getInt(1);
-            srcType = args.getInt(2);
-            this.targetWidth = args.getInt(3);
-            this.targetHeight = args.getInt(4);
-            this.encodingType = args.getInt(5);
-            this.mediaType = args.getInt(6);
-            //this.allowEdit = args.getBoolean(7); // This field is unused.
-            this.correctOrientation = args.getBoolean(8);
-            this.saveToPhotoAlbum = args.getBoolean(9);
-
-            // If the user specifies a 0 or smaller width/height
-            // make it -1 so later comparisons succeed
-            if (this.targetWidth < 1) {
-                this.targetWidth = -1;
-            }
-            if (this.targetHeight < 1) {
-                this.targetHeight = -1;
-            }
-
-            if (srcType == CAMERA) {
-                this.takePicture(destType, encodingType);
-            }
-            else if ((srcType == PHOTOLIBRARY) || (srcType == SAVEDPHOTOALBUM)) {
-                this.getImage(srcType, destType);
-            }
-            PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
-            r.setKeepCallback(true);
-            callbackContext.sendPluginResult(r);
-            return true;
-        }
-        return false;
-    }
-
-    //--------------------------------------------------------------------------
-    // LOCAL METHODS
-    //--------------------------------------------------------------------------
-
-    /**
-     * Take a picture with the camera.
-     * When an image is captured or the camera view is cancelled, the result is returned
-     * in CordovaActivity.onActivityResult, which forwards the result to this.onActivityResult.
-     *
-     * The image can either be returned as a base64 string or a URI that points to the file.
-     * To display base64 string in an img tag, set the source to:
-     *      img.src="data:image/jpeg;base64,"+result;
-     * or to display URI in an img tag
-     *      img.src=result;
-     *
-     * @param quality           Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality)
-     * @param returnType        Set the type of image to return.
-     */
-    public void takePicture(int returnType, int encodingType) {
-        // Save the number of images currently on disk for later
-        this.numPics = queryImgDB(whichContentStore()).getCount();
-
-        // Display camera
-        Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
-
-        // Specify file so that large image is captured and returned
-        File photo = createCaptureFile(encodingType);
-        intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
-        this.imageUri = Uri.fromFile(photo);
-
-        if (this.cordova != null) {
-            this.cordova.startActivityForResult((CordovaPlugin) this, intent, (CAMERA + 1) * 16 + returnType + 1);
-        }
-//        else
-//            LOG.d(LOG_TAG, "ERROR: You must use the CordovaInterface for this to work correctly. Please implement it in your activity");
-    }
-
-    /**
-     * Create a file in the applications temporary directory based upon the supplied encoding.
-     *
-     * @param encodingType of the image to be taken
-     * @return a File object pointing to the temporary picture
-     */
-    private File createCaptureFile(int encodingType) {
-        File photo = null;
-        if (encodingType == JPEG) {
-            photo = new File(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()), ".Pic.jpg");
-        } else if (encodingType == PNG) {
-            photo = new File(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()), ".Pic.png");
-        } else {
-            throw new IllegalArgumentException("Invalid Encoding Type: " + encodingType);
-        }
-        return photo;
-    }
-
-    /**
-     * Get image from photo library.
-     *
-     * @param quality           Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality)
-     * @param srcType           The album to get image from.
-     * @param returnType        Set the type of image to return.
-     */
-    // TODO: Images selected from SDCARD don't display correctly, but from CAMERA ALBUM do!
-    public void getImage(int srcType, int returnType) {
-        Intent intent = new Intent();
-        String title = GET_PICTURE;
-        if (this.mediaType == PICTURE) {
-            intent.setType("image/*");
-        }
-        else if (this.mediaType == VIDEO) {
-            intent.setType("video/*");
-            title = GET_VIDEO;
-        }
-        else if (this.mediaType == ALLMEDIA) {
-            // I wanted to make the type 'image/*, video/*' but this does not work on all versions
-            // of android so I had to go with the wildcard search.
-            intent.setType("*/*");
-            title = GET_All;
-        }
-
-        intent.setAction(Intent.ACTION_GET_CONTENT);
-        intent.addCategory(Intent.CATEGORY_OPENABLE);
-        if (this.cordova != null) {
-            this.cordova.startActivityForResult((CordovaPlugin) this, Intent.createChooser(intent,
-                    new String(title)), (srcType + 1) * 16 + returnType + 1);
-        }
-    }
-
-    /**
-     * Called when the camera view exits.
-     *
-     * @param requestCode       The request code originally supplied to startActivityForResult(),
-     *                          allowing you to identify who this result came from.
-     * @param resultCode        The integer result code returned by the child activity through its setResult().
-     * @param intent            An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
-     */
-    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
-
-        // Get src and dest types from request code
-        int srcType = (requestCode / 16) - 1;
-        int destType = (requestCode % 16) - 1;
-        int rotate = 0;
-
-        // If CAMERA
-        if (srcType == CAMERA) {
-            // If image available
-            if (resultCode == Activity.RESULT_OK) {
-                try {
-                    // Create an ExifHelper to save the exif data that is lost during compression
-                    ExifHelper exif = new ExifHelper();
-                    try {
-                        if (this.encodingType == JPEG) {
-                            exif.createInFile(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/.Pic.jpg");
-                            exif.readExifData();
-                            rotate = exif.getOrientation();
-                        }
-                    } catch (IOException e) {
-                        e.printStackTrace();
-                    }
-
-                    Bitmap bitmap = null;
-                    Uri uri = null;
-
-                    // If sending base64 image back
-                    if (destType == DATA_URL) {
-                        bitmap = getScaledBitmap(FileUtils.stripFileProtocol(imageUri.toString()));
-                        if (bitmap == null) {
-                            // Try to get the bitmap from intent.
-                            bitmap = (Bitmap)intent.getExtras().get("data");
-                        }
-                        
-                        // Double-check the bitmap.
-                        if (bitmap == null) {
-                            Log.d(LOG_TAG, "I either have a null image path or bitmap");
-                            this.failPicture("Unable to create bitmap!");
-                            return;
-                        }
-
-                        if (rotate != 0 && this.correctOrientation) {
-                            bitmap = getRotatedBitmap(rotate, bitmap, exif);
-                        }
-
-                        this.processPicture(bitmap);
-                        checkForDuplicateImage(DATA_URL);
-                    }
-
-                    // If sending filename back
-                    else if (destType == FILE_URI || destType == NATIVE_URI) {
-                        if (!this.saveToPhotoAlbum) {
-                            uri = Uri.fromFile(new File(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()), System.currentTimeMillis() + ".jpg"));
-                        } else {
-                            uri = getUriFromMediaStore();
-                        }
-
-                        if (uri == null) {
-                            this.failPicture("Error capturing image - no media storage found.");
-                        }
-
-                        // If all this is true we shouldn't compress the image.
-                        if (this.targetHeight == -1 && this.targetWidth == -1 && this.mQuality == 100 && 
-                                !this.correctOrientation) {
-                            writeUncompressedImage(uri);
-
-                            this.callbackContext.success(uri.toString());
-                        } else {
-                            bitmap = getScaledBitmap(FileUtils.stripFileProtocol(imageUri.toString()));
-
-                            if (rotate != 0 && this.correctOrientation) {
-                                bitmap = getRotatedBitmap(rotate, bitmap, exif);
-                            }
-
-                            // Add compressed version of captured image to returned media store Uri
-                            OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
-                            bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
-                            os.close();
-
-                            // Restore exif data to file
-                            if (this.encodingType == JPEG) {
-                                String exifPath;
-                                if (this.saveToPhotoAlbum) {
-                                    exifPath = FileUtils.getRealPathFromURI(uri, this.cordova);
-                                } else {
-                                    exifPath = uri.getPath();
-                                }
-                                exif.createOutFile(exifPath);
-                                exif.writeExifData();
-                            }
-
-                        }
-                        // Send Uri back to JavaScript for viewing image
-                        this.callbackContext.success(uri.toString());
-                    }
-
-                    this.cleanup(FILE_URI, this.imageUri, uri, bitmap);
-                    bitmap = null;
-
-                } catch (IOException e) {
-                    e.printStackTrace();
-                    this.failPicture("Error capturing image.");
-                }
-            }
-
-            // If cancelled
-            else if (resultCode == Activity.RESULT_CANCELED) {
-                this.failPicture("Camera cancelled.");
-            }
-
-            // If something else
-            else {
-                this.failPicture("Did not complete!");
-            }
-        }
-
-        // If retrieving photo from library
-        else if ((srcType == PHOTOLIBRARY) || (srcType == SAVEDPHOTOALBUM)) {
-            if (resultCode == Activity.RESULT_OK) {
-                Uri uri = intent.getData();
-
-                // If you ask for video or all media type you will automatically get back a file URI
-                // and there will be no attempt to resize any returned data
-                if (this.mediaType != PICTURE) {
-                    this.callbackContext.success(uri.toString());
-                }
-                else {
-                    // This is a special case to just return the path as no scaling,
-                    // rotating, nor compressing needs to be done
-                    if (this.targetHeight == -1 && this.targetWidth == -1 &&
-                            (destType == FILE_URI || destType == NATIVE_URI) && !this.correctOrientation) {
-                        this.callbackContext.success(uri.toString());
-                    } else {
-                        // Get the path to the image. Makes loading so much easier.
-                        String imagePath = FileUtils.getRealPathFromURI(uri, this.cordova);
-                        String mimeType = FileUtils.getMimeType(imagePath);
-                        // Log.d(LOG_TAG, "Real path = " + imagePath);
-                        // Log.d(LOG_TAG, "mime type = " + mimeType);
-                        // If we don't have a valid image so quit.
-                        if (imagePath == null || mimeType == null || 
-                                !(mimeType.equalsIgnoreCase("image/jpeg") || mimeType.equalsIgnoreCase("image/png"))) {
-                        	Log.d(LOG_TAG, "I either have a null image path or bitmap");
-                            this.failPicture("Unable to retrieve path to picture!");
-                            return;
-                        }
-                        Bitmap bitmap = getScaledBitmap(imagePath);
-                        if (bitmap == null) {
-                        	Log.d(LOG_TAG, "I either have a null image path or bitmap");
-                            this.failPicture("Unable to create bitmap!");
-                            return;
-                        }
-
-                        if (this.correctOrientation) {
-                            String[] cols = { MediaStore.Images.Media.ORIENTATION };
-                            Cursor cursor = this.cordova.getActivity().getContentResolver().query(intent.getData(),
-                                    cols, null, null, null);
-                            if (cursor != null) {
-                                cursor.moveToPosition(0);
-                                rotate = cursor.getInt(0);
-                                cursor.close();
-                            }
-                            if (rotate != 0) {
-                                Matrix matrix = new Matrix();
-                                matrix.setRotate(rotate);
-                                bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
-                            }
-                        }
-
-                        // If sending base64 image back
-                        if (destType == DATA_URL) {
-                            this.processPicture(bitmap);
-                        }
-
-                        // If sending filename back
-                        else if (destType == FILE_URI || destType == NATIVE_URI) {
-                            // Do we need to scale the returned file
-                            if (this.targetHeight > 0 && this.targetWidth > 0) {
-                                try {
-                                    // Create an ExifHelper to save the exif data that is lost during compression
-                                    String resizePath = DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/resize.jpg";
-                                    ExifHelper exif = new ExifHelper();
-                                    try {
-                                        if (this.encodingType == JPEG) {
-                                            exif.createInFile(resizePath);
-                                            exif.readExifData();
-                                            rotate = exif.getOrientation();
-                                        }
-                                    } catch (IOException e) {
-                                        e.printStackTrace();
-                                    }
-
-                                    OutputStream os = new FileOutputStream(resizePath);
-                                    bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
-                                    os.close();
-
-                                    // Restore exif data to file
-                                    if (this.encodingType == JPEG) {
-                                        exif.createOutFile(FileUtils.getRealPathFromURI(uri, this.cordova));
-                                        exif.writeExifData();
-                                    }
-
-                                    // The resized image is cached by the app in order to get around this and not have to delete you
-                                    // application cache I'm adding the current system time to the end of the file url.
-                                    this.callbackContext.success("file://" + resizePath + "?" + System.currentTimeMillis());
-                                } catch (Exception e) {
-                                    e.printStackTrace();
-                                    this.failPicture("Error retrieving image.");
-                                }
-                            }
-                            else {
-                                this.callbackContext.success(uri.toString());
-                            }
-                        }
-                        if (bitmap != null) {
-	                        bitmap.recycle();
-	                        bitmap = null;
-                        }
-                        System.gc();
-                    }
-                }
-            }
-            else if (resultCode == Activity.RESULT_CANCELED) {
-                this.failPicture("Selection cancelled.");
-            }
-            else {
-                this.failPicture("Selection did not complete!");
-            }
-        }
-    }
-
-    /**
-     * Figure out if the bitmap should be rotated. For instance if the picture was taken in
-     * portrait mode
-     *
-     * @param rotate
-     * @param bitmap
-     * @return rotated bitmap
-     */
-    private Bitmap getRotatedBitmap(int rotate, Bitmap bitmap, ExifHelper exif) {
-        Matrix matrix = new Matrix();
-        if (rotate == 180) {
-            matrix.setRotate(rotate);
-        } else {
-            matrix.setRotate(rotate, (float) bitmap.getWidth() / 2, (float) bitmap.getHeight() / 2);
-        }
-        bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
-        exif.resetOrientation();
-        return bitmap;
-    }
-
-    /**
-     * In the special case where the default width, height and quality are unchanged
-     * we just write the file out to disk saving the expensive Bitmap.compress function.
-     *
-     * @param uri
-     * @throws FileNotFoundException
-     * @throws IOException
-     */
-    private void writeUncompressedImage(Uri uri) throws FileNotFoundException,
-            IOException {
-        FileInputStream fis = new FileInputStream(FileUtils.stripFileProtocol(imageUri.toString()));
-        OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
-        byte[] buffer = new byte[4096];
-        int len;
-        while ((len = fis.read(buffer)) != -1) {
-            os.write(buffer, 0, len);
-        }
-        os.flush();
-        os.close();
-        fis.close();
-    }
-
-    /**
-     * Create entry in media store for image
-     *
-     * @return uri
-     */
-    private Uri getUriFromMediaStore() {
-        ContentValues values = new ContentValues();
-        values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
-        Uri uri;
-        try {
-            uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
-        } catch (UnsupportedOperationException e) {
-            LOG.d(LOG_TAG, "Can't write to external media storage.");
-            try {
-                uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values);
-            } catch (UnsupportedOperationException ex) {
-                LOG.d(LOG_TAG, "Can't write to internal media storage.");
-                return null;
-            }
-        }
-        return uri;
-    }
-
-    /**
-     * Return a scaled bitmap based on the target width and height
-     *
-     * @param imagePath
-     * @return
-     */
-    private Bitmap getScaledBitmap(String imagePath) {
-        // If no new width or height were specified return the original bitmap
-        if (this.targetWidth <= 0 && this.targetHeight <= 0) {
-            return BitmapFactory.decodeFile(imagePath);
-        }
-
-        // figure out the original width and height of the image
-        BitmapFactory.Options options = new BitmapFactory.Options();
-        options.inJustDecodeBounds = true;
-        BitmapFactory.decodeFile(imagePath, options);
-        
-        //CB-2292: WTF? Why is the width null?
-        if(options.outWidth == 0 || options.outHeight == 0)
-        {
-            return null;
-        }
-        
-        // determine the correct aspect ratio
-        int[] widthHeight = calculateAspectRatio(options.outWidth, options.outHeight);
-
-        // Load in the smallest bitmap possible that is closest to the size we want
-        options.inJustDecodeBounds = false;
-        options.inSampleSize = calculateSampleSize(options.outWidth, options.outHeight, this.targetWidth, this.targetHeight);
-        Bitmap unscaledBitmap = BitmapFactory.decodeFile(imagePath, options);
-        if (unscaledBitmap == null) {
-            return null;
-        }
-
-        return Bitmap.createScaledBitmap(unscaledBitmap, widthHeight[0], widthHeight[1], true);
-    }
-
-    /**
-     * Maintain the aspect ratio so the resulting image does not look smooshed
-     *
-     * @param origWidth
-     * @param origHeight
-     * @return
-     */
-    public int[] calculateAspectRatio(int origWidth, int origHeight) {
-        int newWidth = this.targetWidth;
-        int newHeight = this.targetHeight;
-
-        // If no new width or height were specified return the original bitmap
-        if (newWidth <= 0 && newHeight <= 0) {
-            newWidth = origWidth;
-            newHeight = origHeight;
-        }
-        // Only the width was specified
-        else if (newWidth > 0 && newHeight <= 0) {
-            newHeight = (newWidth * origHeight) / origWidth;
-        }
-        // only the height was specified
-        else if (newWidth <= 0 && newHeight > 0) {
-            newWidth = (newHeight * origWidth) / origHeight;
-        }
-        // If the user specified both a positive width and height
-        // (potentially different aspect ratio) then the width or height is
-        // scaled so that the image fits while maintaining aspect ratio.
-        // Alternatively, the specified width and height could have been
-        // kept and Bitmap.SCALE_TO_FIT specified when scaling, but this
-        // would result in whitespace in the new image.
-        else {
-            double newRatio = newWidth / (double) newHeight;
-            double origRatio = origWidth / (double) origHeight;
-
-            if (origRatio > newRatio) {
-                newHeight = (newWidth * origHeight) / origWidth;
-            } else if (origRatio < newRatio) {
-                newWidth = (newHeight * origWidth) / origHeight;
-            }
-        }
-
-        int[] retval = new int[2];
-        retval[0] = newWidth;
-        retval[1] = newHeight;
-        return retval;
-    }
-
-    /**
-     * Figure out what ratio we can load our image into memory at while still being bigger than
-     * our desired width and height
-     *
-     * @param srcWidth
-     * @param srcHeight
-     * @param dstWidth
-     * @param dstHeight
-     * @return
-     */
-    public static int calculateSampleSize(int srcWidth, int srcHeight, int dstWidth, int dstHeight) {
-        final float srcAspect = (float)srcWidth / (float)srcHeight;
-        final float dstAspect = (float)dstWidth / (float)dstHeight;
-
-        if (srcAspect > dstAspect) {
-            return srcWidth / dstWidth;
-        } else {
-            return srcHeight / dstHeight;
-        }
-      }
-
-    /**
-     * Creates a cursor that can be used to determine how many images we have.
-     *
-     * @return a cursor
-     */
-    private Cursor queryImgDB(Uri contentStore) {
-        return this.cordova.getActivity().getContentResolver().query(
-                contentStore,
-                new String[] { MediaStore.Images.Media._ID },
-                null,
-                null,
-                null);
-    }
-
-    /**
-     * Cleans up after picture taking. Checking for duplicates and that kind of stuff.
-     * @param newImage
-     */
-    private void cleanup(int imageType, Uri oldImage, Uri newImage, Bitmap bitmap) {
-        if (bitmap != null) {
-            bitmap.recycle();
-        }
-
-        // Clean up initial camera-written image file.
-        (new File(FileUtils.stripFileProtocol(oldImage.toString()))).delete();
-
-        checkForDuplicateImage(imageType);
-        // Scan for the gallery to update pic refs in gallery
-        if (this.saveToPhotoAlbum && newImage != null) {
-            this.scanForGallery(newImage);
-        }
-
-        System.gc();
-    }
-
-    /**
-     * Used to find out if we are in a situation where the Camera Intent adds to images
-     * to the content store. If we are using a FILE_URI and the number of images in the DB
-     * increases by 2 we have a duplicate, when using a DATA_URL the number is 1.
-     *
-     * @param type FILE_URI or DATA_URL
-     */
-    private void checkForDuplicateImage(int type) {
-        int diff = 1;
-        Uri contentStore = whichContentStore();
-        Cursor cursor = queryImgDB(contentStore);
-        int currentNumOfImages = cursor.getCount();
-
-        if (type == FILE_URI && this.saveToPhotoAlbum) {
-            diff = 2;
-        }
-
-        // delete the duplicate file if the difference is 2 for file URI or 1 for Data URL
-        if ((currentNumOfImages - numPics) == diff) {
-            cursor.moveToLast();
-            int id = Integer.valueOf(cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media._ID)));
-            if (diff == 2) {
-                id--;
-            }
-            Uri uri = Uri.parse(contentStore + "/" + id);
-            this.cordova.getActivity().getContentResolver().delete(uri, null, null);
-        }
-    }
-
-    /**
-     * Determine if we are storing the images in internal or external storage
-     * @return Uri
-     */
-    private Uri whichContentStore() {
-        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
-            return android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
-        } else {
-            return android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI;
-        }
-    }
-
-    /**
-     * Compress bitmap using jpeg, convert to Base64 encoded string, and return to JavaScript.
-     *
-     * @param bitmap
-     */
-    public void processPicture(Bitmap bitmap) {
-        ByteArrayOutputStream jpeg_data = new ByteArrayOutputStream();
-        try {
-            if (bitmap.compress(CompressFormat.JPEG, mQuality, jpeg_data)) {
-                byte[] code = jpeg_data.toByteArray();
-                byte[] output = Base64.encodeBase64(code);
-                String js_out = new String(output);
-                this.callbackContext.success(js_out);
-                js_out = null;
-                output = null;
-                code = null;
-            }
-        } catch (Exception e) {
-            this.failPicture("Error compressing image.");
-        }
-        jpeg_data = null;
-    }
-
-    /**
-     * Send error message to JavaScript.
-     *
-     * @param err
-     */
-    public void failPicture(String err) {
-        this.callbackContext.error(err);
-    }
-
-    private void scanForGallery(Uri newImage) {
-        this.scanMe = newImage;
-        if(this.conn != null) {
-            this.conn.disconnect();
-        }
-        this.conn = new MediaScannerConnection(this.cordova.getActivity().getApplicationContext(), this);
-        conn.connect();
-    }
-
-    public void onMediaScannerConnected() {
-        try{
-            this.conn.scanFile(this.scanMe.toString(), "image/*");
-        } catch (java.lang.IllegalStateException e){
-            LOG.e(LOG_TAG, "Can't scan file in MediaScanner after taking picture");
-        }
-
-    }
-
-    public void onScanCompleted(String path, Uri uri) {
-        this.conn.disconnect();
-    }
-}


Mime
View raw message