{ "id": "171872", "key": "TIMOB-26176", "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": "2018-07-02T20:59:00.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "alert", "android", "blur", "dialog", "focus", "parity", "window" ], "versions": [], "issuelinks": [ { "id": "58078", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "174617", "key": "TIMOB-27711", "fields": { "summary": "TiAPI: Add state querying methods to UI components", "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": "7", "description": "gh.issue.story.desc", "name": "Story", "subtask": false } } } } ], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2020-01-14T21:53:26.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\nWhen opening and closing a dialog, the parent window should fire a \"blur\" and \"focus\" event respectively. This is to match iOS' behavior.\r\n\r\n*Steps to reproduce:*\r\n# Build and run the below code on Android.\r\n# Tap on the \"Show Alert\" button.\r\n# View the Android log. Notice that a \"blur\" event was not received.\r\n# Close the alert dialog.\r\n# View the Android log. Notice that a \"focus\" event was not received.\r\n\r\n{code:javascript}\r\nvar window = Ti.UI.createWindow({\r\n\tlayout: \"vertical\",\r\n\tfullscreen: true,\r\n});\r\nvar alertButton = Ti.UI.createButton({\r\n\ttitle: \"Show Alert\",\r\n\ttop: \"20%\",\r\n});\r\nalertButton.addEventListener(\"click\", function(e) {\r\n\t// An alert dialog does not trigger window focus/blur events.\r\n\talert(\"Alert!\");\r\n});\r\nwindow.add(alertButton);\r\nvar windowButton = Ti.UI.createButton({\r\n\ttitle: \"Show Child Window\",\r\n\ttop: \"20%\",\r\n});\r\nwindowButton.addEventListener(\"click\", function(e) {\r\n\t// Displaying a child window does trigger parent window's focus/blur events.\r\n\tvar childWindow = Ti.UI.createWindow({ backgroundColor: \"orange\" });\r\n\tvar closeButton = Ti.UI.createButton({ title: \"Close Me\" });\r\n\tcloseButton.addEventListener(\"click\", function(e) {\r\n\t\tchildWindow.close();\r\n\t});\r\n\tchildWindow.add(closeButton);\r\n\tchildWindow.open();\r\n});\r\nwindow.add(windowButton);\r\nwindow.addEventListener(\"focus\", function(e) {\r\n\tTi.API.info(\"@@@ Window 'focus' event received.\");\r\n});\r\nwindow.addEventListener(\"blur\", function(e) {\r\n\tTi.API.info(\"@@@ Window 'blur' event received.\");\r\n});\r\nwindow.open();\r\n{code}\r\n\r\n*Expected Result:*\r\nOpening a dialog should fire the window's \"blur\" event.\r\nClose a dialog should fire the window's \"focus\" event.\r\n\r\n*Notes:*\r\nThe window's focus/blur events are correctly fired when displaying a child window or when doing a suspend/resume. This is only an issue with displaying dialogs within a window.\r\n\r\n*Recommended Solution:*\r\nOverride the Java {{Activity.onWindowFocusChanged()}} method. This method will be invoked when opening/closing dialogs and child activities.\r\nhttps://developer.android.com/reference/android/app/Activity.html#onWindowFocusChanged(boolean)\r\n\r\nWe'll need to re-evaluate the focus/blur handling via our {{TiBaseActivity}} class' {{onResume()}} and {{onPause()}} methods since the {{onWindowFocusChanged()}} method provides what we need. The current handling is used to handle focus/blur for TabGroup tabs.", "attachment": [], "flagged": false, "summary": "Android: Opening/Closing a dialog should fire a window's blur/focus events (parity)", "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 } } }