mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +01:00
adding a panorama video button for toggling cardboard mode
This commit is contained in:
parent
3ee3887754
commit
33880f7c1b
3 changed files with 41 additions and 15 deletions
|
@ -24,7 +24,7 @@ import kotlinx.android.synthetic.main.activity_panorama_photo.*
|
|||
open class PanoramaPhotoActivity : SimpleActivity() {
|
||||
private val CARDBOARD_DISPLAY_MODE = 3
|
||||
|
||||
private var isFullScreen = false
|
||||
private var isFullscreen = false
|
||||
private var isExploreEnabled = true
|
||||
private var isRendering = false
|
||||
|
||||
|
@ -131,7 +131,7 @@ open class PanoramaPhotoActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
window.decorView.setOnSystemUiVisibilityChangeListener { visibility ->
|
||||
isFullScreen = visibility and View.SYSTEM_UI_FLAG_FULLSCREEN != 0
|
||||
isFullscreen = visibility and View.SYSTEM_UI_FLAG_FULLSCREEN != 0
|
||||
toggleButtonVisibility()
|
||||
}
|
||||
}
|
||||
|
@ -159,8 +159,9 @@ open class PanoramaPhotoActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupButtonMargins() {
|
||||
val navBarHeight = navigationBarHeight
|
||||
(cardboard.layoutParams as RelativeLayout.LayoutParams).apply {
|
||||
bottomMargin = navigationBarHeight
|
||||
bottomMargin = navBarHeight
|
||||
rightMargin = navigationBarWidth
|
||||
}
|
||||
|
||||
|
@ -168,17 +169,17 @@ open class PanoramaPhotoActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun toggleButtonVisibility() {
|
||||
cardboard.animate().alpha(if (isFullScreen) 0f else 1f)
|
||||
cardboard.isClickable = !isFullScreen
|
||||
cardboard.animate().alpha(if (isFullscreen) 0f else 1f)
|
||||
cardboard.isClickable = !isFullscreen
|
||||
|
||||
explore.animate().alpha(if (isFullScreen) 0f else 1f)
|
||||
explore.isClickable = !isFullScreen
|
||||
explore.animate().alpha(if (isFullscreen) 0f else 1f)
|
||||
explore.isClickable = !isFullscreen
|
||||
}
|
||||
|
||||
private fun handleClick() {
|
||||
isFullScreen = !isFullScreen
|
||||
isFullscreen = !isFullscreen
|
||||
toggleButtonVisibility()
|
||||
if (isFullScreen) {
|
||||
if (isFullscreen) {
|
||||
hideSystemUI(false)
|
||||
} else {
|
||||
showSystemUI(false)
|
||||
|
|
|
@ -20,10 +20,7 @@ import com.simplemobiletools.commons.extensions.toast
|
|||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
|
||||
import com.simplemobiletools.commons.helpers.isPiePlus
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.extensions.hideSystemUI
|
||||
import com.simplemobiletools.gallery.extensions.navigationBarHeight
|
||||
import com.simplemobiletools.gallery.extensions.showSystemUI
|
||||
import com.simplemobiletools.gallery.extensions.*
|
||||
import com.simplemobiletools.gallery.helpers.HIDE_PLAY_PAUSE_DELAY
|
||||
import com.simplemobiletools.gallery.helpers.MIN_SKIP_LENGTH
|
||||
import com.simplemobiletools.gallery.helpers.PATH
|
||||
|
@ -33,6 +30,8 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
|
|||
import java.io.File
|
||||
|
||||
open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
|
||||
private val CARDBOARD_DISPLAY_MODE = 3
|
||||
|
||||
private var mIsFullscreen = false
|
||||
private var mIsExploreEnabled = true
|
||||
private var mIsRendering = false
|
||||
|
@ -59,6 +58,10 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
|||
|
||||
setupButtonMargins()
|
||||
|
||||
cardboard.setOnClickListener {
|
||||
vr_video_view.displayMode = CARDBOARD_DISPLAY_MODE
|
||||
}
|
||||
|
||||
explore.setOnClickListener {
|
||||
mIsExploreEnabled = !mIsExploreEnabled
|
||||
vr_video_view.setPureTouchTracking(mIsExploreEnabled)
|
||||
|
@ -254,14 +257,27 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
|||
}
|
||||
|
||||
private fun setupButtonMargins() {
|
||||
(video_time_holder.layoutParams as RelativeLayout.LayoutParams).bottomMargin = navigationBarHeight
|
||||
val navBarHeight = navigationBarHeight
|
||||
video_time_holder.apply {
|
||||
(layoutParams as RelativeLayout.LayoutParams).bottomMargin = navBarHeight
|
||||
setPadding(paddingLeft, paddingTop, navigationBarWidth, paddingBottom)
|
||||
}
|
||||
|
||||
video_time_holder.onGlobalLayout {
|
||||
(explore.layoutParams as RelativeLayout.LayoutParams).bottomMargin = navigationBarHeight + video_time_holder.height
|
||||
(explore.layoutParams as RelativeLayout.LayoutParams).bottomMargin = navBarHeight + video_time_holder.height
|
||||
|
||||
(cardboard.layoutParams as RelativeLayout.LayoutParams).apply {
|
||||
bottomMargin = navBarHeight + video_time_holder.height
|
||||
rightMargin = navigationBarWidth
|
||||
}
|
||||
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
|
||||
|
||||
|
|
|
@ -20,6 +20,15 @@
|
|||
android:padding="@dimen/activity_margin"
|
||||
android:src="@drawable/ic_explore"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cardboard"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:padding="@dimen/activity_margin"
|
||||
android:src="@drawable/ic_cardboard"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/video_play_outline"
|
||||
android:layout_width="@dimen/play_outline_size_big"
|
||||
|
|
Loading…
Reference in a new issue