Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10806] Android: Ti.UI.Button.image property is not working for density specific images

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-11-13T23:38:54.000+0000
Affected Version/sRelease 2.1.2
Fix Version/sRelease 2.1.3, Release 3.0.0, Sprint 2012-19 API, 2012 Sprint 19, 2013 Sprint 23, 2013 Sprint 23 Core, Release 3.2.0
ComponentsAndroid
LabelsSupportTeam, api, module_button, qe-closed-3.2.0, qe-port, qe-testadded
ReporterVarun Joshi
AssigneeChris Barber
Created2012-09-06T15:22:16.000+0000
Updated2013-11-18T21:51:13.000+0000

Description

Issue

The Ti.UI.Button's image property does not work if the images are under the density specific Android image folders (res-port-hdpi etc.) It works if we put the image in the default image dir.

Sample Test Case

1. Run the attached test project 2. The density specific images are placed under Resources/android/images folder. 3. In the sample code, if we swap the Ti.UI.Button with a view or an imageview, the appropriate images are used.

Attachments

FileDateSize
android_search.tiff2012-09-20T12:17:27.000+00006546
ios_search.tiff2012-09-20T12:17:27.000+00005880
T13975.zip2012-09-06T15:22:16.000+00002380189
timob10806.zip2012-09-10T13:53:03.000+00002392426

Comments

  1. Ping Wang 2012-09-10

    PR https://github.com/appcelerator/titanium_mobile/pull/2902 For functional test: 1. Download the attached test project "timob10806.zip". 2. Run the test project. Should see an image on the button. 3. Click the button. Should see the image is changed.
  2. Fokke Zandbergen 2012-09-13

    Also found in SDK 2.1.1.GA
  3. Ping Wang 2012-09-14

    PR for 2_1_X: https://github.com/appcelerator/titanium_mobile/pull/2968
  4. Satyam Sekhri 2012-09-17

    Verified on: Titanium Studio: 2.1.2.201208301612 Titanium SDK: 2.1.3.v20120915120319 Android Device: Samsung Note (v2.3.6), Galaxy Nexus (v4.0.2)
  5. Olga Romero 2012-09-21

    Verified fix with: osx Mountain Lion 10.8.1 Titanium Studio, build: 2.1.2.201208301612 Titanium SDK: 2.1.3.v20120920154617 Titanium SDK: 3.0.0.v20120921144915 Device: Nexus S3 4.0.4
  6. Danny Pham 2013-11-11

    I am using SDK 3.13 and this bug still occurs in the emulator (e.g. WXGA720). However on a real device (Samsung Galaxy S3, same xhdpi) the button image is correctly loading from the density specific Android image folder. Is this only an emulator related bug or can this also happen on production release?
  7. Ping Wang 2013-11-13

    Tested with 3.1.3.GA. The image shows fine on emulator. But when tested with the latest master(3.2.0), this bug still occurs. The log is
       D/TiFileFactory( 5544): (main) [3,118] getting initial from parts: app://images/Tab1.png
       E/TiRHelper( 5544): (main) [4,122] Error looking up resource: tab1_c9dd4dedd9
       E/TiRHelper( 5544): java.lang.NoSuchFieldException: tab1_c9dd4dedd9
       E/TiRHelper( 5544): 	at java.lang.Class.getDeclaredField(Class.java:631)
       E/TiRHelper( 5544): 	at org.appcelerator.titanium.util.TiRHelper.lookupResource(TiRHelper.java:77)
       E/TiRHelper( 5544): 	at org.appcelerator.titanium.util.TiRHelper.getResource(TiRHelper.java:105)
       E/TiRHelper( 5544): 	at org.appcelerator.titanium.util.TiUIHelper.getResourceId(TiUIHelper.java:770)
       E/TiRHelper( 5544): 	at org.appcelerator.titanium.view.TiDrawableReference.fromUrl(TiDrawableReference.java:185)
       E/TiRHelper( 5544): 	at org.appcelerator.titanium.view.TiDrawableReference.fromUrl(TiDrawableReference.java:168)
       E/TiRHelper( 5544): 	at ti.modules.titanium.ui.widget.TiUIButton.processProperties(TiUIButton.java:68)
       E/TiRHelper( 5544): 	at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1185)
       E/TiRHelper( 5544): 	at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:482)
       E/TiRHelper( 5544): 	at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:473)
       E/TiRHelper( 5544): 	at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:451)
       E/TiRHelper( 5544): 	at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:489)
       E/TiRHelper( 5544): 	at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:473)
       E/TiRHelper( 5544): 	at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:451)
       E/TiRHelper( 5544): 	at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:568)
       E/TiRHelper( 5544): 	at org.appcelerator.titanium.proxy.TiViewProxy.add(TiViewProxy.java:546)
       E/TiRHelper( 5544): 	at ti.modules.titanium.ui.WindowProxy.windowCreated(WindowProxy.java:280)
       E/TiRHelper( 5544): 	at org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:32)
       E/TiRHelper( 5544): 	at org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:451)
       E/TiRHelper( 5544): 	at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:527)
       E/TiRHelper( 5544): 	at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18)
       E/TiRHelper( 5544): 	at android.app.Activity.performCreate(Activity.java:5008)
       E/TiRHelper( 5544): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
       E/TiRHelper( 5544): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
       E/TiRHelper( 5544): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
       E/TiRHelper( 5544): 	at android.app.ActivityThread.access$600(ActivityThread.java:130)
       E/TiRHelper( 5544): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
       E/TiRHelper( 5544): 	at android.os.Handler.dispatchMessage(Handler.java:99)
       E/TiRHelper( 5544): 	at android.os.Looper.loop(Looper.java:137)
       E/TiRHelper( 5544): 	at android.app.ActivityThread.main(ActivityThread.java:4745)
       E/TiRHelper( 5544): 	at java.lang.reflect.Method.invokeNative(Native Method)
       E/TiRHelper( 5544): 	at java.lang.reflect.Method.invoke(Method.java:511)
       E/TiRHelper( 5544): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
       E/TiRHelper( 5544): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
       E/TiRHelper( 5544): 	at dalvik.system.NativeStart.main(Native Method)
       W/TiDrawableReference( 5544): (main) [93,215] Could not open stream to get bitmap
       W/TiDrawableReference( 5544): (main) [0,215] Could not open stream to get bitmap
       
    In /build/android/res/drawable-xxx/, I can see the image file "tab1_94b63d84cf.png". But when I use 3.1.3.GA to build the project, I can see the image file "tab1_c9dd4dedd9.png". Seems the hash of the file are calculated differently in the master CLI. Re-opened the ticket. Seems like the same issue with TC-3259.
  8. Chris Barber 2013-11-13

    Pull request: https://github.com/appcelerator/titanium_mobile/pull/4961
  9. Samuel Dowse 2013-11-18

    Verified fixed on: Mac OSX 10.9 Mavericks Titanium Studio, build: 3.2.0.201311160316 Titanium SDK, build: 3.2.0.v20131117001643 CLI: 3.2.0-alpha Alloy: 1.3.0 Android Emulator: 2.3.3, 4.4 Android Device: Xperia Arc S (4.0.4) No error is thrown in the console log. Closing.

JSON Source