diff --git a/app/build.gradle b/app/build.gradle index 0d3df92d8..e13c14951 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -55,6 +55,7 @@ dependencies { implementation 'com.github.chrisbanes:PhotoView:2.1.3' implementation 'com.android.support.constraint:constraint-layout:1.1.2' implementation 'com.google.android.exoplayer:exoplayer-core:2.8.2' + implementation 'org.apache.sanselan:sanselan:0.97-incubator' kapt "android.arch.persistence.room:compiler:1.1.1" implementation "android.arch.persistence.room:runtime:1.1.1" diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index d69f35829..975f4e436 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -36,6 +36,8 @@ import com.simplemobiletools.gallery.helpers.ROTATE_BY_ASPECT_RATIO import com.simplemobiletools.gallery.models.Medium import it.sephiroth.android.library.exif2.ExifInterface import kotlinx.android.synthetic.main.pager_photo_item.view.* +import org.apache.sanselan.common.byteSources.ByteSourceInputStream +import org.apache.sanselan.formats.jpeg.JpegImageParser import pl.droidsonroids.gif.GifDrawable import java.io.File import java.io.FileOutputStream @@ -46,6 +48,7 @@ class PhotoFragment : ViewPagerFragment() { private var isFullscreen = false private var wasInit = false private var useHalfResolution = false + private var isPanorama = false private var imageOrientation = -1 private var gifDrawable: GifDrawable? = null @@ -118,6 +121,7 @@ class PhotoFragment : ViewPagerFragment() { loadImage() initExtendedDetails() wasInit = true + checkIfPanorama() return view } @@ -329,6 +333,18 @@ class PhotoFragment : ViewPagerFragment() { } } + private fun checkIfPanorama() { + isPanorama = try { + val inputStream = if (medium.path.startsWith("content:/")) context!!.contentResolver.openInputStream(Uri.parse(medium.path)) else File(medium.path).inputStream() + val imageParser = JpegImageParser().getXmpXml(ByteSourceInputStream(inputStream, medium.name), HashMap()) + imageParser.contains("GPano:UsePanoramaViewer=\"True\"", true) + } catch (e: Exception) { + false + } + + view.panorama_outline.beVisibleIf(isPanorama) + } + private fun getImageOrientation(): Int { val defaultOrientation = -1 var orient = defaultOrientation diff --git a/app/src/main/res/drawable-hdpi/ic_panorama.png b/app/src/main/res/drawable-hdpi/ic_panorama.png new file mode 100644 index 000000000..ab2b517b7 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_panorama.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_panorama.png b/app/src/main/res/drawable-xhdpi/ic_panorama.png new file mode 100644 index 000000000..8d1a82b24 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_panorama.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_panorama.png b/app/src/main/res/drawable-xxhdpi/ic_panorama.png new file mode 100644 index 000000000..7dd982b25 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_panorama.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_panorama.png b/app/src/main/res/drawable-xxxhdpi/ic_panorama.png new file mode 100644 index 000000000..bc6292769 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_panorama.png differ diff --git a/app/src/main/res/layout/pager_photo_item.xml b/app/src/main/res/layout/pager_photo_item.xml index deb877e71..3a9b587bc 100644 --- a/app/src/main/res/layout/pager_photo_item.xml +++ b/app/src/main/res/layout/pager_photo_item.xml @@ -18,6 +18,16 @@ android:layout_height="match_parent" android:visibility="gone"/> + +