Skip to content

Commit

Permalink
Disable main activity alt view when screen aspect is too small
Browse files Browse the repository at this point in the history
  • Loading branch information
svetter committed Aug 12, 2024
1 parent bd26b64 commit 812ca4e
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,10 @@ class MainActivity : AppCompatActivity() {
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)

val minScreenAspectRatioForAltView = 1.4
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
if (newConfig.screenHeightDp.toDouble() / newConfig.screenWidthDp < minScreenAspectRatioForAltView) return

// Restore graphicsFrame's constraints
graphicsViewLayout.layoutParams = ConstraintLayout.LayoutParams(
portraitGraphicsFrameWidth,
Expand All @@ -661,6 +664,8 @@ class MainActivity : AppCompatActivity() {
graphicsViewLayout.setBackgroundColor(Color.TRANSPARENT)
}
else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
if (newConfig.screenWidthDp.toDouble() / newConfig.screenHeightDp < minScreenAspectRatioForAltView) return

// Save layout values
portraitGraphicsFrameWidth = graphicsViewLayout.width
portraitGraphicsFrameHeight = graphicsViewLayout.height
Expand Down

0 comments on commit 812ca4e

Please sign in to comment.