[android-developers] Measuring/drawing text on a scaled Canvas

2011-10-12 Thread noriato
Hi,

I've been struggling with text measuring and scaled canvases.

When the canvas is unscaled, getTextBounds and measureText deliver
accurate results. However, when the canvas is scaled both methods do
not deliver results that match the actual size of a printed text.

For testing I've created a subclass of View with the following onDraw
method:

final float scaling = 0.51f;
final int fontSize = 50;

canvas.scale(scaling, scaling);
font = Typeface.create(Arial, Typeface.NORMAL);

Paint paint = new Paint();
paint.setColor(0xffff);
paint.setTypeface(font);
paint.setTextSize(fontSize);
paint.setAntiAlias(true);

int x = 10;
int y = 100;
final String text = Lorem ipsum dolor sit amet, consectetur
adipisici elit...;
canvas.drawText(text, x, y, paint);

// draw border using getTextBounds

paint.setColor(0x);
paint.setStyle(Paint.Style.STROKE);
paint.setTypeface(font);
paint.setTextSize(fontSize);
Rect bounds = new Rect();
paint.getTextBounds(text, 0, text.length(), bounds);
bounds.offset(x, y);
paint.setColor(0x8000);
canvas.drawRect(bounds, paint);

// draw border using measureText

float w = paint.measureText(text);
bounds.left = x;
bounds.right = (int) Math.ceil(bounds.left + w);
bounds.top -= 10;
bounds.bottom += 10;
paint.setColor(0x8000);
paint.setPathEffect(new DashPathEffect(new float[] { 10, 10 },
0));
canvas.drawRect(bounds, paint);

for scaling = 0.5 I get the following output:
http://www.tiikoni.com/tis/view/?id=911e914

for scaling = 0.51 the following result is shown:
http://www.tiikoni.com/tis/view/?id=fad4658

(The actual result may vary depending on screen size, the important
part is that the results can vary completely when changing the scale
factor only a little)

The yellow solid border marks the rect delivered from getTextBounds,
the dashed cyan rect is rendered using the width delivered from
measureText.

As you can see, the text with scaling = 0.5 is smaller than the
measured dimensions and with scaling=0.51 the drawn text is way bigger
than the measured dimension.


Any help is appreciated!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Incorrect size for views with mm or inch dimensions

2011-06-22 Thread noriato
I've got a button having a layout_height of 10mm which looks correct
on most devices, but on for instance the Lg Optimus 2X and on the
Motorola Defy the buttons have about half the size:

I retrieved the DisplayMetrics info on those devices and here's a
short overview:

HTC Desire Z:   480x800, density : HIGH, xdpi: 254.0, ydpi: 254.0
Motorola Defy: 480x854, density : HIGH, xdpi: 96.0, ydpi: 96.0
Samsung Galaxy S2: 480x800, density : HIGH, xdpi: 217.71428, ydpi:
218.49463
LG Optimus 2X: 480x800, density : HIGH, xdpi: 160.0, ydpi: 160.0

As you can see the Desire Z and the Samsung have a reasonable looking
x/y-dpi value. the defy and the optimus deliver obsiously incorrect
values that I assume are the reason for the wrong size.

Is there any other way to get around that hardware bug/behaviour?
(Since the density delivers HIGH in all cases i cannot differentiate
the layout files via density / dimension.)

Or is it recommended not using mm/inch sizes at all?

TIA

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] GL_INVALID_OPERATION (1282) after glDrawElements using Vertex Buffer Objects (VBO)

2011-03-14 Thread noriato
Hi,
I'm working on a game using VBO for model rendering. Everything works
fine, except when I lose context and reload all the models and
textures I get a GL_INVALID_OPERATION error after calling
glDrawElements with my VBO.
Actually I have to lose context two times. Restoring after the first
time works fine.
This actually led me to assumtion that there's some kind of internal
out-of-memory error or alike.
But I don't get an GL_OUT_OF_MEMORY error but a GL_INVALID_OPERATION
error instead.

I tried both, actually using glGenTextures/glDeleteTextures and
glGenBuffers/glDeleteBuffers as well as just increasing the buffer ids
manually for each new buffer/texture. Both with the same result.

Any ideas?
Thanks
Peter

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] how many devices have the nexus one / HTC desire multi touch bug and would you release a game utilizing multitouch anyway?

2010-11-06 Thread noriato
Hi,
so there's the multitouch issue with the Nexus One and HTC Desire. Is
there some documentation on what other devices have this hardware
error and what the total market share is?

If you had a game idea that needs massive multitouch gestures, would
you go for it on Android or would it currently be a waste of time with
only a few devices supporting it?

Peter

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: OpenGL ES 2D and 3D mixed graphics?

2010-10-29 Thread noriato
well you can create an orthoview with the dimensions of the screen.
ie
glOrtho(0,0,320,480,0,20);

then you can use pixel coords to draw your stuff.. it would be non
perspective though.
Peter

On 29 Okt., 04:40, Matt Quigley matthew.quig...@gmail.com wrote:
 I'm making a 2D game, with sprites drawn using the glDrawTexfOES()
 method.  I'm wondering if there are ways to draw things like lines and
 squares along side this.

 Now, I know that technically there's nothing stopping me from drawing
 3D cubes and such.  But, you see, glDrawTexfOES draws using pixel
 coordinates, i.e. draw texture at 30,30.  What I'd like is a similar
 approach to boxes and lines, using pixel coordinates, i.e. draw line
 from (5,5) to (10,10).  Is this possible?

 I don't want to simulate 3D coordinates because it would be very hard
 to try to get the camera and perspective in such a perfect way where I
 could say draw cube from (5,5,0) to (10,10,0), as well as from
 (300,300,0) to (310, 310, 0), with no perspective warping in the
 different corners.  (Also, as a backup plan I can always create my
 line and box effects with sprite textures as well, but I thought I'd
 ask)

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: HTC Incredible reboot when downloading massive files.

2010-10-24 Thread noriato
I had a (maybe) similar error when downloading a lot of files with
each being around 1-5MB of size. I was filling a ByteArrayBuffer with
bytes read from a BufferedInputStream of the http connection. This
lead of a OutOfMemory error after a couple of files on some devices. I
assume the gc wasn't freeing the allocated memory quickly enough.

I then changed the code to allocating a byte buffer with the needed
size in advance and reading the whole stream into that buffer at once.
This fixed it for me.
Peter

On Oct 24, 7:51 am, nandroid zlu38...@gmail.com wrote:
 Our app need download a lot of files. Current it works on Samsung
 Galaxy but always makes HTC incredible reset with a sad
 announcementDroid.

 Does anybody know if HTC incredible has some limitation on network
 connections, downloading files/size, or memory leaking with
 downloading etc. issues?

 thanks,

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: LVL found to be easy to crack

2010-10-22 Thread noriato
So then the check for the checksum could be removed... same problem.
Peter

On 22 Okt., 07:50, Jose toco...@gmail.com wrote:
 I think that an easy way to tamper-proof apk would be:

 1) Android Market computes a checksum for the apk when the apk is
 uploaded
 2) In the License Response (eg. in one extra), Android Market send
 this value
 3) The aplication computes the same checsum of itself. If the values
 don`t match, just finis()

 This could be very easy to do for Android Market developers...

 Regards,
 Jose

 On Aug 24, 8:16 pm, Trevor Johns trevorjo...@google.com wrote:



  FYI: We have a blog post up on this topic. It covers many of the points I
  made earlier, but I figured it's worth pointing out.

 http://android-developers.blogspot.com/2010/08/licensing-server-news

  --
  Trevor Johns
  Google Developer Programs, Androidhttp://developer.android.com
  http://android-developers.blogspot.com/2010/08/licensing-server-news

  On Tue, Aug 24, 2010 at 8:26 AM, a1 arco...@gmail.com wrote:
But I'm not sure that native code is any harder to patch, and there
are still identifiable syscalls or calls back up to java for i/o to
show where it tries to accomplish verification.

   First of all it's much harder to bypass especially if you are dealing
   with optimized code and you will have to do it at least twice (for arm
   abi and armv7 abi). Event toolchain setup is more complicated.

   --
   Bart Janusz (Beepstreet)

   --
   You received this message because you are subscribed to the Google
   Groups Android Developers group.
   To post to this group, send email to android-developers@googlegroups.com
   To unsubscribe from this group, send email to
   android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs
cr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=e

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Internal Phone Storage Size

2010-10-15 Thread noriato

start an emulator on the command line like this:
emulator -partition-size size -avd virtual device name

emulator.exe can be found in the tools folder.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Bug in minSdkVersion or what?

2010-09-09 Thread noriato
Hi,
i also have the suspicion that the carriers filter out certain apps
based on the requested permission.
I have a app that requests permission for RECORD_AUDIO, and since i
use admob i also need INTERNET and ACCESS_COARSE_LOCATION.

And with request for RECORD_AUDIO permission i can't see my app in the
newest list but as soon as i remove the permission it shows up.
However, I can always search for the name of the app and find it, even
if it would not show up in the newest list.

My explanation would be that either google or the carriers filter out
completely or partly apps that either would be suitable for voip calls
( INTERNET + RECORD_AUDIO ) or in your case just plain phone apps
(CALL_PHONE) - but could just be the regular paranoia ;)

~Peter


On 9 Sep., 04:02, Lance Nanek lna...@gmail.com wrote:
 The version of aapt you are using, from Android 2.1, appears to be too
 old to show the uses-feature entries, by the way. Example:

 $ platforms/android-8/tools/aapt dump badging test.apk
 package: name='com.mytest' versionCode='1' versionName='1.0'
 application: label='myTest' icon='res/drawable-mdpi/icon.png'
 launchable activity name='com.mytest.MyTest'label='myTest' icon=''
 uses-permission:'android.permission.READ_CONTACTS'
 uses-permission:'android.permission.INTERNET'
 uses-permission:'android.permission.ACCESS_NETWORK_STATE'
 uses-permission:'android.permission.ACCESS_COARSE_LOCATION'
 uses-permission:'android.permission.ACCESS_COARSE_UPDATES'
 uses-permission:'android.permission.READ_PHONE_STATE'
 uses-permission:'android.permission.CALL_PHONE'
 sdkVersion:'4'
 targetSdkVersion:'8'
 uses-feature:'android.hardware.location'
 uses-feature:'android.hardware.location.network'
 uses-feature:'android.hardware.telephony'
 uses-feature:'android.hardware.touchscreen'
 main
 supports-screens: 'small' 'normal' 'large'
 locales: '--_--'
 densities: '120' '160' '240'

 $ platforms/android-7/tools/aapt dump badging test.apk
 package: name='com.mytest' versionCode='1' versionName='1.0'
 application: label='myTest' icon='res/drawable-mdpi/icon.png'
 launchable activity name='com.mytest.MyTest'label='myTest' icon=''
 uses-permission:'android.permission.READ_CONTACTS'
 uses-permission:'android.permission.INTERNET'
 uses-permission:'android.permission.ACCESS_NETWORK_STATE'
 uses-permission:'android.permission.ACCESS_COARSE_LOCATION'
 uses-permission:'android.permission.ACCESS_COARSE_UPDATES'
 uses-permission:'android.permission.READ_PHONE_STATE'
 uses-permission:'android.permission.CALL_PHONE'
 sdkVersion:'4'
 targetSdkVersion:'8'
 main
 supports-screens: 'small' 'normal' 'large'
 locales: '--_--'
 densities: '120' '160' '240'

 They don't look particularly relevant in this case anyway, but just so
 you know in the future. I suppose maybe it could matter here if
 carriers are capable of specifying the Market shouldn't show things
 like telephony apps on devices on their network and some did so and
 some didn't?

 On Sep 3, 8:04 pm, Gustavo gumat...@gmail.com wrote:



  Thanks for the quick reply Lance,

  So I read that post and seems that my app is perfectly fine.

  gust...@gustavo-desktop:/opt/android/platforms/android-2.1/tools$ ./
  aapt dump badging /home/gustavo/android_app/test_app.apk
  package: name='com.test.android' versionCode='1' versionName='1.0'
  application: label='Test' icon='res/drawable-mdpi/icon.png'
  launchable activity name='com.test.android.MainActivity'label=''
  icon=''
  uses-permission:'android.permission.ACCESS_COARSE_UPDATES'
  uses-permission:'android.permission.READ_PHONE_STATE'
  uses-permission:'android.permission.CALL_PHONE'
  uses-permission:'android.permission.INTERNET'
  uses-permission:'android.permission.ACCESS_NETWORK_STATE'
  uses-permission:'android.permission.ACCESS_COARSE_LOCATION'
  uses-permission:'android.permission.READ_CONTACTS'
  sdkVersion:'4'
  main
  other-activities
  other-services
  supports-screens: 'small' 'normal' 'large'
  locales: '--_--'
  densities: '120' '160' '240'

  I don't think there's nothing wrong with it.

  manifest.xml:

          uses-permission
  android:name=android.permission.ACCESS_COARSE_UPDATES
  android:required=false/
          uses-permission android:name=android.permission.READ_PHONE_STATE
  android:required=false/
          uses-permission android:name=android.permission.CALL_PHONE
  android:required=true/
          uses-permission android:name=android.permission.INTERNET
  android:required=true/
          uses-permission
  android:name=android.permission.ACCESS_NETWORK_STATE
  android:required=false/
          uses-permission
  android:name=android.permission.ACCESS_COARSE_LOCATION
  android:required=false /
          uses-permission android:name=android.permission.READ_CONTACTS
  android:required=false /

          supports-screens android:largeScreens=true
                  android:normalScreens=true android:smallScreens=true
                  android:anyDensity=true /

          uses-sdk android:minSdkVersion=4 /