Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16166] Android: Camera Overlay - RuntimeException is thrown when creating custom camera overlay with properties

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-01-30T21:18:45.000+0000
Affected Version/sRelease 3.2.0, Release 3.2.1
Fix Version/s2014 Sprint 02, 2014 Sprint 02 API, Release 3.3.0
ComponentsAndroid
Labelsmodule_media, parity, qe-3.2.1, qe-closed-3.3.0, qe-testadded
ReporterWilson Luu
AssigneeSunila
Created2014-01-10T19:14:42.000+0000
Updated2014-07-31T07:49:51.000+0000

Description

*Details:* If you create a custom camera overlay with properties, then a RuntimeException is thrown on Android. *This is not a regression and this bug is not reproducible on iOS.* *Steps to reproduce:* 1. Create the default Titanium classic app with this sample code:
var window = Ti.UI.createWindow({
	backgroundColor:'white',
	layout:'vertical'
});

var cameraOverlayBtn = Ti.UI.createButton({
	title:'camera overaly'
});

cameraOverlayBtn.addEventListener('click', function(e){
	
	Ti.API.info('### camera overlay');
	
	var customOverlay = Ti.UI.createView({
		// commenting the property will NOT throw a RuntimeException
		borderColor:'red'
	});
	
	var takePhotoButton = Ti.UI.createButton({
		title:'Take Photo',
		backgroundColor : '#fff',
        backgroundSelectedColor : '#efefef',
        borderColor : '#000',
        borderRadius : 17,
        borderWidth : 1,
        bottom : 65,
        color : '#000',
        height : 34,
        opacity : 0.4,
        width : '100dp'
    });
    
    takePhotoButton.addEventListener('click', function(e) {
        Ti.Media.takePicture();
    });
	
	customOverlay.add(takePhotoButton);
	
	Titanium.Media.showCamera({
		success:function(success_event) {
			Ti.API.info('### camera overlay success');
		},
		
		cancel:function(cancel_event) {
			Ti.API.info('### camera overlay cancel');
		},
		
		error:function(error_event) {
			Ti.API.info('### camera overlay error');
		},
		
		overlay:customOverlay,
		
		// only used to verify on iOS
		// showControls: false
	});
});

window.add(cameraOverlayBtn);
window.open();
2. Install the app to an Android device 3. Press on *camera overlay* button *Actual:* A RuntimeException is thrown (see logcat.txt attachment). *Expected:* A RuntimeException should not be thrown and the specified overlay properties should appear on top of the camera ui.

Attachments

FileDateSize
logcat.txt2014-01-10T19:14:42.000+00005298

Comments

  1. Wilson Luu 2014-01-13

    [~ngupta] Will do.
  2. Wilson Luu 2014-01-13

    This issue is still reproducible with 3.1.3 release i.e. got the same RuntimeException in logcat. Tested on: Appcelerator Studio, build: 3.1.3.201309132456 SDK build: 3.1.3.GA CLI: 3.1.2 Alloy: 1.2.0 Devices: Droid3 (2.3.4), Samsung Galaxy S4 (4.2.2)
  3. Sunila 2014-01-30

    Remove view from the parent if it is already attached https://github.com/appcelerator/titanium_mobile/pull/5292
  4. Paras Mishra 2014-04-25

    Verified as fixed, hence closing the issue Verified on: Device : Google Nexus 4, Android Version: 4.1.1 SDK: 3.3.0.v20140423155715 CLI version : 3.3.0-dev OS : MAC OSX 10.9.2 Alloy: 1.4.0-dev ACS: 1.0.14 npm:1.3.2 Appcelerator Studio, build: 3.3.0.201404211130 titanium-code-processor: 1.1.1-alpha XCode : 5.1.1

JSON Source