Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16910] Android: ActionBar.setNavigationMode(STANDARD) hides window content on API 10 devices

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionWon't Fix
Resolution Date2014-11-10T23:43:09.000+0000
Affected Version/sRelease 3.2.2
Fix Version/sn/a
ComponentsAndroid
Labelsactionbar, android
ReporterMark Mokryn
AssigneeIngo Muschenetz
Created2014-04-27T19:57:13.000+0000
Updated2017-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>

Comments

  1. Mark Mokryn 2014-04-28

    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.
  2. Ritu Agrawal 2014-04-30

    Great. Let us know when you have the PR ready and we would look at it at a priority.
  3. Mark Mokryn 2014-04-30

    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.
  4. Ritu Agrawal 2014-05-04

    Moving this ticket and associated PR to engineering for further evaluation.
  5. Mark Mokryn 2014-06-03

    Again - this ticket is fixed by my scrollable tabs PR, please don't do any engineering work on this issue.
  6. Ingo Muschenetz 2014-08-14

    3.4.0 is moved forward, and 3.5.0 is taking its place in the calendar.
  7. Mark Mokryn 2014-08-14

    If you accept the PR for TIMOB-13392 for 3.4.0, as currently scheduled, then this one is already fixed by that PR.
  8. Mark Mokryn 2014-10-28

    [~ingo] this will be taken care of by merging this https://github.com/appcelerator/titanium_mobile/pull/6008 - already reviewed by [~hpham] and [~pwang]
  9. Mark Mokryn 2014-11-10

    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.
  10. Ingo Muschenetz 2014-11-10

    Resolving as won't fix since this method is now deprecated on the new ActionBar version.
  11. Lee Morris 2017-03-21

    Closing ticket as the issue will not fix.

JSON Source