lyspring / adwhirl

Automatically exported from code.google.com/p/adwhirl
0 stars 0 forks source link

house ad icon is too small on hi-res device #137

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Android SDK v2.5.5

/src/com/adwhirl/adapters/CustomAdapter.java
Please search the code that uses "new LayoutParams()" and "setPadding()" 
functions. The values are in pixel. Please multiple the values with current 
display density; otherwise the house ad icon and padding are too small on WVGA 
devices.

Original issue reported on code.google.com by a0s...@gmail.com on 30 Oct 2010 at 4:13

GoogleCodeExporter commented 8 years ago

Original comment by nigelc...@google.com on 3 Nov 2010 at 11:38

GoogleCodeExporter commented 8 years ago

Original comment by jpin...@google.com on 4 Nov 2010 at 12:06

GoogleCodeExporter commented 8 years ago
I just found the cause to this issue in app code.
It's caused by android:targetSdkVersion in the manifest. It needs to be 
undefined or 3 or lower for the house ad icons to appear properly.

Just to point out, with this issue the icon is also too big on low-res devices. 
On med-res it appears normally.

I originally posted about it in the forum at 
https://groups.google.com/group/adwhirl-users/browse_thread/thread/432877662418b
a3c

Original comment by pilota51 on 6 Nov 2010 at 1:01

GoogleCodeExporter commented 8 years ago
This will also cause it if targetSdkVersion is undefined or <=3:
<supports-screens android:anyDensity="true" />

If targetSdkVersion is >3, setting anyDensity to false will fix it.

On the other hand, I noticed that by fixing it in the app as I described, it 
messes with matrix scaling in other areas of the app. So in my case this issue 
just got a little more complicated.

Original comment by pilota51 on 6 Nov 2010 at 5:47

GoogleCodeExporter commented 8 years ago
Turning anyDensity to false will enable scaling by the android framework. While 
some developers desire this, it's typically not what you want. 

I made the fix - it'll be out in the next release.

Original comment by jpin...@google.com on 18 Nov 2010 at 7:35

GoogleCodeExporter commented 8 years ago
Hmm... I don't see it fixed in 2.6.0. Am I missing something?

Original comment by pilota51 on 25 Nov 2010 at 8:23

GoogleCodeExporter commented 8 years ago
This has been confirmed by me and another developer to NOT be fixed in v2.6.0. 
That leaves me wondering why it was said to be fixed in the change log when it 
really isn't (is there no testing before release?), but the bottom line is that 
it still needs fixed.

Original comment by pilota51 on 29 Nov 2010 at 7:16

GoogleCodeExporter commented 8 years ago
The changes were tested before release - I'd imagine that the issue still has 
something to do with manifest differences. If you can list specific devices and 
android versions you are still seeing the issue on that would be very helpful.

Please take a look at: 
http://code.google.com/p/adwhirl/source/detail?r=b6e7670b31c7e2969abefbe190706b0
2bad39c38&repo=sdk-android

Original comment by jpin...@google.com on 29 Nov 2010 at 7:49

GoogleCodeExporter commented 8 years ago
Tested in 1.5, 1.6 and 2.2 emulators for both QVGA and WVGA854, plus a Droid 
running CyanogenMod6 (2.2.1). 1.5 is the only one that does not have this 
issue. As mentioned before, the icon is too big on QVGA and too small on WVGA, 
while HVGA is not noticeably affected.

Project build target: API8 (2.2)
These are the only elements I have in Manifest outside the application tags:
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="8"/>
<uses-permission android:name="android.permission.INTERNET"/>

To cause the bug, be sure that targetSdkVersion is 4 or higher and anyDensity 
is undefined or true. Or if targetSdkVersion is undefined or 3 or lower, set 
anyDensity to true. I am unaware of anything else in the Manifest that triggers 
the issue.

After skimming the source I don't see where the problem lies, but I'm still 
sort of a newbie dev so I'd need to spend more time familiarizing myself with 
the source. I'll dig deeper if you still can't find it.

Original comment by pilota51 on 29 Nov 2010 at 11:49

GoogleCodeExporter commented 8 years ago
We now scale the icon in the code. If the Android framework is scaling as well 
that might cause issues. We'll investigate - feel free to update this issue 
with any other information you have as well.

Original comment by jpin...@google.com on 30 Nov 2010 at 9:54

GoogleCodeExporter commented 8 years ago
Got it working in source!

In CustomAdapter under displayCustom() where iconImageView and frameImageView 
are configured, remove .setScaleType(ScaleType.CENTER) and change the width for 
RelativeLayout.LayoutParams to (int)px50.

Original comment by pilota51 on 4 Dec 2010 at 6:03

GoogleCodeExporter commented 8 years ago
Hi guys

The <supports-screens/> element in the Manifest was causing me all the 
problems. If I set [android:anyDensity="true"] then I have problems with the 
house Icon scaling on platforms 1.6 and above. If I set 
[android:anyDensity="false"] then the icon scales correctly. 

Hope this helps.
Thanks for the great work on this btw. 

Don

Original comment by dole...@google.com on 4 Dec 2010 at 3:47

GoogleCodeExporter commented 8 years ago
Any news about whether my fix will be implemented? If it's not good enough for 
whatever reason and my help might still be useful I'd like to know so I could 
look into alternative fixes. Otherwise I'd just like some assurance that it has 
been seen and will be included in the next release.

Original comment by pilota51 on 18 Dec 2010 at 10:12

GoogleCodeExporter commented 8 years ago
Hi Pilota51, 

Thanks for taking the time to debug the issue - we really appreciate it. 

I made your changes and ran the application, and the icon does show up as 
50dip. I think that this issue is stemming from the AdWhirl icon & text ad type 
itself. The banner should be 50dip, but the icon should not take up that entire 
space vertically. If you go to the "House Ads" tab and click on "Preview", you 
should see what the intended display of the ad should be (with possible 
differences in background color).

If I'm misunderstanding the issue could you please attach a screenshot to 
clarify?

Original comment by jpin...@google.com on 20 Dec 2010 at 6:26

GoogleCodeExporter commented 8 years ago
I see what you mean and even expected it to take up the vertical space, but it 
didn't and looked fine when I tested it. Further testing revealed that my fix 
worked when targetSdkVersion was 4 or higher and broke with SDK3 in the manner 
you describe.

I figured it was mostly a matter of detecting the difference between a target 
of 3 and of 4+. I found that adWhirlLayout.custom.image.getIntrinsicHeight() 
was constantly 38 when the target SDK was 3 or undefined, but with the target 
SDK set to 4 the value changed depending on density, 38 being mdpi which wasn't 
visually affected by this bug, 25 for hdpi, and 51 for ldpi.

Here's my new fix:
    int iconScale = android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
    if (adWhirlLayout.custom.image.getIntrinsicHeight() != 38) {
        iconScale = (int)(48*density);
    }
For both iconImageView and frameImageView:
    .setScaleType(ScaleType.FIT_CENTER);
    Set width in LayoutParams to iconScale.

It works perfectly as far as I can tell. Let me know how it goes for you.

Original comment by pilota51 on 21 Dec 2010 at 3:15

GoogleCodeExporter commented 8 years ago
Hmm I see what you mean - what an annoying bug. 

The issue has to do with the framework scaling or not scaling the image. So we 
don't get confused by the language (there are different ways to scale), I'll 
try to explain fully.

In Android 1.5 (v3), the image is being displayed in the same physical size in 
pixels, so it is scaled up to maintain that size on the screen. In Android 1.6+ 
(v4+), the image is being keep the same size in intrinsic pixels, so it appears 
that it is being scaled down when it displays on the higher density screen.

Your suggestion does work for me as well. We'll include it in the next release.

Original comment by jpin...@google.com on 21 Dec 2010 at 7:42

GoogleCodeExporter commented 8 years ago
I still get this problem with the latest 2.6.1.

Original comment by seymo...@gmail.com on 13 Jan 2011 at 9:02

GoogleCodeExporter commented 8 years ago
2.6.1 appears to fix it for me. Although with the latest source and change log 
still on 2.6.0 I can't be sure if it's fixed exactly the way I fixed it (which 
I tested rather extensively). According to comment 16, I'm assuming it was.

Sort of as an experiment I created a clone project where I've applied the fix.

If you still have this problem, more details will be necessary to determine if 
it's even the same issue. For example the hardware/emulators you've tested on, 
Android versions, and any specific steps to reproduce or work around it. Does 
the workaround I posted earlier (don't set targetSdkVersion in manifest) work?

Original comment by pilota51 on 15 Jan 2011 at 5:35

GoogleCodeExporter commented 8 years ago
pilota51, tweaking the manifest for screen size works. Thanks! :-)

Original comment by t...@favoritemedium.com on 19 Jan 2011 at 8:35

GoogleCodeExporter commented 8 years ago
hello, ads still show up very small using the banner and 2.6.1  I have been 
using admob house ads as a work around.  Please email me and I would be happy 
to send you any details you need to debug.
Thanks
Jake

Original comment by JacobrJo...@gmail.com on 23 Jan 2011 at 10:31

GoogleCodeExporter commented 8 years ago
It's broken again in 2.6.2...
What's going on and why is the public source still at 2.6.0?

Original comment by pilota51 on 28 Jan 2011 at 12:56

GoogleCodeExporter commented 8 years ago
Is this why on my emulator my house ads look great but on my droid incredible 
they are really small(definately not 52dip) please someone respond.  Is there 
anyway to fix this?  Or does adwhirl have to fix this?

    <LinearLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:myapp="http://schemas.android.com/apk/res/com.jayavon.larrysoundboard"
        android:orientation="vertical"
        android:layout_width="fill_parent" 
        android:layout_height="52dip">
        <com.adwhirl.AdWhirlLayout
            android:id="@+id/adwhirl_layout"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" /> 
    </LinearLayout> 

Original comment by jaya...@gmail.com on 28 Jan 2011 at 2:09

GoogleCodeExporter commented 8 years ago
What density is the emulator set to? If it's HVGA (160) you won't see the 
problem, to see it the density needs to be WVGA (240) like your Droid 
Incredible or QVGA (120) which makes the icon appear too big.

If you read through the comments, I've posted the workaround a few times. But 
as I indicated in my last 2 comments, my testing shows that 2.6.1 is the only 
release that does not have this issue. Give it a try and if that fails then try 
the workaround and report back.

Original comment by pilota51 on 28 Jan 2011 at 2:43

GoogleCodeExporter commented 8 years ago
I don't know if this is related, but I am experiencing problems with banner 
house ads also being shown very small on WVGA screen (Samsung Galaxy S i9000, 
Android 2.1. update 1). I use a modified version of the public Android source 
(which seems not to be the latest version? ref comment 21)

Getting the intrinsic height of the custom.image for the banner yields a value 
of 33 pixels. The banner image was uploaded as a png file with dimensions 
320x50. What's up with this? Does the server scale the image in some way?

Regards,
Leif

                final int ih = custom.image.getIntrinsicHeight();
                Log.d(AdWhirlUtil.ADWHIRL, "Banner intrinsic height = " + String.valueOf(ih));

Original comment by LeifRi...@gmail.com on 31 Jan 2011 at 10:11

GoogleCodeExporter commented 8 years ago
Digging a little deeper, it seems maybe that the core issue might be the 
creation of the Drawable from the image stream in the 
AdWhirlManager.fetchImage(..) method:

      InputStream is = (InputStream) url.getContent();
      Drawable d = Drawable.createFromStream(is, "src");

When replacing the above with the following, the problems seem to disappear on 
my Samsung, and also seems to work on HVGA and QVGA emulator skins. Maybe 
someone could try it on actual devices?

      final BitmapFactory.Options options = new BitmapFactory.Options();
      options.inScaled = true;
      options.inDensity = DisplayMetrics.DENSITY_DEFAULT;
      options.inTargetDensity = resources.getDisplayMetrics().densityDpi;
      options.inDither = true;
      final Bitmap bitmap = BitmapFactory.decodeStream(is, null, options);
      final Drawable d = new BitmapDrawable(resources, bitmap);

In order to do this I had to pass along the Resources object in order to be 
able to get the value for the target density.

Regards,

Leif

Original comment by LeifRi...@gmail.com on 1 Feb 2011 at 8:32

GoogleCodeExporter commented 8 years ago
Hi, 99% sure both icon in text house ad and banner house ad is affected by this 
bug too.

Can we fix it right now?

Original comment by doqkh...@gmail.com on 10 Feb 2011 at 3:22

GoogleCodeExporter commented 8 years ago
I've tested this on versions 2.6.1, 2.6.2, and 2.63 of the sdk and none of them 
have resolved this issue.

Original comment by amirk...@gmail.com on 16 Mar 2011 at 11:57

GoogleCodeExporter commented 8 years ago
The problem already happens in last release (2.6.3), why the bug state is set 
to Fixed?

Original comment by ljann...@gmail.com on 21 Mar 2011 at 9:09

GoogleCodeExporter commented 8 years ago
I just deployed a banner ad in 320x50 resolution as suggested and it is scaled 
to about 1/4 of the size. This is using version 2.6.3.

I can't believe this issue isn't prioritized more, almost everyone is using 
HDPI devices..

Original comment by sve...@gmail.com on 31 Mar 2011 at 11:57

GoogleCodeExporter commented 8 years ago
I am facing the same issue even with version 3.0
This is ridiculous

Original comment by mvision....@gmail.com on 4 Apr 2011 at 3:50

GoogleCodeExporter commented 8 years ago
I can confirm this is NOT FIXED in v3.0.0.

I've also looked at the source and found that my suggested fix has not been 
applied, let alone CustomAdapter not even changed (in public source) since 
v2.6.0.

I'll make it even easier, here's my exact fix in a cloned project: 
https://code.google.com/r/pilota51-adwhirl/source/detail?r=031945e6eb9f5140dafbc
f151ebd73e19eced16e

It baffles me how it hasn't been fixed for several months and versions after a 
solution is provided when, as comment 29 mentioned, just about everyone these 
days uses an HDPI device which would be affected by this issue.

Original comment by pilota51 on 4 Apr 2011 at 8:09

GoogleCodeExporter commented 8 years ago
I can also confirm it is not fixed yet...

but I have found some nasty workaround, that works for image-only house ads... 
Other ad formats shure need adapted workarounds:

[code]
AdWhirlLayout adwhirl = new AdWhirlLayout(activity,adwhirlKey);

final int DIP_WIDTH = 320;
final int DIP_HEIGHT = 52;
final float DENSITY = 
MailApp.context.getResources().getDisplayMetrics().density;
final int scaledHeight = (int) (DENSITY * DIP_HEIGHT + 0.5f);
final int scaledWidth = (int) (DENSITY * DIP_WIDTH);

adwhirl.setOnHierarchyChangeListener(new OnHierarchyChangeListener() {
    @Override
    public void onChildViewRemoved(View parent, View child) {       }

    @Override
    public void onChildViewAdded(View parent, View child) {
        if (child instanceof RelativeLayout){
            RelativeLayout banner = (RelativeLayout)((RelativeLayout) child); 
                if(banner.getChildAt(0) instanceof ImageView){
                    // TODO other ad formats may be wrongly sized after that
                    ImageView im = (ImageView)banner.getChildAt(0);
                    im.setMinimumHeight(scaledHeight);
                    im.setMinimumWidth(scaledWidth);
                    im.setScaleType(ScaleType.FIT_XY);
                }
        }
    }
}); 
[/code]

Original comment by johannes...@gmail.com on 5 Apr 2011 at 9:20

GoogleCodeExporter commented 8 years ago
When will this be fixed?!?!?!

Original comment by jaya...@gmail.com on 4 May 2011 at 3:18

GoogleCodeExporter commented 8 years ago
I tried emailing the issue owner and it bounced back saying account disabled, 
so I think s/he is no longer working for AdWhirl/Google. I tried a couple other 
AdWhirl developers who have been somewhat active on the Android issues and so 
far no response or visible action after about a week. It looks like we might be 
waiting awhile longer for an official fix.

Original comment by pilota51 on 22 May 2011 at 9:58

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Is it fixed yet?

Original comment by nubee...@gmail.com on 4 Aug 2011 at 8:11

GoogleCodeExporter commented 8 years ago
Not fixed.

Original comment by gdonald on 3 Sep 2011 at 7:14

GoogleCodeExporter commented 8 years ago
The Adbanner is not adjusting properly in HTC evo 3d

Original comment by bene...@qburst.com on 17 Oct 2011 at 2:12

GoogleCodeExporter commented 8 years ago
Image house ads are still not showing properly on the latest sdk.

Original comment by paulino....@gmail.com on 10 Feb 2012 at 10:39

GoogleCodeExporter commented 8 years ago
Not fixed in 3.1.1

Original comment by info@enthusiastudios.com on 8 Mar 2012 at 12:56

GoogleCodeExporter commented 8 years ago
I am sorry but WTF? Does it take software engineers in Google 2+ years to fix 
this bug and it still remains not fiexed as I can tell? 
Please fix it guys so that AdWhirl users don't have to set minSDK to 3 in their 
apps in order to make this work.  

Original comment by roma...@it-dimension.com on 10 May 2012 at 9:53

GoogleCodeExporter commented 8 years ago
May the Forks be with you

Original comment by ivan.chu...@gmail.com on 13 May 2012 at 5:01