From affcc078ddf2321333e8fc48599ab23452ac91e6 Mon Sep 17 00:00:00 2001 From: darthpaul Date: Thu, 18 Aug 2022 14:53:25 +0100 Subject: [PATCH] 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 --- .../camera/activities/MainActivity.kt | 19 +++++- app/src/main/res/layout/activity_main.xml | 60 +++++++++---------- app/src/main/res/values/styles.xml | 4 +- 3 files changed, 50 insertions(+), 33 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt index 19660784..3a95791f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt @@ -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, diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 20cbc359..384dc4d3 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -30,18 +30,31 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + + - - - - + app:layout_constraintTop_toTopOf="@id/toggle_photo_video" /> + + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index b04b82ae..1ba2a099 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,11 +1,13 @@ -