[TIMOB-19833] Allow users to access images via Ti.Filesystem when app thinning is enabled
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-01-11T21:22:27.000+0000 |
Affected Version/s | Release 5.1.0 |
Fix Version/s | Release 5.4.0 |
Components | iOS |
Labels | appthinning, qe-5.4.0 |
Reporter | Fokke Zandbergen |
Assignee | Chee Kiat Ng |
Created | 2015-10-30T10:34:57.000+0000 |
Updated | 2016-07-26T23:14:08.000+0000 |
Description
Because of TIMOB-19757 we have made app-thinning of image assets optional (for existing projects).
This means that when a developer needs to have access to an image via
Ti.Filesystem.getFile()
he has to disable app-thinning for *all* images.
We need a better solution for this.
Some thoughts:
* Provide away to exclude images from asset catalogs
** (n) Requires new folder or meta file
* Modify Ti.Filesystem.getFile()
to find images in asset catalogs
** (n) Requires hack to recognise image requests under resourceDirectory and translate that to [UIImage imageNamed:@"my-name"];
* Add Ti.Filesystem.getAsset()
to get an asset via [UIImage imageNamed:@"my-name"];
** (y) Looks like the best option.
Ti.Filesystem.getAsset(file path of bundled image) shall return a blob. This makes the method more versatile, allowing the developer the choice of saving it as a file in any location.
PR here: https://github.com/appcelerator/titanium_mobile/pull/7622
Steps to test:
1. create a new classic project 2. include in tiapp.xml3. include any image,
foo.png
in *Resources/images/foo.png* 4. Run this sample code Sample Code:Expected Result
You will see the image shown in the imageView.Extra Tests
you can include more images named *foo@2x.png*, *foo~iphone.png* and retest with *Ti.Filesystem.getAsset('images/foo@2x.png')* and *Ti.Filesystem.getAsset('images/foo~iphone.png')* respectively, you will still see the image.[~cng] I don't even think we could return a file since assets in asset catalogs (except for AppIcon and LaunchImage) are compressed into a single
Assets.car
file? I assume writing to a file in the example is for the purpose of demonstration since you could just assign the blob to the ImageView'simage
property as well?Yes that was my intention.
FT and CR approved. Thanks Kiat! Merging.
Verified as fixed, I am now able to access images using Ti.Filesystem when app thinning is enabled. Tested on:
*Closing ticket*