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

Commit beaaf868 authored by Maryam Dehaini's avatar Maryam Dehaini Committed by Android (Google) Code Review
Browse files

Merge "[6/N] WindowDecor refactor: inflate caption views in view holders" into main

parents 7956a2b9 bba2313d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -859,6 +859,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        if (mRelayoutParams.mLayoutResId == R.layout.desktop_mode_app_handle) {
            return mAppHandleViewHolderFactory.create(
                    mResult.mRootView,
                    mDecorWindowContext,
                    mOnCaptionTouchListener,
                    mOnCaptionButtonClickListener,
                    mWindowManagerWrapper,
@@ -868,6 +869,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        } else if (mRelayoutParams.mLayoutResId == R.layout.desktop_mode_app_header) {
            return mAppHeaderViewHolderFactory.create(
                    mResult.mRootView,
                    mDecorWindowContext,
                    mWindowDecorationActions,
                    mOnCaptionTouchListener,
                    mOnCaptionButtonClickListener,
+17 −3
Original line number Diff line number Diff line
@@ -17,12 +17,14 @@ package com.android.wm.shell.windowdecor.viewholder

import android.app.ActivityManager.RunningTaskInfo
import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Color
import android.graphics.Point
import android.hardware.input.InputManager
import android.os.Bundle
import android.os.Handler
import android.view.LayoutInflater
import android.view.MotionEvent.ACTION_DOWN
import android.view.SurfaceControl
import android.view.View
@@ -33,6 +35,7 @@ import android.view.accessibility.AccessibilityEvent
import android.view.accessibility.AccessibilityNodeInfo
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction
import android.widget.ImageButton
import android.window.DesktopExperienceFlags
import android.window.DesktopModeFlags
import androidx.core.view.ViewCompat
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat
@@ -43,6 +46,7 @@ import com.android.wm.shell.desktopmode.DesktopModeUiEventLogger
import com.android.wm.shell.desktopmode.DesktopModeUiEventLogger.DesktopUiEventEnum.A11Y_APP_HANDLE_MENU_OPENED
import com.android.wm.shell.shared.bubbles.BubbleAnythingFlagHelper
import com.android.wm.shell.windowdecor.AppHandleAnimator
import com.android.wm.shell.windowdecor.WindowDecorLinearLayout
import com.android.wm.shell.windowdecor.WindowManagerWrapper
import com.android.wm.shell.windowdecor.additionalviewcontainer.AdditionalSystemViewContainer

@@ -51,13 +55,14 @@ import com.android.wm.shell.windowdecor.additionalviewcontainer.AdditionalSystem
 * It hosts a simple handle bar from which to initiate a drag motion to enter desktop mode.
 */
class AppHandleViewHolder(
    rootView: View,
    appHandleView: View?,
    private val context: Context,
    onCaptionTouchListener: View.OnTouchListener,
    onCaptionButtonClickListener: OnClickListener,
    private val windowManagerWrapper: WindowManagerWrapper,
    private val handler: Handler,
    private val desktopModeUiEventLogger: DesktopModeUiEventLogger,
) : WindowDecorationViewHolder<AppHandleViewHolder.HandleData>(rootView) {
) : WindowDecorationViewHolder<AppHandleViewHolder.HandleData>() {

    data class HandleData(
        val taskInfo: RunningTaskInfo,
@@ -69,6 +74,13 @@ class AppHandleViewHolder(
    ) : Data()

    private lateinit var taskInfo: RunningTaskInfo
    override val rootView =
        appHandleView ?: if (DesktopExperienceFlags.ENABLE_WINDOW_DECORATION_REFACTOR.isTrue) {
            LayoutInflater.from(context)
                .inflate(R.layout.desktop_mode_app_handle, null) as WindowDecorLinearLayout
        } else {
            error("App Handle root view should not be null")
        }
    private val captionView: View = rootView.requireViewById(R.id.desktop_mode_caption)
    private val captionHandle: ImageButton = rootView.requireViewById(R.id.caption_handle)
    private val inputManager = context.getSystemService(InputManager::class.java)
@@ -301,7 +313,8 @@ class AppHandleViewHolder(
         * input layer logic.
         */
        fun create(
            rootView: View,
            rootView: View?,
            context: Context,
            onCaptionTouchListener: View.OnTouchListener,
            onCaptionButtonClickListener: OnClickListener,
            windowManagerWrapper: WindowManagerWrapper,
@@ -309,6 +322,7 @@ class AppHandleViewHolder(
            desktopModeUiEventLogger: DesktopModeUiEventLogger,
        ): AppHandleViewHolder = AppHandleViewHolder(
            rootView,
            context,
            onCaptionTouchListener,
            onCaptionButtonClickListener,
            windowManagerWrapper,
+17 −4
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.wm.shell.windowdecor.viewholder
import android.annotation.ColorInt
import android.annotation.DrawableRes
import android.app.ActivityManager.RunningTaskInfo
import android.content.Context
import android.content.res.ColorStateList
import android.content.res.Configuration
import android.graphics.Bitmap
@@ -27,6 +28,7 @@ import android.graphics.Rect
import android.graphics.Shader
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.View.OnLongClickListener
import android.view.ViewTreeObserver
@@ -63,6 +65,7 @@ import com.android.wm.shell.desktopmode.DesktopModeUiEventLogger.DesktopUiEventE
import com.android.wm.shell.desktopmode.DesktopModeUiEventLogger.DesktopUiEventEnum.A11Y_APP_WINDOW_MAXIMIZE_RESTORE_BUTTON
import com.android.wm.shell.desktopmode.DesktopModeUiEventLogger.DesktopUiEventEnum.A11Y_APP_WINDOW_MINIMIZE_BUTTON
import com.android.wm.shell.windowdecor.MaximizeButtonView
import com.android.wm.shell.windowdecor.WindowDecorLinearLayout
import com.android.wm.shell.windowdecor.WindowDecorationActions
import com.android.wm.shell.windowdecor.common.DecorThemeUtil
import com.android.wm.shell.windowdecor.common.DrawableInsets
@@ -87,7 +90,8 @@ import kotlin.math.roundToInt
 * controls.
 */
class AppHeaderViewHolder(
    rootView: View,
    appHeaderView: View?,
    private val context: Context,
    windowDecorationActions: WindowDecorationActions,
    onCaptionTouchListener: View.OnTouchListener,
    onCaptionButtonClickListener: View.OnClickListener,
@@ -95,7 +99,7 @@ class AppHeaderViewHolder(
    onCaptionGenericMotionListener: View.OnGenericMotionListener,
    onMaximizeHoverAnimationFinishedListener: () -> Unit,
    private val desktopModeUiEventLogger: DesktopModeUiEventLogger,
) : WindowDecorationViewHolder<AppHeaderViewHolder.HeaderData>(rootView) {
) : WindowDecorationViewHolder<AppHeaderViewHolder.HeaderData>() {

    data class HeaderData(
        val taskInfo: RunningTaskInfo,
@@ -172,6 +176,13 @@ class AppHeaderViewHolder(
            .getDimensionPixelSize(R.dimen.desktop_mode_header_close_ripple_inset_horizontal)
    )

    override val rootView =
        appHeaderView ?: if (DesktopExperienceFlags.ENABLE_WINDOW_DECORATION_REFACTOR.isTrue) {
            LayoutInflater.from(context)
            .inflate(R.layout.desktop_mode_app_header, null) as WindowDecorLinearLayout
    } else {
        error("App Header root view should not be null")
    }
    private val captionView: View = rootView.requireViewById(R.id.desktop_mode_caption)
    private val captionHandle: View = rootView.requireViewById(R.id.caption_handle)
    private val openMenuButton: View = rootView.requireViewById(R.id.open_menu_button)
@@ -996,7 +1007,8 @@ class AppHeaderViewHolder(

    class Factory {
        fun create(
            rootView: View,
            rootView: View?,
            context: Context,
            windowDecorationActions: WindowDecorationActions,
            onCaptionTouchListener: View.OnTouchListener,
            onCaptionButtonClickListener: View.OnClickListener,
@@ -1006,6 +1018,7 @@ class AppHeaderViewHolder(
            desktopModeUiEventLogger: DesktopModeUiEventLogger
        ): AppHeaderViewHolder = AppHeaderViewHolder(
            rootView,
            context,
            windowDecorationActions,
            onCaptionTouchListener,
            onCaptionButtonClickListener,
+3 −3
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
package com.android.wm.shell.windowdecor.viewholder

import android.app.ActivityManager.RunningTaskInfo
import android.content.Context
import android.view.View
import com.android.wm.shell.windowdecor.viewholder.WindowDecorationViewHolder.Data

@@ -24,8 +23,9 @@ import com.android.wm.shell.windowdecor.viewholder.WindowDecorationViewHolder.Da
 * Encapsulates the root [View] of a window decoration and its children to facilitate looking up
 * children (via findViewById) and updating to the latest data from [RunningTaskInfo].
 */
abstract class WindowDecorationViewHolder<T : Data>(rootView: View) : AutoCloseable {
  val context: Context = rootView.context
abstract class WindowDecorationViewHolder<T : Data> : AutoCloseable {
  /** The root view of the window decoration. */
  abstract val rootView: View

  /**
   * A signal to the view holder that new data is available and that the views should be updated to
+2 −2
Original line number Diff line number Diff line
@@ -319,10 +319,10 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
        when(mMockMultiInstanceHelper.supportsMultiInstanceSplit(any(), anyInt()))
                .thenReturn(false);
        when(mMockAppHeaderViewHolderFactory
                .create(any(), any(), any(), any(), any(), any(), any(), any()))
                .create(any(), any(), any(), any(), any(), any(), any(), any(), any()))
                .thenReturn(mMockAppHeaderViewHolder);
        when(mMockAppHandleViewHolderFactory
                .create(any(), any(), any(), any(), any(), any()))
                .create(any(), any(), any(), any(), any(), any(), any()))
                .thenReturn(mMockAppHandleViewHolder);
        when(mMockDesktopUserRepositories.getCurrent()).thenReturn(mDesktopRepository);
        when(mMockDesktopUserRepositories.getProfile(anyInt())).thenReturn(mDesktopRepository);
Loading