{ "id": "85002", "key": "TIMOB-7233", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "12097", "description": "", "name": "Sprint 2012-05", "archived": true, "released": true, "releaseDate": "2012-03-11" }, { "id": "12593", "name": "Release 2.0.0", "archived": false, "released": true, "releaseDate": "2012-03-30" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-03-05T09:29:58.000+0000", "created": "2012-01-16T15:35:17.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "module_module", "qe-testadded", "regression" ], "versions": [ { "id": "12580", "description": "Dual Runtime 1.8.0", "name": "Release 1.8.0.1", "archived": true, "released": true, "releaseDate": "2011-12-22" } ], "issuelinks": [ { "id": "15255", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "86522", "key": "TIMOB-7663", "fields": { "summary": "Android: Create Module API specification", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Critical", "id": "1" }, "issuetype": { "id": "7", "description": "gh.issue.story.desc", "name": "Story", "subtask": false } } } } ], "assignee": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2012-07-05T10:30:03.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h3.Issue\r\nOne of the General changes while porting modules to our current SDK 1.8.0.1 was remove TiContext.\r\n\r\nh6.Customer's remarks\r\nInside my Android module, I have to execute some JavaScript statements in the current context. I was using TiContext to do that in pre-1.8.0.1 versions of SDK. Since TiContext is deprecated where in 1.8.0.1 Android module SDK can I find evalJS() and evalFile() methods?\r\n\r\nh6.General changes\r\n{noformat}\r\n TiContext is being replaced, and any implementation utilizing TiContext will take a performance / stability hit compared to using the desired API's directly.\r\n In most of the places where TiContext is used as an argument, the TiContext argument can be removed entirely or replaced with an Activity reference.\r\n{noformat}\r\n\r\nh6.evalJS and evalFile methods migrated\r\n{code:title=TiContext.java}\r\n\tpublic Object evalFile(String filename)\r\n\t\tthrows IOException\r\n\t{\r\n\t\treturn evalFile(filename, null, -1);\r\n\t}\r\n\r\n\tpublic Object evalJS(String src)\r\n\t{\r\n\t\tif (krollBridge == null)\r\n\t\t{\r\n\t\t\tLog.e(LCAT,\"on evalJS, evaluator is null and shouldn't be\");\r\n\t\t}\r\n\t\treturn krollBridge.evalJS(src);\r\n\t}\r\n{code}\r\n\r\nh6.References\r\nhttps://wiki.appcelerator.org/display/guides/Android+Module+Porting+Guide+for+1.8.0.1\r\n", "attachment": [ { "id": "25941", "filename": "com.arcaner.testmodule2-android-0.1.zip", "author": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-02-29T10:38:54.000+0000", "size": 46708, "mimeType": "application/zip" } ], "flagged": false, "summary": "Android: evalJS and evalFile methods deprecated in TiContext", "creator": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "environment": "Titanium SDK: Mobile 1.8.0.1\r\nPlatform OS: Android\r\nPlatform OS Version: 2.2 ", "comment": { "comments": [ { "id": "182794", "author": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "body": "We need to get some insight into how TiContext evalJS / evalFile are being currently used, as it makes a significant impact on the amount of time it will take us to re-introduce this functionality.", "updateAuthor": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-02-10T14:36:33.000+0000", "updated": "2012-02-10T14:36:33.000+0000" }, { "id": "184637", "author": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Make sure to run this test for both V8 and Rhino:\r\n\r\n* Copy the attached module zip into a project and add this to your tiapp.xml:\r\n{code}\r\n\r\n com.arcaner.testModule2\r\n\r\n{code}\r\n\r\n* Use this code inside the app:\r\n{code}\r\nvar test = require(\"com.arcaner.testModule2\");\r\ntest.evalJS(\"Ti.API.debug('Hello World'); 100+1\");\r\ntest.evalJSWithContext(\"Ti.API.debug('Hello from TiContext'); 1.1+100;\");\r\ntest.evalFileWithContext(\"test.js\");\r\n{code}\r\n\r\n* In the console, you should see these messages printed when the application runs:\r\n{code}\r\nD/TiAPI ( 6489): Hello World\r\nD/Testmodule2Module( 6489): (KrollRuntimeThread) [100,465] Result = 101.0\r\nD/TiAPI ( 6489): Hello from TiContext\r\nD/Testmodule2Module( 6489): (KrollRuntimeThread) [1,466] TiContext Result = 101.1\r\nD/TiAPI ( 6489): Hello world from a file\r\nD/Testmodule2Module( 6489): (KrollRuntimeThread) [1,467] TiContext File Result = 102.0\r\n{code}\r\n\r\nNote:\r\n\r\nThis is the java snippet that was used to expose these APIs for the module:\r\n{code}\r\n\t@Kroll.method\r\n\tpublic void evalJS(String code) {\r\n\t\tObject result = KrollRuntime.getInstance().evalString(code);\r\n\t\tLog.d(LCAT, \"Result = \" + result);\r\n\t}\r\n\r\n\t@Kroll.method\r\n\tpublic void evalJSWithContext(String code) {\r\n\t\tObject result = getTiContext().evalJS(code);\r\n\t\tLog.d(LCAT, \"TiContext Result = \" + result);\r\n\t}\r\n\r\n\t@Kroll.method\r\n\tpublic void evalFileWithContext(String path) {\r\n\t\ttry {\r\n\t\t\tObject result = getTiContext().evalFile(path);\r\n\t\t\tLog.d(LCAT, \"TiContext File Result = \" + result);\r\n\t\t} catch (Exception e) {\r\n\t\t\tLog.e(LCAT, \"Error\", e);\r\n\t\t}\r\n\t}\r\n{code}", "updateAuthor": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-02-29T10:01:30.000+0000", "updated": "2012-02-29T10:33:08.000+0000" }, { "id": "184652", "author": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Pull request is ready:\r\nhttps://github.com/appcelerator/titanium_mobile/pull/1538", "updateAuthor": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-02-29T10:38:08.000+0000", "updated": "2012-02-29T10:38:08.000+0000" }, { "id": "187194", "author": { "name": "nhuynh", "key": "nhuynh", "displayName": "Natalie Huynh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Tested with 2.0.0.v20120319003254 v8/rhino on Droid 2.2.2 and Emulator 2.3.3. Getting the correct console output", "updateAuthor": { "name": "nhuynh", "key": "nhuynh", "displayName": "Natalie Huynh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-03-19T14:26:40.000+0000", "updated": "2012-03-19T14:26:40.000+0000" } ], "maxResults": 9, "total": 9, "startAt": 0 } } }