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

fix(android): Fixes TabLayout gravity when changing orientation #10687

Merged
merged 6 commits into from Mar 25, 2019

Conversation

ypbnv
Copy link
Contributor

@ypbnv ypbnv commented Feb 8, 2019

JIRA: https://jira.appcelerator.org/browse/TIMOB-26698

Description:
Takes care of switching a TabLayout's TabGravity depending on current orientation. Due to Titanium not recreating activities on orientation changes the style defined for the TabLayout in Design support library will not be applied, because the TabLayout won't be redrawn. This PR makes the change on configurationChanged event and effectively changes the component according to the new style. The change from the default style is actually only the tabGravity property.

Edit: No unit test for this one - it is a visual change.

Test case:
There is a good code sample in the JIRA ticket.

Takes care of switching a TabLayout's TabGravity depending on current orientation.
@ypbnv ypbnv added this to the 8.0.1 milestone Feb 8, 2019
@ypbnv ypbnv modified the milestones: 8.0.1, 8.1.0 Feb 8, 2019
@build build requested a review from a team February 8, 2019 14:12
@build
Copy link
Contributor

build commented Feb 8, 2019

Messages
📖

💾 Here's the generated SDK zipfile.

📖

✅ All tests are passing
Nice one! All 3633 tests are passing.

Generated by 🚫 dangerJS against 5b964d0

} else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
mTabLayout.setTabGravity(TabLayout.GRAVITY_CENTER);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit-pick. You can get rid of the mTabLayout. part since you're overriding the TabLayout class' onConfigurationChanged() method. The rest is fine. Nice and simple solution. 👍

Copy link
Contributor

@jquick-axway jquick-axway left a comment

Choose a reason for hiding this comment

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

CR: Pass

@ssekhri
Copy link

ssekhri commented Feb 26, 2019

FR Passed.
The layout of the tabs is as expected in both portrait and landscape orientation. In portrait the tabs, one or more, in the tab group would fill the entire width and in landscape mode the tabs would be centred and each tab taking the width of its title text.
Environment:
Studio: 5.1.2.201812191831
SDK: 8.1.0 local build
Mac OS: 10.14.3
Xcode: Xcode 10.1
Appc NPM: 4.2.13
Appc CLI: 7.0.10-master.17
Node: 8.12.0
NPM Ver: 6.4.1
Java Ver: 9.0.4

@sgtcoolguy sgtcoolguy merged commit 684ad19 into tidev:master Mar 25, 2019
sgtcoolguy pushed a commit that referenced this pull request Mar 25, 2019
)

Takes care of switching a TabLayout's TabGravity depending on current orientation.

Fixes TIMOB-26698
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants