Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Declared constant for Android contact photo size?

Contact photos are 96x96 on my Nexus S. I really don't want to 'bake' that knowledge into my code - is there a constant somewhere that declares this? I've looked, but can't seem to find one.

like image 927
Jon Shemitz Avatar asked Aug 05 '11 21:08

Jon Shemitz


1 Answers

In android 2.3+ there is a ThumbnailUtils class that has

/**
 * Constant used to indicate the dimension of micro thumbnail.
 * @hide Only used by media framework and media provider internally.
 */
public static final int TARGET_SIZE_MICRO_THUMBNAIL = 96;

but that @hide hides it from us.

Looking at the Contacts app source code, file AttachImage.java I found another interesting thing:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent result) {
    // omitted

    if (requestCode == REQUEST_PICK_CONTACT) {
        // A contact was picked. Launch the cropper to get face detection, the right size, etc.
        // TODO: get these values from constants somewhere
        Intent myIntent = getIntent();
        Intent intent = new Intent("com.android.camera.action.CROP", myIntent.getData());
        if (myIntent.getStringExtra("mimeType") != null) {
            intent.setDataAndType(myIntent.getData(), myIntent.getStringExtra("mimeType"));
        }
        intent.putExtra("crop", "true");
        intent.putExtra("aspectX", 1);
        intent.putExtra("aspectY", 1);
        intent.putExtra("outputX", 96);
        intent.putExtra("outputY", 96);
        intent.putExtra("return-data", true);
        startActivityForResult(intent, REQUEST_CROP_PHOTO);

That TODO and those intent.putExtra say a lot, even if there is a thumbnail size constant, it isn't used in the contact app.

like image 171
grprado Avatar answered Oct 08 '22 08:10

grprado