{ "id": "174211", "key": "TIMOB-27437", "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": [], "resolution": null, "resolutiondate": null, "created": "2019-10-02T18:57:52.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "android", "annotations", "java" ], "versions": [], "issuelinks": [ { "id": "57863", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "174261", "key": "TIMOB-27473", "fields": { "summary": "Android: Replace clang Java formatter with gradle \"checkstyle\" tool", "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": "Low", "id": "4" }, "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false } } } } ], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2021-02-22T19:06:11.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "*Summary:*\r\nGoogle supports Java annotation {{@RequiresApi(number)}} which can be applied to classes, methods, member variables, etc. This can be used to trigger linting errors/warnings if an API was accessed on an API Level older than what was set in the annotation.\r\nhttps://developer.android.com/reference/android/support/annotation/RequiresApi\r\n\r\nWe should leverage this feature throughout our core Titanium code to help minimize mistakes and ensure we're checking the currently running API Level before making high API Level call. This will help avoid crashes when on older Android OS versions.\r\n\r\n*Example:*\r\nThe below screenshot shows this in action. A {{@RequiresApi(20)}} annotation is applied to method {{onApplyWindowInsets()}}. In the method below, we call the {{onApplyWindowInsets()}} method twice. One call is unguarded and the other call is within an if-check block which checks if we're running in API Level 20 or higher. The linting tool correctly shows a red underline for the unguarded method call. This is what we want.\r\n !RequireApiLinting.png|thumbnail! \r\n\r\n*Notes:*\r\nWe should do this after switching our build system to gradle. This is because the gradle linting tool performs the API Level checks.", "attachment": [ { "id": "67005", "filename": "RequireApiLinting.png", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-10-02T18:39:09.000+0000", "size": 438741, "mimeType": "image/png" } ], "flagged": false, "summary": "Android: Add @RequiresApi() annotations to core java code", "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": [], "maxResults": 0, "total": 0, "startAt": 0 } } }