make preview fill up to the cutoff (notch)

- add theme attribute android:windowLayoutInDisplayCutoutMode to shortEdges in the theme
- add flags FLAG_LAYOUT_NO_LIMITS to the window flags
- add top margin to the icons on top, set to the statusBarHeight
- add bottom margin to the icons at the bottom, set to the navigationBarHeight + view margin
This commit is contained in:
darthpaul
2022-08-18 14:53:25 +01:00
parent d9193f7494
commit affcc078dd
3 changed files with 50 additions and 33 deletions

View File

@ -64,16 +64,21 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
setShowWhenLocked(true)
setTurnScreenOn(true)
window.insetsController?.hide(WindowInsets.Type.statusBars())
window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
} else if (isOreoMr1Plus()) {
setShowWhenLocked(true)
setTurnScreenOn(true)
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
window.addFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN or
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
)
} else {
window.addFlags(
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or
WindowManager.LayoutParams.FLAG_FULLSCREEN
WindowManager.LayoutParams.FLAG_FULLSCREEN or
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
)
}
}
@ -214,6 +219,16 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
setContentView(R.layout.activity_main)
initButtons()
(toggle_photo_video.layoutParams as ConstraintLayout.LayoutParams).setMargins(
0,
statusBarHeight,
0,
0,
)
val goneMargin = (navigationBarHeight + resources.getDimension(R.dimen.big_margin)).toInt()
(shutter.layoutParams as ConstraintLayout.LayoutParams).goneBottomMargin = goneMargin
(video_rec_curr_timer.layoutParams as ConstraintLayout.LayoutParams).setMargins(
0,
0,