Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/extension/View.kt 0 → 100644 +31 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.wm.shell.windowdecor.extension import android.view.View /** * Throttles clicking on the view - if a view gets a click/tap within the delay given, then the * click is dropped. */ fun View.throttleFirstClicks(delay: Long, onClick: (View) -> Unit) { setOnClickListener { onClick(this) isClickable = false postDelayed({ isClickable = true }, delay) } } libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/AppHeaderViewHolder.kt +11 −3 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ import com.android.wm.shell.windowdecor.common.createBackgroundDrawable import com.android.wm.shell.windowdecor.extension.identityHashCode import com.android.wm.shell.windowdecor.extension.isLightCaptionBarAppearance import com.android.wm.shell.windowdecor.extension.isTransparentCaptionBarAppearance import com.android.wm.shell.windowdecor.extension.throttleFirstClicks import com.android.wm.shell.windowdecor.viewholder.util.AppHeaderDimensions import com.android.wm.shell.windowdecor.viewholder.util.DefaultAppHeaderDimensions import com.android.wm.shell.windowdecor.viewholder.util.LargeAppHeaderDimensions Loading Loading @@ -166,13 +167,19 @@ class AppHeaderViewHolder( captionHandle.setOnTouchListener(onCaptionTouchListener) openMenuButton.setOnClickListener(onCaptionButtonClickListener) openMenuButton.setOnTouchListener(onCaptionTouchListener) closeWindowButton.setOnClickListener(onCaptionButtonClickListener) maximizeWindowButton.setOnClickListener(onCaptionButtonClickListener) closeWindowButton.throttleFirstClicks(CLICK_DELAY) { v -> onCaptionButtonClickListener.onClick(v) } maximizeWindowButton.throttleFirstClicks(CLICK_DELAY) { v -> onCaptionButtonClickListener.onClick(v) } maximizeWindowButton.setOnTouchListener(onCaptionTouchListener) maximizeWindowButton.setOnGenericMotionListener(onCaptionGenericMotionListener) maximizeWindowButton.onLongClickListener = onLongClickListener closeWindowButton.setOnTouchListener(onCaptionTouchListener) minimizeWindowButton.setOnClickListener(onCaptionButtonClickListener) minimizeWindowButton.throttleFirstClicks(CLICK_DELAY) { v -> onCaptionButtonClickListener.onClick(v) } minimizeWindowButton.setOnTouchListener(onCaptionTouchListener) maximizeButtonView.onHoverAnimationFinishedListener = onMaximizeHoverAnimationFinishedListener Loading Loading @@ -982,6 +989,7 @@ class AppHeaderViewHolder( private const val DARK_THEME_UNFOCUSED_OPACITY = 140 // 55% private const val LIGHT_THEME_UNFOCUSED_OPACITY = 166 // 65% private const val FOCUSED_OPACITY = 255 private const val CLICK_DELAY: Long = 500 } class Factory { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/extension/View.kt 0 → 100644 +31 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.wm.shell.windowdecor.extension import android.view.View /** * Throttles clicking on the view - if a view gets a click/tap within the delay given, then the * click is dropped. */ fun View.throttleFirstClicks(delay: Long, onClick: (View) -> Unit) { setOnClickListener { onClick(this) isClickable = false postDelayed({ isClickable = true }, delay) } }
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/AppHeaderViewHolder.kt +11 −3 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ import com.android.wm.shell.windowdecor.common.createBackgroundDrawable import com.android.wm.shell.windowdecor.extension.identityHashCode import com.android.wm.shell.windowdecor.extension.isLightCaptionBarAppearance import com.android.wm.shell.windowdecor.extension.isTransparentCaptionBarAppearance import com.android.wm.shell.windowdecor.extension.throttleFirstClicks import com.android.wm.shell.windowdecor.viewholder.util.AppHeaderDimensions import com.android.wm.shell.windowdecor.viewholder.util.DefaultAppHeaderDimensions import com.android.wm.shell.windowdecor.viewholder.util.LargeAppHeaderDimensions Loading Loading @@ -166,13 +167,19 @@ class AppHeaderViewHolder( captionHandle.setOnTouchListener(onCaptionTouchListener) openMenuButton.setOnClickListener(onCaptionButtonClickListener) openMenuButton.setOnTouchListener(onCaptionTouchListener) closeWindowButton.setOnClickListener(onCaptionButtonClickListener) maximizeWindowButton.setOnClickListener(onCaptionButtonClickListener) closeWindowButton.throttleFirstClicks(CLICK_DELAY) { v -> onCaptionButtonClickListener.onClick(v) } maximizeWindowButton.throttleFirstClicks(CLICK_DELAY) { v -> onCaptionButtonClickListener.onClick(v) } maximizeWindowButton.setOnTouchListener(onCaptionTouchListener) maximizeWindowButton.setOnGenericMotionListener(onCaptionGenericMotionListener) maximizeWindowButton.onLongClickListener = onLongClickListener closeWindowButton.setOnTouchListener(onCaptionTouchListener) minimizeWindowButton.setOnClickListener(onCaptionButtonClickListener) minimizeWindowButton.throttleFirstClicks(CLICK_DELAY) { v -> onCaptionButtonClickListener.onClick(v) } minimizeWindowButton.setOnTouchListener(onCaptionTouchListener) maximizeButtonView.onHoverAnimationFinishedListener = onMaximizeHoverAnimationFinishedListener Loading Loading @@ -982,6 +989,7 @@ class AppHeaderViewHolder( private const val DARK_THEME_UNFOCUSED_OPACITY = 140 // 55% private const val LIGHT_THEME_UNFOCUSED_OPACITY = 166 // 65% private const val FOCUSED_OPACITY = 255 private const val CLICK_DELAY: Long = 500 } class Factory { Loading