Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-15812] Android: Fix for camera overlay for devices having only fr... #6536

Merged
merged 1 commit into from Jan 7, 2015

Conversation

ashcoding
Copy link
Contributor

...ont facing camera

Jira: https://jira.appcelerator.org/browse/TIMOB-15812

Issue was for devices like Nexus 7 (2012), code was trying to use rear facing camera which doesn't exists when overlay is being used.

var _window = Ti.UI.createWindow({
    backgroundColor:'white'
}); 
    var openCameraButton = Ti.UI.createButton({
        title : 'Open Camera'
    });

    openCameraButton.addEventListener('click', function(e) {
        var cameraOverlay = Ti.UI.createView();

        var takePhotoButton = Ti.UI.createButton({
            backgroundColor : '#fff',
            backgroundSelectedColor : '#efefef',
            borderColor : '#000',
            borderRadius : 17,
            borderWidth : 1,
            bottom : 65,
            color : '#000',
            height : 34,
            opacity : 0.4,
            title : 'Take Photo',
            width : '100dp'
        });

        var closeCameraButton = Ti.UI.createButton({
            backgroundColor : '#fff',
            backgroundSelectedColor : '#efefef',
            borderColor : '#000',
            borderRadius : 17,
            borderWidth : 1,
            bottom : 65,
            color : '#000',
            height : 34,
            opacity : 0.4,
            right : 10,
            title : 'Close Camera',
            top : 10,
            width : '150dp'
        });

        takePhotoButton.addEventListener('click', function(e) {
            Ti.Media.takePicture();
        });

        closeCameraButton.addEventListener('click', function(e) {
            alert('closing camera');
            Ti.Media.hideCamera();
        });

        cameraOverlay.add(takePhotoButton);
        cameraOverlay.add(closeCameraButton);

        Ti.Media.showCamera({
            success : function(e) {
                alert('success callback');
            },
            cancel : function() {
                Ti.API.info('cancel callback');
            },
            error : function(e) {
                Ti.API.info('error callback');
            },
            allowEditing : false,
            animated : false,
            autohide : false,
            mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO],
            overlay : cameraOverlay,
            saveToPhotoGallery : false,
            showControls : false
        });
    });

    _window.add(openCameraButton);

_window.open();

@ashcoding
Copy link
Contributor Author

Please test this with devices with only front facing cameras. Eg Nexus 7 (2012).

@hieupham007
Copy link
Contributor

Code reviewed and functionally tested. Request accepted

hieupham007 added a commit that referenced this pull request Jan 7, 2015
[TIMOB-15812] Android: Fix for camera overlay for devices having only fr...
@hieupham007 hieupham007 merged commit 564fdf5 into tidev:master Jan 7, 2015
@ashcoding ashcoding deleted the TIMOB-15812 branch May 21, 2015 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants