Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-27232

Android: Setting Window "barColor" while using a theme without an ActionBar/TitleBar will cause a crash as of 8.1.0

    Details

    • Story Points:
      3

      Description

      Summary:
      Setting Ti.UI.Window property "barColor" if it's using a theme without an ActionBar will cause a crash as of Titanium 8.1.0.

      Note that this bug was never in a release version. It was caught before release.

      Steps to reproduce:

      1. Set up a Classic project to build with Titanium 8.1.0.
      2. Copy the below code to your "app.js".
      3. Build and run on Android.

      var window = Ti.UI.createWindow({
      	barColor: "blue",
      	theme: "Theme.AppCompat.NoTitleBar",
      });
      window.add(Ti.UI.createLabel({ text: "Window Title Test" }));
      window.open();
      

      Result:
      App crashes on startup and the following exception gets logged...

      [ERROR] :  TiExceptionHandler: (main) [1,6371] Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setBackgroundDrawable(android.graphics.drawable.Drawable)' on a null object reference
      [ERROR] :  TiExceptionHandler:
      [ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.WindowProxy.windowCreated(WindowProxy.java:313)
      [ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:57)
      [ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:578)
      [ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:726)
      [ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:47)
      [ERROR] :  TiExceptionHandler:     android.app.Activity.performCreate(Activity.java:6975)


      Use-case:
      This issue is more likely to happen in apps that use theme/style XML file applied globally to the app. Like the one below supplied by Andreas Pingas.

      <style name="FullScreen" parent="@style/Theme.AppCompat.Light">
      	<item name="android:soundEffectsEnabled">false</item>
      	<item name="colorPrimaryDark">#000000</item>
      	<item name="colorPrimary">#EF4938</item>
      	<item name="colorAccent">#FFFFFF</item>
      	<item name="colorControlNormal">#EF4938</item>
      	<item name="colorControlActivated">#2EA1FC</item>
      	<item name="colorControlHighlight">#F26D60</item>
      	<item name="colorSwitchThumbNormal">#FFFFFF</item>  
      	<item name="android:colorButtonNormal">#00BCFF</item>
      	<item name="android:colorEdgeEffect">#EF4938</item>
      	<item name="android:navigationBarColor">#000000</item>
      	<item name="windowNoTitle">true</item>
      	<item name="windowActionBar">false</item>
      </style>
      

      var win = Titanium.UI.createWindow({
           barColor:’#FFF’
           theme:'FullScreen'
      });
      win.open();
      

        Attachments

          Activity

            People

            • Assignee:
              ybanev Yordan Banev
              Reporter:
              andreas.pingas Andreas Pingas
              Reviewer:
              Joshua Quick
              Tester:
              Samir Mohammed
            • Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Source Code