From f1b0e6a0018ce5f48c64f8e74c65c28db033c1f6 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 21 Oct 2018 21:44:39 +0200 Subject: [PATCH] adding some bottom gradient to panoramas for easier button visibility --- .../gallery/activities/PanoramaPhotoActivity.kt | 14 +++++++++----- .../gallery/activities/PanoramaVideoActivity.kt | 17 +++++++++-------- .../main/res/layout/activity_panorama_photo.xml | 7 +++++++ .../main/res/layout/activity_panorama_video.xml | 7 +++++++ 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PanoramaPhotoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PanoramaPhotoActivity.kt index 27584fdc9..a1dfb2664 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PanoramaPhotoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PanoramaPhotoActivity.kt @@ -12,6 +12,7 @@ import android.widget.RelativeLayout import com.google.vr.sdk.widgets.pano.VrPanoramaEventListener import com.google.vr.sdk.widgets.pano.VrPanoramaView import com.simplemobiletools.commons.extensions.beVisible +import com.simplemobiletools.commons.extensions.onGlobalLayout import com.simplemobiletools.commons.extensions.showErrorToast import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE @@ -166,14 +167,17 @@ open class PanoramaPhotoActivity : SimpleActivity() { } (explore.layoutParams as RelativeLayout.LayoutParams).bottomMargin = navigationBarHeight + + cardboard.onGlobalLayout { + panorama_gradient_background.layoutParams.height = navBarHeight + cardboard.height + } } 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 + arrayOf(cardboard, explore, panorama_gradient_background).forEach { + it.animate().alpha(if (isFullscreen) 0f else 1f) + it.isClickable = !isFullscreen + } } private fun handleClick() { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PanoramaVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PanoramaVideoActivity.kt index 30e76ad5a..3e65534ff 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PanoramaVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PanoramaVideoActivity.kt @@ -56,7 +56,7 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) } - setupButtonMargins() + setupButtons() cardboard.setOnClickListener { vr_video_view.displayMode = CARDBOARD_DISPLAY_MODE @@ -179,7 +179,7 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList override fun onConfigurationChanged(newConfig: Configuration?) { super.onConfigurationChanged(newConfig) - setupButtonMargins() + setupButtons() } private fun setupDuration(duration: Long) { @@ -256,7 +256,7 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList }, HIDE_PLAY_PAUSE_DELAY) } - private fun setupButtonMargins() { + private fun setupButtons() { val navBarHeight = navigationBarHeight video_time_holder.apply { (layoutParams as RelativeLayout.LayoutParams).bottomMargin = navBarHeight @@ -270,16 +270,17 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList bottomMargin = navBarHeight + video_time_holder.height rightMargin = navigationBarWidth } + vr_view_gradient_background.layoutParams.height = navBarHeight + video_time_holder.height + explore.height explore.requestLayout() } } private fun toggleButtonVisibility() { - cardboard.animate().alpha(if (mIsFullscreen) 0f else 1f) - cardboard.isClickable = !mIsFullscreen - - explore.animate().alpha(if (mIsFullscreen) 0f else 1f) - explore.isClickable = !mIsFullscreen + val newAlpha = if (mIsFullscreen) 0f else 1f + arrayOf(cardboard, explore, vr_view_gradient_background).forEach { + it.animate().alpha(newAlpha) + it.isClickable = !mIsFullscreen + } var anim = android.R.anim.fade_in if (mIsFullscreen) { diff --git a/app/src/main/res/layout/activity_panorama_photo.xml b/app/src/main/res/layout/activity_panorama_photo.xml index ff13ef97c..4592d8838 100644 --- a/app/src/main/res/layout/activity_panorama_photo.xml +++ b/app/src/main/res/layout/activity_panorama_photo.xml @@ -12,6 +12,13 @@ android:layout_height="match_parent" android:visibility="gone"/> + + + +