{ "id": "119221", "key": "TIMOB-14991", "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": [], "resolution": { "id": "2", "description": "The problem described is an issue which will never be fixed.", "name": "Won't Fix" }, "resolutiondate": "2015-11-11T07:55:23.000+0000", "created": "2013-08-28T22:20:39.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "look1", "parity", "supportTeam" ], "versions": [], "issuelinks": [ { "id": "31469", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "65832", "key": "TIMOB-4233", "fields": { "summary": "iOS: Provide mechanism for module resources to be placed in the application bundle root folder", "status": { "description": "This issue was once resolved, but the resolution was deemed incorrect. From here issues are either marked assigned or resolved.", "name": "Reopened", "id": "4", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } }, { "id": "31468", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "76435", "key": "TIMOB-4417", "fields": { "summary": "Add pathing to assets for Javascript Modules", "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": "Medium", "id": "3" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } }, { "id": "32319", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "103072", "key": "TIMOB-11360", "fields": { "summary": "Tooling: Android module build scripts throw NoClassFoundException when native Android project is included as library which has UI built in XML", "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": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "32123", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "86942", "key": "TIMOB-7827", "fields": { "summary": "Android: Add support for extrahigh density (320 dpi) devices", "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": "High", "id": "2" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "updated": "2018-08-02T22:20:06.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": "h6.Problem\r\nClient is trying to get images from Android Titanium Module and refer to them via Javascript. \r\n\r\nSo instead of return a TiBlob they would like to get path access resolved so they just have to link image in their image proxy on a similar way like:\r\n\r\n{code}\r\nvar image = Ti.UI.ImageView({\r\n image: '/modules/com.mod-id.org/images/image.png'\r\n});\r\n{code}\r\n\r\n\"image.png\" would be contained at \"/RootModuleFolder/assets/image.png\"\r\n\r\nAs the assets/README suggests, if you put the image.png in an \"images/\" subdirectory under assets. Then try to refer to it from a Javascript file.\r\n\r\nh6.assets/README\r\n{code}\r\nPlace your assets like PNG files in this directory and they will be packaged with your module.\r\n\r\nIf you create a file named org.appcelerator.wifissid.js in this directory, it will be compiled and used as your module. This allows you to run pure Javascript modules that are pre-compiled.\r\n{code}\r\n\r\nh6.Steps to reproduce\r\nCreate the scenario as follows:\r\n1) Create android module\r\n2) Create directory in assets call 'images'\r\n3) Put an image.png in assets/images\r\n4) Create a test app\r\n5) Replace app.js with snippet below.\r\n6) Public the android module into the Test app\r\n7) Launch the test app in an Android Device\r\n8) Notice how nothing shows up\r\n\r\nIf you create an iOS module in the same way as the android module and you publish it, when running the test app on an iOS device, you'll see the image.\r\n\r\nh6.A Snippet\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: 'yellow'\r\n});\r\nvar view1 = Ti.UI.createImageView({\r\n top: 0,\r\n left: 0,\r\n height: Ti.UI.SIZE,\r\n width: Ti.UI.SIZE,\r\n // works for iOS, doesn't work for android\r\n image: '/modules/com.mod-id.org/images/image.png'\r\n})\r\nwin.add(view1);\r\nwin.open();\r\n{code}\r\n\r\nh6.Additional details\r\nIf you try any of these paths and attempt to use a TiUIImageView warning below is thrown as a drawable reference:\r\n\r\n{code}\r\n//None of these paths worked\r\n//var imagePNG = '/modules/org.appcelerator.org/yes.png';\r\n//var imagePNG = '/modules/org.appcelerator.org/assets/yes.png';\r\n//var imagePNG = 'modules/org.appcelerator.org/assets/yes.png';\r\n//var imagePNG = '/org.appcelerator.org/assets/yes.png';\r\n\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: 'yellow'\r\n});\r\nvar image = Ti.UI.createImageView({\r\n\ttop: 150,\r\n\timage: imagePNG\r\n});\r\nwin.add(image);\r\nwin.open();\r\n{code}\r\n\r\n- 08-27 09:56:56.778: W/TiDrawableReference(3030): (pool-3-thread-2) [632,632] Could not open stream to get bitmap\r\n\r\nOther than parity, this can be just a TIDOC issue. But from javascript how does one refer to an image that's included as part of an android module?", "attachment": [], "flagged": false, "summary": "Android: Javascript can't get path of assets folder of module", "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": "Android 2.3 & 4.2\r\nTiSDK 3.1.2.GA", "closedSprints": [ { "id": 1058, "state": "closed", "name": "2018 Sprint 16 SDK", "startDate": "2018-07-29T22:26:06.486Z", "endDate": "2018-08-12T22:26:00.000Z", "completeDate": "2018-08-13T17:38:16.757Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "268945", "author": { "name": "jenglish", "key": "jenglish", "displayName": "Jeff English", "active": true, "timeZone": "America/Chicago" }, "body": "A couple of possible workarounds for now:\r\n\r\n**Module provides access to assets**\r\n\r\nProvide an API in the module to return the requested module resource. See the `loadImageFromModule` method provided in the moddevguide reference module found here: \r\nhttps://github.com/appcelerator/titanium_modules/blob/master/moddevguide/mobile/android/src/ti/moddevguide/ModdevguideModule.java \r\n\r\nand here: \r\n\r\nhttps://github.com/appcelerator/titanium_modules/blob/master/moddevguide/mobile/ios/Classes/TiModdevguideModule.m. \r\n\r\nThe application can call such a method whenever it needs to get the assets from the module. This option provides parity across platforms.\r\n\r\n**Module makes assets available as drawable assets**\r\n\r\n1. Place the module's assets in the 'platform/android/res/drawable' folder of the module project (you may have to create this folder). These assets will be packaged with the module when it is built.\r\n2. The application can reference these assets as `Ti.App.Android.R.drawable.`. For example, \"image: Ti.App.Android.R.drawable.flower\"\r\n\r\nThis option requires platform-specific logic in the application.", "updateAuthor": { "name": "jalter", "key": "jalter", "displayName": "Jon Alter", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-08-29T21:12:03.000+0000", "updated": "2013-08-29T21:20:06.000+0000" }, { "id": "268956", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "body": "When we build the app APK file, we merge the the module's assets folder into the apk's assets folder. With this, a quick workaround would be:\n1. Inside the module's assets folder, create Resources/ folder.\n2. Put image into assets/Resources/\n3. Then you can treat the path as if the image is actually in your app's Resources/ folder.\n\nFor instance, if my module name is emodule and I put image.png in emodule/assets/Resources/image.png, I would simply use the path 'image.png'.\n\nOne drawback of this method is name duplication (i.e: if I have two same name images, one in my module's assets/Resources, and one in my app's Resources folder, one would overwrite the other). To prevent this, you can simply create unique sub-directories inside your module's assets/Resources.", "updateAuthor": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-08-29T21:49:17.000+0000", "updated": "2013-08-29T21:49:17.000+0000" }, { "id": "268969", "author": { "name": "jenglish", "key": "jenglish", "displayName": "Jeff English", "active": true, "timeZone": "America/Chicago" }, "body": "The use of the assets/Resources folder does not currently work. TIMOB-4233 mentions this issue for iOS, but the same issue exists for Android. IIRC, the build scripts explicitly ignores the Resources folder, but I could be wrong there.\r\n\r\nCorrection: putting the assets in the 'assets/Resources' folder does work. The assets are bundled into the module's jar file, so you won't see them in the module's zip file. You can verify that the assets are bundled by running 'jar -xf ' and then looking in the 'assets/Resources' folder that is created. The module assets are then included in the application's apk", "updateAuthor": { "name": "jenglish", "key": "jenglish", "displayName": "Jeff English", "active": true, "timeZone": "America/Chicago" }, "created": "2013-08-29T22:39:09.000+0000", "updated": "2013-08-29T23:24:39.000+0000" }, { "id": "268971", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I tested the above workaround on Android and it worked for me. I can see the image in Resources/ folder inside the APK file. Though that workaround doesn't work with density images. In that case, you'd need to use the 'assets as drawables' workaround.", "updateAuthor": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-08-29T22:52:04.000+0000", "updated": "2013-08-29T22:52:04.000+0000" }, { "id": "268979", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "body": "'Assets as drawables' can work for them. Just they will need to deal with density-specific image logic. \n\nFurthermore, I tried using density specific folders but can't get it to work. They are definitely bundled with module.jar. But can't seem to find them in the APK. Is it possible at all?\n\ne.g. \n{code}\nwifissid//platform/android/res/drawable/drawable-hdpi\nwifissid//platform/android/res/drawable/drawable-hdpi/yes.png\nwifissid//platform/android/res/drawable/drawable-ldpi\nwifissid//platform/android/res/drawable/drawable-ldpi/yes.png\nwifissid//platform/android/res/drawable/drawable-mdpi\nwifissid//platform/android/res/drawable/drawable-mdpi/yes.png \n{code}", "updateAuthor": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2013-08-29T23:32:12.000+0000", "updated": "2013-08-29T23:32:12.000+0000" }, { "id": "278842", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "After discussing with [~jenglish] and [~ayeung], I am going to be fixing this by adding support for two new directories within modules: \"app\" and \"resources\". The current behavior with how the \"assets\" directory will be preserved.\n\nCurrently the \"assets\" folder copies to the following folder:\n\nAndroid: build/android/res/assets\niOS: build/iphone/build/Debug-iphoneos/testapp.app/modules/com.mymodule\n\nTo normalize how assets are copied, files in the \"app\" and \"resources\" directories will be copied as such:\n\n\"app\" directory will be copied to:\nAndroid: build/android/res/assets\niOS: build/iphone/build/Debug-iphoneos/testapp.app\n\n\"resources\" directory will be copied to:\nAndroid: build/android/res/assets/Resources/modules/com.mymodule\niOS: build/iphone/build/Debug-iphoneos/testapp.app/modules/com.mymodule", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2013-11-09T02:18:16.000+0000", "updated": "2013-11-09T02:18:16.000+0000" }, { "id": "347260", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Proposed solution for parity:-\r\n\r\nPerhaps a simple solution for parity to work when using: '/modules/com.mod-id.org/images/image.png' in Android is internally in the Android code, when it sees it is referring to the modules directory, it will map that to '/images/image.png'. Basically stripping the '/modules/com.mod-id.org/'.\r\n\r\nWould this be an acceptable solution for this?\r\n", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-03-25T08:29:06.000+0000", "updated": "2015-03-25T23:07:32.000+0000" }, { "id": "347387", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~jalter] [~penrique] Any thoughts on this?", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-03-26T02:03:17.000+0000", "updated": "2015-03-26T02:03:17.000+0000" }, { "id": "347436", "author": { "name": "jalter", "key": "jalter", "displayName": "Jon Alter", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~msamah] - Could I get another example? The solution is not totally clear to me.", "updateAuthor": { "name": "jalter", "key": "jalter", "displayName": "Jon Alter", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-03-26T15:17:21.000+0000", "updated": "2015-03-26T15:17:21.000+0000" }, { "id": "369413", "author": { "name": "chmiiller", "key": "chmiiller", "displayName": "Carlos Henrique Zinato", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Guys, I've tried a lot of paths and I'm still not able to \"embed\" an image with my Android module =/\r\nFor iOS \"modules/com.mymodule/image.png\" works fine!", "updateAuthor": { "name": "chmiiller", "key": "chmiiller", "displayName": "Carlos Henrique Zinato", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-11-09T16:05:21.000+0000", "updated": "2015-11-09T16:05:21.000+0000" }, { "id": "369418", "author": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~chmiiller] Did you try one of the workarounds earlier in the ticket?", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-11-09T16:38:17.000+0000", "updated": "2015-11-09T16:38:17.000+0000" }, { "id": "369419", "author": { "name": "chmiiller", "key": "chmiiller", "displayName": "Carlos Henrique Zinato", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Ok guys, I was kind of lost in the comments but figured out how to do it.\r\nYou need to create a Resources folder inside \"assets\" like Hieu Pham said.\r\nSo, you want to call \"logo.png\":\r\n\r\n1. Create \"Resources\" folder inside the \"assets\" folder.\r\n2. Use your image name as path:\r\n Ti.UI.createImageView({\r\n image:'logo.png' \r\n });\r\n3. Done!\r\n\r\nThank you all!", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-11-09T16:48:24.000+0000", "updated": "2015-11-09T16:52:33.000+0000" }, { "id": "369423", "author": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~chmiiller] That's great!", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-11-09T16:57:47.000+0000", "updated": "2015-11-09T16:57:47.000+0000" }, { "id": "439743", "author": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing old \"Won't fix\" tickets. If you disagree, please reopen.", "updateAuthor": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-08-02T22:20:06.000+0000", "updated": "2018-08-02T22:20:06.000+0000" } ], "maxResults": 35, "total": 35, "startAt": 0 } } }