10
votes

I'm an getting a list of files in a folder. The response contains a iconLink for every file returned. This icon is 16x16 pixels.

Does anyone know a way to retrieve a retina image? Or another way to retrieve a bigger icon image?

https://developers.google.com/drive/v2/reference/files

top: Google Drive UI

bottom: Google Drive API integration

Example

3
What have you done so far? In every file returned, have you tried to re-size the icon image in a bigger icon? - Android Enthusiast
The icon url returned leads to a 16x16 pixel image. (eg ssl.gstatic.com/docs/doclist/images/icon_12_pdf_list.png). I tried to add @2x to see if thats available, but no luck so far - Mark Mooibroek
Did you find a solution for this? - Daniel Dudas
Nope not yet ;-( Maybe we will get an answer with a bounty on it - Mark Mooibroek

3 Answers

3
votes

The good news is although not officailly documented driver does have 2x resolution icons. The bad news is they have inconsistent file names; for example the icon you linked in the comments has a 32px version availabel here: ssl.gstatic.com/docs/doclist/images/mediatype/icon_3_pdf_x32.png

Now here is my soltion, it's not perfect but it will do the job for a while:

function getIcons($file_type)
{ 
    $icons = [
        'pdf' => [
            'icon' => 'icon_12_pdf_list.png',
            'retina' => 'icon_3_pdf_x32.png'
         ],
        'document' => [
            'icon' => 'icon_1_document_x16.png',
            'retina' => 'icon_1_document_x32.png'
        ],
        'image' => [
            'icon' => 'con_1_image_x16.png',
            'retina' => 'icon_1_image_x32.png'
        ],
        'word' => [
            'icon' => 'icon_1_word_x16.png',
            'retina' => 'icon_1_word_x32.png'
        ],
        'text' => [
            'icon' => 'icon_1_text_x16.png',
            'retina' => 'icon_1_text_x32.png'
        ],
        'spreadsheet' => [
            'icon' => 'icon_1_spreadsheet_x16.png',
            'retina' => 'icon_1_spreadsheet_x32.png'
        ],
        'form' => [
            'icon' => 'icon_2_form_x16.png',
            'retina' => 'icon_2_form_x32.png'
        ],
        'audio' => [
            'icon' => 'icon_1_audio_x16.png',
            'retina' => 'icon_1_audio_x32.png'
        ]
    ];

    return isset($icons[$file_type]) ? $icons[$file_type] : $icons['text'];
}

The reasion I say it will work for a while is that I'm asuming the _3_ in pdf icon file name for instance is the version number. So if Google updates it's icons again in the future this solution may brake.

2
votes

I'm using drive rest api and what i observed was that iconLink attribute had a definite pattern. "https://drive-thirdparty.googleusercontent.com/" + size + mimetype By default size is 16. So, before adding your icon to Image, use this:

    String iconLink = (String) jsonObject.get("iconLink");
    iconLink=iconLink.replace("16","128");

check out these both links: https://drive-thirdparty.googleusercontent.com/128/type/application/pdf https://drive-thirdparty.googleusercontent.com/16/type/application/pdf

0
votes

Looks like images with x128 also added/present for various versions:

Ver. 1

Ver. 2

Ver. 3

Better to replace the x16 from the fetched iconLink and replace it with x128.