[ALOY-994] Add <ActionBar> tag to set activity.actionBar properties
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-11-26T02:21:26.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Alloy 1.5.0 |
Components | XML |
Labels | qe-manualtest |
Reporter | Tim Poulsen |
Assignee | Tim Poulsen |
Created | 2014-04-25T17:22:16.000+0000 |
Updated | 2014-11-26T02:21:26.000+0000 |
Description
Implement a parser for an tag to provide functionality like that implemented in ALOY-784. Don't remove features enabled by ALOY-784. Will also require a docs update and a sample app.
Possible implementation:
and
<Alloy>
<Window>
<ActionBar id="actionbar" title="My App Title" subtitle="App subtitle" .../>
</Window>
</Alloy>
* - This tag would be valid as a child of Window or TabGroup and should throw a compiler error if placed elsewhere.
* - It would be an empty tag with no valid children (actionBar properties would be set via tag attributes).
* - If both
Should also support new properties added in TIMOB-16212
Possible implementation options:
ActionBar and Menu as separate tags
Order shouldn't matter. Both tags are children of Window. *Pros:* - clear that these are separate controls (which they are at SDK level) - thus clear that you can use one or the other or both - simplest to implement within Alloy and easy to document - likewise relatively simple for developers to implement in their apps *Cons:* - Seems like extra code - Visually, the menu is part of the ActionBar, thus is probably conceptually related for many developersActionBar properties become properties of the Window, but Menu is a separate tag
*Pros:* - Titles and such are properties of Window on iOS, so putting them as properties for Android makes sense - Clear that the menu is a separately-added component *Cons:* - To later change these properties, you need a handle to the Activity. We'll need to define a way for developers to hook into this activity in their controllers -- perhaps $.index.activity would be logical? - Adds platform-specific properties to a cross-platform tag, which could cause developer confusion - This would be a bit more difficult to document given that our docs are organized by API and we're adding properties at the Alloy level that aren't there at the SDK level - Need to account for cases when ti.android.useLegacyWindow is set to true in the tiapp.xml (until the option for lightweight windows is fully removed). Adds an SDK version dependency.Menu as child of ActionBar
*Pros:* - Probably conceptually clear to developers given that visually, the menu is part of the ActionBar *Cons:* - Again, we'd need to expose a hook to the activity and menu in the controller so the developer can reset menu items (when a TabGroup is involved and the developer needs different menus on different tabs). - Maintains the current platform differences for Window titles (e.g. on iOS, title is a property of the Window) - Would we maintain theSeems to me that option #1 would be best, if only because it would give us the ability to add #3 in the future and maintain backwards compatiblity. I don't like #2. Adding APIs to comopnents should be an absolute last resort.
Def. no on #2. #1 and #3 both make sense to me. I'm assuming you'll generate the onCreate when the activity open event fires and all that...what happens when I want to put stuff in the activity onCreate and such in addition to what you'll auto put in there for me?
Another possibility, taking future features into account:
Activity tag with Menu and BottomBar as children
Hell no to #2 Liking #1 Would tolerate #3 but will bitz about it to you everyday.
(y) #1
PR https://github.com/appcelerator/alloy/pull/470 Test app: https://github.com/skypanther/alloy/blob/ALOY-994/test/apps/testing/ALOY-994 Functional test: run the associated sample app in the Android emulator, Genymotion, or on a device. The app should feature a customized ActionBar with title and subtitle, background image, and icon. Open the menu, choose 'option 2' to open the child window. It also has a customized actionBar. Tap the home icon to close the child window. [~fmiao] would you please test before I merge?
Tested on Nexus 4 with provided test app, it works fine! (y)
PR merged
Verified working as expected on Nexus Galaxy 4.3 and Sony Xperia 2.3.4 - Genymotion 2.3.7 and 4.3. TiSDK 3.4.0.v20140808101714 Appcelerator Studio 3.3.1.201408080925 Alloy 1.5.0-dev Note: With the sample code provided, MenuItems are not visible on Android 2.3.X devices. On 2.3.X devices, MenuItem has to be set in this way:
This is also valid for Classic Titanium projects when using Menu in the ActionBar.
Two pull requests: https://github.com/appcelerator/alloy/pull/513 against the 1_5_X branch https://github.com/appcelerator/alloy/pull/512 against master Both implement the same fix. Functional test 1. Run the included ALOY\-994b test app for Android. This app contains a tab group with a customized actionbar and menu. One of the menu options opens a child window, which also has a customized actionbar. The app should run without errors. 2. Run the ALOY\-994 test app, which sets a customized actionbar with just a window (no tab group)
**APPROVED**
PR merged
Description regarding how to access to the activity property should be changed. This bullet
Verified working as expected with the provided samples. TiSDK 3.5.0.v20141124092514 CLI 3.4.1-GA Alloy 1.5.1-GA Appceleator Studio 3.4.1.201410281743 Android Nexus 5 (Android 5)