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

Commit d0b0fa16 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Revert "Snap docked stack after screen rotation""

parents 51df6b88 3dc52ed1
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -1328,15 +1328,4 @@ public interface WindowManagerPolicy {
     * @param fadeoutDuration the duration of the exit animation, in milliseconds
     */
    public void startKeyguardExitAnimation(long startTime, long fadeoutDuration);

    /**
     * Calculates the stable insets without running a layout.
     *
     * @param displayRotation the current display rotation
     * @param outInsets the insets to return
     * @param displayWidth the current display width
     * @param displayHeight the current display height
     */
    public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight,
            Rect outInsets);
}
+0 −74
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 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.internal.policy;

import android.graphics.Rect;
import android.view.WindowManager;

/**
 * Utility functions for docked stack divider used by both window manager and System UI.
 *
 * @hide
 */
public class DockedDividerUtils {

    public static void calculateBoundsForPosition(int position, int dockSide, Rect outRect,
            int displayWidth, int displayHeight, int dividerSize) {
        outRect.set(0, 0, displayWidth, displayHeight);
        switch (dockSide) {
            case WindowManager.DOCKED_LEFT:
                outRect.right = position;
                break;
            case WindowManager.DOCKED_TOP:
                outRect.bottom = position;
                break;
            case WindowManager.DOCKED_RIGHT:
                outRect.left = position + dividerSize;
                break;
            case WindowManager.DOCKED_BOTTOM:
                outRect.top = position + dividerSize;
                break;
        }
        if (outRect.left > outRect.right) {
            outRect.left = outRect.right;
        }
        if (outRect.top > outRect.bottom) {
            outRect.top = outRect.bottom;
        }
        if (outRect.right < outRect.left) {
            outRect.right = outRect.left;
        }
        if (outRect.bottom < outRect.top) {
            outRect.bottom = outRect.top;
        }
    }

    public static int calculatePositionForBounds(Rect bounds, int dockSide, int dividerSize) {
        switch (dockSide) {
            case WindowManager.DOCKED_LEFT:
                return bounds.right;
            case WindowManager.DOCKED_TOP:
                return bounds.bottom;
            case WindowManager.DOCKED_RIGHT:
                return bounds.left - dividerSize;
            case WindowManager.DOCKED_BOTTOM:
                return bounds.top - dividerSize;
            default:
                return 0;
        }
    }
}
+11 −21
Original line number Diff line number Diff line
@@ -14,19 +14,18 @@
 * limitations under the License.
 */

package com.android.internal.policy;
package com.android.systemui.stackdivider;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Rect;

import com.android.systemui.statusbar.FlingAnimationUtils;

import java.util.ArrayList;

/**
 * Calculates the snap targets and the snap position given a position and a velocity. All positions
 * here are to be interpreted as the left/top edge of the divider rectangle.
 *
 * @hide
 */
public class DividerSnapAlgorithm {

@@ -45,7 +44,8 @@ public class DividerSnapAlgorithm {
     */
    private static final int SNAP_ONLY_1_1 = 2;

    private final float mMinFlingVelocityPxPerSecond;
    private final Context mContext;
    private final FlingAnimationUtils mFlingAnimationUtils;
    private final int mDisplayWidth;
    private final int mDisplayHeight;
    private final int mDividerSize;
@@ -63,17 +63,18 @@ public class DividerSnapAlgorithm {
    private final SnapTarget mDismissStartTarget;
    private final SnapTarget mDismissEndTarget;

    public DividerSnapAlgorithm(Resources res, float minFlingVelocityPxPerSecond,
    public DividerSnapAlgorithm(Context ctx, FlingAnimationUtils flingAnimationUtils,
            int displayWidth, int displayHeight, int dividerSize, boolean isHorizontalDivision,
            Rect insets) {
        mMinFlingVelocityPxPerSecond = minFlingVelocityPxPerSecond;
        mContext = ctx;
        mFlingAnimationUtils = flingAnimationUtils;
        mDividerSize = dividerSize;
        mDisplayWidth = displayWidth;
        mDisplayHeight = displayHeight;
        mInsets.set(insets);
        mSnapMode = res.getInteger(
        mSnapMode = ctx.getResources().getInteger(
                com.android.internal.R.integer.config_dockedStackDividerSnapMode);
        mFixedRatio = res.getFraction(
        mFixedRatio = ctx.getResources().getFraction(
                com.android.internal.R.fraction.docked_stack_divider_fixed_ratio, 1, 1);
        calculateTargets(isHorizontalDivision);
        mFirstSplitTarget = mTargets.get(1);
@@ -83,7 +84,7 @@ public class DividerSnapAlgorithm {
    }

    public SnapTarget calculateSnapTarget(int position, float velocity) {
        if (Math.abs(velocity) < mMinFlingVelocityPxPerSecond) {
        if (Math.abs(velocity) < mFlingAnimationUtils.getMinVelocityPxPerSecond()) {
            return snap(position);
        }
        if (position < mFirstSplitTarget.position && velocity < 0) {
@@ -99,17 +100,6 @@ public class DividerSnapAlgorithm {
        }
    }

    public SnapTarget calculateNonDismissingSnapTarget(int position) {
        SnapTarget target = snap(position);
        if (target == mDismissStartTarget) {
            return mFirstSplitTarget;
        } else if (target == mDismissEndTarget) {
            return mLastSplitTarget;
        } else {
            return target;
        }
    }

    public float calculateDismissingFraction(int position) {
        if (position < mFirstSplitTarget.position) {
            return 1f - (float) position / mFirstSplitTarget.position;
+34 −10
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.graphics.Rect;
import android.graphics.Region.Op;
import android.hardware.display.DisplayManager;
import android.util.AttributeSet;
import android.util.MathUtils;
import android.view.Display;
import android.view.DisplayInfo;
import android.view.MotionEvent;
@@ -38,6 +39,7 @@ import android.view.View.OnTouchListener;
import android.view.ViewConfiguration;
import android.view.ViewTreeObserver.InternalInsetsInfo;
import android.view.ViewTreeObserver.OnComputeInternalInsetsListener;
import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
@@ -46,10 +48,8 @@ import android.view.animation.PathInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageButton;

import com.android.internal.policy.DividerSnapAlgorithm;
import com.android.internal.policy.DockedDividerUtils;
import com.android.systemui.R;
import com.android.internal.policy.DividerSnapAlgorithm.SnapTarget;
import com.android.systemui.stackdivider.DividerSnapAlgorithm.SnapTarget;
import com.android.systemui.statusbar.FlingAnimationUtils;

import static android.view.PointerIcon.STYLE_HORIZONTAL_DOUBLE_ARROW;
@@ -167,8 +167,7 @@ public class DividerView extends FrameLayout implements OnTouchListener,
    public boolean startDragging(boolean animate) {
        mHandle.setTouching(true, animate);
        mDockSide = mWindowManagerProxy.getDockSide();
        mSnapAlgorithm = new DividerSnapAlgorithm(getContext().getResources(),
                mFlingAnimationUtils.getMinVelocityPxPerSecond(), mDisplayWidth,
        mSnapAlgorithm = new DividerSnapAlgorithm(getContext(), mFlingAnimationUtils, mDisplayWidth,
                mDisplayHeight, mDividerSize, isHorizontalDivision(), mStableInsets);
        if (mDockSide != WindowManager.DOCKED_INVALID) {
            mWindowManagerProxy.setResizing(true);
@@ -363,6 +362,36 @@ public class DividerView extends FrameLayout implements OnTouchListener,
        return mStartPosition + touchY - mStartY;
    }

    public void calculateBoundsForPosition(int position, int dockSide, Rect outRect) {
        outRect.set(0, 0, mDisplayWidth, mDisplayHeight);
        switch (dockSide) {
            case WindowManager.DOCKED_LEFT:
                outRect.right = position;
                break;
            case WindowManager.DOCKED_TOP:
                outRect.bottom = position;
                break;
            case WindowManager.DOCKED_RIGHT:
                outRect.left = position + mDividerWindowWidth - 2 * mDividerInsets;
                break;
            case WindowManager.DOCKED_BOTTOM:
                outRect.top = position + mDividerWindowWidth - 2 * mDividerInsets;
                break;
        }
        if (outRect.left > outRect.right) {
            outRect.left = outRect.right;
        }
        if (outRect.top > outRect.bottom) {
            outRect.top = outRect.bottom;
        }
        if (outRect.right < outRect.left) {
            outRect.right = outRect.left;
        }
        if (outRect.bottom < outRect.top) {
            outRect.bottom = outRect.top;
        }
    }

    private int invertDockSide(int dockSide) {
        switch (dockSide) {
            case WindowManager.DOCKED_LEFT:
@@ -392,11 +421,6 @@ public class DividerView extends FrameLayout implements OnTouchListener,
                containingRect.right, containingRect.bottom);
    }

    public void calculateBoundsForPosition(int position, int dockSide, Rect outRect) {
        DockedDividerUtils.calculateBoundsForPosition(position, dockSide, outRect, mDisplayWidth,
                mDisplayHeight, mDividerSize);
    }

    public void resizeStack(int position, int taskPosition, SnapTarget taskSnapTarget) {
        calculateBoundsForPosition(position, mDockSide, mDockedRect);

+2 −1
Original line number Diff line number Diff line
@@ -29,7 +29,8 @@ import com.android.internal.logging.MetricsLogger;
import com.android.systemui.R;
import com.android.systemui.RecentsComponent;
import com.android.systemui.stackdivider.Divider;
import com.android.internal.policy.DividerSnapAlgorithm.SnapTarget;
import com.android.systemui.stackdivider.DividerSnapAlgorithm.SnapTarget;
import com.android.systemui.stackdivider.DividerView;
import com.android.systemui.tuner.TunerService;

import static android.view.WindowManager.*;
Loading