[TIMOB-13059] Android: WebView: remove requirement to set baseURL
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-03-14T03:48:09.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 3.1.0 |
Components | Android |
Labels | android, qe-port, regression, webview |
Reporter | Banzai Mobile |
Assignee | Ingo Muschenetz |
Created | 2013-02-13T17:50:03.000+0000 |
Updated | 2013-03-14T09:21:15.000+0000 |
Description
The following works on SDK 2.x and 3.0.0 on all platforms and on 3.0.2RC on iOS, but not on 3.0.2RC on Android:
Ti.UI.setBackgroundColor('#000');
var win = Ti.UI.createWindow();
var wv = Ti.UI.createWebView({
html: '<p>This is an accented e character: è</p><img width="30" height="30" src="images/img.png" />'
});
win.add(wv);
win.open();
The defects are:
1) the accented character displays as garbage
2) the local image does not show at all (changing its path to "/images/img.png" does not work either)
I think this bug has not been given enough attention. Encoding issue can be solved by adding mimeType to a setHtml call, but I cannot find any way to show local images. IMHO, it is a showstopper and should have blocked release of 3.0.2GA Could somebody please at least find and publish a workaround for displaying local images in a webview on Android?
@Banzai--can you see if adding a baseURL solves the issues with images? See the related ticket TIMOB-9593.
@Ingo: Yes, setting the baseURL solves both problems (image and text encoding). That's good, because now calling setHtml with BOTH baseURL AND mimeType makes the html appear as code instead of rendered.
@Banzai. Great. So this was a change...where do you think the best place to advertise this is? Where would you have expected to find a note about this (and didn't)?
@Ingo: I'd mention it in the API docs for WebView, specifically under the html property and setHtml method. And of course in its own paragraph in the 3.0.2 release notes.
Yes this would be nice to be mentioned in the API docs, the 3.0.2 release notes, and also the WebView user guide page: http://docs.appcelerator.com/titanium/3.0/#!/guide/The_WebView_Component-section-29004918_TheWebViewComponent-UsingLocalWebContentwithWebView. Note I have added an informational post to the Q&A forums: http://developer.appcelerator.com/question/148638/notice-titanium-302-android-webview-not-loading-local-resource-files-properly-via-html-property
I reproduced this issue with 3.0.2.GA Defects ARE GONE with: Titanium Studio, build: 3.0.3.201302201202 Titanium SDK, build: 3.1.0.v20130312161655 Device: Nexus7 Android version: 4.2
This was fixed as a result of re-fixing TIMOB-9593.
The local image is being shown now. Environment used for verification - Titanium SDK: 3.1.0.v20130311192922 Titanium Studio:3.0.2.201302151605 Device: Nexus 7 Android 4.1