You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/12/05 01:59:46 UTC

[1/8] git commit: CB-5188:

Updated Branches:
  refs/heads/master 5f50ac704 -> 79a22d50a


CB-5188:


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/6b1a781e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/6b1a781e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/6b1a781e

Branch: refs/heads/master
Commit: 6b1a781ee8dbbea408f0316319d5f1733947d225
Parents: 5f50ac7
Author: Steven Gill <st...@gmail.com>
Authored: Mon Oct 28 12:27:16 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Oct 28 12:27:16 2013 -0700

----------------------------------------------------------------------
 plugin.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/6b1a781e/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index cd22f66..ad8290e 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -3,7 +3,7 @@
 <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
 xmlns:android="http://schemas.android.com/apk/res/android"
            id="org.apache.cordova.media-capture"
-      version="0.2.4">
+      version="0.2.5-dev">
     <name>Capture</name>
 
     <description>Cordova Media Capture Plugin</description>


[6/8] git commit: Merge branch 'dev' of github.com:archananaik/cordova-plugin-media-capture into dev

Posted by st...@apache.org.
Merge branch 'dev' of github.com:archananaik/cordova-plugin-media-capture into dev


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/70eee7f9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/70eee7f9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/70eee7f9

Branch: refs/heads/master
Commit: 70eee7f9774b46a38c6fc627ef40eb3cc79d72e7
Parents: 1b42035 0b37dac
Author: Steven Gill <st...@gmail.com>
Authored: Tue Nov 26 16:42:22 2013 -0800
Committer: Steven Gill <st...@gmail.com>
Committed: Tue Nov 26 16:42:22 2013 -0800

----------------------------------------------------------------------
 plugin.xml           | 18 ++++++++++++++++++
 test/cordova-incl.js |  3 ++-
 2 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[4/8] git commit: CB-5291 - ios - Media Capture Audio - status bar issues under iOS 7

Posted by st...@apache.org.
CB-5291 - ios - Media Capture Audio - status bar issues under iOS 7

When AudioRecorderView shows, use UIStatusBarStyleDefault; when
AudioRecorderView is dismissed, use previous status bar style.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/1b42035b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/1b42035b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/1b42035b

Branch: refs/heads/master
Commit: 1b42035b88bc3554f9ee466f8f6e951c44f3e0c4
Parents: 237d55f
Author: lmnbeyond <lm...@gmail.com>
Authored: Fri Nov 8 14:36:11 2013 +0800
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Mon Nov 11 17:34:41 2013 -0800

----------------------------------------------------------------------
 src/ios/CDVCapture.m | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/1b42035b/src/ios/CDVCapture.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVCapture.m b/src/ios/CDVCapture.m
index 39219b7..b214412 100644
--- a/src/ios/CDVCapture.m
+++ b/src/ios/CDVCapture.m
@@ -558,6 +558,11 @@
 
 @end
 
+@interface CDVAudioRecorderViewController () {
+    UIStatusBarStyle _previousStatusBarStyle;
+}
+@end
+
 @implementation CDVAudioRecorderViewController
 @synthesize errorCode, callbackId, duration, captureCommand, doneButton, recordingView, recordButton, recordImage, stopRecordImage, timerLabel, avRecorder, avSession, pluginResult, timer, isTimed;
 
@@ -588,6 +593,7 @@
         self.callbackId = theCallbackId;
         self.errorCode = CAPTURE_NO_MEDIA_FILES;
         self.isTimed = self.duration != nil;
+        _previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
 
         return self;
     }
@@ -846,6 +852,10 @@
     UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
     // return result
     [self.captureCommand.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
+
+    if (IsAtLeastiOSVersion(@"7.0")) {
+        [[UIApplication sharedApplication] setStatusBarStyle:_previousStatusBarStyle];
+    }
 }
 
 - (void)updateTime
@@ -896,4 +906,18 @@
     [self dismissAudioView:nil];
 }
 
+- (UIStatusBarStyle)preferredStatusBarStyle
+{
+    return UIStatusBarStyleDefault;
+}
+
+- (void)viewWillAppear:(BOOL)animated
+{
+    if (IsAtLeastiOSVersion(@"7.0")) {
+        [[UIApplication sharedApplication] setStatusBarStyle:[self preferredStatusBarStyle]];
+    }
+
+    [super viewWillAppear:animated];
+}
+
 @end


[3/8] git commit: CB-5275: CaptureImage and CaptureVideo have runnables and CaptureVideo works on 4.2. Still doesn't work for 4.3

Posted by st...@apache.org.
CB-5275: CaptureImage and CaptureVideo have runnables and CaptureVideo works on 4.2.  Still doesn't work for 4.3


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/237d55f6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/237d55f6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/237d55f6

Branch: refs/heads/master
Commit: 237d55f64ba68e4c70bb33750b4a7f3fdbfeda3e
Parents: 6b1a781
Author: Joe Bowser <bo...@apache.org>
Authored: Mon Nov 4 13:34:31 2013 -0800
Committer: Joe Bowser <bo...@apache.org>
Committed: Mon Nov 4 13:34:31 2013 -0800

----------------------------------------------------------------------
 src/android/Capture.java | 140 ++++++++++++++++++++++++------------------
 1 file changed, 79 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/237d55f6/src/android/Capture.java
----------------------------------------------------------------------
diff --git a/src/android/Capture.java b/src/android/Capture.java
index bea115b..9cfa9b9 100644
--- a/src/android/Capture.java
+++ b/src/android/Capture.java
@@ -253,7 +253,7 @@ public class Capture extends CordovaPlugin {
      * @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) {
+    public void onActivityResult(int requestCode, int resultCode, final Intent intent) {
 
         // Result received okay
         if (resultCode == Activity.RESULT_OK) {
@@ -276,71 +276,89 @@ public class Capture extends CordovaPlugin {
                 // 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.");
+
+                final Capture that = this;
+                Runnable captureImage = new Runnable() {
+                    @Override
+                    public void run() {
                         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;
+                            // TODO Auto-generated method stub
+                            // 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 = that.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 = that.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.");
+                                    that.fail(createErrorObject(CAPTURE_INTERNAL_ERR, "Error capturing image - no media storage found."));
+                                    return;
+                                }
+                            }
+                            FileInputStream fis = new FileInputStream(getTempDirectoryPath() + "/Capture.jpg");
+                            OutputStream os = that.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
+                                that.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results));
+                            } else {
+                                // still need to capture more images
+                                captureImage();
+                            }
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                            that.fail(createErrorObject(CAPTURE_INTERNAL_ERR, "Error capturing image."));
                         }
                     }
-                    FileInputStream fis = new FileInputStream(getTempDirectoryPath() + "/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."));
-                }
+                };
+                this.cordova.getThreadPool().execute(captureImage);
             } else if (requestCode == CAPTURE_VIDEO) {
-                // Get the uri of the video clip
-                Uri data = intent.getData();
-                // create a file object from the uri
-                if(data == null)
-                {
-                    this.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Error: data is null"));
-                }
-                else
-                {
-                    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);
+                
+                final Capture that = this;
+                Runnable captureVideo = new Runnable() {
+                    
+                    @Override
+                    public void run() {
+                        // Get the uri of the video clip
+                        Uri data = intent.getData();
+                        // create a file object from the uri
+                        if(data == null)
+                        {
+                            that.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Error: data is null"));
+                        }
+                        else
+                        {
+                            results.put(createMediaFile(data));
+
+                            if (results.length() >= limit) {
+                                // Send Uri back to JavaScript for viewing video
+                                that.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results));
+                            } else {
+                                // still need to capture more video clips
+                                captureVideo(duration);
+                            }
+                        }
                     }
-                }
+                };
+                this.cordova.getThreadPool().execute(captureVideo);
             }
         }
         // If canceled


[2/8] git commit: Added amazon-fireos platform. Change to use amazon-fireos as a platform if user agent string contains 'cordova-amazon-fireos'

Posted by st...@apache.org.
Added amazon-fireos platform.
Change to use amazon-fireos as a platform if user agent string contains 'cordova-amazon-fireos'


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/0b37dac4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/0b37dac4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/0b37dac4

Branch: refs/heads/master
Commit: 0b37dac4e54dfd6057cbabf681fe4b0ce247c536
Parents: 6b1a781
Author: Archana Naik <na...@lab126.com>
Authored: Fri Oct 18 15:15:24 2013 -0700
Committer: Archana Naik <na...@lab126.com>
Committed: Wed Oct 30 14:42:37 2013 -0700

----------------------------------------------------------------------
 plugin.xml           | 18 ++++++++++++++++++
 test/cordova-incl.js |  3 ++-
 2 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/0b37dac4/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index ad8290e..a2ea8bd 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -60,6 +60,24 @@ xmlns:android="http://schemas.android.com/apk/res/android"
         <source-file src="src/android/FileHelper.java" target-dir="src/org/apache/cordova/mediacapture" />
     </platform>
     
+    <!-- amazon-fireos -->
+    <platform name="amazon-fireos">
+        <config-file target="res/xml/config.xml" parent="/*">
+            <feature name="Capture" >
+                <param name="android-package" value="org.apache.cordova.mediacapture.Capture"/>
+            </feature>
+        </config-file>
+        
+        <config-file target="AndroidManifest.xml" parent="/*">
+            <uses-permission android:name="android.permission.RECORD_AUDIO" />
+            <uses-permission android:name="android.permission.RECORD_VIDEO"/>
+            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+        </config-file>
+
+        <source-file src="src/android/Capture.java" target-dir="src/org/apache/cordova/mediacapture" />
+        <source-file src="src/android/FileHelper.java" target-dir="src/org/apache/cordova/mediacapture" />
+    </platform>
+    
     <!-- ios -->
     <platform name="ios">    
         <config-file target="config.xml" parent="/*">

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/0b37dac4/test/cordova-incl.js
----------------------------------------------------------------------
diff --git a/test/cordova-incl.js b/test/cordova-incl.js
index a82c590..bd612be 100644
--- a/test/cordova-incl.js
+++ b/test/cordova-incl.js
@@ -22,6 +22,7 @@
 var PLAT;
 (function getPlatform() {
     var platforms = {
+        amazon_fireos: /cordova-amazon-fireos/,
         android: /Android/,
         ios: /(iPad)|(iPhone)|(iPod)/,
         blackberry10: /(BB10)/,
@@ -76,7 +77,7 @@ if (!window._doNotWriteCordovaScript) {
 }
 
 function backHome() {
-    if (window.device && device.platform && device.platform.toLowerCase() == 'android') {
+    if (window.device && device.platform && (device.platform.toLowerCase() == 'android' || device.platform.toLowerCase() == 'amazon-fireos')) {
         navigator.app.backHistory();
     }
     else {


[8/8] git commit: [CB-5565] Updated version and RELEASENOTES.md for release 0.2.5

Posted by st...@apache.org.
[CB-5565] Updated version and RELEASENOTES.md for release 0.2.5


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/79a22d50
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/79a22d50
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/79a22d50

Branch: refs/heads/master
Commit: 79a22d50a1953998d214e1eade8345f9c33f6565
Parents: 648445d
Author: Steven Gill <st...@gmail.com>
Authored: Wed Dec 4 15:16:31 2013 -0800
Committer: Steven Gill <st...@gmail.com>
Committed: Wed Dec 4 15:16:31 2013 -0800

----------------------------------------------------------------------
 RELEASENOTES.md | 8 +++++++-
 plugin.xml      | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/79a22d50/RELEASENOTES.md
----------------------------------------------------------------------
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index b72177c..e1e400b 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -42,4 +42,10 @@
  ### 0.2.4 (Oct 28, 2013)
 * CB-5199 - ios - Media Capture - UI issues under iOS 7
 * CB-5128: added repo + issue tag to plugin.xml for media capture plugin
-* [CB-5010] Incremented plugin version on dev branch.
+* [CB-5010] Incremented plugin version on dev branch. 
+
+### 0.2.5 (Dec 4, 2013)
+* add ubuntu platform
+* Added amazon-fireos platform. Change to use amazon-fireos as a platform if user agent string contains 'cordova-amazon-fireos'
+* CB-5291 - ios - Media Capture Audio - status bar issues under iOS 7
+* CB-5275: CaptureImage and CaptureVideo have runnables and CaptureVideo works on 4.2.  Still doesn't work for 4.3

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/79a22d50/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 86fc297..451c837 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -3,7 +3,7 @@
 <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
 xmlns:android="http://schemas.android.com/apk/res/android"
            id="org.apache.cordova.media-capture"
-      version="0.2.5-dev">
+      version="0.2.5">
     <name>Capture</name>
 
     <description>Cordova Media Capture Plugin</description>


[7/8] git commit: added ubuntu support

Posted by st...@apache.org.
added ubuntu support


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/648445d4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/648445d4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/648445d4

Branch: refs/heads/master
Commit: 648445d4f3126644157d0987e12e19caf6416b40
Parents: 70eee7f 291b25f
Author: Steven Gill <st...@gmail.com>
Authored: Mon Dec 2 16:26:57 2013 -0800
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Dec 2 16:26:57 2013 -0800

----------------------------------------------------------------------
 plugin.xml                    |  17 ++++
 src/ubuntu/back.png           | Bin 0 -> 12428 bytes
 src/ubuntu/capture.cpp        | 167 +++++++++++++++++++++++++++++++++++++
 src/ubuntu/capture.h          |  84 +++++++++++++++++++
 src/ubuntu/microphone.png     | Bin 0 -> 10415 bytes
 src/ubuntu/record_off.png     | Bin 0 -> 10087 bytes
 src/ubuntu/record_on.png      | Bin 0 -> 4902 bytes
 src/ubuntu/shoot.png          | Bin 0 -> 14430 bytes
 src/ubuntu/toolbar-left.png   | Bin 0 -> 1212 bytes
 src/ubuntu/toolbar-middle.png | Bin 0 -> 4416 bytes
 src/ubuntu/toolbar-right.png  | Bin 0 -> 1161 bytes
 11 files changed, 268 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/648445d4/plugin.xml
----------------------------------------------------------------------
diff --cc plugin.xml
index a2ea8bd,38a306e..86fc297
--- a/plugin.xml
+++ b/plugin.xml
@@@ -59,25 -59,23 +59,42 @@@ xmlns:android="http://schemas.android.c
          <source-file src="src/android/Capture.java" target-dir="src/org/apache/cordova/mediacapture" />
          <source-file src="src/android/FileHelper.java" target-dir="src/org/apache/cordova/mediacapture" />
      </platform>
 +    
 +    <!-- amazon-fireos -->
 +    <platform name="amazon-fireos">
 +        <config-file target="res/xml/config.xml" parent="/*">
 +            <feature name="Capture" >
 +                <param name="android-package" value="org.apache.cordova.mediacapture.Capture"/>
 +            </feature>
 +        </config-file>
 +        
 +        <config-file target="AndroidManifest.xml" parent="/*">
 +            <uses-permission android:name="android.permission.RECORD_AUDIO" />
 +            <uses-permission android:name="android.permission.RECORD_VIDEO"/>
 +            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
 +        </config-file>
 +
 +        <source-file src="src/android/Capture.java" target-dir="src/org/apache/cordova/mediacapture" />
 +        <source-file src="src/android/FileHelper.java" target-dir="src/org/apache/cordova/mediacapture" />
 +    </platform>
 +    
+ 
+     <!-- ubuntu -->
+     <platform name="ubuntu">
+         <header-file src="src/ubuntu/capture.h" />
+         <source-file src="src/ubuntu/capture.cpp" />
+ 
+         <resource-file src="src/ubuntu/back.png" />
+         <resource-file src="src/ubuntu/MediaCaptureWidget.qml" />
+         <resource-file src="src/ubuntu/shoot.png" />
+         <resource-file src="src/ubuntu/microphone.png" />
+         <resource-file src="src/ubuntu/record_on.png" />
+         <resource-file src="src/ubuntu/record_off.png" />
+         <resource-file src="src/ubuntu/toolbar-left.png" />
+         <resource-file src="src/ubuntu/toolbar-middle.png" />
+         <resource-file src="src/ubuntu/toolbar-right.png" />
+     </platform>
+ 
      <!-- ios -->
      <platform name="ios">    
          <config-file target="config.xml" parent="/*">


[5/8] git commit: add ubuntu platform

Posted by st...@apache.org.
add ubuntu platform


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/291b25f5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/291b25f5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/291b25f5

Branch: refs/heads/master
Commit: 291b25f5cce3493812d0fcd3742f7ec6dad57c79
Parents: 5f50ac7
Author: Maxim Ermilov <ma...@canonical.com>
Authored: Mon Nov 18 15:08:23 2013 +0400
Committer: Maxim Ermilov <ma...@canonical.com>
Committed: Mon Nov 18 15:08:23 2013 +0400

----------------------------------------------------------------------
 plugin.xml                    |  18 +++-
 src/ubuntu/back.png           | Bin 0 -> 12428 bytes
 src/ubuntu/capture.cpp        | 167 +++++++++++++++++++++++++++++++++++++
 src/ubuntu/capture.h          |  84 +++++++++++++++++++
 src/ubuntu/microphone.png     | Bin 0 -> 10415 bytes
 src/ubuntu/record_off.png     | Bin 0 -> 10087 bytes
 src/ubuntu/record_on.png      | Bin 0 -> 4902 bytes
 src/ubuntu/shoot.png          | Bin 0 -> 14430 bytes
 src/ubuntu/toolbar-left.png   | Bin 0 -> 1212 bytes
 src/ubuntu/toolbar-middle.png | Bin 0 -> 4416 bytes
 src/ubuntu/toolbar-right.png  | Bin 0 -> 1161 bytes
 11 files changed, 268 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/291b25f5/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index cd22f66..38a306e 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -59,7 +59,23 @@ xmlns:android="http://schemas.android.com/apk/res/android"
         <source-file src="src/android/Capture.java" target-dir="src/org/apache/cordova/mediacapture" />
         <source-file src="src/android/FileHelper.java" target-dir="src/org/apache/cordova/mediacapture" />
     </platform>
-    
+
+    <!-- ubuntu -->
+    <platform name="ubuntu">
+        <header-file src="src/ubuntu/capture.h" />
+        <source-file src="src/ubuntu/capture.cpp" />
+
+        <resource-file src="src/ubuntu/back.png" />
+        <resource-file src="src/ubuntu/MediaCaptureWidget.qml" />
+        <resource-file src="src/ubuntu/shoot.png" />
+        <resource-file src="src/ubuntu/microphone.png" />
+        <resource-file src="src/ubuntu/record_on.png" />
+        <resource-file src="src/ubuntu/record_off.png" />
+        <resource-file src="src/ubuntu/toolbar-left.png" />
+        <resource-file src="src/ubuntu/toolbar-middle.png" />
+        <resource-file src="src/ubuntu/toolbar-right.png" />
+    </platform>
+
     <!-- ios -->
     <platform name="ios">    
         <config-file target="config.xml" parent="/*">

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/291b25f5/src/ubuntu/back.png
----------------------------------------------------------------------
diff --git a/src/ubuntu/back.png b/src/ubuntu/back.png
new file mode 100644
index 0000000..af78faa
Binary files /dev/null and b/src/ubuntu/back.png differ

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/291b25f5/src/ubuntu/capture.cpp
----------------------------------------------------------------------
diff --git a/src/ubuntu/capture.cpp b/src/ubuntu/capture.cpp
new file mode 100644
index 0000000..cab4074
--- /dev/null
+++ b/src/ubuntu/capture.cpp
@@ -0,0 +1,167 @@
+/*
+ *
+ * Copyright 2013 Canonical Ltd.
+ *
+ * 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.
+ *
+*/
+#include "capture.h"
+
+const char code[] = "\
+var component, object;                                                  \
+function createObject() {                                               \
+    component = Qt.createComponent(%1);                                 \
+    if (component.status == Component.Ready)                            \
+        finishCreation();                                               \
+    else                                                                \
+        component.statusChanged.connect(finishCreation);                \
+}                                                                       \
+function finishCreation() {                                             \
+    CordovaWrapper.captureObject = component.createObject(root,         \
+        {root: root, cordova: cordova, state: \"%2\"});                 \
+}                                                                       \
+createObject()";
+
+static QString formatFile(const QMimeDatabase &db, const QString &path) {
+    QFileInfo info(path);
+    QMimeType mime = db.mimeTypeForFile(info.fileName());
+
+    QVariantMap file;
+    file.insert("name", info.fileName());
+    file.insert("fullPath", info.absoluteFilePath());
+    file.insert("lastModifiedDate", info.lastModified().toMSecsSinceEpoch());
+    file.insert("size", info.size());
+    file.insert("type", mime.name());
+
+    return CordovaInternal::format(file);
+}
+
+MediaCapture::MediaCapture(Cordova *cordova): CPlugin(cordova), _scId(0), _ecId(0) {
+}
+
+void MediaCapture::captureAudio(int scId, int ecId, QVariantMap options) {
+    if (_scId || _ecId) {
+        this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_APPLICATION_BUSY));
+        return;
+    }
+
+    QString path = m_cordova->get_app_dir() + "/../qml/MediaCaptureWidget.qml";
+
+    // TODO: relative url
+    QString qml = QString(code).arg(CordovaInternal::format(path)).arg("audio");
+    m_cordova->execQML(qml);
+
+    _scId = scId;
+    _ecId = ecId;
+}
+
+void MediaCapture::onAudioRecordError(QMediaRecorder::Error) {
+    if (!_ecId)
+        return;
+    this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_INTERNAL_ERR));
+    _ecId = _scId = 0;
+
+    _recorder.clear();
+    _files.clear();
+
+    m_cordova->execQML("CordovaWrapper.captureObject.destroy()");
+}
+
+void MediaCapture::recordAudio() {
+    if (_recorder.data()) {
+        QUrl url = _recorder->outputLocation();
+
+        QString path = url.toString();
+        _recorder->stop();
+
+        _recorder.clear();
+
+        this->callback(_scId, QString("[%1]").arg(formatFile(_db, path)));
+        _ecId = _scId = 0;
+
+        m_cordova->execQML("CordovaWrapper.captureObject.destroy()");
+    } else {
+        _recorder = QSharedPointer<QAudioRecorder>(new QAudioRecorder);
+        QObject::connect(_recorder.data(), SIGNAL(error(QMediaRecorder::Error)), this, SLOT(onAudioRecordError(QMediaRecorder::Error)));
+
+        if (_options.find("mode")->toString() == "audio/amr") {
+            _recorder->setContainerFormat("amr");
+            _recorder->setOutputLocation(generateLocation("amr"));
+        } else {
+            _recorder->setContainerFormat("wav");
+            _recorder->setOutputLocation(generateLocation("wav"));
+        }
+        _recorder->record();
+    }
+}
+
+void MediaCapture::cancel() {
+    if (!_ecId)
+        return;
+
+    m_cordova->execQML("CordovaWrapper.captureObject.destroy()");
+
+    _recorder.clear();
+    this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_NO_MEDIA_FILES));
+    _ecId = _scId = 0;
+
+    _recorder.clear();
+}
+
+void MediaCapture::captureVideo(int scId, int ecId, QVariantMap options) {
+    if (_scId || _ecId) {
+        this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_APPLICATION_BUSY));
+        return;
+    }
+
+    QString path = m_cordova->get_app_dir() + "/../qml/MediaCaptureWidget.qml";
+
+    // TODO: relative url
+    QString qml = QString(code).arg(CordovaInternal::format(path)).arg("videoRecording");
+    m_cordova->execQML(qml);
+
+    _scId = scId;
+    _ecId = ecId;
+}
+
+void MediaCapture::onVideoRecordEnd(QString path) {
+    assert(path.startsWith("file:"));
+    path = path.mid(5);
+
+    this->callback(_scId, QString("[%1]").arg(formatFile(_db, path)));
+    _ecId = _scId = 0;
+
+    m_cordova->execQML("CordovaWrapper.captureObject.destroy()");
+}
+
+void MediaCapture::captureImage(int scId, int ecId, QVariantMap options) {
+    if (_scId || _ecId) {
+        this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_APPLICATION_BUSY));
+        return;
+    }
+
+    QString path = m_cordova->get_app_dir() + "/../qml/MediaCaptureWidget.qml";
+
+    // TODO: relative url
+    QString qml = QString(code).arg(CordovaInternal::format(path)).arg("camera");
+    m_cordova->execQML(qml);
+
+    _scId = scId;
+    _ecId = ecId;
+}
+
+void MediaCapture::onImageSaved(const QString &path) {
+    this->callback(_scId, QString("[%1]").arg(formatFile(_db, path)));
+    _ecId = _scId = 0;
+}

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/291b25f5/src/ubuntu/capture.h
----------------------------------------------------------------------
diff --git a/src/ubuntu/capture.h b/src/ubuntu/capture.h
new file mode 100644
index 0000000..2c6caa4
--- /dev/null
+++ b/src/ubuntu/capture.h
@@ -0,0 +1,84 @@
+/*
+ *
+ * Copyright 2013 Canonical Ltd.
+ *
+ * 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.
+ *
+*/
+#ifndef CAPTURE_H_ASCXZFG975
+#define CAPTURE_H_ASCXZFG975
+
+#include <cordova.h>
+#include <cplugin.h>
+#include <QtMultimedia>
+#include <QtCore>
+#include <QtQuick>
+
+class MediaCapture: public CPlugin {
+    Q_OBJECT
+public:
+    explicit MediaCapture(Cordova *cordova);
+
+    virtual const QString fullName() override {
+        return MediaCapture::fullID();
+    }
+
+    virtual const QString shortName() override {
+        return "Capture";
+    }
+
+    static const QString fullID() {
+        return "Capture";
+    }
+
+public slots:
+    void captureAudio(int scId, int ecId, QVariantMap options);
+    void captureImage(int scId, int ecId, QVariantMap options);
+    void captureVideo(int scId, int ecId, QVariantMap options);
+
+    void recordAudio();
+    void cancel();
+    void onVideoRecordEnd(QString path);
+    void onImageSaved(const QString &path);
+
+    QString generateLocation(const QString &extension) {
+        int i = 1;
+        for (;;++i) {
+            QString path = QString("%1/.local/share/%2/persistent/%3.%4").arg(QDir::homePath())
+                .arg(QCoreApplication::applicationName()).arg(i).arg(extension);
+
+            if (!QFileInfo(path).exists())
+                return path;
+        }
+    }
+private slots:
+    void onAudioRecordError(QMediaRecorder::Error);
+private:
+    QSharedPointer<QAudioRecorder> _recorder;
+
+    int _scId, _ecId;
+    QList<QString> _files;
+    QVariantMap _options;
+    QMimeDatabase _db;
+
+    enum CaptureError {
+        CAPTURE_INTERNAL_ERR = 0,
+        CAPTURE_APPLICATION_BUSY = 1,
+        CAPTURE_INVALID_ARGUMENT = 2,
+        CAPTURE_NO_MEDIA_FILES = 3,
+        CAPTURE_NOT_SUPPORTED = 20
+    };
+};
+
+#endif

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/291b25f5/src/ubuntu/microphone.png
----------------------------------------------------------------------
diff --git a/src/ubuntu/microphone.png b/src/ubuntu/microphone.png
new file mode 100644
index 0000000..4f2a5cf
Binary files /dev/null and b/src/ubuntu/microphone.png differ

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/291b25f5/src/ubuntu/record_off.png
----------------------------------------------------------------------
diff --git a/src/ubuntu/record_off.png b/src/ubuntu/record_off.png
new file mode 100644
index 0000000..adc822c
Binary files /dev/null and b/src/ubuntu/record_off.png differ

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/291b25f5/src/ubuntu/record_on.png
----------------------------------------------------------------------
diff --git a/src/ubuntu/record_on.png b/src/ubuntu/record_on.png
new file mode 100644
index 0000000..985658a
Binary files /dev/null and b/src/ubuntu/record_on.png differ

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/291b25f5/src/ubuntu/shoot.png
----------------------------------------------------------------------
diff --git a/src/ubuntu/shoot.png b/src/ubuntu/shoot.png
new file mode 100644
index 0000000..c093b63
Binary files /dev/null and b/src/ubuntu/shoot.png differ

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/291b25f5/src/ubuntu/toolbar-left.png
----------------------------------------------------------------------
diff --git a/src/ubuntu/toolbar-left.png b/src/ubuntu/toolbar-left.png
new file mode 100644
index 0000000..720d7f6
Binary files /dev/null and b/src/ubuntu/toolbar-left.png differ

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/291b25f5/src/ubuntu/toolbar-middle.png
----------------------------------------------------------------------
diff --git a/src/ubuntu/toolbar-middle.png b/src/ubuntu/toolbar-middle.png
new file mode 100644
index 0000000..77595bb
Binary files /dev/null and b/src/ubuntu/toolbar-middle.png differ

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/291b25f5/src/ubuntu/toolbar-right.png
----------------------------------------------------------------------
diff --git a/src/ubuntu/toolbar-right.png b/src/ubuntu/toolbar-right.png
new file mode 100644
index 0000000..e4e6aa6
Binary files /dev/null and b/src/ubuntu/toolbar-right.png differ