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

Commit 3a00b5db authored by Merissa Mitchell's avatar Merissa Mitchell Committed by Automerger Merge Worker
Browse files

Merge "Minor style cleanup for Shell caption classes." into tm-qpr-dev am: 1c58bf55

parents 595d584b 1c58bf55
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
    }

    private void setupCaptionColor(RunningTaskInfo taskInfo, CaptionWindowDecoration decoration) {
        int statusBarColor = taskInfo.taskDescription.getStatusBarColor();
        final int statusBarColor = taskInfo.taskDescription.getStatusBarColor();
        decoration.setCaptionColor(statusBarColor);
    }

@@ -152,7 +152,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
            SurfaceControl taskSurface,
            SurfaceControl.Transaction startT,
            SurfaceControl.Transaction finishT) {
        CaptionWindowDecoration oldDecoration = mWindowDecorByTaskId.get(taskInfo.taskId);
        final CaptionWindowDecoration oldDecoration = mWindowDecorByTaskId.get(taskInfo.taskId);
        if (oldDecoration != null) {
            // close the old decoration if it exists to avoid two window decorations being added
            oldDecoration.close();
@@ -169,9 +169,9 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
                        mSyncQueue);
        mWindowDecorByTaskId.put(taskInfo.taskId, windowDecoration);

        TaskPositioner taskPositioner =
        final TaskPositioner taskPositioner =
                new TaskPositioner(mTaskOrganizer, windowDecoration);
        CaptionTouchEventListener touchEventListener =
        final CaptionTouchEventListener touchEventListener =
                new CaptionTouchEventListener(taskInfo, taskPositioner);
        windowDecoration.setCaptionListeners(touchEventListener, touchEventListener);
        windowDecoration.setDragResizeCallback(taskPositioner);
@@ -221,11 +221,11 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
            if (e.getAction() != MotionEvent.ACTION_DOWN) {
                return false;
            }
            RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId);
            final RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId);
            if (taskInfo.isFocused) {
                return false;
            }
            WindowContainerTransaction wct = new WindowContainerTransaction();
            final WindowContainerTransaction wct = new WindowContainerTransaction();
            wct.reorder(mTaskToken, true /* onTop */);
            mSyncQueue.queue(wct);
            return true;
@@ -236,7 +236,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
         * @return {@code true} if a drag is happening; or {@code false} if it is not
         */
        private void handleEventForMove(MotionEvent e) {
            RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId);
            final RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId);
            if (taskInfo.getWindowingMode() == WINDOWING_MODE_FULLSCREEN) {
                return;
            }
+28 −29
Original line number Diff line number Diff line
@@ -48,15 +48,13 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
    private View.OnClickListener mOnCaptionButtonClickListener;
    private View.OnTouchListener mOnCaptionTouchListener;
    private DragResizeCallback mDragResizeCallback;

    private DragResizeInputListener mDragResizeListener;
    private final DragDetector mDragDetector;

    private RelayoutParams mRelayoutParams = new RelayoutParams();
    private final RelayoutResult<WindowDecorLinearLayout> mResult =
            new RelayoutResult<>();

    private DragDetector mDragDetector;

    CaptionWindowDecoration(
            Context context,
            DisplayController displayController,
@@ -104,14 +102,14 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
                taskInfo.getWindowingMode() == WindowConfiguration.WINDOWING_MODE_FREEFORM;
        final boolean isDragResizeable = isFreeform && taskInfo.isResizeable;

        WindowDecorLinearLayout oldRootView = mResult.mRootView;
        final WindowDecorLinearLayout oldRootView = mResult.mRootView;
        final SurfaceControl oldDecorationSurface = mDecorationContainerSurface;
        final WindowContainerTransaction wct = new WindowContainerTransaction();

        int outsetLeftId = R.dimen.freeform_resize_handle;
        int outsetTopId = R.dimen.freeform_resize_handle;
        int outsetRightId = R.dimen.freeform_resize_handle;
        int outsetBottomId = R.dimen.freeform_resize_handle;
        final int outsetLeftId = R.dimen.freeform_resize_handle;
        final int outsetTopId = R.dimen.freeform_resize_handle;
        final int outsetRightId = R.dimen.freeform_resize_handle;
        final int outsetBottomId = R.dimen.freeform_resize_handle;

        mRelayoutParams.reset();
        mRelayoutParams.mRunningTaskInfo = taskInfo;
@@ -123,7 +121,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
        }

        relayout(mRelayoutParams, startT, finishT, wct, oldRootView, mResult);
        taskInfo = null; // Clear it just in case we use it accidentally
        // After this line, mTaskInfo is up-to-date and should be used instead of taskInfo

        mTaskOrganizer.applyTransaction(wct);

@@ -152,12 +150,13 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
                    mDragResizeCallback);
        }

        int touchSlop = ViewConfiguration.get(mResult.mRootView.getContext()).getScaledTouchSlop();
        final int touchSlop = ViewConfiguration.get(mResult.mRootView.getContext())
                .getScaledTouchSlop();
        mDragDetector.setTouchSlop(touchSlop);

        int resize_handle = mResult.mRootView.getResources()
        final int resize_handle = mResult.mRootView.getResources()
                .getDimensionPixelSize(R.dimen.freeform_resize_handle);
        int resize_corner = mResult.mRootView.getResources()
        final int resize_corner = mResult.mRootView.getResources()
                .getDimensionPixelSize(R.dimen.freeform_resize_corner);
        mDragResizeListener.setGeometry(
                mResult.mWidth, mResult.mHeight, resize_handle, resize_corner, touchSlop);
@@ -167,15 +166,15 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
     * Sets up listeners when a new root view is created.
     */
    private void setupRootView() {
        View caption = mResult.mRootView.findViewById(R.id.caption);
        final View caption = mResult.mRootView.findViewById(R.id.caption);
        caption.setOnTouchListener(mOnCaptionTouchListener);
        View close = caption.findViewById(R.id.close_window);
        final View close = caption.findViewById(R.id.close_window);
        close.setOnClickListener(mOnCaptionButtonClickListener);
        View back = caption.findViewById(R.id.back_button);
        final View back = caption.findViewById(R.id.back_button);
        back.setOnClickListener(mOnCaptionButtonClickListener);
        View minimize = caption.findViewById(R.id.minimize_window);
        final View minimize = caption.findViewById(R.id.minimize_window);
        minimize.setOnClickListener(mOnCaptionButtonClickListener);
        View maximize = caption.findViewById(R.id.maximize_window);
        final View maximize = caption.findViewById(R.id.maximize_window);
        maximize.setOnClickListener(mOnCaptionButtonClickListener);
    }

@@ -184,31 +183,31 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
            return;
        }

        View caption = mResult.mRootView.findViewById(R.id.caption);
        GradientDrawable captionDrawable = (GradientDrawable) caption.getBackground();
        final View caption = mResult.mRootView.findViewById(R.id.caption);
        final GradientDrawable captionDrawable = (GradientDrawable) caption.getBackground();
        captionDrawable.setColor(captionColor);

        int buttonTintColorRes =
        final int buttonTintColorRes =
                Color.valueOf(captionColor).luminance() < 0.5
                        ? R.color.decor_button_light_color
                        : R.color.decor_button_dark_color;
        ColorStateList buttonTintColor =
        final ColorStateList buttonTintColor =
                caption.getResources().getColorStateList(buttonTintColorRes, null /* theme */);

        View back = caption.findViewById(R.id.back_button);
        VectorDrawable backBackground = (VectorDrawable) back.getBackground();
        final View back = caption.findViewById(R.id.back_button);
        final VectorDrawable backBackground = (VectorDrawable) back.getBackground();
        backBackground.setTintList(buttonTintColor);

        View minimize = caption.findViewById(R.id.minimize_window);
        VectorDrawable minimizeBackground = (VectorDrawable) minimize.getBackground();
        final View minimize = caption.findViewById(R.id.minimize_window);
        final VectorDrawable minimizeBackground = (VectorDrawable) minimize.getBackground();
        minimizeBackground.setTintList(buttonTintColor);

        View maximize = caption.findViewById(R.id.maximize_window);
        VectorDrawable maximizeBackground = (VectorDrawable) maximize.getBackground();
        final View maximize = caption.findViewById(R.id.maximize_window);
        final VectorDrawable maximizeBackground = (VectorDrawable) maximize.getBackground();
        maximizeBackground.setTintList(buttonTintColor);

        View close = caption.findViewById(R.id.close_window);
        VectorDrawable closeBackground = (VectorDrawable) close.getBackground();
        final View close = caption.findViewById(R.id.close_window);
        final VectorDrawable closeBackground = (VectorDrawable) close.getBackground();
        closeBackground.setTintList(buttonTintColor);
    }

+30 −31
Original line number Diff line number Diff line
@@ -68,9 +68,8 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
    private final Choreographer mMainChoreographer;
    private final DisplayController mDisplayController;
    private final SyncTransactionQueue mSyncQueue;
    private FreeformTaskTransitionStarter mTransitionStarter;
    private Optional<DesktopModeController> mDesktopModeController;
    private Optional<DesktopTasksController> mDesktopTasksController;
    private final Optional<DesktopModeController> mDesktopModeController;
    private final Optional<DesktopTasksController> mDesktopTasksController;
    private boolean mTransitionDragActive;

    private SparseArray<EventReceiver> mEventReceiversByDisplay = new SparseArray<>();
@@ -78,7 +77,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
    private final SparseArray<DesktopModeWindowDecoration> mWindowDecorByTaskId =
            new SparseArray<>();
    private final DragStartListenerImpl mDragStartListener = new DragStartListenerImpl();
    private InputMonitorFactory mInputMonitorFactory;
    private final InputMonitorFactory mInputMonitorFactory;
    private TaskOperations mTaskOperations;

    public DesktopModeWindowDecorViewModel(
@@ -199,7 +198,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
        if (decoration == null) return;

        decoration.close();
        int displayId = taskInfo.displayId;
        final int displayId = taskInfo.displayId;
        if (mEventReceiversByDisplay.contains(displayId)) {
            removeTaskFromEventReceiver(displayId);
        }
@@ -227,7 +226,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {

        @Override
        public void onClick(View v) {
            DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId);
            final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId);
            final int id = v.getId();
            if (id == R.id.close_window) {
                mTaskOperations.closeTask(mTaskToken);
@@ -250,7 +249,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
        @Override
        public boolean onTouch(View v, MotionEvent e) {
            boolean isDrag = false;
            int id = v.getId();
            final int id = v.getId();
            if (id != R.id.caption_handle && id != R.id.desktop_mode_caption) {
                return false;
            }
@@ -261,11 +260,11 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
            if (e.getAction() != MotionEvent.ACTION_DOWN) {
                return isDrag;
            }
            RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId);
            final RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId);
            if (taskInfo.isFocused) {
                return isDrag;
            }
            WindowContainerTransaction wct = new WindowContainerTransaction();
            final WindowContainerTransaction wct = new WindowContainerTransaction();
            wct.reorder(mTaskToken, true /* onTop */);
            mSyncQueue.queue(wct);
            return true;
@@ -276,7 +275,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
         * @return {@code true} if a drag is happening; or {@code false} if it is not
         */
        private void handleEventForMove(MotionEvent e) {
            RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId);
            final RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId);
            if (DesktopModeStatus.isProto2Enabled()
                    && taskInfo.getWindowingMode() == WINDOWING_MODE_FULLSCREEN) {
                return;
@@ -295,16 +294,16 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
                    break;
                }
                case MotionEvent.ACTION_MOVE: {
                    int dragPointerIdx = e.findPointerIndex(mDragPointerId);
                    final int dragPointerIdx = e.findPointerIndex(mDragPointerId);
                    mDragResizeCallback.onDragResizeMove(
                            e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
                    break;
                }
                case MotionEvent.ACTION_UP:
                case MotionEvent.ACTION_CANCEL: {
                    int dragPointerIdx = e.findPointerIndex(mDragPointerId);
                    int statusBarHeight = mDisplayController.getDisplayLayout(taskInfo.displayId)
                            .stableInsets().top;
                    final int dragPointerIdx = e.findPointerIndex(mDragPointerId);
                    final int statusBarHeight = mDisplayController
                            .getDisplayLayout(taskInfo.displayId).stableInsets().top;
                    mDragResizeCallback.onDragResizeEnd(
                            e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
                    if (e.getRawY(dragPointerIdx) <= statusBarHeight) {
@@ -378,7 +377,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
     */
    private void incrementEventReceiverTasks(int displayId) {
        if (mEventReceiversByDisplay.contains(displayId)) {
            EventReceiver eventReceiver = mEventReceiversByDisplay.get(displayId);
            final EventReceiver eventReceiver = mEventReceiversByDisplay.get(displayId);
            eventReceiver.incrementTaskNumber();
        } else {
            createInputChannel(displayId);
@@ -388,7 +387,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
    // If all tasks on this display are gone, we don't need to monitor its input.
    private void removeTaskFromEventReceiver(int displayId) {
        if (!mEventReceiversByDisplay.contains(displayId)) return;
        EventReceiver eventReceiver = mEventReceiversByDisplay.get(displayId);
        final EventReceiver eventReceiver = mEventReceiversByDisplay.get(displayId);
        if (eventReceiver == null) return;
        eventReceiver.decrementTaskNumber();
        if (eventReceiver.getTasksOnDisplay() == 0) {
@@ -403,7 +402,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
     */
    private void handleReceivedMotionEvent(MotionEvent ev, InputMonitor inputMonitor) {
        if (DesktopModeStatus.isProto2Enabled()) {
            DesktopModeWindowDecoration focusedDecor = getFocusedDecor();
            final DesktopModeWindowDecoration focusedDecor = getFocusedDecor();
            if (focusedDecor == null
                    || focusedDecor.mTaskInfo.getWindowingMode() != WINDOWING_MODE_FREEFORM) {
                handleCaptionThroughStatusBar(ev);
@@ -428,9 +427,9 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {

    // If an UP/CANCEL action is received outside of caption bounds, turn off handle menu
    private void handleEventOutsideFocusedCaption(MotionEvent ev) {
        int action = ev.getActionMasked();
        final int action = ev.getActionMasked();
        if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
            DesktopModeWindowDecoration focusedDecor = getFocusedDecor();
            final DesktopModeWindowDecoration focusedDecor = getFocusedDecor();
            if (focusedDecor == null) {
                return;
            }
@@ -450,7 +449,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
        switch (ev.getActionMasked()) {
            case MotionEvent.ACTION_DOWN: {
                // Begin drag through status bar if applicable.
                DesktopModeWindowDecoration focusedDecor = getFocusedDecor();
                final DesktopModeWindowDecoration focusedDecor = getFocusedDecor();
                if (focusedDecor != null) {
                    boolean dragFromStatusBarAllowed = false;
                    if (DesktopModeStatus.isProto2Enabled()) {
@@ -469,14 +468,14 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
                break;
            }
            case MotionEvent.ACTION_UP: {
                DesktopModeWindowDecoration focusedDecor = getFocusedDecor();
                final DesktopModeWindowDecoration focusedDecor = getFocusedDecor();
                if (focusedDecor == null) {
                    mTransitionDragActive = false;
                    return;
                }
                if (mTransitionDragActive) {
                    mTransitionDragActive = false;
                    int statusBarHeight = mDisplayController
                    final int statusBarHeight = mDisplayController
                            .getDisplayLayout(focusedDecor.mTaskInfo.displayId).stableInsets().top;
                    if (ev.getY() > statusBarHeight) {
                        if (DesktopModeStatus.isProto2Enabled()) {
@@ -500,10 +499,10 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {

    @Nullable
    private DesktopModeWindowDecoration getFocusedDecor() {
        int size = mWindowDecorByTaskId.size();
        final int size = mWindowDecorByTaskId.size();
        DesktopModeWindowDecoration focusedDecor = null;
        for (int i = 0; i < size; i++) {
            DesktopModeWindowDecoration decor = mWindowDecorByTaskId.valueAt(i);
            final DesktopModeWindowDecoration decor = mWindowDecorByTaskId.valueAt(i);
            if (decor != null && decor.isFocused()) {
                focusedDecor = decor;
                break;
@@ -513,16 +512,16 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
    }

    private void createInputChannel(int displayId) {
        InputManager inputManager = InputManager.getInstance();
        InputMonitor inputMonitor =
        final InputManager inputManager = InputManager.getInstance();
        final InputMonitor inputMonitor =
                mInputMonitorFactory.create(inputManager, mContext);
        EventReceiver eventReceiver = new EventReceiver(inputMonitor,
        final EventReceiver eventReceiver = new EventReceiver(inputMonitor,
                inputMonitor.getInputChannel(), Looper.myLooper());
        mEventReceiversByDisplay.put(displayId, eventReceiver);
    }

    private void disposeInputChannel(int displayId) {
        EventReceiver eventReceiver = mEventReceiversByDisplay.removeReturnOld(displayId);
        final EventReceiver eventReceiver = mEventReceiversByDisplay.removeReturnOld(displayId);
        if (eventReceiver != null) {
            eventReceiver.dispose();
        }
@@ -541,7 +540,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
            SurfaceControl taskSurface,
            SurfaceControl.Transaction startT,
            SurfaceControl.Transaction finishT) {
        DesktopModeWindowDecoration oldDecoration = mWindowDecorByTaskId.get(taskInfo.taskId);
        final DesktopModeWindowDecoration oldDecoration = mWindowDecorByTaskId.get(taskInfo.taskId);
        if (oldDecoration != null) {
            // close the old decoration if it exists to avoid two window decorations being added
            oldDecoration.close();
@@ -558,9 +557,9 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
                        mSyncQueue);
        mWindowDecorByTaskId.put(taskInfo.taskId, windowDecoration);

        TaskPositioner taskPositioner =
        final TaskPositioner taskPositioner =
                new TaskPositioner(mTaskOrganizer, windowDecoration, mDragStartListener);
        DesktopModeTouchEventListener touchEventListener =
        final DesktopModeTouchEventListener touchEventListener =
                new DesktopModeTouchEventListener(
                        taskInfo, taskPositioner, windowDecoration.getDragDetector());
        windowDecoration.setCaptionListeners(touchEventListener, touchEventListener);
+47 −49

File changed.

Preview size limit exceeded, changes collapsed.