[TIMOB-16910] Android: ActionBar.setNavigationMode(STANDARD) hides window content on API 10 devices
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2014-11-10T23:43:09.000+0000 |
Affected Version/s | Release 3.2.2 |
Fix Version/s | n/a |
Components | Android |
Labels | actionbar, android |
Reporter | Mark Mokryn |
Assignee | Ingo Muschenetz |
Created | 2014-04-27T19:57:13.000+0000 |
Updated | 2017-03-21T18:18:28.000+0000 |
Description
The following code works as expected on ICS+ devices, but destroys window content on Gingerbread.
index.js:
$.index.addEventListener('open', function() {
var actionBar = $.index.activity.actionBar;
setTimeout(function() {
actionBar.setNavigationMode(Ti.Android.NAVIGATION_MODE_STANDARD);
}, 5000);
});
$.index.open();
index.xml:
<Alloy>
<TabGroup>
<Tab title="Tab 1" icon="KS_nav_ui.png">
<Window id="win1" title="Tab 1">
<Label>I am Window 1</Label>
</Window>
</Tab>
<Tab title="Tab 2" icon="KS_nav_views.png">
<Window title="Tab 2">
<Label>I am Window 2</Label>
</Window>
</Tab>
</TabGroup>
</Alloy>
Found the problem! In TiUIActionBarTabGroup.java, onTabUnselected gets called by the Android system when ActionBar.setNavigationMore(NAVIGATION_MODE_STANDARD) is called. This function calls FragmentTransaction.hide() on the tab's fragment. This apparently has no effect on ICS+, but on Gingerbread (where the support library goes into effect, since Fragments are API 11+), FragmentTransaction.hide indeed hides the view - thus the tab content is hidden when the navigation mode is changed. Proposed solution: ActionBar.setNavigationMode(NAVIGATION_MODE_STANDARD) cannot be used alone in order to hide the tabs on Android. We need to expose a new property on the TabGroup, e.g. tabsEnabled which can be used to toggle the tabs (i.e. the setter will toggle the navigation mode). Then onTabUnselected will call FragmentTransaction.hide only if tabsEnabled == true. I will submit a PR for this soon.
Great. Let us know when you have the PR ready and we would look at it at a priority.
The swipe tabs PR https://github.com/appcelerator/titanium_mobile/pull/5651 takes care of this too, so close this if that one is accepted.
Moving this ticket and associated PR to engineering for further evaluation.
Again - this ticket is fixed by my scrollable tabs PR, please don't do any engineering work on this issue.
3.4.0 is moved forward, and 3.5.0 is taking its place in the calendar.
If you accept the PR for TIMOB-13392 for 3.4.0, as currently scheduled, then this one is already fixed by that PR.
[~ingo] this will be taken care of by merging this https://github.com/appcelerator/titanium_mobile/pull/6008 - already reviewed by [~hpham] and [~pwang]
You should just close this ticket since ActionBar.setNavigationMode is deprecated in API 21, and once we fully move over to that AppCompat lib (and require targetSdkVersion=21+) this API should no longer be exposed.
Resolving as won't fix since this method is now deprecated on the new ActionBar version.
Closing ticket as the issue will not fix.