{ "id": "150070", "key": "TIMOB-19377", "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": "16925", "description": "WatchKit Support--all going into 5.0 now", "name": "Release 5.0.0", "archived": true, "released": true, "releaseDate": "2015-09-16" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2015-08-31T02:06:38.000+0000", "created": "2015-07-31T19:21:37.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [], "versions": [], "issuelinks": [ { "id": "48831", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "150831", "key": "TIMOB-19435", "fields": { "summary": "Android: Change Preference Activity to Preference Fragment", "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": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false } } } } ], "assignee": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "updated": "2015-09-03T18:22:55.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": "Upgraded my app to SDK 4.0.0+. I noticed that the preferences activity no longer has the action bar (title bar). In previous version it does.\r\n\r\nCreate a default Alloy project with the following:\r\n\r\nindex.xml\r\n{code}\r\n\r\n\t\r\n\r\n{code}\r\n\r\nindex.js\r\n{code}\r\n$.index.open();\r\nTi.UI.Android.openPreferences();\r\n{code}\r\n\r\npreferences.xml\r\n{code}\r\n\r\n\r\n \r\n \r\n\r\n{code}", "attachment": [], "flagged": false, "summary": "Android Lollipop - Preferences Activity no longer has action bar", "creator": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "SDK 4.1.0/Android 5.0", "closedSprints": [ { "id": 464, "state": "closed", "name": "2015 Sprint 17 SDK", "startDate": "2015-08-15T00:30:59.243Z", "endDate": "2015-08-29T00:30:00.000Z", "completeDate": "2015-08-31T08:10:47.969Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "360315", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "For those who want to test this with classic app.js:-\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow({backgroundColor: 'white'});\r\nvar button = Ti.UI.createButton({\r\n title: 'Click to Open Preferences'\r\n});\r\nbutton.addEventListener('click', function() {\r\n Ti.UI.Android.openPreferences();\r\n});\r\nwin.add(button);\r\nwin.open();\r\n{code}", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-08-19T08:09:28.000+0000", "updated": "2015-08-19T08:09:28.000+0000" }, { "id": "360329", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "PR: https://github.com/appcelerator/titanium_mobile/pull/7045\r\n\r\nRun test steps with code above and an XML file as mention in original comment.\r\n\r\nPlease run tests on both Android Lollipop and a version below Android Lollipop.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-08-19T09:04:50.000+0000", "updated": "2015-08-19T09:04:50.000+0000" }, { "id": "360437", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Workaround if you want to implement this now:\r\nIf you need to use it now, take a look at http://docs.appcelerator.com/platform/latest/#!/guide/Android_Themes-section-34636181_AndroidThemes-OverrideanActivityTheme\r\n\r\nAll you need to do is implement a theme for TiPreferencesActivity class. One for a \"values\" and another for \"values-v21\". Take a look at the PR https://github.com/appcelerator/titanium_mobile/pull/7045/files if you want to implement it this way.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-08-20T02:05:29.000+0000", "updated": "2015-08-20T02:05:29.000+0000" }, { "id": "360574", "author": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I already assign it a theme with action bar, but the issue persists on Lollipop.\r\n\r\n{code}\r\n\r\n{code}", "updateAuthor": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-08-20T22:54:22.000+0000", "updated": "2015-08-20T22:54:44.000+0000" }, { "id": "360586", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~shawnlan] You would need 2 Themes. Theme.AppCompat for anything less than Lollipop and Theme.Material for Lollipop and above.\r\n\r\nTheme.AppCompat does not provide an action bar on Lollipop. Theme.Material does.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-08-20T23:21:44.000+0000", "updated": "2015-08-20T23:21:44.000+0000" }, { "id": "360595", "author": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Theme.AppCompat does provide action bar. Please take a look at Android's doc and [here|https://docs.appcelerator.com/platform/latest/#!/guide/Android_Themes-section-34636181_AndroidThemes-MaterialTheme]\r\n\r\nAll my activities use Theme.AppCompat. They all show an action bar, except the preferences activity. Test it yourself.", "updateAuthor": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-08-20T23:42:29.000+0000", "updated": "2015-08-20T23:42:29.000+0000" }, { "id": "360616", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~shawnlan], you are almost there. Here's what you need to do exactly:-\r\n\r\nWe are going to use a new theme for the activity. The theme will be different based on what version of android we are using. In the tiapp.xml write this:-\r\n{code}\r\n \r\n \r\n \r\n \t\t\r\n\t \r\n \r\n \r\n{code}\r\n\r\nThen, we need to create a folder in these path, `/platform/android/res/values` and `/platform/android/res/values-v21`\r\n\r\nIn `/platform/android/res/values-v21`, put this file: https://github.com/ashcoding/titanium_mobile/blob/TIMOB-19377/android/modules/ui/res/values-v21/styles.xml\r\n\r\nIn '/platform/android/res/values', put this file: https://github.com/ashcoding/titanium_mobile/blob/TIMOB-19377/android/modules/ui/res/values/styles.xml\r\n\r\nI also made a repo here: https://github.com/ashcoding/TIMOB-19377_Example that you can take a look.\r\n\r\nOn the logic behind this:-\r\nAppcompat only adds an action bar to activities that derive from ActionBarActivity. PreferenceActivity does not subclass ActionBarActivity. \r\n\r\nThis should work. :)", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-08-21T02:44:22.000+0000", "updated": "2015-08-21T02:46:45.000+0000" }, { "id": "360713", "author": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Your workaround only works in Lollipop. On Android 4 and below it is still not showing action bar.\r\n\r\nMaybe you need to switch to preferencefragment?", "updateAuthor": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-08-21T18:58:00.000+0000", "updated": "2015-08-21T18:58:00.000+0000" }, { "id": "360832", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~shawnlan] That might be a good idea to switch to a preferencefragment.\r\n\r\nAnyway, there was a missing style for v14. https://github.com/ashcoding/TIMOB-19377_Example/tree/master/platform/android/res/values-v14 \r\nI have updated the code. It should now have the actionbar for below lollipop. Feel free to style it more. :)\r\n\r\nLet me know if it solves this for you for now.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-08-24T02:13:58.000+0000", "updated": "2015-08-24T02:13:58.000+0000" }, { "id": "360969", "author": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Yes it works for now, but since my app use AppCompat everywhere else, the preference activity with Theme.Holo does look different. Still prefer this to be fixed so that I can use just AppCompat, not only for look consistency but also that I don't need to have these extra style. Thanks.", "updateAuthor": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-08-24T18:31:50.000+0000", "updated": "2015-08-24T18:31:50.000+0000" }, { "id": "361022", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~shawnlan] You could actually customise the theme to make it look like how you want it. And that includes making it look similar to how AppCompat does it.\r\nHere's how, https://developer.android.com/training/basics/actionbar/styling.html\r\n\r\nFor reference, I updated the v14 style folder, https://github.com/ashcoding/TIMOB-19377_Example/blob/master/platform/android/res/values-v14/styles.xml \r\n\r\nHope this helps.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-08-25T03:34:56.000+0000", "updated": "2015-08-25T03:34:56.000+0000" }, { "id": "361023", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "PR for fix: https://github.com/appcelerator/titanium_mobile/pull/7045", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-08-25T03:49:38.000+0000", "updated": "2015-08-25T03:49:38.000+0000" }, { "id": "361128", "author": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "body": "1. The window just looks similar to, but not exactly the same as how AppCompat does it.\r\n\r\n2. The child elements (checkboxes, on/off buttons, etc.) still look inconsistent.\r\n\r\nIt's too much work to style everything and make them look like AppCompat. Your solution can be a temporary workaround, but shouldn't be a permanent fix.\r\n\r\nThanks.", "updateAuthor": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-08-25T17:02:27.000+0000", "updated": "2015-08-25T17:02:27.000+0000" }, { "id": "361181", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~shawnlan] Understand what you mean. Got it. ", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-08-26T01:55:47.000+0000", "updated": "2015-08-26T01:55:47.000+0000" }, { "id": "361684", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-08-31T02:05:56.000+0000", "updated": "2015-08-31T02:06:16.000+0000" }, { "id": "362189", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-09-03T18:22:40.000+0000", "updated": "2015-09-03T18:22:40.000+0000" } ], "maxResults": 20, "total": 20, "startAt": 0 } } }