Loading packages/SystemUI/res/layout/screenshot_shelf.xml +126 −121 Original line number Diff line number Diff line Loading @@ -20,6 +20,10 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/screenshot_static" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/actions_container_background" android:visibility="gone" Loading Loading @@ -147,6 +151,7 @@ <include layout="@layout/screenshot_work_profile_first_run" /> <include layout="@layout/screenshot_detection_notice" /> </FrameLayout> </androidx.constraintlayout.widget.ConstraintLayout> <ImageView android:id="@+id/screenshot_flash" android:layout_width="match_parent" Loading packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotShelfViewProxy.kt +4 −1 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ constructor( onDismissalRequested = { event, velocity -> requestDismissal(event, velocity) }, onDismissalCancelled = { animationController.getSwipeReturnAnimation().start() } ) view.updateInsets(windowManager.currentWindowMetrics.windowInsets) addPredictiveBackListener { requestDismissal(SCREENSHOT_DISMISSED_OTHER) } setOnKeyListener { requestDismissal(SCREENSHOT_DISMISSED_OTHER) } debugLog(DEBUG_WINDOW) { "adding OnComputeInternalInsetsListener" } Loading @@ -112,7 +113,9 @@ constructor( isPendingSharedTransition = false viewModel.reset() } override fun updateInsets(insets: WindowInsets) {} override fun updateInsets(insets: WindowInsets) { view.updateInsets(insets) } override fun updateOrientation(insets: WindowInsets) {} override fun createScreenshotDropInAnimation(screenRect: Rect, showFlash: Boolean): Animator { Loading packages/SystemUI/src/com/android/systemui/screenshot/ui/ScreenshotAnimationController.kt +2 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.graphics.Rect import android.util.MathUtils import android.view.View import android.view.animation.AnimationUtils import android.widget.ImageView import androidx.core.animation.doOnEnd import androidx.core.animation.doOnStart import com.android.systemui.res.R Loading @@ -34,7 +35,7 @@ import kotlin.math.sign class ScreenshotAnimationController(private val view: ScreenshotShelfView) { private var animator: Animator? = null private val screenshotPreview = view.requireViewById<View>(R.id.screenshot_preview) private val screenshotPreview = view.requireViewById<ImageView>(R.id.screenshot_preview) private val flashView = view.requireViewById<View>(R.id.screenshot_flash) private val actionContainer = view.requireViewById<View>(R.id.actions_container_background) private val fastOutSlowIn = Loading packages/SystemUI/src/com/android/systemui/screenshot/ui/ScreenshotShelfView.kt +42 −2 Original line number Diff line number Diff line Loading @@ -17,20 +17,25 @@ package com.android.systemui.screenshot.ui import android.content.Context import android.content.res.Configuration import android.graphics.Insets import android.graphics.Rect import android.graphics.Region import android.util.AttributeSet import android.view.MotionEvent import android.view.View import android.view.ViewGroup import android.view.WindowInsets import android.widget.FrameLayout import android.widget.ImageView import androidx.constraintlayout.widget.ConstraintLayout import com.android.systemui.res.R import com.android.systemui.screenshot.FloatingWindowUtil import kotlin.math.max class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) : ConstraintLayout(context, attrs) { FrameLayout(context, attrs) { lateinit var screenshotPreview: ImageView private lateinit var screenshotStatic: ViewGroup var onTouchInterceptListener: ((MotionEvent) -> Boolean)? = null private val displayMetrics = context.resources.displayMetrics Loading @@ -43,6 +48,7 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) : // Get focus so that the key events go to the layout. isFocusableInTouchMode = true screenshotPreview = requireViewById(R.id.screenshot_preview) screenshotStatic = requireViewById(R.id.screenshot_static) actionsContainerBackground = requireViewById(R.id.actions_container_background) dismissButton = requireViewById(R.id.screenshot_dismiss_button) } Loading @@ -66,6 +72,40 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) : return region } fun updateInsets(insets: WindowInsets) { val orientation = mContext.resources.configuration.orientation val inPortrait = orientation == Configuration.ORIENTATION_PORTRAIT val p = screenshotStatic.layoutParams as LayoutParams val cutout = insets.displayCutout val navBarInsets = insets.getInsets(WindowInsets.Type.navigationBars()) if (cutout == null) { p.setMargins(0, 0, 0, navBarInsets.bottom) } else { val waterfall = cutout.waterfallInsets if (inPortrait) { p.setMargins( waterfall.left, max(cutout.safeInsetTop.toDouble(), waterfall.top.toDouble()).toInt(), waterfall.right, max( cutout.safeInsetBottom.toDouble(), max(navBarInsets.bottom.toDouble(), waterfall.bottom.toDouble()) ) .toInt() ) } else { p.setMargins( max(cutout.safeInsetLeft.toDouble(), waterfall.left.toDouble()).toInt(), waterfall.top, max(cutout.safeInsetRight.toDouble(), waterfall.right.toDouble()).toInt(), max(navBarInsets.bottom.toDouble(), waterfall.bottom.toDouble()).toInt() ) } } screenshotStatic.layoutParams = p screenshotStatic.requestLayout() } private fun getSwipeRegion(): Region { val swipeRegion = Region() val padding = FloatingWindowUtil.dpToPx(displayMetrics, -1 * TOUCH_PADDING_DP).toInt() Loading packages/SystemUI/src/com/android/systemui/screenshot/ui/binder/ScreenshotShelfViewBinder.kt +23 −1 Original line number Diff line number Diff line Loading @@ -16,8 +16,11 @@ package com.android.systemui.screenshot.ui.binder import android.graphics.Bitmap import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.FrameLayout import android.widget.ImageView import android.widget.LinearLayout import androidx.lifecycle.Lifecycle Loading Loading @@ -68,7 +71,7 @@ object ScreenshotShelfViewBinder { launch { viewModel.preview.collect { bitmap -> if (bitmap != null) { previewView.setImageBitmap(bitmap) setScreenshotBitmap(previewView, bitmap) previewView.visibility = View.VISIBLE previewBorder.visibility = View.VISIBLE } else { Loading Loading @@ -128,4 +131,23 @@ object ScreenshotShelfViewBinder { } } } private fun setScreenshotBitmap(screenshotPreview: ImageView, bitmap: Bitmap) { screenshotPreview.setImageBitmap(bitmap) val hasPortraitAspectRatio = bitmap.width < bitmap.height val fixedSize = screenshotPreview.resources.getDimensionPixelSize(R.dimen.overlay_x_scale) val params: ViewGroup.LayoutParams = screenshotPreview.layoutParams if (hasPortraitAspectRatio) { params.width = fixedSize params.height = FrameLayout.LayoutParams.WRAP_CONTENT screenshotPreview.scaleType = ImageView.ScaleType.FIT_START } else { params.width = FrameLayout.LayoutParams.WRAP_CONTENT params.height = fixedSize screenshotPreview.scaleType = ImageView.ScaleType.FIT_END } screenshotPreview.layoutParams = params screenshotPreview.requestLayout() } } Loading
packages/SystemUI/res/layout/screenshot_shelf.xml +126 −121 Original line number Diff line number Diff line Loading @@ -20,6 +20,10 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/screenshot_static" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/actions_container_background" android:visibility="gone" Loading Loading @@ -147,6 +151,7 @@ <include layout="@layout/screenshot_work_profile_first_run" /> <include layout="@layout/screenshot_detection_notice" /> </FrameLayout> </androidx.constraintlayout.widget.ConstraintLayout> <ImageView android:id="@+id/screenshot_flash" android:layout_width="match_parent" Loading
packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotShelfViewProxy.kt +4 −1 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ constructor( onDismissalRequested = { event, velocity -> requestDismissal(event, velocity) }, onDismissalCancelled = { animationController.getSwipeReturnAnimation().start() } ) view.updateInsets(windowManager.currentWindowMetrics.windowInsets) addPredictiveBackListener { requestDismissal(SCREENSHOT_DISMISSED_OTHER) } setOnKeyListener { requestDismissal(SCREENSHOT_DISMISSED_OTHER) } debugLog(DEBUG_WINDOW) { "adding OnComputeInternalInsetsListener" } Loading @@ -112,7 +113,9 @@ constructor( isPendingSharedTransition = false viewModel.reset() } override fun updateInsets(insets: WindowInsets) {} override fun updateInsets(insets: WindowInsets) { view.updateInsets(insets) } override fun updateOrientation(insets: WindowInsets) {} override fun createScreenshotDropInAnimation(screenRect: Rect, showFlash: Boolean): Animator { Loading
packages/SystemUI/src/com/android/systemui/screenshot/ui/ScreenshotAnimationController.kt +2 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.graphics.Rect import android.util.MathUtils import android.view.View import android.view.animation.AnimationUtils import android.widget.ImageView import androidx.core.animation.doOnEnd import androidx.core.animation.doOnStart import com.android.systemui.res.R Loading @@ -34,7 +35,7 @@ import kotlin.math.sign class ScreenshotAnimationController(private val view: ScreenshotShelfView) { private var animator: Animator? = null private val screenshotPreview = view.requireViewById<View>(R.id.screenshot_preview) private val screenshotPreview = view.requireViewById<ImageView>(R.id.screenshot_preview) private val flashView = view.requireViewById<View>(R.id.screenshot_flash) private val actionContainer = view.requireViewById<View>(R.id.actions_container_background) private val fastOutSlowIn = Loading
packages/SystemUI/src/com/android/systemui/screenshot/ui/ScreenshotShelfView.kt +42 −2 Original line number Diff line number Diff line Loading @@ -17,20 +17,25 @@ package com.android.systemui.screenshot.ui import android.content.Context import android.content.res.Configuration import android.graphics.Insets import android.graphics.Rect import android.graphics.Region import android.util.AttributeSet import android.view.MotionEvent import android.view.View import android.view.ViewGroup import android.view.WindowInsets import android.widget.FrameLayout import android.widget.ImageView import androidx.constraintlayout.widget.ConstraintLayout import com.android.systemui.res.R import com.android.systemui.screenshot.FloatingWindowUtil import kotlin.math.max class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) : ConstraintLayout(context, attrs) { FrameLayout(context, attrs) { lateinit var screenshotPreview: ImageView private lateinit var screenshotStatic: ViewGroup var onTouchInterceptListener: ((MotionEvent) -> Boolean)? = null private val displayMetrics = context.resources.displayMetrics Loading @@ -43,6 +48,7 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) : // Get focus so that the key events go to the layout. isFocusableInTouchMode = true screenshotPreview = requireViewById(R.id.screenshot_preview) screenshotStatic = requireViewById(R.id.screenshot_static) actionsContainerBackground = requireViewById(R.id.actions_container_background) dismissButton = requireViewById(R.id.screenshot_dismiss_button) } Loading @@ -66,6 +72,40 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) : return region } fun updateInsets(insets: WindowInsets) { val orientation = mContext.resources.configuration.orientation val inPortrait = orientation == Configuration.ORIENTATION_PORTRAIT val p = screenshotStatic.layoutParams as LayoutParams val cutout = insets.displayCutout val navBarInsets = insets.getInsets(WindowInsets.Type.navigationBars()) if (cutout == null) { p.setMargins(0, 0, 0, navBarInsets.bottom) } else { val waterfall = cutout.waterfallInsets if (inPortrait) { p.setMargins( waterfall.left, max(cutout.safeInsetTop.toDouble(), waterfall.top.toDouble()).toInt(), waterfall.right, max( cutout.safeInsetBottom.toDouble(), max(navBarInsets.bottom.toDouble(), waterfall.bottom.toDouble()) ) .toInt() ) } else { p.setMargins( max(cutout.safeInsetLeft.toDouble(), waterfall.left.toDouble()).toInt(), waterfall.top, max(cutout.safeInsetRight.toDouble(), waterfall.right.toDouble()).toInt(), max(navBarInsets.bottom.toDouble(), waterfall.bottom.toDouble()).toInt() ) } } screenshotStatic.layoutParams = p screenshotStatic.requestLayout() } private fun getSwipeRegion(): Region { val swipeRegion = Region() val padding = FloatingWindowUtil.dpToPx(displayMetrics, -1 * TOUCH_PADDING_DP).toInt() Loading
packages/SystemUI/src/com/android/systemui/screenshot/ui/binder/ScreenshotShelfViewBinder.kt +23 −1 Original line number Diff line number Diff line Loading @@ -16,8 +16,11 @@ package com.android.systemui.screenshot.ui.binder import android.graphics.Bitmap import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.FrameLayout import android.widget.ImageView import android.widget.LinearLayout import androidx.lifecycle.Lifecycle Loading Loading @@ -68,7 +71,7 @@ object ScreenshotShelfViewBinder { launch { viewModel.preview.collect { bitmap -> if (bitmap != null) { previewView.setImageBitmap(bitmap) setScreenshotBitmap(previewView, bitmap) previewView.visibility = View.VISIBLE previewBorder.visibility = View.VISIBLE } else { Loading Loading @@ -128,4 +131,23 @@ object ScreenshotShelfViewBinder { } } } private fun setScreenshotBitmap(screenshotPreview: ImageView, bitmap: Bitmap) { screenshotPreview.setImageBitmap(bitmap) val hasPortraitAspectRatio = bitmap.width < bitmap.height val fixedSize = screenshotPreview.resources.getDimensionPixelSize(R.dimen.overlay_x_scale) val params: ViewGroup.LayoutParams = screenshotPreview.layoutParams if (hasPortraitAspectRatio) { params.width = fixedSize params.height = FrameLayout.LayoutParams.WRAP_CONTENT screenshotPreview.scaleType = ImageView.ScaleType.FIT_START } else { params.width = FrameLayout.LayoutParams.WRAP_CONTENT params.height = fixedSize screenshotPreview.scaleType = ImageView.ScaleType.FIT_END } screenshotPreview.layoutParams = params screenshotPreview.requestLayout() } }