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 works with:
- Drawable resources
- Uris
- URL using Glide
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 Builder class to facilitate their creation.
I recommend creating an extended function to show the dialog when clicking on an ImageView.
// GalleryDialog
private fun ImageView.setGalleryDialogOnClick() = setOnClickListener {
GalleryDialog.Builder
.createWithUrl(
url = "{url}",
alt = "Test image"
)
.setErrorDrawable(R.drawable.errorDrawable)
.setAllowRotation(true)
.setFileProviderAuthorities("{your_file_provider_authorities}")
.build()
.show(supportFragmentManager, "gallery_dialog")
}
// Gallery360Dialog
private fun ImageView.setGallery360DialogOnClick() = setOnClickListener {
Gallery360Dialog.Builder
.createWithUrl(
url = "{url}",
alt = "Test image"
)
.setErrorDrawable(R.drawable.errorDrawable)
.setAllowRotation(true)
.setSensorialRotation(true)
.build()
.show(supportFragmentManager, "gallery_dialog")
}
With the Builder functions, 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.