cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [52/53] removed core plugins not needed to build pluginless cordova project
Date Tue, 30 Apr 2013 21:36:08 GMT
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/701dfb3b/framework/src/org/apache/cordova/core/Capture.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/core/Capture.java b/framework/src/org/apache/cordova/core/Capture.java
deleted file mode 100644
index 69d2c69..0000000
--- a/framework/src/org/apache/cordova/core/Capture.java
+++ /dev/null
@@ -1,447 +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.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import android.os.Build;
-
-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 org.json.JSONObject;
-
-import android.app.Activity;
-import android.content.ContentValues;
-import android.content.Intent;
-import android.database.Cursor;
-import android.graphics.BitmapFactory;
-import android.media.MediaPlayer;
-import android.net.Uri;
-import android.os.Environment;
-import android.provider.MediaStore;
-import android.util.Log;
-
-public class Capture extends CordovaPlugin {
-
-    private static final String VIDEO_3GPP = "video/3gpp";
-    private static final String VIDEO_MP4 = "video/mp4";
-    private static final String AUDIO_3GPP = "audio/3gpp";
-    private static final String IMAGE_JPEG = "image/jpeg";
-
-    private static final int CAPTURE_AUDIO = 0;     // Constant for capture audio
-    private static final int CAPTURE_IMAGE = 1;     // Constant for capture image
-    private static final int CAPTURE_VIDEO = 2;     // Constant for capture video
-    private static final String LOG_TAG = "Capture";
-
-    private static final int CAPTURE_INTERNAL_ERR = 0;
-//    private static final int CAPTURE_APPLICATION_BUSY = 1;
-//    private static final int CAPTURE_INVALID_ARGUMENT = 2;
-    private static final int CAPTURE_NO_MEDIA_FILES = 3;
-
-    private CallbackContext callbackContext;        // The callback context from which we
were invoked.
-    private long limit;                             // the number of pics/vids/clips to take
-    private double duration;                        // optional duration parameter for video
recording
-    private JSONArray results;                      // The array of results to be returned
to the user
-    private int numPics;                            // Number of pictures before capture
activity
-
-    //private CordovaInterface cordova;
-
-//    public void setContext(Context 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");
-//    }
-
-    @Override
-    public boolean execute(String action, JSONArray args, CallbackContext callbackContext)
throws JSONException {
-        this.callbackContext = callbackContext;
-        this.limit = 1;
-        this.duration = 0.0f;
-        this.results = new JSONArray();
-
-        JSONObject options = args.optJSONObject(0);
-        if (options != null) {
-            limit = options.optLong("limit", 1);
-            duration = options.optDouble("duration", 0.0f);
-        }
-
-        if (action.equals("getFormatData")) {
-            JSONObject obj = getFormatData(args.getString(0), args.getString(1));
-            callbackContext.success(obj);
-            return true;
-        }
-        else if (action.equals("captureAudio")) {
-            this.captureAudio();
-        }
-        else if (action.equals("captureImage")) {
-            this.captureImage();
-        }
-        else if (action.equals("captureVideo")) {
-            this.captureVideo(duration);
-        }
-        else {
-            return false;
-        }
-
-        return true;
-    }
-
-    /**
-     * Provides the media data file data depending on it's mime type
-     *
-     * @param filePath path to the file
-     * @param mimeType of the file
-     * @return a MediaFileData object
-     */
-    private JSONObject getFormatData(String filePath, String mimeType) throws JSONException
{
-        JSONObject obj = new JSONObject();
-        // setup defaults
-        obj.put("height", 0);
-        obj.put("width", 0);
-        obj.put("bitrate", 0);
-        obj.put("duration", 0);
-        obj.put("codecs", "");
-
-        // If the mimeType isn't set the rest will fail
-        // so let's see if we can determine it.
-        if (mimeType == null || mimeType.equals("") || "null".equals(mimeType)) {
-            mimeType = FileUtils.getMimeType(filePath);
-        }
-        Log.d(LOG_TAG, "Mime type = " + mimeType);
-
-        if (mimeType.equals(IMAGE_JPEG) || filePath.endsWith(".jpg")) {
-            obj = getImageData(filePath, obj);
-        }
-        else if (mimeType.endsWith(AUDIO_3GPP)) {
-            obj = getAudioVideoData(filePath, obj, false);
-        }
-        else if (mimeType.equals(VIDEO_3GPP) || mimeType.equals(VIDEO_MP4)) {
-            obj = getAudioVideoData(filePath, obj, true);
-        }
-        return obj;
-    }
-
-    /**
-     * Get the Image specific attributes
-     *
-     * @param filePath path to the file
-     * @param obj represents the Media File Data
-     * @return a JSONObject that represents the Media File Data
-     * @throws JSONException
-     */
-    private JSONObject getImageData(String filePath, JSONObject obj) throws JSONException
{
-        BitmapFactory.Options options = new BitmapFactory.Options();
-        options.inJustDecodeBounds = true;
-        BitmapFactory.decodeFile(FileUtils.stripFileProtocol(filePath), options);
-        obj.put("height", options.outHeight);
-        obj.put("width", options.outWidth);
-        return obj;
-    }
-
-    /**
-     * Get the Image specific attributes
-     *
-     * @param filePath path to the file
-     * @param obj represents the Media File Data
-     * @param video if true get video attributes as well
-     * @return a JSONObject that represents the Media File Data
-     * @throws JSONException
-     */
-    private JSONObject getAudioVideoData(String filePath, JSONObject obj, boolean video)
throws JSONException {
-        MediaPlayer player = new MediaPlayer();
-        try {
-            player.setDataSource(filePath);
-            player.prepare();
-            obj.put("duration", player.getDuration() / 1000);
-            if (video) {
-                obj.put("height", player.getVideoHeight());
-                obj.put("width", player.getVideoWidth());
-            }
-        } catch (IOException e) {
-            Log.d(LOG_TAG, "Error: loading video file");
-        }
-        return obj;
-    }
-
-    /**
-     * Sets up an intent to capture audio.  Result handled by onActivityResult()
-     */
-    private void captureAudio() {
-        Intent intent = new Intent(android.provider.MediaStore.Audio.Media.RECORD_SOUND_ACTION);
-
-        this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_AUDIO);
-    }
-
-    /**
-     * Sets up an intent to capture images.  Result handled by onActivityResult()
-     */
-    private void captureImage() {
-        // Save the number of images currently on disk for later
-        this.numPics = queryImgDB(whichContentStore()).getCount();
-
-        Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
-
-        // Specify file so that large image is captured and returned
-        File photo = new File(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()),
"Capture.jpg");
-        intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
-
-        this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_IMAGE);
-    }
-
-    /**
-     * Sets up an intent to capture video.  Result handled by onActivityResult()
-     */
-    private void captureVideo(double duration) {
-        Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
-        // Introduced in API 8
-        //intent.putExtra(android.provider.MediaStore.EXTRA_DURATION_LIMIT, duration);
-
-        this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_VIDEO);
-    }
-
-    /**
-     * Called when the video 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").
-     * @throws JSONException
-     */
-    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
-
-        // Result received okay
-        if (resultCode == Activity.RESULT_OK) {
-            // An audio clip was requested
-            if (requestCode == CAPTURE_AUDIO) {
-                // Get the uri of the audio clip
-                Uri data = intent.getData();
-                // create a file object from the uri
-                results.put(createMediaFile(data));
-
-                if (results.length() >= limit) {
-                    // Send Uri back to JavaScript for listening to audio
-                    this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK,
results));
-                } else {
-                    // still need to capture more audio clips
-                    captureAudio();
-                }
-            } else if (requestCode == CAPTURE_IMAGE) {
-                // For some reason if I try to do:
-                // Uri data = intent.getData();
-                // It crashes in the emulator and on my phone with a null pointer exception
-                // To work around it I had to grab the code from CameraLauncher.java
-                try {
-                    // Create entry in media store for image
-                    // (Don't use insertImage() because it uses default compression setting
of 50 - no way to change it)
-                    ContentValues values = new ContentValues();
-                    values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, IMAGE_JPEG);
-                    Uri uri = null;
-                    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.");
-                            this.fail(createErrorObject(CAPTURE_INTERNAL_ERR, "Error capturing
image - no media storage found."));
-                            return;
-                        }
-                    }
-                    FileInputStream fis = new FileInputStream(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity())
+ "/Capture.jpg");
-                    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();
-
-                    // Add image to results
-                    results.put(createMediaFile(uri));
-
-                    checkForDuplicateImage();
-
-                    if (results.length() >= limit) {
-                        // Send Uri back to JavaScript for viewing image
-                        this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK,
results));
-                    } else {
-                        // still need to capture more images
-                        captureImage();
-                    }
-                } catch (IOException e) {
-                    e.printStackTrace();
-                    this.fail(createErrorObject(CAPTURE_INTERNAL_ERR, "Error capturing image."));
-                }
-            } else if (requestCode == CAPTURE_VIDEO) {
-                // Get the uri of the video clip
-                Uri data = intent.getData();
-                // create a file object from the uri
-                results.put(createMediaFile(data));
-
-                if (results.length() >= limit) {
-                    // Send Uri back to JavaScript for viewing video
-                    this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK,
results));
-                } else {
-                    // still need to capture more video clips
-                    captureVideo(duration);
-                }
-            }
-        }
-        // If canceled
-        else if (resultCode == Activity.RESULT_CANCELED) {
-            // If we have partial results send them back to the user
-            if (results.length() > 0) {
-                this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK,
results));
-            }
-            // user canceled the action
-            else {
-                this.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Canceled."));
-            }
-        }
-        // If something else
-        else {
-            // If we have partial results send them back to the user
-            if (results.length() > 0) {
-                this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK,
results));
-            }
-            // something bad happened
-            else {
-                this.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Did not complete!"));
-            }
-        }
-    }
-
-    /**
-     * Creates a JSONObject that represents a File from the Uri
-     *
-     * @param data the Uri of the audio/image/video
-     * @return a JSONObject that represents a File
-     * @throws IOException
-     */
-    private JSONObject createMediaFile(Uri data) {
-        File fp = new File(FileUtils.getRealPathFromURI(data, this.cordova));
-        JSONObject obj = new JSONObject();
-
-        try {
-            // File properties
-            obj.put("name", fp.getName());
-            obj.put("fullPath", "file://" + fp.getAbsolutePath());
-            // Because of an issue with MimeTypeMap.getMimeTypeFromExtension() all .3gpp
files
-            // are reported as video/3gpp. I'm doing this hacky check of the URI to see if
it
-            // is stored in the audio or video content store.
-            if (fp.getAbsoluteFile().toString().endsWith(".3gp") || fp.getAbsoluteFile().toString().endsWith(".3gpp"))
{
-                if (data.toString().contains("/audio/")) {
-                    obj.put("type", AUDIO_3GPP);
-                } else {
-                    obj.put("type", VIDEO_3GPP);
-                }
-            } else {
-                obj.put("type", FileUtils.getMimeType(fp.getAbsolutePath()));
-            }
-
-            obj.put("lastModifiedDate", fp.lastModified());
-            obj.put("size", fp.length());
-        } catch (JSONException e) {
-            // this will never happen
-            e.printStackTrace();
-        }
-
-        return obj;
-    }
-
-    private JSONObject createErrorObject(int code, String message) {
-        JSONObject obj = new JSONObject();
-        try {
-            obj.put("code", code);
-            obj.put("message", message);
-        } catch (JSONException e) {
-            // This will never happen
-        }
-        return obj;
-    }
-
-    /**
-     * Send error message to JavaScript.
-     *
-     * @param err
-     */
-    public void fail(JSONObject err) {
-        this.callbackContext.error(err);
-    }
-
-
-    /**
-     * 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);
-    }
-
-    /**
-     * Used to find out if we are in a situation where the Camera Intent adds to images
-     * to the content store.
-     */
-    private void checkForDuplicateImage() {
-        Uri contentStore = whichContentStore();
-        Cursor cursor = queryImgDB(contentStore);
-        int currentNumOfImages = cursor.getCount();
-
-        // delete the duplicate file if the difference is 2
-        if ((currentNumOfImages - numPics) == 2) {
-            cursor.moveToLast();
-            int id = Integer.valueOf(cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media._ID)))
- 1;
-            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;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/701dfb3b/framework/src/org/apache/cordova/core/CompassListener.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/core/CompassListener.java b/framework/src/org/apache/cordova/core/CompassListener.java
deleted file mode 100755
index 8f39003..0000000
--- a/framework/src/org/apache/cordova/core/CompassListener.java
+++ /dev/null
@@ -1,296 +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.util.List;
-
-import org.apache.cordova.CordovaWebView;
-import org.apache.cordova.api.CallbackContext;
-import org.apache.cordova.api.CordovaInterface;
-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.hardware.Sensor;
-import android.hardware.SensorEvent;
-import android.hardware.SensorEventListener;
-import android.hardware.SensorManager;
-import android.content.Context;
-
-import android.os.Handler;
-import android.os.Looper;
-
-/**
- * This class listens to the compass sensor and stores the latest heading value.
- */
-public class CompassListener extends CordovaPlugin implements SensorEventListener {
-
-    public static int STOPPED = 0;
-    public static int STARTING = 1;
-    public static int RUNNING = 2;
-    public static int ERROR_FAILED_TO_START = 3;
-
-    public long TIMEOUT = 30000;        // Timeout in msec to shut off listener
-
-    int status;                         // status of listener
-    float heading;                      // most recent heading value
-    long timeStamp;                     // time of most recent value
-    long lastAccessTime;                // time the value was last retrieved
-    int accuracy;                       // accuracy of the sensor
-
-    private SensorManager sensorManager;// Sensor manager
-    Sensor mSensor;                     // Compass sensor returned by sensor manager
-
-    private CallbackContext callbackContext;
-
-    /**
-     * Constructor.
-     */
-    public CompassListener() {
-        this.heading = 0;
-        this.timeStamp = 0;
-        this.setStatus(CompassListener.STOPPED);
-    }
-
-    /**
-     * Sets the context of the Command. This can then be used to do things like
-     * get file paths associated with the Activity.
-     *
-     * @param cordova The context of the main Activity.
-     * @param webView The CordovaWebView Cordova is running in.
-     */
-    public void initialize(CordovaInterface cordova, CordovaWebView webView) {
-        super.initialize(cordova, webView);
-        this.sensorManager = (SensorManager) cordova.getActivity().getSystemService(Context.SENSOR_SERVICE);
-    }
-
-    /**
-     * Executes the request and returns PluginResult.
-     *
-     * @param action                The action to execute.
-     * @param args          	    JSONArry of arguments for the plugin.
-     * @param callbackS=Context     The callback id used when calling back into JavaScript.
-     * @return              	    True if the action was valid.
-     * @throws JSONException 
-     */
-    public boolean execute(String action, JSONArray args, CallbackContext callbackContext)
throws JSONException {
-        if (action.equals("start")) {
-            this.start();
-        }
-        else if (action.equals("stop")) {
-            this.stop();
-        }
-        else if (action.equals("getStatus")) {
-            int i = this.getStatus();
-            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, i));
-        }
-        else if (action.equals("getHeading")) {
-            // If not running, then this is an async call, so don't worry about waiting
-            if (this.status != CompassListener.RUNNING) {
-                int r = this.start();
-                if (r == CompassListener.ERROR_FAILED_TO_START) {
-                    callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION,
CompassListener.ERROR_FAILED_TO_START));
-                    return true;
-                }
-                // Set a timeout callback on the main thread.
-                Handler handler = new Handler(Looper.getMainLooper());
-                handler.postDelayed(new Runnable() {
-                    public void run() {
-                        CompassListener.this.timeout();
-                    }
-                }, 2000);
-            }
-            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, getCompassHeading()));
-        }
-        else if (action.equals("setTimeout")) {
-            this.setTimeout(args.getLong(0));
-        }
-        else if (action.equals("getTimeout")) {
-            long l = this.getTimeout();
-            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, l));
-        } else {
-            // Unsupported action
-            return false;
-        }
-        return true;
-    }
-
-    /**
-     * Called when listener is to be shut down and object is being destroyed.
-     */
-    public void onDestroy() {
-        this.stop();
-    }
-
-    /**
-     * Called when app has navigated and JS listeners have been destroyed.
-     */
-    public void onReset() {
-        this.stop();
-    }
-
-    //--------------------------------------------------------------------------
-    // LOCAL METHODS
-    //--------------------------------------------------------------------------
-
-    /**
-     * Start listening for compass sensor.
-     *
-     * @return          status of listener
-     */
-    public int start() {
-
-        // If already starting or running, then just return
-        if ((this.status == CompassListener.RUNNING) || (this.status == CompassListener.STARTING))
{
-            return this.status;
-        }
-
-        // Get compass sensor from sensor manager
-        @SuppressWarnings("deprecation")
-        List<Sensor> list = this.sensorManager.getSensorList(Sensor.TYPE_ORIENTATION);
-
-        // If found, then register as listener
-        if (list != null && list.size() > 0) {
-            this.mSensor = list.get(0);
-            this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_NORMAL);
-            this.lastAccessTime = System.currentTimeMillis();
-            this.setStatus(CompassListener.STARTING);
-        }
-
-        // If error, then set status to error
-        else {
-            this.setStatus(CompassListener.ERROR_FAILED_TO_START);
-        }
-
-        return this.status;
-    }
-
-    /**
-     * Stop listening to compass sensor.
-     */
-    public void stop() {
-        if (this.status != CompassListener.STOPPED) {
-            this.sensorManager.unregisterListener(this);
-        }
-        this.setStatus(CompassListener.STOPPED);
-    }
-
-    public void onAccuracyChanged(Sensor sensor, int accuracy) {
-        // TODO Auto-generated method stub
-    }
-
-    /**
-     * Called after a delay to time out if the listener has not attached fast enough.
-     */
-    private void timeout() {
-        if (this.status == CompassListener.STARTING) {
-            this.setStatus(CompassListener.ERROR_FAILED_TO_START);
-            if (this.callbackContext != null) {
-                this.callbackContext.error("Compass listener failed to start.");
-            }
-        }
-    }
-
-    /**
-     * Sensor listener event.
-     *
-     * @param SensorEvent event
-     */
-    public void onSensorChanged(SensorEvent event) {
-
-        // We only care about the orientation as far as it refers to Magnetic North
-        float heading = event.values[0];
-
-        // Save heading
-        this.timeStamp = System.currentTimeMillis();
-        this.heading = heading;
-        this.setStatus(CompassListener.RUNNING);
-
-        // If heading hasn't been read for TIMEOUT time, then turn off compass sensor to
save power
-        if ((this.timeStamp - this.lastAccessTime) > this.TIMEOUT) {
-            this.stop();
-        }
-    }
-
-    /**
-     * Get status of compass sensor.
-     *
-     * @return          status
-     */
-    public int getStatus() {
-        return this.status;
-    }
-
-    /**
-     * Get the most recent compass heading.
-     *
-     * @return          heading
-     */
-    public float getHeading() {
-        this.lastAccessTime = System.currentTimeMillis();
-        return this.heading;
-    }
-
-    /**
-     * Set the timeout to turn off compass sensor if getHeading() hasn't been called.
-     *
-     * @param timeout       Timeout in msec.
-     */
-    public void setTimeout(long timeout) {
-        this.TIMEOUT = timeout;
-    }
-
-    /**
-     * Get the timeout to turn off compass sensor if getHeading() hasn't been called.
-     *
-     * @return timeout in msec
-     */
-    public long getTimeout() {
-        return this.TIMEOUT;
-    }
-
-    /**
-     * Set the status and send it to JavaScript.
-     * @param status
-     */
-    private void setStatus(int status) {
-        this.status = status;
-    }
-
-    /**
-     * Create the CompassHeading JSON object to be returned to JavaScript
-     *
-     * @return a compass heading
-     */
-    private JSONObject getCompassHeading() throws JSONException {
-        JSONObject obj = new JSONObject();
-
-        obj.put("magneticHeading", this.getHeading());
-        obj.put("trueHeading", this.getHeading());
-        // Since the magnetic and true heading are always the same our and accuracy
-        // is defined as the difference between true and magnetic always return zero
-        obj.put("headingAccuracy", 0);
-        obj.put("timestamp", this.timeStamp);
-
-        return obj;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/701dfb3b/framework/src/org/apache/cordova/core/ContactAccessor.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/core/ContactAccessor.java b/framework/src/org/apache/cordova/core/ContactAccessor.java
deleted file mode 100644
index 75d0b21..0000000
--- a/framework/src/org/apache/cordova/core/ContactAccessor.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed 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.util.HashMap;
-
-import android.util.Log;
-import android.webkit.WebView;
-
-import org.apache.cordova.api.CordovaInterface;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- * This abstract class defines SDK-independent API for communication with
- * Contacts Provider. The actual implementation used by the application depends
- * on the level of API available on the device. If the API level is Cupcake or
- * Donut, we want to use the {@link ContactAccessorSdk3_4} class. If it is
- * Eclair or higher, we want to use {@link ContactAccessorSdk5}.
- */
-public abstract class ContactAccessor {
-
-    protected final String LOG_TAG = "ContactsAccessor";
-    protected CordovaInterface mApp;
-    protected WebView mView;
-
-    /**
-     * Check to see if the data associated with the key is required to
-     * be populated in the Contact object.
-     * @param key
-     * @param map created by running buildPopulationSet.
-     * @return true if the key data is required
-     */
-    protected boolean isRequired(String key, HashMap<String,Boolean> map) {
-        Boolean retVal = map.get(key);
-        return (retVal == null) ? false : retVal.booleanValue();
-    }
-
-    /**
-     * Create a hash map of what data needs to be populated in the Contact object
-     * @param fields the list of fields to populate
-     * @return the hash map of required data
-     */
-    protected HashMap<String,Boolean> buildPopulationSet(JSONArray fields) {
-        HashMap<String,Boolean> map = new HashMap<String,Boolean>();
-
-        String key;
-        try {
-            if (fields.length() == 1 && fields.getString(0).equals("*")) {
-                map.put("displayName", true);
-                map.put("name", true);
-                map.put("nickname", true);
-                map.put("phoneNumbers", true);
-                map.put("emails", true);
-                map.put("addresses", true);
-                map.put("ims", true);
-                map.put("organizations", true);
-                map.put("birthday", true);
-                map.put("note", true);
-                map.put("urls", true);
-                map.put("photos", true);
-                map.put("categories", true);
-           } 
-            else {
-                for (int i=0; i<fields.length(); i++) {
-                    key = fields.getString(i);
-                    if (key.startsWith("displayName")) {
-                        map.put("displayName", true);
-                    }
-                    else if (key.startsWith("name")) {
-                        map.put("displayName", true);
-                        map.put("name", true);
-                    }
-                    else if (key.startsWith("nickname")) {
-                        map.put("nickname", true);
-                    }
-                    else if (key.startsWith("phoneNumbers")) {
-                        map.put("phoneNumbers", true);
-                    }
-                    else if (key.startsWith("emails")) {
-                        map.put("emails", true);
-                    }
-                    else if (key.startsWith("addresses")) {
-                        map.put("addresses", true);
-                    }
-                    else if (key.startsWith("ims")) {
-                        map.put("ims", true);
-                    }
-                    else if (key.startsWith("organizations")) {
-                        map.put("organizations", true);
-                    }
-                    else if (key.startsWith("birthday")) {
-                        map.put("birthday", true);
-                    }
-                    else if (key.startsWith("note")) {
-                        map.put("note", true);
-                    }
-                    else if (key.startsWith("urls")) {
-                        map.put("urls", true);
-                    }
-                    else if (key.startsWith("photos")) {
-                        map.put("photos", true);
-                    }
-                    else if (key.startsWith("categories")) {
-                        map.put("categories", true);
-                    }
-                }
-            }
-       }
-        catch (JSONException e) {
-            Log.e(LOG_TAG, e.getMessage(), e);
-        }
-        return map;
-    }
-
-    /**
-     * Convenience method to get a string from a JSON object.  Saves a
-     * lot of try/catch writing.
-     * If the property is not found in the object null will be returned.
-     *
-     * @param obj contact object to search
-     * @param property to be looked up
-     * @return The value of the property
-     */
-    protected String getJsonString(JSONObject obj, String property) {
-        String value = null;
-        try {
-            if (obj != null) {
-                value = obj.getString(property);
-                if (value.equals("null")) {
-                    Log.d(LOG_TAG, property + " is string called 'null'");
-                    value = null;
-                }
-            }
-       }
-        catch (JSONException e) {
-            Log.d(LOG_TAG, "Could not get = " + e.getMessage());
-        }
-        return value;
-    }
-
-    /**
-     * Handles adding a JSON Contact object into the database.
-     * @return TODO
-     */
-    public abstract String save(JSONObject contact);
-
-    /**
-     * Handles searching through SDK-specific contacts API.
-     */
-    public abstract JSONArray search(JSONArray filter, JSONObject options);
-
-    /**
-     * Handles searching through SDK-specific contacts API.
-     * @throws JSONException
-     */
-    public abstract JSONObject getContactById(String id) throws JSONException;
-
-    /**
-     * Handles removing a contact from the database.
-     */
-    public abstract boolean remove(String id);
-
-   /**
-     * A class that represents the where clause to be used in the database query 
-     */
-    class WhereOptions {
-        private String where;
-        private String[] whereArgs;
-        public void setWhere(String where) {
-            this.where = where;
-        }
-        public String getWhere() {
-            return where;
-        }
-        public void setWhereArgs(String[] whereArgs) {
-            this.whereArgs = whereArgs;
-        }
-        public String[] getWhereArgs() {
-            return whereArgs;
-        }
-    }
-}


Mime
View raw message