diff --git a/app/build.gradle b/app/build.gradle index e13c14951..bb27dc37c 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 'com.google.vr:sdk-panowidget:1.150.0' implementation 'org.apache.sanselan:sanselan:0.97-incubator' kapt "android.arch.persistence.room:compiler:1.1.1" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 601881fd6..e6b56c92d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,12 +1,16 @@ + + + + + isFullScreen = visibility and View.SYSTEM_UI_FLAG_FULLSCREEN != 0 + toggleButtonVisibility() + } + } + + private fun toggleButtonVisibility() { + cardboard.animate().alpha(if (isFullScreen) 0f else 1f) + cardboard.isClickable = !isFullScreen + + explore.animate().alpha(if (isFullScreen) 0f else 1f) + explore.isClickable = !isFullScreen + } + + private fun handleClick() { + isFullScreen = !isFullScreen + toggleButtonVisibility() + if (isFullScreen) { + hideSystemUI(false) + } else { + showSystemUI(false) + } + } +} diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt index 17201aee8..10c636fea 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt @@ -85,7 +85,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList } } - showSystemUI() + showSystemUI(true) val bundle = Bundle() val file = File(mUri.toString()) val type = when { @@ -201,9 +201,9 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList override fun fragmentClicked() { mIsFullScreen = !mIsFullScreen if (mIsFullScreen) { - hideSystemUI() + hideSystemUI(true) } else { - showSystemUI() + showSystemUI(true) } if (!bottom_actions.isGone()) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 014a40fda..87e029a27 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -207,7 +207,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View config.isThirdPartyIntent = true } - showSystemUI() + showSystemUI(true) val isShowingFavorites = intent.getBooleanExtra(SHOW_FAVORITES, false) val isShowingRecycleBin = intent.getBooleanExtra(SHOW_RECYCLE_BIN, false) @@ -379,7 +379,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View if (getMediaForSlideshow()) { view_pager.onGlobalLayout { if (!isActivityDestroyed()) { - hideSystemUI() + hideSystemUI(true) mSlideshowInterval = config.slideshowInterval mSlideshowMoveBackwards = config.slideshowMoveBackwards mIsSlideshowActive = true @@ -457,7 +457,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun stopSlideshow() { if (mIsSlideshowActive) { mIsSlideshowActive = false - showSystemUI() + showSystemUI(true) mSlideshowHandler.removeCallbacksAndMessages(null) window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) } @@ -1072,10 +1072,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun checkSystemUI() { if (mIsFullScreen) { - hideSystemUI() + hideSystemUI(true) } else { stopSlideshow() - showSystemUI() + showSystemUI(true) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt index 443440702..c912b0b53 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt @@ -78,15 +78,21 @@ fun SimpleActivity.launchAbout() { or LICENSE_SUBSAMPLING or LICENSE_PATTERN or LICENSE_REPRINT or LICENSE_GIF_DRAWABLE or LICENSE_PHOTOVIEW or LICENSE_EXOPLAYER, BuildConfig.VERSION_NAME, faqItems) } -fun AppCompatActivity.showSystemUI() { - supportActionBar?.show() +fun AppCompatActivity.showSystemUI(toggleActionBarVisibility: Boolean) { + if (toggleActionBarVisibility) { + supportActionBar?.show() + } + window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN } -fun AppCompatActivity.hideSystemUI() { - supportActionBar?.hide() +fun AppCompatActivity.hideSystemUI(toggleActionBarVisibility: Boolean) { + if (toggleActionBarVisibility) { + supportActionBar?.hide() + } + window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or 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 975f4e436..13abaf0b5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -1,5 +1,6 @@ package com.simplemobiletools.gallery.fragments +import android.content.Intent import android.content.res.Configuration import android.graphics.Bitmap import android.graphics.BitmapFactory @@ -26,12 +27,15 @@ import com.davemorrissey.labs.subscaleview.ImageSource import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.OTG_PATH +import com.simplemobiletools.commons.helpers.isLollipopPlus import com.simplemobiletools.gallery.R +import com.simplemobiletools.gallery.activities.PanoramaActivity import com.simplemobiletools.gallery.activities.PhotoActivity import com.simplemobiletools.gallery.activities.ViewPagerActivity import com.simplemobiletools.gallery.extensions.* import com.simplemobiletools.gallery.helpers.GlideRotateTransformation import com.simplemobiletools.gallery.helpers.MEDIUM +import com.simplemobiletools.gallery.helpers.PATH import com.simplemobiletools.gallery.helpers.ROTATE_BY_ASPECT_RATIO import com.simplemobiletools.gallery.models.Medium import it.sephiroth.android.library.exif2.ExifInterface @@ -65,6 +69,7 @@ class PhotoFragment : ViewPagerFragment() { photo_view.setOnClickListener { photoClicked() } instant_prev_item.setOnClickListener { listener?.goToPrevItem() } instant_next_item.setOnClickListener { listener?.goToNextItem() } + panorama_outline.setOnClickListener { openPanorama() } instant_prev_item.parentView = container instant_next_item.parentView = container @@ -290,6 +295,13 @@ class PhotoFragment : ViewPagerFragment() { } } + private fun openPanorama() { + Intent(context, PanoramaActivity::class.java).apply { + putExtra(PATH, medium.path) + startActivity(this) + } + } + private fun addZoomableView() { if (!context!!.config.replaceZoomableImages && medium.isImage() && isFragmentVisible && view.subsampling_view.isGone()) { ViewPagerActivity.wasDecodedByGlide = false @@ -342,7 +354,7 @@ class PhotoFragment : ViewPagerFragment() { false } - view.panorama_outline.beVisibleIf(isPanorama) + view.panorama_outline.beVisibleIf(isPanorama && isLollipopPlus()) } private fun getImageOrientation(): Int { diff --git a/app/src/main/res/drawable-hdpi/ic_cardboard.png b/app/src/main/res/drawable-hdpi/ic_cardboard.png new file mode 100644 index 000000000..0df820802 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_cardboard.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_explore.png b/app/src/main/res/drawable-hdpi/ic_explore.png new file mode 100644 index 000000000..ad948505a Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_explore.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_explore_off.png b/app/src/main/res/drawable-hdpi/ic_explore_off.png new file mode 100644 index 000000000..59363f9ab Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_explore_off.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_cardboard.png b/app/src/main/res/drawable-xhdpi/ic_cardboard.png new file mode 100644 index 000000000..1c978a019 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_cardboard.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_explore.png b/app/src/main/res/drawable-xhdpi/ic_explore.png new file mode 100644 index 000000000..c5e971610 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_explore.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_explore_off.png b/app/src/main/res/drawable-xhdpi/ic_explore_off.png new file mode 100644 index 000000000..a2cb5e92b Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_explore_off.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_cardboard.png b/app/src/main/res/drawable-xxhdpi/ic_cardboard.png new file mode 100644 index 000000000..71c05230d Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_cardboard.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_explore.png b/app/src/main/res/drawable-xxhdpi/ic_explore.png new file mode 100644 index 000000000..2260fa95e Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_explore.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_explore_off.png b/app/src/main/res/drawable-xxhdpi/ic_explore_off.png new file mode 100644 index 000000000..1007be3b7 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_explore_off.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_cardboard.png b/app/src/main/res/drawable-xxxhdpi/ic_cardboard.png new file mode 100644 index 000000000..d33c6ef77 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_cardboard.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_explore.png b/app/src/main/res/drawable-xxxhdpi/ic_explore.png new file mode 100644 index 000000000..e127a202b Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_explore.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_explore_off.png b/app/src/main/res/drawable-xxxhdpi/ic_explore_off.png new file mode 100644 index 000000000..a6638ac85 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_explore_off.png differ diff --git a/app/src/main/res/layout/activity_panorama.xml b/app/src/main/res/layout/activity_panorama.xml new file mode 100644 index 000000000..ab146f09e --- /dev/null +++ b/app/src/main/res/layout/activity_panorama.xml @@ -0,0 +1,33 @@ + + + + + + + + + + diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml new file mode 100644 index 000000000..7f1ac50b0 --- /dev/null +++ b/app/src/main/res/values-v21/styles.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 0be50415b..9bb53721a 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -2,4 +2,9 @@ + +