GalleryDialog is a library created to display images and 360 panoramic images in a comfortable and simple way. It allows adding explanatory text for the photo in a footer that appears and hides dynamically.
Currently, it only works with image loading via URL using Glide. In the future, I would like to add the option to pass created drawables or bitmaps.
Standard images use the TouchImageView library, which allows zooming through gestures.
360 images use the PanoramaGL library, which allows zooming through gestures and activating sensor rotation.
GalleryDialog ->
GalleryDialog360 ->
(Both galleries support screen rotation using the rotation button)
Both classes are DialogFragments, with a static function newInstance() to facilitate their creation.
I recommend creating an extended function to show the dialog when clicking on an ImageView.
// GalleryDialog
private fun ImageView.setGalleryDialogOnClick(position: Int) = setOnClickListener {
GalleryDialog.newInstance(
images,
position,
GalleryDialogOptions(
fileProviderAuthorities = "com.marcosanz.app",
errorDrawable = R.drawable.ic_launcher_foreground,
rotation = false
)
).show(supportFragmentManager, "gallery_dialog")
}
// Gallery360Dialog
private fun ImageView.setGallery360DialogOnClick(position: Int) = setOnClickListener {
Gallery360Dialog.newInstance(
images360[position],
Gallery360DialogOptions(
rotation = true,
sensorialRotation = true
)
).show(supportFragmentManager, "gallery_dialog")
}
With the DialogOptions classes, you can customize some minor settings, such as the texts displayed, allow rotation, or enable sensor rotation.
Check the sample app to see all these features implemented.
- To share images, you must declare a FileProvider and pass the FileProviderAuthorities through GalleryDialogOptions.
- If the Activity has the android:configChanges="layoutDirection" field set in the Manifest, screen rotation will not work correctly.
Add the Jitpack repository to your build.gradle file
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add the dependency in your module
dependencies {
implementation 'com.github.MarcoSanz12:GalleryDialog:{ LATEST_VERSION }'
}
GalleryDialog is available under the MIT license. Read the LICENSE.txt file for more information.