[ALOY-1688] Android: ActionBar Subtitle not working when using both Alloy & NavigationWindow
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Not Our Bug |
Resolution Date | 2019-06-19T12:14:09.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | n/a |
Reporter | Adam Armstrong |
Assignee | Ewan Harris |
Created | 2019-04-09T13:12:34.000+0000 |
Updated | 2019-06-19T12:14:09.000+0000 |
Description
Using these conditions:
* SDK 8.0.0.GA
* Alloy
* NavigationWindow (cross-platform newly implemented in SDK 8.x)
* Android
* ActionBar
* Subtitle (of ActionBar)
With all of those set, when I try to set the subtitle I get the following error:
{color:red}[WARN] ActionBarProxy: (main) [201,14240] ActionBar is not enabled
{color}
and no subtitle is set.
* It doesnt matter whether I try to set the subtitle in the .tss file or whether I set in the onOpen Method. In either case setting the subtitle fails with the above error.
* Joshua Quick said "subtitle" works for him if he uses Classic Ti (not Alloy).
* If I simply, only, remove the parent NavigationWindow, then the "subtitle" works for me in Alloy.
*+From index.js, I open my Alloy Window with this code:+*
from my .xml then everything works fine.
var settingsView = Alloy.createController('settings').getView();
settingsView.open();
And here is my Alloy code for my settings view:
*+settings.xml+*
<Alloy>
<NavigationWindow>
<Window id="settings" title="Settings" onOpen="onWindowOpen">
<ActionBar displayHomeAsUp="true" onHomeIconItemSelected="closeWindow" platform="android" />
<View width="Ti.UI.FILL" height="Ti.UI.FILL" layout="vertical">
<Label text="Settings Here" />
</View>
</Window>
</NavigationWindow>
</Alloy>
*+settings.js+*
function onWindowOpen(){
var actionBar = $.settings.activity.actionBar;
actionBar.subtitle = "Subtitle Here";
}
And I even thought it might be an issue with trying to update in the onOpen method so I removed the section in my settings.js and moved the subtitle piece to my settings.tss file like this
"ActionBar": {
subtitle: "subtitle text here"
}
and I still got the same error.
And then, again, to reiterate....if I simply remove
This might be an Alloy issue. After doing a build, we need to double check the JS code that Alloy generates under the project's "Resources" directory to see what's going wrong. Because the below works fine in a Classic app. So, we know it's possible to set the ActionBar's subtitle when launched via NavigationWindow.
Thanks for reporting the issue [~amwinsauto].
Its been well over a month with no update....has anyone @ AppC at least been able to identify where/what this issue is?
Hey [~amwinsauto], Looking at the compiled sourcecode, this looks to be because as there's no id set on the NavigationWindow alloy gives it a default id, which is the filename
settings
. Which classes with your Window id. So then when the onWindowOpen function is called$.settings
references the NavigationWindow and not the Window instance. You can fix this by either changing the id for the Windows, or creating a throwaway id for the NavigationWindow. Based off the compile code and my observations locally, when alloy is processing the view there _should_ be a warning in the log output\[WARN\] <Window> at line 3 is using this view's default ID "settings". Only a top-level element in a view should use the default ID
, which is super easy to miss[~amwinsauto], I'm just following-up on this since the ticket is still open. Based on [~eharris]'s findings, the issue is that there is variable name collision. Alloy automatically creates a variable based on the XML file you have. In this case, a "settings" variable for your "settings.xml" file which references
<NavigationWindow/>
. This variable name is colliding with your<Window/>
variable "settings". The solution is to change your<Window/>
"id" to a different name, such as "settingsWindow", and fetch the activity from that variable. This will solve the issue. Sorry about the delay. I hope this helps.Closing as not our bug