Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4745] Android: Camera - view not displaying overlay correctly

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionDuplicate
Resolution Date2012-03-05T20:39:38.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsdr-list, overlay, showcamera
ReporterTrevor Ward
AssigneePing Wang
Created2011-06-16T04:27:17.000+0000
Updated2017-03-22T20:35:03.000+0000

Description

I have an app which uses Ti.Media.showCamera with an overlay of buttons etc. This works really well on iPhone where the camera view is displayed with the overlay and the buttons function. Also when the window is closed the close event is fired which runs the Ti.Media.hideCamera. On Android, the camera view is shown with the overlay ... but the overlay is rotated 90% and none of the buttons work, also the close event on the window isn't fired when the window is closed. I am hoping I am doing something wrong but think this may be a bug. Info...
// All source code open Source Copyright 2011
// Code submitted by thewarpedcoder .... trevor@thewarpedcoder.net

Ti.UI.setBackgroundColor('#ffffff');

var homeWindow =	Titanium.UI.createWindow
({

});
homeWindow.open();

var displayVoucherOverlayView 	= 	Ti.UI.createView
({
	top:		0,
	bottom:		0,
	left:		0,
	right:		0,
	opacity:	0.75
});
var setAButton	=	Ti.UI.createButton
({
	top:		100,
	left:		30,
	right:		30,
	height:		75,
	title:		"HELLO"
});
displayVoucherOverlayView.add(setAButton);

setAButton.addEventListener('click', function() { alert("I HAVE BEEN PRESSED");} );

var navigationBar = 	Ti.UI.createView
({
	bottom: 			0,
	height: 			50,
	right:				0,
	backgroundColor: 	"#000000",
	opacity:			0.75
});
var navBarTestBtn 	= 	Ti.UI.createView
({
	left:				5,
	width: 				90,
	height: 			50,
	top: 				0,
	backgroundColor: 	"#000000",
	borderColor: 		"#FFFFFF",
	borderWidth: 		2
});
var navBarTestBtnText 	= 	Ti.UI.createLabel
({
	width: 				90,
	text: 				"TEST",
	color: 				"#FFFFFF",
	textAlign: 			'center',
	font: 				{fontSize: 		10}
});
navBarTestBtn.add(navBarTestBtnText);
navigationBar.add(navBarTestBtn);

navBarTestBtn.addEventListener('click',   function() {alert("IM A VIEW WITH A LISTENER");} );

displayVoucherOverlayView.add(navigationBar);

var cameraTransform 	= 	Ti.UI.create2DMatrix();
cameraTransform 		= 	cameraTransform.scale(2);

Ti.Media.showCamera
({
    success:			function(event) {},
    cancel:				function() {},
    error:				function(error) 
	{
        if (error.code == Ti.Media.NO_CAMERA) 
		{
			alert("NO CAMERA");
        } 
		else 
		{
			alert("CAMERA ERROR");
        }
    },
	mediaTypes:			[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO],
    showControls:		false,
    autohide:			false,
    transform:			cameraTransform,
    overlay:			displayVoucherOverlayView
});

Comments

  1. Paul Dowsett 2011-06-20

    I'm sorry, Trevor, I cannot accept a 350-line usecase. In order for us to progress this issue, please would you edit your ticket and replace your code with a [Use-case](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-CreatingGoodUsecases). To summarize, this is the simplest code that will demonstrate the issue, and will run without any modification. You can read more about this in [Submitting Bug Reports](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-SubmittingBugReports).
  2. Trevor Ward 2011-06-21

    Hi Paul I have created a smaller user case, however it shows some of the problems specifically the overlay orientation. I have again created a gist and pastebin paste. Code length ... 128 lines. https://gist.github.com/1037834 http://pastebin.com/HkWQhycG It does not however show the buttons not working on the overlay as the original does. The original code is also set to show the close event. The latest code is not, however the close event does not fire. The latest user case works on Android and iPhone devices. Does not run in emulator as it requires camera. The code shows how the application which actually has the issue with is coded uses NameSpaces and calls which is why it is structured in this way. Hope this is all OK, please let me know if you require anything else. T...
  3. Eduardo Gomez 2011-07-08

    There is a HD ticket relying on this, http://appc.me/c/APP-148816
  4. Paul Dowsett 2011-07-09

    Trevor A usecase is not intended to be an example of best coding practice; ideally it's a sequential list of Ti API calls, without any namespaces or functions. The KitchenSink will give you a good idea of what I mean by this. Furthermore, it must run without modification, which yours does not. If there is more than one issue involved, then please submit a separate ticket for each of them. Thanks
  5. Trevor Ward 2011-07-18

    Hi Paul Sorry this has taken so long, but had limited computer access for the past week or so. OK I think I understand my mistake, I had basically cut and pasted the code from the main application which does use Name Spaces etc. Here is a new Use Case. git://gist.github.com/1089764.git I have run it on a Nexus 1 using Ti SDK 1.7.1 and 1.8. I only have the app.js with the pasted code in. Hope this is as required. There are a few other issues with the camera with buttons on the overlay not working and event handlers not working, but I am thinking that as this is only on Android, it may all be related to the overlay being displayed at a 90% rotation. as the components in my full overlay are overwriting each other, and the buttons in the Use Case work. Please let me now if you need anything else
  6. Trevor Ward 2011-07-22

    Hi Paul No worries it has been removed. T...
  7. Lee Morris 2017-03-22

    Closing ticket as duplicate of the ticket that is mentioned above.

JSON Source