eclipsesource / tabris-js

Create native mobile apps in JavaScript or TypeScript.
https://tabrisjs.com
BSD 3-Clause "New" or "Revised" License
1.4k stars 172 forks source link

Theme preference does not work with Tabris.js 3.9 #2261

Closed cpetrov closed 12 months ago

cpetrov commented 1 year ago

Problem description

When using Tabris.js 3.9 and configuring a Theme as described in the Theming an Android app documentation article, the theme is not applied:

<platform name="android">
    <resource-file src="res/android/values/myapp_theme.xml"
                   target="app/src/main/res/values/myapp_theme.xml" />
    <preference name="Theme" value="@style/Theme.MyApp" />
</platform>

~As a workaround, one needs to patch AndroidManifest.xml to configure the theme on the application activity (workaround by @elshadsm):~

  <edit-config file="AndroidManifest.xml" target="/manifest/application/activity" mode="merge">
    <activity android:theme="@style/Theme.MyApp" />
  </edit-config>

UPDATE: Don't use this workaround as this will break the app on API level 30, see https://github.com/apache/cordova-android/issues/1497#issuecomment-1266900918. Set AndroidPostSplashScreenTheme instead.

Expected behavior

Tabris.js should take care of configuring the theme of the activity itself when the Theme preference is specified.

Environment

cpetrov commented 12 months ago

The initial theme needs to be a splash theme, so overriding it through the method previously suggested as a workaround causes breakage, in particular on API level 30, see https://github.com/apache/cordova-android/issues/1497#issuecomment-1266900918. Instead, use AndroidPostSplashScreenTheme to configure the theme used after the splash screen gets shown:

<preference name="AndroidPostSplashScreenTheme" value="@style/Theme.MyApp"/>