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

[6_1_X][TIMOB-24987] Android: Setting a custom theme's parent to "Theme.Titanium" no longer causes a recursive lookup. #9253

Merged
merged 4 commits into from Jul 26, 2017

Conversation

jquick-axway
Copy link
Contributor

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

Notes:

Test Case:

  1. Create a "classic" Titanium app project.
  2. In this project, add the following folder: ./platform/android/res/values
  3. Under this folder, create a new "custom_theme.xml" file using the contents down below.
  4. Add the below "tiapp.xml" Android settings to your project. (Note the theme reference.)
  5. Use the below "app.js" code in your project.
  6. Build and run the project on an Android device.
  7. Verify that all button text are not in all-caps and labels are green. (Note: This verifies that TIMOB-19629 is still fixed.)
  8. Open the "custom_theme.xml" file.
  9. Replace XML style parent attribute "@style/Theme.AppCompat" with "@style/Theme.Titanium" and save.
  10. Delete the project's generated "build" directory. (This is to force a rebuild.)
  11. Build and run the project on an Android device.
  12. Look at the Android log and verify that the following error message does NOT appear. (This verifies that TIMOB-24987 is fixed.)
  • ResourceType: Attempt to retrieve bag 0x7f050090 which is invalid or in a cycle.

custom_theme.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
	<style name="Theme.Custom" parent="@style/Theme.AppCompat">
		<item name="android:windowBackground">@drawable/appicon</item>
		<item name="android:windowActionBar">false</item>		
		<item name="android:windowNoTitle">true</item>
		<item name="windowActionBar">false</item>
		<item name="windowNoTitle">true</item>
		<item name="android:textAllCaps">false</item>
		<item name="android:textColorTertiary">#00FF00</item>
	</style>
</resources>

tiapp.xml

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

app.js

var window = Ti.UI.createWindow(
{
	layout: "vertical",
});
var listItemTemplate =
{
	properties:
	{
		height: Ti.UI.SIZE,
	},
	childTemplates:
	[
		{
			bindId: "rowView",
			type: "Ti.UI.View",
			properties:
			{
				layout: "horizontal",
				height: Ti.UI.SIZE,
			},
			childTemplates:
			[
				{
					type: "Ti.UI.Label",
					bindId: "title",
					properties:
					{
						height: Ti.UI.SIZE,
						left: "5%",
					}
				},
				{
					type: "Ti.UI.Button",
					bindId: "button",
					properties:
					{
						title: "Click Me",
						width: Ti.UI.SIZE,
						height: Ti.UI.SIZE,
						left: "5%",
					}
				},
			],
		},
	],
};
var listSection = Ti.UI.createListSection(
{
	headerView: Ti.UI.createButton({ title: "Header Button" }),
	footerView: Ti.UI.createButton({ title: "Footer Button" }),
});
for (var index = 1; index <= 4; index++) {
	listSection.appendItems(
	[
		{
			title: { text: "Row " + index.toString() },
		},
	]);
}
var listView = Ti.UI.createListView(
{
	templates: { 'listItemTemplate': listItemTemplate },
	defaultItemTemplate: "listItemTemplate",
});
listView.sections = [listSection];
window.add(listView);
window.open();

…nium" no longer causes a recursive lookup.

- Modified "Theme.Titanium" to no longer use the AndroidManifest.xml <application> tag's  theme as its parent.
  * This was the cause of the recursion if the custom theme was applied to the application.
  * Fixed by reverting PR tidev#8592 (ie: TIMOB-19629).
- Also fixed ListView to correctly apply its activity's theme to its rows, headers, and footers.
  * This addresses the bug for PR tidev#8592 that I reverted.
@@ -707,10 +707,16 @@ public void generateCellContent(int sectionIndex, KrollDict data, TiListViewTemp

public void generateChildContentViews(DataItem item, TiUIView parentContent, TiBaseListViewItem rootItem, boolean root) {

android.app.Activity activity = getActivity();
Copy link
Contributor

Choose a reason for hiding this comment

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

minor, import android.app.Activity

@jquick-axway jquick-axway added this to the 6.1.2 milestone Jul 26, 2017
Copy link
Contributor

@garymathews garymathews 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 👍

@lokeshchdhry
Copy link
Contributor

FR Passed.

For TIMOB-19629 - the buttons are lower cased & the labels have the color green as expected.
For TIMOB-24987 - no ResourceType: Attempt to retrieve bag 0x7f050090 which is invalid or in a cycle. message is seen.

Verified it with an alloy app with a textField & custom theme. The keyboard did pop up as expected when tapped on the textField.

Studio Ver: 4.9.1.201707200100
SDK Ver: 6.1.2 local build
OS Ver: 10.12.3
Xcode Ver: Xcode 8.3.3
Appc NPM: 4.2.9
Appc CLI: 6.2.2
Ti CLI Ver: 5.0.14
Alloy Ver: 1.9.11
Node Ver: 6.10.1
Java Ver: 1.8.0_101
Devices: ⇨ google Nexus 5 --- Android 6.0.1

@lokeshchdhry lokeshchdhry merged commit 9328024 into tidev:6_1_X Jul 26, 2017
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

4 participants