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

Android: Webview with '_.template' rendered HTML not displayed

    Details

      Description

      Problem description

      In the Dynamic Styling Alloy sample https://github.com/appcelerator/alloy/tree/master/test/apps/advanced/dynamic_styling , in the 'rawStyle' window, there is a webView whose html content is rendered using the Underscore.js '_.template' utility:

      $.styleArray.html = _.template(Alloy.Globals.htmlTemplate, {
      	CODE: JSON.stringify(require('alloy/styles/features/rawStyle'), null, '  '),
      	BRUSH: 'js'
      });
      

      Alloy.Globals.htmlTemplate (in app/alloy.js):

      Alloy.Globals.htmlTemplate = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><script type="text/javascript" src="web/syntaxhighlighter/scripts/shCore.js"></script><script type="text/javascript" src="web/syntaxhighlighter/scripts/shBrushJScript.js"></script><link type="text/css" rel="stylesheet" href="web/syntaxhighlighter/styles/shCoreDefault.css"/><script type="text/javascript">SyntaxHighlighter.all();</script></head><body style="background: white; font-family: Helvetica; "><pre class="brush: <%= BRUSH %>; gutter: false;"><%= CODE %></pre></html>';
      

      If no targetSdkVersion is specified or if a targetSdkVersion specified is greater than 13, running the sample on Android using the latest SDK (3.2.3.v20140403105720), the Webview is not visible.
      Is correctly visible using 3.2.2.GA on both iOS and Android.

      Steps to reproduce

      1. Create a new Alloy project and import the Alloy sample code https://github.com/appcelerator/alloy/tree/master/test/apps/advanced/dynamic_styling (or get the attached project)
      2. Run on Android and click on 'Raw Style Modules'
      Result: second webView (<WebView id="styleArray" height="800dp"/>) is not visible.

      3. Edit tiapp.xml, add the following and run on Android:

      <android xmlns:android="http://schemas.android.com/apk/res/android">
              <manifest>
                  <uses-sdk android:targetSdkVersion="11"/>
              </manifest>
      </android>
      

      Result: the webView is now correctly displayed

      4. Edit tiapp.xml, add the following and run on Android:

      <android xmlns:android="http://schemas.android.com/apk/res/android">
              <manifest>
                  <uses-sdk android:targetSdkVersion="19"/>
              </manifest>
      </android>
      

      Result: Webview is no longer displayed.

      5. Edit tiapp.xml, switch to SDK 3.2.2.GA, use any targetSdkVersion (from 11 to 19) and run on device:
      Result: webview is always correctly displayed. It seems to be a regression on the SDK (also no changes made on Alloy).

      Attached screenshots for comparison between a displayed and not-displayed webview.

      Note

      If using Jake to import the Alloy sample project, it works fine as in this case an Harness template with targetSdkVersion='11' is being used.
      If using the default new app tiapp.xml file (with no targetSdkVersion being specified in the manifest), the sample webview is not visible.

        Attachments

          Activity

            People

            • Assignee:
              hpham Hieu Pham
              Reporter:
              fcasali Federico Casali
              Reviewer:
              Vishal Duggal (Inactive)
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-18628
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Source Code