Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-11341] Android: App build with targetSdkVersion > 11 should use newer themes

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2013-10-19T01:20:57.000+0000
Affected Version/sRelease 3.0.0
Fix Version/s2013 Sprint 21, 2013 Sprint 21 Core, Release 3.2.0
ComponentsAndroid, Tooling
Labelsandroidbuild, cb-verified, core, insight, qe-closed-3.2.0, triage
ReporterArthur Evans
AssigneeChris Barber
Created2012-10-10T01:49:20.000+0000
Updated2013-12-23T20:34:15.000+0000

Description

Setting tool-api-version and targetSdkVersion to something about 11 should let us use the device's built-in themes, but apps still show up in the old themes unless we override the themes explicitly. I added the following to the tiapp.xml file:
    <android xmlns:android="http://schemas.android.com/apk/res/android">
    	<tool-api-level>15</tool-api-level>
    	<manifest>
    		<uses-sdk targetSdkVersion="15" />
    	</manifest>
    </android>
However, the app still looks old-style on a Nexus 7. For example, menu items are displayed in the options menu, not the action bar, even if showAsAction is set. And for that matter--no action bar. Testing with the sample code for Action Items from TIMOB-9910.

Comments

  1. Allen Yeung 2012-12-13

    I think the attribute for the 'uses-sdk' should be 'android:targetSdkVersion' instead of just 'targetSdkVersion'. I tried switching it to that and it works fine for me. Please reopen if there are any other issues.
  2. Arthur Evans 2013-01-08

    That works for ordinary windows (since they use the Titanium theme, which should default to the device's default theme). However, windows created with modal: true or any opacity value are hard-coded to the Android Translucent theme, which _doesn't_, include an action bar. To override these, the user has to add entries to tiapp.xml for each of these (and probably create a custom theme that defaults to Translucent in earlier releases, and Holo (or the device default) in later releases. As near as I can tell, we don't actually need the separate translucent theme in newer versions of Android (although I may be mistaken here).
  3. Allen Yeung 2013-10-19

    PR: https://github.com/appcelerator/titanium_mobile/pull/4781
  4. Samuel Dowse 2013-12-17

    Verified fixed on: Mac OSX 10.9 Mavericks Titanium Studio, build: 3.2.0.201312142258 Titanium SDK, build: 3.2.0.v20131216064236 CLI: 3.2.0-cr3 Alloy: 1.3.0-cr Added the code snippet from the description. Ran on device using API set to 15 and set to 10. API15 displayed new theme, API 10 displayed older theme. Closing.
  5. Sameeh Harfoush 2013-12-23

    i compiled my app with 3.2 SDK. when opening a date-picker in a modal window i get the very old UI of the date-picker. only when i use date-picker in a normal window i get it in Holo.Light theme
       <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="19"/>
       <application android:debuggable="true" android:hardwareAccelerated="true"
                       android:largeHeap="true" android:theme="@android:style/Theme.Holo.Light"/>
       
    am i missing anything?
  6. Ping Wang 2013-12-23

    This is a theme issue. We need to add some custom themes to the app template. For now, here is the workaround: 1. Create the file /platform/android/res/values/theme.xml:
       <?xml version="1.0" encoding="utf-8"?>
       <resources>
       	<style name="Theme.Titanium" parent="android:Theme">
       		<item name="android:windowBackground">@drawable/background</item>
       	</style>
       	<style name="Theme.Titanium.Transparent" parent="android:Theme">
       		<item name="android:windowIsTranslucent">true</item>
       		<item name="android:windowBackground">@android:color/transparent</item>
       	</style>
       </resources>
       
    2. Create the file /platform/android/res/values-v11/theme.xml:
       <?xml version="1.0" encoding="utf-8"?>
       <resources>
       	<style name="Theme.Titanium" parent="android:Theme.Holo">
       		<item name="android:windowBackground">@drawable/background</item>
       	</style>
       	<style name="Theme.Titanium.Transparent" parent="android:Theme.Holo">
       		<item name="android:windowIsTranslucent">true</item>
       		<item name="android:windowBackground">@android:color/transparent</item>
       	</style>
       </resources>
       
    3. In tiapp.xml, add
       <android xmlns:android="http://schemas.android.com/apk/res/android">
               <manifest>
                   <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="14"/>
                   <application>
                   	<activity android:configChanges="keyboardHidden|orientation|screenSize" android:name="org.appcelerator.titanium.TiTranslucentActivity" android:theme="@style/Theme.Titanium.Transparent"/>
               	</application>
               </manifest>
           </android>
       

JSON Source