[MOD][FIX] Gallery3D - high-resolution, stock and HTC cameras [update 28-Apr-2011]

Search This thread

Jack_R1

Senior Member
Aug 9, 2009
4,362
964
Since Enomther ported HTC camera to Nexus, one issue was plaguing it. The same issue is present for Desire users that like Gallery3D.

The default sort for folders in Gallery3D is ascending - the oldest photo is shown first, the newest is last. But since it's not comfortable for the "Camera" folder, in which you want to see the last made photo without scrolling to the end, it (and also "download" folder) is sorted descending - the latest photo shows on top.
When you use HTC Camera (or just happen to have Desire), it saves photos under 100MEDIA folder, which is sorted ascending, like any regular folder. And looking at the last taken photo becomes a long task.

So, to save HTC Camera users the pain, I've modified the Gallery3D. The default camera folder always shows in Gallery as "Camera", on the top of the list, and is sorted descending. I've adjusted it to suit the different actual folders.


Update log
v0.3
Changed to Edify scripting for installation on Clockworkmod 3.x.

v0.2
- Rebased Gallery3D on Cyanogen repo - performance increases and high-res patch built in.
- Single file for both stock and HTC Camera.
- If directory "DCIM/100MEDIA" exists on SD card, Gallery assumes HTC Camera mode, using 100MEDIA as default Camera folder. If not - it uses the regular Camera folder.

v0.1
- Based on Froyo AOSP repo, 2.2.1.
- Two versions: for stock Camera and for HTC Camera.
- Added high resolution Gallery3D patch by Number22.
- For HTC Camera version - Changed the Gallery3D to use "100MEDIA" as the default Camera folder.


Instructions

Flash corresponding ZIP in recovery. It refreshes the thumbnails (erases /sdcard/Android/data/com.cooliris.media) upon flash.

HTC Camera users on Nexus ROMs: if you have any photos left in your default "Camera" folder, you'll see 2 "Camera" folders in Gallery - one with camera icon and one with folder icon. To avoid confusion, please rename "Camera" folder to "OldCamera" before flashing or before running, or move the photos from there to "100MEDIA" folder.



Thanks go to Number22 for high res patch, Cyanogen for higher Gallery3D performance.


Source

Line 47, replace with:
Code:
    public static final String CAMERA_STRING = getCameraName();
Line 53, add:
Code:
    public static String getCameraName() {
	if ((new File(Environment.getExternalStorageDirectory().toString() + "/DCIM/" + "100MEDIA")).exists()) {
	    return "100MEDIA";
	}
        return "Camera";
    }
 

Attachments

  • old_Gallery3D_high_res_for_HTC_Camera_v0.1.zip
    403.3 KB · Views: 122
  • old_Gallery3D_high_res_for_stock_Camera_v0.1.zip
    403.3 KB · Views: 175
  • Gallery3D_high_res_fast_for_HTC_stock_Camera_v0.2.zip
    503.8 KB · Views: 967
  • Gallery3D_high_res_fast_for_HTC_stock_Camera_v0.3.zip
    660.3 KB · Views: 756
Last edited:

mik101

Senior Member
Jul 13, 2010
765
194
Works great here too. Wish the high-resolution fix would be implemented into the stock gallery app in cm6 (if it hasnt already, i haven't checked in a while). Thanks!
 

Qwest905

Senior Member
Aug 9, 2010
254
44
if i install the stock camera ...would it change the folder that my camera saves the pictures it takes???..or will it stay as normal

it will only change if i had the HTC camera right?
 

vk2bea

Senior Member
Sep 7, 2009
247
13
Washington D.C.
New pictures with wrong name ..

When a new picture is taken it appears with the wrong name and no geo tag (as you noted in the post in Enomthers' thread). I've restarted the gallery3D but this doesn't correct the issue. It only seems to be corrected with a reboot.

Is there something short of a reboot I can do to see the correct name / tag ?
 

Jack_R1

Senior Member
Aug 9, 2009
4,362
964
if i install the stock camera ...would it change the folder that my camera saves the pictures it takes???..or will it stay as normal

it will only change if i had the HTC camera right?

The folder that your camera saves the pictures to is determined ONLY by your camera. This Gallery3D was modified to enable HTC Camera users to have the same benefits as stock camera users - having their default camera album sorted in reverse.


When a new picture is taken it appears with the wrong name and no geo tag (as you noted in the post in Enomthers' thread). I've restarted the gallery3D but this doesn't correct the issue. It only seems to be corrected with a reboot.

Is there something short of a reboot I can do to see the correct name / tag ?

This is most probably HTC Camera incompatibility that needs to be addressed. I suppose (I'm not sure - since I don't know how it works, Enomther or Cyanogen team would be the right people to know for sure) that intent is passed from Camera to Gallery (since the Gallery refreshes the new photo - if you just try to copy the photo to SD card by ADB, it won't "see" the photo until the media info is refreshed), but the Gallery doesn't read the information correctly (maybe because some information is passed incorrectly between HTC Camera and Gallery).

I'll try to assist Enomther in making HTC Camera and Gallery3D compatible.

As noted by vk2bea, this is the regular Gallery3D with fixes/patches that show higher resolution images without degrading the resolution like stock Gallery3D (for details, see the thread that I've linked to), and HTC Camera users from various ROMs get their own version that sorts the photos in their default camera folder correctly.
 

Jack_R1

Senior Member
Aug 9, 2009
4,362
964
Ever since CM6 final (kangorama) my phone had not displayed any pictures in the gallery, it was useless pretty much this actually fixed my gallery and now everything is displayed. Thanks a million jack. Got a donation link??

I'm not much of a dev, so I didn't set up that kind of thing :) I'm glad you got your problems solved, most probably it's the thumbnail cache clearing process that helped you. I've experienced lots of weird behavior when I was trying to test the changes between stock and HTC cameras, but clearing thumbnail cache each time made these changes seamless.
 

DBBGBA

Senior Member
Apr 9, 2010
232
28
New York
can you post the source code?

also I have some folders with a .nomedia file but the gallery seems to ignore that... I don't know if it's this Gallery3D problem or a general problem coming from google.
 

Jack_R1

Senior Member
Aug 9, 2009
4,362
964
also I have some folders with a .nomedia file but the gallery seems to ignore that... I don't know if it's this Gallery3D problem or a general problem coming from google.

Gallery3D doesn't scan the media, it's coming from Media Provider.
Check that your .nomedia file is correct (I have 3 on my SD card and they work like they should), and try to unmount/remount the SD card, reboot and clear the thumbnail cache (installation of this Gallery3D does it).
 

Jack_R1

Senior Member
Aug 9, 2009
4,362
964
Source for HTC Gallery fix:
/src/com/cooliris/media/LocalDataSource.java

Replace:
Code:
  46     public static final String CAMERA_STRING = "Camera";
With:
Code:
  46     public static final String CAMERA_STRING = "100MEDIA";


Source for the high res fix:
/src/com/cooliris/media/Utils.java

Replace:
Code:
 287             roundedSize = (initialSize + 7) / 8 * 8;
 288         }
 289 
 290         return roundedSize;

With:
Code:
            roundedSize = (initialSize + 7) ;
        }
        int vmHeapSizeMB = (int) Runtime.getRuntime().maxMemory()/1048576; // Get the VM heapsize in mBytes
        int respatchQualityFactor = vmHeapSizeMB/12; // Double the quality for 24mB devices and quadruple it for 36mB devices
        int result = roundedSize/respatchQualityFactor;
        if(result<=1) return 1;
        	else return result;

As seen here, from the linked thread in Desire forum by Number22:
http://github.com/mrPjer/android_pa.../blob/froyo/src/com/cooliris/media/Utils.java
 

britoso

Senior Member
Jan 13, 2010
2,794
302
Orlando
Rodrigo didn't mention if his MIUI ROM included this, so I copied over the stock version and it works fine. thanks.