{ "id": "176313", "key": "TIMOB-28559", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "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": "21249", "name": "Release 10.2.0", "archived": false, "released": false } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2021-10-19T22:04:12.000+0000", "created": "2021-10-15T23:49:20.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "android", "button", "drawable", "image", "resource" ], "versions": [], "issuelinks": [], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2021-10-19T22:04:42.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": "*Summary:*\r\nThe {{Ti.UI.Button}} \"image\" property currently only supports {{String}} paths and {{Ti.Blob}} objects. On Android, we should add support for native resource IDs to load drawables, such as vector drawables. These are more commonly used and Android Studio has a wizard dialog to easy generate standard material icons that most apps use.\r\n\r\n*To-Do:*\r\nModify \"image\" property to also support {{Number}} type to be a resource ID from {{Ti.App.Android.R.drawable.*}}. We should change our Java drawable loading code to call the static {{TiDrawableReference.fromObject()}} instead, which already supports {{Number}} type as well as {{File}} type.\r\nhttps://github.com/appcelerator/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIButton.java#L145-L150\r\nhttps://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/view/TiDrawableReference.java#L303-L326\r\n\r\n*Example:*\r\n{code:javascript}\r\nconst window = Ti.UI.createWindow();\r\nconst imageButton = Ti.UI.createButton({\r\n\ttitle: \"Delete\",\r\n\timage: Ti.App.Android.R.drawable.titanium_icon_delete,\r\n});\r\nimageButton.addEventListener(\"click\", () => {\r\n\talert(\"Button clicked on.\");\r\n});\r\nwindow.add(imageButton);\r\nwindow.open();\r\n{code}\r\n\r\n !Button-Light.png|thumbnail! !Button-Dark.png|thumbnail! \r\n", "attachment": [ { "id": "68006", "filename": "Button-Dark.png", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2021-10-15T23:56:37.000+0000", "size": 405087, "mimeType": "image/png" }, { "id": "68005", "filename": "Button-Light.png", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2021-10-15T23:56:37.000+0000", "size": 402953, "mimeType": "image/png" } ], "flagged": false, "summary": "Android: Modify Ti.UI.Button \"image\" to support \"R.drawable\" IDs", "creator": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "459106", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR (master): https://github.com/appcelerator/titanium_mobile/pull/13125", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2021-10-16T01:40:50.000+0000", "updated": "2021-10-16T01:40:50.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }