Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIMOB-13392: Android scrollable tabs #5651

Merged
merged 4 commits into from Aug 30, 2014
Merged

Conversation

mokesmokes
Copy link
Contributor

Android tab group can now by default be navigated by swipes (e.g. see Play Store app). The functionality can be toggled with the new TabGroup.swipeable property. In addition, tab navigation can be disabled (or re-enabled) by calling disableTabNavigation(boolean). Plus added tab selected and unselected events (currently these events exist in Android only. In iOS the tab focus/blur events do the same - I suggest they be renamed to selected/unselected). Note that all additional events are fired exactly as before.

@mokesmokes
Copy link
Contributor Author

See test app in JIRA: https://jira.appcelerator.org/browse/TIMOB-13392

@mokesmokes
Copy link
Contributor Author

Note this PR will break https://jira.appcelerator.org/browse/TIMOB-13864 since we lose the capability to setId on the tab fragment when using a ViewPager as the fragment container. But we have no choice - we want swipe tabs! :) ...... In any case, the fix should be rather simple: The FragmentPagerAdapter in the implementation can return a unique ID per fragment which can be stored somewhere and checked, similar to the current solution of 13864. This however is not part of this PR.

@mokesmokes mokesmokes changed the title TIMOB-13392: Android swipe tabs TIMOB-13392: Android scrollable tabs May 5, 2014
@mokesmokes
Copy link
Contributor Author

Changed PR name to "scrollable tabs" to indicate this functionality exists. You can scroll tabs offscreen if you have many tabs and/or long tab titles :)

@@ -247,6 +241,14 @@ void close(boolean activityIsFinishing) {

void onSelectionChanged(boolean selected)
{
if (!selected) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Åny reason why you move this from onFocusChanged to onSelectionChanged?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, there's a good reason: as it turns out, in Android the Tab focus/blur events fire in many cases, not just when the tab is selected and unselected. For example - when the screen is locked/unlocked blur/focus will be fired (this is unlike iOS, BTW). So for clarity and also backwards compatibility, I did not touch the focus/blur stuff at all, but I did move relevant selection/unselection logic into the relevant events.
That's also why I added the selected/unselected tab events for Android. Again, the focus/blur events work exactly as before, so anything relying on them is not broken.

@hieupham007
Copy link
Contributor

I did functional on KitchenSink. Fantastic work, everything seems to work! My only concern is that this is a breaking change that will probably affect all modules extending the current framework of tabgroup.
Like you said, this will also break https://jira.appcelerator.org/browse/TIMOB-13864 and will have an impact on this PR as well #5836

@mokesmokes
Copy link
Contributor Author

@hieupham007 I don't see what else it can break besides those two issues. I suggest you merge this, and then we tackle these two specific issues ASAP. Makes no sense to fix #5836 before this merge, and it's also possible that this issue will affect the map module issue in any case (both deal with fragment handling).

BTW - there is a flag to disable the swiping, so old behavior can be maintained by just setting this flag.

@mokesmokes
Copy link
Contributor Author

In any case I see you wrote #5836 (comment) that it's not fixed.

private boolean tabsDisabled = false;
private Fragment savedFragment = null;
private boolean savedSwipeable;
public boolean swipeable = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use a getter and setter to get access to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pingwang2011 this is internal to the implementation and not accessed from Javascript. In TabGroupProxy.java it is indeed a getter/setter - here it is of no consequence in my opinion.

@mokesmokes
Copy link
Contributor Author

TIMOB-17016 is now fixed for swipe tabs, fixed the regression for a map inside a tab, and fixed up remoteTab. The merge conflict is due to #5836 , the fix for TIMOB-17016 for the non-swipe tabs, the merge should just be to accept my version of the files and that's it.

@mokesmokes
Copy link
Contributor Author

@pingwang2011 @hieupham007 I made the change to propertyAccessors as requested, please let me know if any more issues, and let's close this one. Thanks!

@hieupham007
Copy link
Contributor

Merging. Thank you so much for this!

hieupham007 added a commit that referenced this pull request Aug 30, 2014
TIMOB-13392: Android scrollable tabs
@hieupham007 hieupham007 merged commit 7bec8e1 into tidev:master Aug 30, 2014
@mokesmokes mokesmokes mentioned this pull request Sep 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants