Description:
Since Ti SDK 3.5.0, WebView does no recognise the html file when using Ti.sourceDirectory File system, if there is space in app name.
Reproduce:
1. Create a classic project named "Simple Test" (with space)
2. Create a folder named "html" under Resource folder.
3. Create a simple html file name "comingSoon.html", like following
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<div>
<p>Content to follow soon</p>
</div>
</body>
</html>
4.Add following code into app.js file
ar win = Ti.UI.createWindow({
backgroundColor: 'white'
});
var f = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory,'/html/comingSoon.html');
if (f.exists()) {
var contents = f.read();
alert('Output the file:'+contents.text);
} else {
Ti.API.info("No such file!");
}
var URL = Ti.Filesystem.resourcesDirectory + '/html/comingSoon.html';
var wv = Ti.UI.createWebView({
top: 30,
url: URL
});
win.add(wv);
win.open();
Expect Result:
The webview should display normally.
Actual Result:
The error pop out in console log:
*"couldn't load URL: app://com.cocoafish.sliangPush/Users/shuoliang/Library/Developer/CoreSimulator/Devices/EA379BD7-8255-4555-9A89-79678C7C68EB/data/Containers/Bundle/Application/BCD65E99-C189-4889-9177-CD870924377D/Simple%20Push.app/html/comingSoon.html"*
Note:
1. No such problem in SDK 3.4.1
2. Change the app name without space, problem gone.
PR: https://github.com/appcelerator/titanium_mobile/pull/6794 4_0_X PR: https://github.com/appcelerator/titanium_mobile/pull/6795
master PR merged. Backport PR not merged since ticket has no labels to indicate it needs to be backported
[~vduggal], sorry missed that. Ticket updated accordingly, can you please merge? Thanks.
[~sliang] 4_0_X once the back port is merged.
Backport merged
Verified using: Mac OSX 10.10.3 Appc Studio: 4.0.0.201504272049 Titanium SDK build: 4.0.0.v20150427093413 Appc CLI (NPM): 0.3.51 Appc CLI (Registry): 0.2.273 iPhone 5s (8.0.2) When the project name has a space the local HTML file loads with no issues Closing ticket
The change implemented in TiUtils.m has affected the ImageView image property which now will not display an image if there is a space in the image name.
<ImageView image="/images/thumb P6.jpg"></ImageView>
This displays the image in 4.0.0.RC but not in 4.0.0.RC2Please see latest comment on possible regression caused by this change.
Regression addressed here: Master: https://github.com/appcelerator/titanium_mobile/pull/6821 4_0_X: https://github.com/appcelerator/titanium_mobile/pull/6822
Remote images are broken on master now. I believe [this is the cause](https://github.com/cheekiatng/titanium_mobile/commit/484683cb34757b8d697fd56c4cf1691091f3a51d) (only taking path of a url): iphone/Classes/TiUIImageView.m
Reopening based on comments.
Hi all, does that commit explain this bug: !https://pp.vk.me/c625823/v625823842/30a41/fqhPXEwWTBg.jpg|height=200! paths to images are OK, iOS displays them if I use backgroundImage attribute like this:
, but if I use:
I see that stubs.
[~zo0m], yes this is most likely the cause. sorry about that we will fix this as soon as we can. And thanks [~athorne] for spotting this.
Master PR: https://github.com/appcelerator/titanium_mobile/pull/6830 4_0_X PR: https://github.com/appcelerator/titanium_mobile/pull/6831
Additional test cases
1. Set image in imageView with a remote url image 2. Set image in imageView with a local url image 3. Set image in imageView with a local url image that contains whitespace in filenameExpected result
Image will show in all test casesThank you, [~cng], for the quick fix!
Are you sure you have tested number 3? The ImageView image property will not display an image if there is a space in the image name.
<ImageView image="/images/thumb P6.jpg"></ImageView>
This displays the image in 4.0.0.RC but not in 4.0.0.RC3Yes I have tested it for this pr. It will be verified again when reviewed before merging :)
Above PR's closed New PR's master - https://github.com/appcelerator/titanium_mobile/pull/6833 4_0_X - https://github.com/appcelerator/titanium_mobile/pull/6834
Thank you, everyone!
[~skateboss] Those two tickets are duplicate of this. So, to confirm, these two test cases fail:
and: file:///Users/abannanmacmini/Library/Developer/CoreSimulator/Devices/192189D6-2D20-4572-B050-08C2DEB45E78/data/Containers/Data/Application/A80D5311-494A-435D-84A6-3D352E77C638/Library/Caches/abreader/cache/7fe480f7-0a05-41d1-a837-5ab900e583fd/5b6ae379-f7f0-4a70-b5ad-cd4a7759a8d6/OverlayResources/InDesign_BNDLR_RSRC21316-1764919231/members_State%201_602_Content_L.png
Spaces in image names or path to image work fine. I've also tested setting the image to a blob or file directly and that also works. The reason nativePath property of the file no longer works with the image property in certain cases is because nativePath returns the path in the encoded form and then ImageView re-encodes it to a location that is invalid (Essentially space->%20->%2520). So the workaround is to use the resolve() method on the File Object instead of the nativePath property. Test case below.
Reopening; I still encounter the "image with space in name not displaying" issue with Tab icons in Alloy projects: *Steps to reproduce issue*: 1. Create a new Alloy 2 Tab project 2. Modify the first tab in the
index.xml
to useicon="KS_nav ui.png"
3. Rename theKS_nav_ui.png
file toKS_nav ui.png
4. Run the project *Actual Results*: The icon for the first tab does not show up *Expected Results*: The icon is displayed I used: Studio 4.0.0.201505121820 Ti SDK 4.0.0.RC4 Appc NPM 0.3.55 Appc CLI 0.2.285 Ti CLI 4.0.0-beta8 Alloy 1.6.0-beta4 on iPhone 6 Simulator, iOS 8.3[~ewieber] What does the generated code look like?
@Ingo My generated code from Alloy produces the following: $.__views.__alloyId1 = Ti.UI.createImageView({ image: "/images/thumb%20P6.jpg", id: "__alloyId1" }); @Vishal - I have noticed that I can use
resolve()
as a workaround, but is this acceptable without being notified about the change and what aboutbackgroundImage
properties - should there be such an inconsistency?[~ingo] Here is my generated code for the entire Tabgroup/Alloy view: The tab that does show the icon seems to match the tab that does not show the icon.
PR's to address double encoding master - https://github.com/appcelerator/titanium_mobile/pull/6852 4_0_X - https://github.com/appcelerator/titanium_mobile/pull/6853
I can no longer reproduce the "image with space in name not displaying" issue with Tab icons in Alloy projects MacOS 10.10.3 Studio 4.0.0.201505170122 Ti SDK 4.0.0.v20150516200211 Appc NPM 0.3.55 CLI: 0.2.290 Ti CLI 4.0.0-beta9 Alloy 1.6.0-beta4 Node v0.10.37 Java 1.7.0_45 Icons for tabs correctly display.
Closing this ticket as it looks fixed. [~lawrence.wilson@abannan.com] Please comment if your issue is not resolved when using the above environment.