From https://github.com/vikaskanani/Android-Custom-Gallery-And-Instant-Upload.git