Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47a68242 authored by Maryam Dehaini's avatar Maryam Dehaini
Browse files

Run ktfmt on windowdecor and windowdecor unittest directories

Bug: 432536321
Test: m
Flag: EXEMPT formatting
Change-Id: I0dacf66dffd51dd2e18187ff975b3190f24933ff
parent 2968777a
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -16,9 +16,6 @@

package com.android.wm.shell.windowdecor

/**
 * Abstract decorator for a [TaskPositioner].
 */
abstract class AbstractTaskPositionerDecorator(
    private val taskPositioner: TaskPositioner
) : TaskPositioner by taskPositioner
/** Abstract decorator for a [TaskPositioner]. */
abstract class AbstractTaskPositionerDecorator(private val taskPositioner: TaskPositioner) :
    TaskPositioner by taskPositioner
+4 −11
Original line number Diff line number Diff line
@@ -21,26 +21,19 @@ import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.FrameLayout

/**
 * View group that allows a hover listener to be set for the entire menu layout.
 */
/** View group that allows a hover listener to be set for the entire menu layout. */
class CaptionMenuLayout : FrameLayout {
    /** Called when menu receives hover event without consuming the event. */
    var onInterceptHoverListener: ((MotionEvent) -> Unit)? = null

    constructor(
        context: Context
    ) : super(context)
    constructor(context: Context) : super(context)

    constructor(
        context: Context,
        attrs: AttributeSet?
    ) : super(context, attrs)
    constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)

    constructor(
        context: Context,
        attrs: AttributeSet?,
        defStyleAttr: Int
        defStyleAttr: Int,
    ) : super(context, attrs, defStyleAttr)

    override fun onInterceptHoverEvent(ev: MotionEvent): Boolean {
+309 −295

File changed.

Preview size limit exceeded, changes collapsed.

+26 −23
Original line number Diff line number Diff line
@@ -33,8 +33,7 @@ import com.android.wm.shell.windowdecor.common.DecorThemeUtil
import com.android.wm.shell.windowdecor.common.calculateMenuPosition

/**
 * Implementation of [ManageWindowsViewContainer] meant to be used in desktop header and app
 * handle.
 * Implementation of [ManageWindowsViewContainer] meant to be used in desktop header and app handle.
 */
class DesktopHandleManageWindowsMenu(
    private val callerTaskInfo: RunningTaskInfo,
@@ -46,10 +45,11 @@ class DesktopHandleManageWindowsMenu(
    context: Context,
    snapshotList: List<Pair<Int, TaskSnapshot?>>,
    onIconClickListener: ((Int) -> Unit),
    onOutsideClickListener: (() -> Unit)
) : ManageWindowsViewContainer(
    onOutsideClickListener: (() -> Unit),
) :
    ManageWindowsViewContainer(
        context,
    DecorThemeUtil(context).getColorScheme(callerTaskInfo).background.toArgb()
        DecorThemeUtil(context).getColorScheme(callerTaskInfo).background.toArgb(),
    ) {
    private var menuViewContainer: AdditionalViewContainer? = null

@@ -63,27 +63,30 @@ class DesktopHandleManageWindowsMenu(
            splitScreenController,
            callerTaskInfo,
            marginStart = 0,
            marginTop = context.resources.getDimensionPixelSize(
            marginTop =
                context.resources.getDimensionPixelSize(
                    R.dimen.desktop_mode_handle_menu_margin_top
                ),
            captionX,
            0,
            captionWidth,
            menuView.menuWidth,
            context.isRtl()
            context.isRtl(),
        )
    }

    override fun addToContainer(menuView: ManageWindowsView) {
        val menuPosition = calculateMenuPosition()
        menuViewContainer = AdditionalSystemViewContainer(
        menuViewContainer =
            AdditionalSystemViewContainer(
                windowManagerWrapper = windowManagerWrapper,
                taskId = callerTaskInfo.taskId,
                x = menuPosition.x,
                y = menuPosition.y,
                width = menuView.menuWidth,
                height = menuView.scrollableMenuHeight,
            flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or
                flags =
                    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or
                        WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
                view = menuView.scrollableMenuView,
                ignoreCutouts = desktopState.canEnterDesktopModeOrShowAppHandle,
+47 −48
Original line number Diff line number Diff line
@@ -41,8 +41,7 @@ import com.android.wm.shell.windowdecor.common.DecorThemeUtil
import java.util.function.Supplier

/**
 * Implementation of [ManageWindowsViewContainer] meant to be used in desktop header and app
 * handle.
 * Implementation of [ManageWindowsViewContainer] meant to be used in desktop header and app handle.
 */
class DesktopHeaderManageWindowsMenu(
    private val callerTaskInfo: RunningTaskInfo,
@@ -56,13 +55,13 @@ class DesktopHeaderManageWindowsMenu(
    private val surfaceControlTransactionSupplier: Supplier<SurfaceControl.Transaction>,
    snapshotList: List<Pair<Int, TaskSnapshot?>>,
    onIconClickListener: ((Int) -> Unit),
    onOutsideClickListener: (() -> Unit)
) : ManageWindowsViewContainer(
    onOutsideClickListener: (() -> Unit),
) :
    ManageWindowsViewContainer(
        context,
    DecorThemeUtil(context).getColorScheme(callerTaskInfo).background.toArgb()
        DecorThemeUtil(context).getColorScheme(callerTaskInfo).background.toArgb(),
    ) {
    @VisibleForTesting
    var menuViewContainer: AdditionalViewContainer? = null
    @VisibleForTesting var menuViewContainer: AdditionalViewContainer? = null

    init {
        createMenu(snapshotList, onIconClickListener, onOutsideClickListener)
@@ -73,11 +72,15 @@ class DesktopHeaderManageWindowsMenu(

    override fun addToContainer(menuView: ManageWindowsView) {
        val menuPosition = Point(x, y)
        val flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or
        val flags =
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or
                WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
        val desktopRepository = desktopUserRepositories.getProfile(callerTaskInfo.userId)
        menuViewContainer = if (DesktopModeFlags.ENABLE_FULLY_IMMERSIVE_IN_DESKTOP.isTrue
            && desktopRepository.isTaskInFullImmersiveState(callerTaskInfo.taskId)) {
        menuViewContainer =
            if (
                DesktopModeFlags.ENABLE_FULLY_IMMERSIVE_IN_DESKTOP.isTrue &&
                    desktopRepository.isTaskInFullImmersiveState(callerTaskInfo.taskId)
            ) {
                // Use system view container so that forcibly shown system bars take effect in
                // immersive.
                createAsSystemViewContainer(menuPosition, flags)
@@ -88,9 +91,8 @@ class DesktopHeaderManageWindowsMenu(

    private fun createAsSystemViewContainer(position: Point, flags: Int): AdditionalViewContainer {
        return AdditionalSystemViewContainer(
            windowManagerWrapper = WindowManagerWrapper(
                context.getSystemService(WindowManager::class.java)
            ),
            windowManagerWrapper =
                WindowManagerWrapper(context.getSystemService(WindowManager::class.java)),
            taskId = callerTaskInfo.taskId,
            x = position.x,
            y = position.y,
@@ -98,33 +100,34 @@ class DesktopHeaderManageWindowsMenu(
            height = menuView.scrollableMenuHeight,
            flags = flags,
            forciblyShownTypes = systemBars(),
            view = menuView.scrollableMenuView
            view = menuView.scrollableMenuView,
        )
    }

    private fun createAsViewHostContainer(position: Point, flags: Int): AdditionalViewContainer {
        val builder = surfaceControlBuilderSupplier.get()
        rootTdaOrganizer.attachToDisplayArea(callerTaskInfo.displayId, builder)
        val leash = builder
            .setName("Manage Windows Menu")
            .setContainerLayer()
            .build()
        val lp = WindowManager.LayoutParams(
        val leash = builder.setName("Manage Windows Menu").setContainerLayer().build()
        val lp =
            WindowManager.LayoutParams(
                menuView.menuWidth,
                menuView.scrollableMenuHeight,
                WindowManager.LayoutParams.TYPE_APPLICATION,
                flags,
            PixelFormat.TRANSPARENT
                PixelFormat.TRANSPARENT,
            )
        val windowManager = WindowlessWindowManager(
        val windowManager =
            WindowlessWindowManager(
                callerTaskInfo.configuration,
                leash,
            null // HostInputToken
                null, // HostInputToken
            )
        val viewHost = SurfaceControlViewHost(
        val viewHost =
            SurfaceControlViewHost(
                context,
            displayController.getDisplay(callerTaskInfo.displayId), windowManager,
            "MaximizeMenu"
                displayController.getDisplay(callerTaskInfo.displayId),
                windowManager,
                "MaximizeMenu",
            )
        menuView.let { viewHost.setView(it.scrollableMenuView, lp) }
        val t = surfaceControlTransactionSupplier.get()
@@ -132,11 +135,7 @@ class DesktopHeaderManageWindowsMenu(
            .setPosition(leash, position.x.toFloat(), position.y.toFloat())
            .show(leash)
        t.apply()
        return AdditionalViewHostViewContainer(
            leash,
            viewHost,
            surfaceControlTransactionSupplier
        )
        return AdditionalViewHostViewContainer(leash, viewHost, surfaceControlTransactionSupplier)
    }

    override fun removeFromContainer() {
Loading