[TIMOB-7188] Android: Media module methods takeScreenshot and previewImage not implemented in 1.8.0.1
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Critical |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2012-01-23T16:47:13.000+0000 |
| Affected Version/s | Release 1.8.0.1 |
| Fix Version/s | Sprint 2012-02, Release 2.0.0, Release 1.8.1 |
| Components | Android |
| Labels | module_media, qe-testadded, regression |
| Reporter | Opie Cyrus |
| Assignee | Bill Dawson |
| Created | 2012-01-14T15:34:33.000+0000 |
| Updated | 2012-02-01T12:18:54.000+0000 |
Description
Ti.Media.takeScreenshot and Ti.Media.previewImage are commented out inside MediaModule.java since 1.8.0.1. We need investigate why (if any reason) and re-enable these. Documentation should be updated with the addition of these methods.
Test app
This test app exercises bothtakeScreenshotandpreviewImage. Create a new Titanium app and replace its app.js contents with the following. When you click the button it will take a screenshot then callpreviewImageto show the saved screenshot image.Titanium.UI.setBackgroundColor('#000'); var win = Titanium.UI.createWindow({ title:'Test', backgroundColor:'#000', exitOnClose: true }); win.add(Ti.UI.createLabel({ backgroundColor: "blue", color: "yellow", text: "Hello There", textAlign: "center", left: "10dp", right: "10dp", top: "5dp", height: "40dp" })); win.add(Ti.UI.createImageView({ height: "43dp", width: "46dp", image: "KS_nav_ui.png", top: "100dp" })); var btn; win.add(btn = Ti.UI.createButton({ title: "Take screenshot", bottom: "5dp", height: "40dp", left: "50dp", right: "50dp" })); function previewCallback(args) { Ti.API.info("previewImage success"); } function previewError(e) { alert("previewImage failure: " + e.message); Ti.API.error(e.message); } function screenshotCallback(image) { if (!image) { alert("Eeks, takeScreenshot didn't return anything."); return; } else { var blob = image.media; if (!blob) { alert("Eeks, there was no useful 'media' member of the passed result dictionary."); return; } if (Ti.Platform.osname === "android") { Ti.API.info("Got an image blob back from takeScreenshot. Gonna store it and preview it."); var tempdir = Ti.Filesystem.tempDirectory; var file = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, "temp.png"); if (file.exists()) { file.deleteFile(); } file.write(blob); Ti.Media.previewImage({ success: previewCallback, error: previewError, image: file.read() }); } else { alert("Call to takeScreenshot successful. Got a blob back."); } } } btn.addEventListener("click", function() { Ti.Media.takeScreenshot(screenshotCallback); }); win.open();Pull request ready: https://github.com/appcelerator/titanium_mobile/pull/1208
Verified fixed with SDK 1.9.0.v20120119134634 on Nexus S (2.3.6) and emulator 2.3.1
updated labels