Titanium JIRA Archive
Appcelerator Community (AC)

[AC-6499] Android Material Theme not working in SDK 9

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionDuplicate
Resolution Date2020-04-08T02:21:19.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid
ReporterTony Lau
AssigneeAbir Mukherjee
Created2020-03-04T07:59:52.000+0000
Updated2020-04-08T02:21:19.000+0000

Description

Material them and custom button not working in SDK 9. Worked in 8.2.x With the mytheme.xml, the buttons are supposed to be not with the standard grey rectangle and text should not in caps.
<resources>
	<style name="materialTheme" parent="@style/Theme.AppCompat">
		 <item name="colorPrimary">#033047</item>
		 <item name="colorPrimaryDark">#4c6a7a</item>
		 <item name="colorAccent">#4d88a3</item>
		 <item name="colorControlNormal">#757575</item>
		 <item name="colorControlActivated">#FF6E40</item>
		 <item name="colorControlHighlight">#4d88a3</item>
		 <item name="colorSwitchThumbNormal">#BDBDBD</item>
		 <item name="android:colorButtonNormal">#0D0C05</item>
		 <item name="android:colorEdgeEffect">#4d88a3</item>
		 <item name="android:buttonStyle">@style/customButton</item>
	</style>
	<style name="customButton" parent="Widget.AppCompat.Button">
		<item name="android:textAllCaps">false</item>
	</style>
</resources>

Attachments

FileDateSize
Android-kitchensink.png2020-03-07T04:30:25.000+000090461

Comments

  1. Joshua Quick 2020-03-04

    This is likely an issue in your "AndroidManifest.xml" settings. We've switched to Google's newest gradle build tools, which is much more strict regarding your XML settings. For example, you need to make sure you have @style/ prefixed in front of your theme name when referencing it in XML. Our "kitchensink-v2" sample app successfully overrides the theme in Titanium 9.0.0. Note that we reference it via android:theme="@style/kitchensink" in the "tiapp.xml" file where "kitchensink" is our custom theme/style. https://github.com/appcelerator/kitchensink-v2/blob/master/tiapp.xml https://github.com/appcelerator/kitchensink-v2/blob/master/app/platform/android/res/values/custom_theme.xml
  2. Tony Lau 2020-03-06

    I took the kitchensink theme and works fine. If I added the except the customButton section, that is the part that is not functioning. . . @style/customButton . . I also tried to modify the last section to specify android, still no luck
  3. Joshua Quick 2020-03-07

    This works for me...
       <?xml version="1.0" encoding="utf-8"?>
       <resources>
       	<style name="kitchensink" parent="@style/Theme.AppCompat.Light">
       		<!-- ... -->
       		<item name="buttonStyle">@style/MyTheme.Button</item>
       	</style>
       	<style name="MyTheme.Button" parent="@style/Widget.AppCompat.Button">
       		<item name="android:textAllCaps">false</item>
       	</style>
       </resources>
       
    Here is a screenshot of it working in kitchensink-v2. !Android-kitchensink.png|thumbnail!
  4. Joshua Quick 2020-03-07

    I think it's an issue with your leading "android:" in...
       <item name="android:buttonStyle">@style/customButton</item>
       
    This below works when I tested it on Android 4.4 and 9.0. My understanding is because the theme comes from Google's AndroidX library (or in the past the Support library) instead of the Android system library.
       <item name="buttonStyle">@style/customButton</item>
       
    But I suppose if you're really paranoid, you can just define both. It won't hurt anything. :)
       <item name="buttonStyle">@style/customButton</item>
       <item name="android:buttonStyle">@style/customButton</item>
       
    https://stackoverflow.com/a/31359459
  5. Tony Lau 2020-03-09

    No luck but I tested on real Android phones. Nexus 5X Android 8.1.0 Galaxy Note3 Android 5.0 For both devices, when I just switched back to 8.2.0GA, the lower caps showed up properly! A bit frustrating.
  6. Joshua Quick 2020-03-10

    Without any more information, we can't help you. Especially since this is working for us. Do you see any warning or errors in the build log?
  7. Tony Lau 2020-04-05

    I final stumbled into how it can be reproduced. It has to do with how the controller is opened in modal or not. Alloy.createController('xxxxxxxxx').getView().open({modal:true}); ---> All text in button becomes all capital letters Alloy.createController('xxxxxxxxx').getView().open({modal:false}); ---> All text in button showed up as what were typed in code So, the problem is pertained to when windows are opened as modal.
  8. Joshua Quick 2020-04-07

    Okay. I'm able to reproduce it now. Thanks for isolating it. A bug has been introduced into Titanium 9.0.0. Your custom style is being applied to the wrong translucent activity theme internally. If you need a solution now, then you can work-around it in 1 of 2 ways. *Work-Around 1:* Set the "theme" property to the below string when creating a window in code like this...
       var window = Ti.UI.createWindow({
       	modal: true,
       	theme: "Theme.AppCompat.Translucent",
       });
       
    *Work-Around 2:* Set the theme of the "TiTranslucentActivity" like the below...
       <ti:app>
       	<android>
       		<manifest>
       			<application android:theme="@style/MyStyle">
       				<activity android:name="org.appcelerator.titanium.TiTranslucentActivity" android:theme="@style/Theme.AppCompat.Translucent"/>
       			</application>
       		</manifest>
       	</android>
       </ti:app>
       
    Note that the above 2 solutions are temporary, because the translucent activity theme is supposed to use "Theme.AppCompat.Translucent", not "Theme.AppCompat.Translucent" (it's currently backwards in 9.0.0). So, the above won't work in older Titanium versions... or future versions. We'll see about addressing it in 9.0.1. Thanks for reporting this issue.
  9. Joshua Quick 2020-04-08

    I've written a ticket that better clarifies the issue here: [TIMOB-27837] I'm going to close this ticket in favor of the above one. We've scheduled it to be fixed in Titanium 9.0.1. Thanks for reporting this issue.

JSON Source