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): TabGroup without badge crashes when using AppCompat theme as of 9.3.0 #12175

Merged
merged 3 commits into from Oct 21, 2020

Conversation

jquick-axway
Copy link
Contributor

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

Summary:
TabGroup should only throw an exception if using Theme.AppCompat and you also assign the "badge" property. This is because badges requires an app to use the Theme.MaterialComponents theme (which is the default). It should NOT throw an exception if the "badge" property is NOT set for backward compatibility, which is the regression this PR fixes.

Test:

  1. Create a Classic app project from template.
  2. Add the below <application/> entry into the "tiapp.xml".
  3. Copy the below app.js to the project.
  4. Build and run the below on Android.
  5. Verify app does NOT crash and a badge is NOT shown. (This is the fix.)
  6. Uncomment line: tabGroupSettings.style = Ti.UI.Android.TABS_STYLE_BOTTOM_NAVIGATION;
  7. Build and run on Android.
  8. Verify app does NOT crash and a badge is NOT shown. (This is the fix.)
  9. Uncomment line: tabGroup.tabs[1].badge = "5";
  10. Build and run on Android.
  11. Verify app does crash with below exception. (This is okay.)
    The style on this component requires your app theme to be Theme.MaterialComponents
  12. Comment-out line: tabGroupSettings.style = Ti.UI.Android.TABS_STYLE_BOTTOM_NAVIGATION;
  13. Build and run on Android.
  14. Verify app does crash with below exception. (This is okay.)
    The style on this component requires your app theme to be Theme.MaterialComponents
  15. In "tiapp.xml", delete the <application/> XML element.
  16. Build and run on Android.
  17. Verify app starts fine and top tab bar shows a badge of 5.
  18. Uncomment line: tabGroupSettings.style = Ti.UI.Android.TABS_STYLE_BOTTOM_NAVIGATION;
  19. Build and run on Android.
  20. Verify app starts fine and bottom tab bar shows a badge of 5.

tiapp.xml

<ti:app>
	<android xmlns:android="http://schemas.android.com/apk/res/android">
		<manifest>
			<application android:theme="@style/Theme.AppCompat"/>
		</manifest>
	</android>
</ti:app>

app.js

function createTab(title) {
	var window = Ti.UI.createWindow({ title: title });
	window.add(Ti.UI.createLabel({ text: title + " View" }));
	var tab = Ti.UI.createTab({
		title: title,
		icon: "/assets/images/tab1.png",
		window: window,
	});
	return tab;
}

var tabGroupSettings = {
	tabs: [createTab("Tab 1"), createTab("Tab 2"), createTab("Tab 3")],
};
if (OS_ANDROID) {
	tabGroupSettings.shiftMode = false;
//	tabGroupSettings.style = Ti.UI.Android.TABS_STYLE_BOTTOM_NAVIGATION;
}
var tabGroup = Ti.UI.createTabGroup(tabGroupSettings);
tabGroup.addEventListener("open", function() {
//	tabGroup.tabs[1].badge = "5";
});
tabGroup.open();

@build
Copy link
Contributor

build commented Oct 13, 2020

Messages
📖

💾 Here's the generated SDK zipfile.

📖 ✊ The commits in this PR match our conventions! Feel free to Rebase and Merge this PR when ready.
📖

✅ All tests are passing
Nice one! All 10041 tests are passing.
(There are 982 skipped tests not included in that total)

Generated by 🚫 dangerJS against 6df098b

Copy link
Contributor

@sgtcoolguy sgtcoolguy left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@ssjsamir ssjsamir left a comment

Choose a reason for hiding this comment

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

FR Passed, tested using the code in the description, application no longer crashes.

Test Environment

MacOS Big Sur: 11.0 Beta 9
Xcode: 12.2 Beta
Java Version: 1.8.0_242
Android NDK: 21.3.6528147
Node.js: 12.18.1
""NPM":"5.0.0","CLI":"8.1.1""
PIXEL XL API 29

@sgtcoolguy sgtcoolguy merged commit 6403da2 into tidev:master Oct 21, 2020
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

5 participants