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

Commit 6bcc447c authored by Wes Okuhara's avatar Wes Okuhara
Browse files

Screen capture: Escape keypress closes the activity

Bug: 412722570
Test: Manual
Flag: com.android.systemui.desktop_screen_capture
Change-Id: I56798a64903507a4230525429450b83577e97ea0
parent bc7e4214
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.screencapture.ui

import android.os.Bundle
import android.view.KeyEvent
import android.view.Window
import android.view.WindowManager
import androidx.activity.ComponentActivity
@@ -67,6 +68,21 @@ constructor(
        component = null
        super.onDestroy()
    }

    override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {
        val noModifierKeys =
            !event.isShiftPressed &&
                !event.isCtrlPressed &&
                !event.isAltPressed &&
                !event.isMetaPressed
        return when {
            (keyCode == KeyEvent.KEYCODE_ESCAPE && noModifierKeys) -> {
                finish()
                true
            }
            else -> super.onKeyUp(keyCode, event)
        }
    }
}

private fun Window.updateAttributes(update: WindowManager.LayoutParams.() -> Unit) {