tidev / titanium-sdk

🚀 Native iOS and Android Apps with JavaScript
https://titaniumsdk.com/
Other
2.76k stars 1.21k forks source link

fix(android): optimize cameraX rotation after camera is active #14139

Open m1ga opened 4 weeks ago

m1ga commented 4 weeks ago

When you use cameraX and rotate the camera AFTER opening it in portrait mode it won't update the target rotation and the image had the wrong orientation.

Test

var win = Ti.UI.createWindow();
var img = Ti.UI.createImageView();
win.addEventListener("click", function() {
    Ti.Media.requestCameraPermissions(function(e) {
        if (e.success) {
            var overlay = Ti.UI.createView();
            var btn = Ti.UI.createButton({
                bottom: 0,
                title: "take"
            })
            overlay.add(btn);
            Ti.Media.showCamera({
                overlay: overlay,
                useCameraX: true,
                success: function(e){
                    img.image = e.media;
                }
            });

            btn.addEventListener("click", function() {
                Ti.Media.takePicture();
            })
        }
    });
})
win.add(img);
win.open();

Run the app and click on the screen to open the camera.

Test 2: