refresh panorama buttons on device rotation

This commit is contained in:
tibbi 2018-07-03 21:50:16 +02:00
parent cf07b918de
commit 08ec62b3e1
2 changed files with 19 additions and 4 deletions

View file

@ -118,8 +118,8 @@
<activity <activity
android:name=".activities.PanoramaActivity" android:name=".activities.PanoramaActivity"
android:theme="@style/FullScreenTheme" android:configChanges="orientation|keyboardHidden|screenSize"
android:configChanges="orientation|keyboardHidden|screenSize"/> android:theme="@style/FullScreenTheme"/>
<activity <activity
android:name=".activities.IncludedFoldersActivity" android:name=".activities.IncludedFoldersActivity"

View file

@ -1,5 +1,6 @@
package com.simplemobiletools.gallery.activities package com.simplemobiletools.gallery.activities
import android.content.res.Configuration
import android.graphics.BitmapFactory import android.graphics.BitmapFactory
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
@ -13,6 +14,7 @@ import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.extensions.hideSystemUI import com.simplemobiletools.gallery.extensions.hideSystemUI
import com.simplemobiletools.gallery.extensions.navigationBarHeight import com.simplemobiletools.gallery.extensions.navigationBarHeight
import com.simplemobiletools.gallery.extensions.navigationBarWidth
import com.simplemobiletools.gallery.extensions.showSystemUI import com.simplemobiletools.gallery.extensions.showSystemUI
import com.simplemobiletools.gallery.helpers.PATH import com.simplemobiletools.gallery.helpers.PATH
import kotlinx.android.synthetic.main.activity_panorama.* import kotlinx.android.synthetic.main.activity_panorama.*
@ -29,8 +31,7 @@ open class PanoramaActivity : SimpleActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_panorama) setContentView(R.layout.activity_panorama)
supportActionBar?.hide() supportActionBar?.hide()
(cardboard.layoutParams as RelativeLayout.LayoutParams).bottomMargin = navigationBarHeight setupButtonMargins()
(explore.layoutParams as RelativeLayout.LayoutParams).bottomMargin = navigationBarHeight
cardboard.setOnClickListener { cardboard.setOnClickListener {
panorama_view.displayMode = CARDBOARD_DISPLAY_MODE panorama_view.displayMode = CARDBOARD_DISPLAY_MODE
@ -110,6 +111,20 @@ open class PanoramaActivity : SimpleActivity() {
} }
} }
override fun onConfigurationChanged(newConfig: Configuration?) {
super.onConfigurationChanged(newConfig)
setupButtonMargins()
}
private fun setupButtonMargins() {
(cardboard.layoutParams as RelativeLayout.LayoutParams).apply {
bottomMargin = navigationBarHeight
rightMargin = navigationBarWidth
}
(explore.layoutParams as RelativeLayout.LayoutParams).bottomMargin = navigationBarHeight
}
private fun toggleButtonVisibility() { private fun toggleButtonVisibility() {
cardboard.animate().alpha(if (isFullScreen) 0f else 1f) cardboard.animate().alpha(if (isFullScreen) 0f else 1f)
cardboard.isClickable = !isFullScreen cardboard.isClickable = !isFullScreen