You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2013/05/28 17:32:45 UTC

android commit: CB-3358: Change Commons-codec:base64 to Android:Base64

Updated Branches:
  refs/heads/master 8077091b3 -> 78efe2a96


CB-3358: Change Commons-codec:base64 to Android:Base64


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

Branch: refs/heads/master
Commit: 78efe2a960ba2b320680da18b7c0fc20d442c604
Parents: 8077091
Author: David Kemp <dr...@chromium.org>
Authored: Thu May 23 10:23:25 2013 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Mon May 27 22:25:23 2013 -0400

----------------------------------------------------------------------
 README.md                                          |    7 +--
 bin/create                                         |   10 ----
 bin/create.js                                      |   42 ---------------
 bin/update                                         |   10 ----
 bin/update.js                                      |   42 ---------------
 framework/build.xml                                |   16 ------
 .../src/org/apache/cordova/CameraLauncher.java     |    4 +-
 framework/src/org/apache/cordova/FileUtils.java    |    4 +-
 8 files changed, 5 insertions(+), 130 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/78efe2a9/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index a785943..0b14551 100755
--- a/README.md
+++ b/README.md
@@ -14,7 +14,6 @@ Requires
 - Java JDK 1.5 or greater
 - Apache ANT 1.8.0 or greater
 - Android SDK [http://developer.android.com](http://developer.android.com)
-- Apache Commons Codec [http://commons.apache.org/codec/](http://commons.apache.org/codec/)
 
  
 Cordova Android Developer Tools
@@ -83,11 +82,7 @@ Note: The Developer Tools handle this.  This is only to be done if the tooling f
 you are developing directly against the framework.
 
 
-To create your `cordova.jar` file, copy the commons codec:
-
-    mv commons-codec-1.7.jar framework/libs
-
-then run in the framework directory:
+To create your `cordova.jar` file, run in the framework directory:
 
     android update project -p . -t android-17
     ant jar

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/78efe2a9/bin/create
----------------------------------------------------------------------
diff --git a/bin/create b/bin/create
index 39aff6b..71f98bc 100755
--- a/bin/create
+++ b/bin/create
@@ -99,16 +99,6 @@ then
     # update the cordova-android framework for the desired target
     "$ANDROID_BIN" update project --target $TARGET --path "$BUILD_PATH"/framework &> /dev/null
 
-    if [ ! -e "$BUILD_PATH"/framework/libs/commons-codec-1.7.jar ]; then
-        # Use curl to get the jar (TODO: Support Apache Mirrors)
-        curl -OL http://archive.apache.org/dist/commons/codec/binaries/commons-codec-1.7-bin.zip &> /dev/null
-        unzip commons-codec-1.7-bin.zip &> /dev/null
-        mkdir -p "$BUILD_PATH"/framework/libs
-        cp commons-codec-1.7/commons-codec-1.7.jar "$BUILD_PATH"/framework/libs
-        # cleanup yo
-        rm commons-codec-1.7-bin.zip && rm -rf commons-codec-1.7
-    fi
-
     # compile cordova.js and cordova.jar
     pushd "$BUILD_PATH"/framework > /dev/null
     ant jar > /dev/null

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/78efe2a9/bin/create.js
----------------------------------------------------------------------
diff --git a/bin/create.js b/bin/create.js
index b1de5fe..07c2e56 100644
--- a/bin/create.js
+++ b/bin/create.js
@@ -120,46 +120,6 @@ function cleanup() {
     }
 }
 
-function downloadCommonsCodec() {
-    if (!fso.FileExists(ROOT + '\\framework\\libs\\commons-codec-1.7.jar')) {
-      // We need the .jar
-      var url = 'http://archive.apache.org/dist/commons/codec/binaries/commons-codec-1.7-bin.zip';
-      var libsPath = ROOT + '\\framework\\libs';
-      var savePath = libsPath + '\\commons-codec-1.7-bin.zip';
-      if (!fso.FileExists(savePath)) {
-        if(!fso.FolderExists(ROOT + '\\framework\\libs')) {
-            fso.CreateFolder(libsPath);
-        }
-        // We need the zip to get the jar
-        var xhr = WScript.CreateObject('MSXML2.XMLHTTP');
-        xhr.open('GET', url, false);
-        xhr.send();
-        if (xhr.status == 200) {
-          var stream = WScript.CreateObject('ADODB.Stream');
-          stream.Open();
-          stream.Type = 1;
-          stream.Write(xhr.ResponseBody);
-          stream.Position = 0;
-          stream.SaveToFile(savePath);
-          stream.Close();
-        } else {
-          Log('Could not retrieve the commons-codec. Please download it yourself and put into the framework/libs directory. This process may fail now. Sorry.');
-        }
-      }
-      var app = WScript.CreateObject('Shell.Application');
-      var source = app.NameSpace(savePath).Items();
-      var target = app.NameSpace(ROOT + '\\framework\\libs');
-      target.CopyHere(source, 256);
-      
-      // Move the jar into libs
-      fso.MoveFile(ROOT + '\\framework\\libs\\commons-codec-1.7\\commons-codec-1.7.jar', ROOT + '\\framework\\libs\\commons-codec-1.7.jar');
-      
-      // Clean up
-      fso.DeleteFile(ROOT + '\\framework\\libs\\commons-codec-1.7-bin.zip');
-      fso.DeleteFolder(ROOT + '\\framework\\libs\\commons-codec-1.7', true);
-    }
-}
-    
 // working dir
 var ROOT = WScript.ScriptFullName.split('\\bin\\create.js').join('');
 if (args.Count() > 0) {
@@ -206,8 +166,6 @@ if (!fso.FileExists(ROOT+'\\cordova-'+VERSION+'.jar') &&
     Log("Building jar and js files...");
     // update the cordova framework project to a target that exists on this machine
     exec('android.bat update project --target "'+TARGET+'" --path "'+ROOT+'\\framework"');
-    // pull down commons codec if necessary
-    downloadCommonsCodec();
     exec('ant.bat -f "'+ ROOT +'\\framework\\build.xml" jar');
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/78efe2a9/bin/update
----------------------------------------------------------------------
diff --git a/bin/update b/bin/update
index 9a968b1..2e716a7 100755
--- a/bin/update
+++ b/bin/update
@@ -105,16 +105,6 @@ then
 # update the cordova-android framework for the desired target
     "$ANDROID_BIN" update project --target $TARGET --path "$BUILD_PATH"/framework &> /dev/null
 
-    if [ ! -e "$BUILD_PATH"/framework/libs/commons-codec-1.7.jar ]; then
-        # Use curl to get the jar (TODO: Support Apache Mirrors)
-        curl -OL http://archive.apache.org/dist/commons/codec/binaries/commons-codec-1.7-bin.zip &> /dev/null
-        unzip commons-codec-1.7-bin.zip &> /dev/null
-        mkdir -p "$BUILD_PATH"/framework/libs
-        cp commons-codec-1.7/commons-codec-1.7.jar "$BUILD_PATH"/framework/libs
-        # cleanup yo
-        rm commons-codec-1.7-bin.zip && rm -rf commons-codec-1.7
-    fi
-
 # compile cordova.js and cordova.jar
     (cd "$BUILD_PATH"/framework && ant jar &> /dev/null )
 fi

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/78efe2a9/bin/update.js
----------------------------------------------------------------------
diff --git a/bin/update.js b/bin/update.js
index 748d602..8396d6f 100644
--- a/bin/update.js
+++ b/bin/update.js
@@ -96,46 +96,6 @@ function cleanup() {
     }
 }
 
-function downloadCommonsCodec() {
-    if (!fso.FileExists(ROOT + '\\framework\\libs\\commons-codec-1.7.jar')) {
-      // We need the .jar
-      var url = 'http://archive.apache.org/dist/commons/codec/binaries/commons-codec-1.7-bin.zip';
-      var libsPath = ROOT + '\\framework\\libs';
-      var savePath = libsPath + '\\commons-codec-1.7-bin.zip';
-      if (!fso.FileExists(savePath)) {
-        if(!fso.FolderExists(ROOT + '\\framework\\libs')) {
-            fso.CreateFolder(libsPath);
-        }
-        // We need the zip to get the jar
-        var xhr = WScript.CreateObject('MSXML2.XMLHTTP');
-        xhr.open('GET', url, false);
-        xhr.send();
-        if (xhr.status == 200) {
-          var stream = WScript.CreateObject('ADODB.Stream');
-          stream.Open();
-          stream.Type = 1;
-          stream.Write(xhr.ResponseBody);
-          stream.Position = 0;
-          stream.SaveToFile(savePath);
-          stream.Close();
-        } else {
-          WScript.Echo('Could not retrieve the commons-codec. Please download it yourself and put into the framework/libs directory. This process may fail now. Sorry.');
-        }
-      }
-      var app = WScript.CreateObject('Shell.Application');
-      var source = app.NameSpace(savePath).Items();
-      var target = app.NameSpace(ROOT + '\\framework\\libs');
-      target.CopyHere(source, 256);
-      
-      // Move the jar into libs
-      fso.MoveFile(ROOT + '\\framework\\libs\\commons-codec-1.7\\commons-codec-1.7.jar', ROOT + '\\framework\\libs\\commons-codec-1.7.jar');
-      
-      // Clean up
-      fso.DeleteFile(ROOT + '\\framework\\libs\\commons-codec-1.7-bin.zip');
-      fso.DeleteFolder(ROOT + '\\framework\\libs\\commons-codec-1.7', true);
-    }
-}
-
 var args = WScript.Arguments, PROJECT_PATH="example", 
     shell=WScript.CreateObject("WScript.Shell");
     
@@ -161,8 +121,6 @@ if (!fso.FileExists(ROOT+'\\cordova-'+VERSION+'.jar') &&
     WScript.Echo("Building jar and js files...");
     // update the cordova framework project to a target that exists on this machine
     exec('android.bat update project --target '+TARGET+' --path '+ROOT+'\\framework');
-    // pull down commons codec if necessary
-    downloadCommonsCodec();
     exec('ant.bat -f \"'+ ROOT +'\\framework\\build.xml\" jar');
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/78efe2a9/framework/build.xml
----------------------------------------------------------------------
diff --git a/framework/build.xml b/framework/build.xml
index 989dbb2..46242aa 100644
--- a/framework/build.xml
+++ b/framework/build.xml
@@ -31,22 +31,6 @@
     <fail message="The required minimum version of ant is 1.8.0, you have ${ant.version}"
           unless="thisantversion" />
 
-    <!-- check that commons codec is available. You should copy the codec jar to
-         framework/libs, as it is not included in the Cordova distribution. 
-         The name of the jar file in framework/libs does not matter. -->
-    <available classname="org.apache.commons.codec.binary.Base64"
-               property="exists.base64"
-               ignoresystemclasses="true">
-        <classpath>
-            <pathelement path="${classpath}" />
-            <fileset dir="libs">
-                <include name="*.jar" />
-            </fileset>
-        </classpath>
-    </available>
-    <fail message="You need to put a copy of Apache Commons Codec jar in the framework/libs directory"
-          unless="exists.base64" />
-
     <!-- The local.properties file is created and updated by the 'android' 
          tool. (For example "sdkdir/tools/android update project -p ." inside
          of this directory where the AndroidManifest.xml file exists. This

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/78efe2a9/framework/src/org/apache/cordova/CameraLauncher.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CameraLauncher.java b/framework/src/org/apache/cordova/CameraLauncher.java
index 1974dd7..134cf09 100755
--- a/framework/src/org/apache/cordova/CameraLauncher.java
+++ b/framework/src/org/apache/cordova/CameraLauncher.java
@@ -26,7 +26,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 
-import org.apache.commons.codec.binary.Base64;
 import org.apache.cordova.api.CallbackContext;
 import org.apache.cordova.api.CordovaPlugin;
 import org.apache.cordova.api.DataResource;
@@ -48,6 +47,7 @@ import android.media.MediaScannerConnection.MediaScannerConnectionClient;
 import android.net.Uri;
 import android.os.Environment;
 import android.provider.MediaStore;
+import android.util.Base64;
 import android.util.Log;
 
 /**
@@ -778,7 +778,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
         try {
             if (bitmap.compress(CompressFormat.JPEG, mQuality, jpeg_data)) {
                 byte[] code = jpeg_data.toByteArray();
-                byte[] output = Base64.encodeBase64(code);
+                byte[] output = Base64.encode(code, Base64.DEFAULT);
                 String js_out = new String(output);
                 this.callbackContext.success(js_out);
                 js_out = null;

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/78efe2a9/framework/src/org/apache/cordova/FileUtils.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileUtils.java b/framework/src/org/apache/cordova/FileUtils.java
index e62fc4a..4b136ed 100755
--- a/framework/src/org/apache/cordova/FileUtils.java
+++ b/framework/src/org/apache/cordova/FileUtils.java
@@ -20,9 +20,9 @@ package org.apache.cordova;
 
 import android.os.Environment;
 import android.provider.MediaStore;
+import android.util.Base64;
 import android.util.Log;
 
-import org.apache.commons.codec.binary.Base64;
 import org.apache.cordova.api.CallbackContext;
 import org.apache.cordova.api.CordovaPlugin;
 import org.apache.cordova.api.DataResource;
@@ -912,7 +912,7 @@ public class FileUtils extends CordovaPlugin {
                             break;
                         default: // Base64.
                             String contentType = dataResource.getMimeType();
-                            byte[] base64 = Base64.encodeBase64(bytes);
+                            byte[] base64 = Base64.encode(bytes, Base64.DEFAULT);
                             String s = "data:" + contentType + ";base64," + new String(base64, "US-ASCII");
                             result = new PluginResult(PluginResult.Status.OK, s);
                     }