incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject android commit: Fixing CB-210 with patch and adding fix for CB-210
Date Mon, 12 Mar 2012 20:30:31 GMT
Updated Branches:
  refs/heads/master f3c96ce1a -> 8a7af9376


Fixing CB-210 with patch and adding fix for CB-210


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

Branch: refs/heads/master
Commit: 8a7af937656c0e81256662824b0976bf596b7bff
Parents: f3c96ce
Author: Joe Bowser <bowserj@apache.org>
Authored: Mon Mar 12 13:30:16 2012 -0700
Committer: Joe Bowser <bowserj@apache.org>
Committed: Mon Mar 12 13:30:16 2012 -0700

----------------------------------------------------------------------
 .../src/org/apache/cordova/CameraLauncher.java     |   42 ++++++++++++---
 framework/src/org/apache/cordova/FileTransfer.java |    5 ++-
 2 files changed, 38 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/8a7af937/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 4960f91..03cf1fb 100755
--- a/framework/src/org/apache/cordova/CameraLauncher.java
+++ b/framework/src/org/apache/cordova/CameraLauncher.java
@@ -39,6 +39,7 @@ import android.content.ContentValues;
 import android.content.Intent;
 import android.database.Cursor;
 import android.graphics.Bitmap;
+import android.graphics.Matrix;
 import android.graphics.Bitmap.CompressFormat;
 import android.net.Uri;
 import android.provider.MediaStore;
@@ -272,19 +273,24 @@ public class CameraLauncher extends Plugin {
         // Get src and dest types from request code
         int srcType = (requestCode/16) - 1;
         int destType = (requestCode % 16) - 1;
+     int rotate = 0;
         
+     // 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(ctx.getContext()) + "/Pic.jpg");
+            exif.readExifData();
+         }
+     } catch (IOException e) {
+         e.printStackTrace();
+     }
+
         // 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();
-                    if (this.encodingType == JPEG) {
-                        exif.createInFile(DirectoryManager.getTempDirectoryPath(ctx.getContext())
+ "/Pic.jpg");
-                        exif.readExifData();
-                    }
-
                     // Read in bitmap of captured image
                     Bitmap bitmap;
                     try {
@@ -375,6 +381,20 @@ public class CameraLauncher extends Plugin {
                     if (destType == DATA_URL) {
                         try {
                             Bitmap bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri));
+                 String[] cols = { MediaStore.Images.Media.ORIENTATION };
+                 Cursor cursor = this.ctx.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);
+                 }
                             bitmap = scaleBitmap(bitmap);
                             this.processPicture(bitmap);
                             bitmap.recycle();
@@ -399,6 +419,12 @@ public class CameraLauncher extends Plugin {
                                 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.ctx));
+                                    exif.writeExifData();
+                                }
+
                                 bitmap.recycle();
                                 bitmap = null;
                                 
@@ -497,4 +523,4 @@ public class CameraLauncher extends Plugin {
     public void failPicture(String err) {
         this.error(new PluginResult(PluginResult.Status.ERROR, err), this.callbackId);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/8a7af937/framework/src/org/apache/cordova/FileTransfer.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileTransfer.java b/framework/src/org/apache/cordova/FileTransfer.java
index be0cbdb..05a950b 100644
--- a/framework/src/org/apache/cordova/FileTransfer.java
+++ b/framework/src/org/apache/cordova/FileTransfer.java
@@ -320,7 +320,10 @@ public class FileTransfer extends Plugin {
         }
 
         dos.writeBytes(LINE_START + BOUNDRY + LINE_END);
-        dos.writeBytes("Content-Disposition: form-data; name=\"" + fileKey + "\";" + " filename=\""
+ fileName +"\"" + LINE_END);
+        dos.writeBytes("Content-Disposition: form-data; name=\"" + fileKey + "\";" + " filename=\"");
+        //We don't want to chagne encoding, we just want this to write for all Unicode.
+        dos.write(fileName.getBytes("UTF-8"));
+        dos.writeBytes("\"" + LINE_END);
         dos.writeBytes("Content-Type: " + mimeType + LINE_END);
         dos.writeBytes(LINE_END);
 


Mime
View raw message