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

Commit bc4ad051 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use expression functions when appropriate" into main

parents 8283aa5c baf854db
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -32,9 +32,7 @@ enum class DesktopModeTransitionSource : Parcelable {
    /** Transitions with source unknown. */
    UNKNOWN;

    override fun describeContents(): Int {
        return 0
    }
    override fun describeContents(): Int = 0

    override fun writeToParcel(dest: Parcel, flags: Int) {
        dest.writeString(name)
@@ -44,9 +42,8 @@ enum class DesktopModeTransitionSource : Parcelable {
        @JvmField
        val CREATOR =
            object : Parcelable.Creator<DesktopModeTransitionSource> {
                override fun createFromParcel(parcel: Parcel): DesktopModeTransitionSource {
                    return parcel.readString()?.let { valueOf(it) } ?: UNKNOWN
                }
                override fun createFromParcel(parcel: Parcel): DesktopModeTransitionSource =
                    parcel.readString()?.let { valueOf(it) } ?: UNKNOWN

                override fun newArray(size: Int) = arrayOfNulls<DesktopModeTransitionSource>(size)
            }
+2 −3
Original line number Diff line number Diff line
@@ -93,9 +93,8 @@ class DesktopModeDragAndDropTransitionHandler(private val transitions: Transitio
        return matchingChanges.first()
    }

    private fun isValidTaskChange(change: TransitionInfo.Change): Boolean {
        return change.taskInfo != null && change.taskInfo?.taskId != -1
    }
    private fun isValidTaskChange(change: TransitionInfo.Change): Boolean =
        change.taskInfo != null && change.taskInfo?.taskId != -1

    override fun handleRequest(
        transition: IBinder,
+5 −9
Original line number Diff line number Diff line
@@ -434,18 +434,14 @@ class DesktopModeLoggerTransitionObserver(
        visibleFreeformTaskInfos.set(taskInfo.taskId, taskInfo)
    }

    private fun TransitionInfo.Change.requireTaskInfo(): RunningTaskInfo {
        return this.taskInfo ?: throw IllegalStateException("Expected TaskInfo in the Change")
    }
    private fun TransitionInfo.Change.requireTaskInfo(): RunningTaskInfo =
        this.taskInfo ?: throw IllegalStateException("Expected TaskInfo in the Change")

    private fun TaskInfo.isFreeformWindow(): Boolean {
        return this.windowingMode == WINDOWING_MODE_FREEFORM
    }
    private fun TaskInfo.isFreeformWindow(): Boolean = this.windowingMode == WINDOWING_MODE_FREEFORM

    private fun TransitionInfo.isExitToRecentsTransition(): Boolean {
        return this.type == WindowManager.TRANSIT_TO_FRONT &&
    private fun TransitionInfo.isExitToRecentsTransition(): Boolean =
        this.type == WindowManager.TRANSIT_TO_FRONT &&
            this.flags == WindowManager.TRANSIT_FLAG_IS_RECENTS
    }

    companion object {
        @VisibleForTesting const val VISIBLE_TASKS_COUNTER_NAME = "desktop_mode_visible_tasks"
+2 −3
Original line number Diff line number Diff line
@@ -24,8 +24,8 @@ import java.io.PrintWriter
class DesktopModeShellCommandHandler(private val controller: DesktopTasksController) :
    ShellCommandHandler.ShellCommandActionHandler {

    override fun onShellCommand(args: Array<String>, pw: PrintWriter): Boolean {
        return when (args[0]) {
    override fun onShellCommand(args: Array<String>, pw: PrintWriter): Boolean =
        when (args[0]) {
            "moveToDesktop" -> {
                if (!runMoveToDesktop(args, pw)) {
                    pw.println("Task not found. Please enter a valid taskId.")
@@ -47,7 +47,6 @@ class DesktopModeShellCommandHandler(private val controller: DesktopTasksControl
                false
            }
        }
    }

    private fun runMoveToDesktop(args: Array<String>, pw: PrintWriter): Boolean {
        if (args.size < 2) {
+13 −27
Original line number Diff line number Diff line
@@ -41,49 +41,35 @@ sealed class DesktopTaskPosition {
            return Point(x, y.toInt())
        }

        override fun next(): DesktopTaskPosition {
            return BottomRight
        }
        override fun next(): DesktopTaskPosition = BottomRight
    }

    data object BottomRight : DesktopTaskPosition() {
        override fun getTopLeftCoordinates(frame: Rect, window: Rect): Point {
            return Point(frame.right - window.width(), frame.bottom - window.height())
        }
        override fun getTopLeftCoordinates(frame: Rect, window: Rect): Point =
            Point(frame.right - window.width(), frame.bottom - window.height())

        override fun next(): DesktopTaskPosition {
            return TopLeft
        }
        override fun next(): DesktopTaskPosition = TopLeft
    }

    data object TopLeft : DesktopTaskPosition() {
        override fun getTopLeftCoordinates(frame: Rect, window: Rect): Point {
            return Point(frame.left, frame.top)
        }
        override fun getTopLeftCoordinates(frame: Rect, window: Rect): Point =
            Point(frame.left, frame.top)

        override fun next(): DesktopTaskPosition {
            return BottomLeft
        }
        override fun next(): DesktopTaskPosition = BottomLeft
    }

    data object BottomLeft : DesktopTaskPosition() {
        override fun getTopLeftCoordinates(frame: Rect, window: Rect): Point {
            return Point(frame.left, frame.bottom - window.height())
        }
        override fun getTopLeftCoordinates(frame: Rect, window: Rect): Point =
            Point(frame.left, frame.bottom - window.height())

        override fun next(): DesktopTaskPosition {
            return TopRight
        }
        override fun next(): DesktopTaskPosition = TopRight
    }

    data object TopRight : DesktopTaskPosition() {
        override fun getTopLeftCoordinates(frame: Rect, window: Rect): Point {
            return Point(frame.right - window.width(), frame.top)
        }
        override fun getTopLeftCoordinates(frame: Rect, window: Rect): Point =
            Point(frame.right - window.width(), frame.top)

        override fun next(): DesktopTaskPosition {
            return Center
        }
        override fun next(): DesktopTaskPosition = Center
    }

    /**
Loading