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

Commit 0bea7ebf authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "New behavior for docked stack when going home" into nyc-dev

parents 15d6eafe 42625d1b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -33,4 +33,13 @@ oneway interface IDockedStackListener {
     * Called when the docked stack gets created or removed.
     */
    void onDockedStackExistsChanged(boolean exists);

    /**
     * Called when window manager decides to minimize the docked stack. The divider should make
     * itself not interactable and shrink a bit in this state.
     *
     * @param minimized Whether the docked stack is currently minimized.
     * @param animDuration The duration of the animation for changing the minimized state.
     */
    void onDockedStackMinimizedChanged(boolean minimized, long animDuration);
}
+46 −31
Original line number Diff line number Diff line
@@ -17,9 +17,9 @@
package com.android.internal.policy;

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

import static android.view.WindowManager.DOCKED_BOTTOM;
import static android.view.WindowManager.DOCKED_INVALID;
import static android.view.WindowManager.DOCKED_LEFT;
import static android.view.WindowManager.DOCKED_RIGHT;
import static android.view.WindowManager.DOCKED_TOP;
@@ -35,29 +35,43 @@ public class DockedDividerUtils {
            int displayWidth, int displayHeight, int dividerSize) {
        outRect.set(0, 0, displayWidth, displayHeight);
        switch (dockSide) {
            case WindowManager.DOCKED_LEFT:
            case DOCKED_LEFT:
                outRect.right = position;
                break;
            case WindowManager.DOCKED_TOP:
            case DOCKED_TOP:
                outRect.bottom = position;
                break;
            case WindowManager.DOCKED_RIGHT:
            case DOCKED_RIGHT:
                outRect.left = position + dividerSize;
                break;
            case WindowManager.DOCKED_BOTTOM:
            case DOCKED_BOTTOM:
                outRect.top = position + dividerSize;
                break;
        }
        sanitizeStackBounds(outRect);
        sanitizeStackBounds(outRect, dockSide == DOCKED_LEFT || dockSide == DOCKED_TOP);
    }

    public static void sanitizeStackBounds(Rect bounds) {
    /**
     * Makes sure that the bounds are always valid, i. e. they are at least one pixel high and wide.
     *
     * @param bounds The bounds to sanitize.
     * @param topLeft Pass true if the bounds are at the top/left of the screen, false if they are
     *                at the bottom/right. This is used to determine in which direction to extend
     *                the bounds.
     */
    public static void sanitizeStackBounds(Rect bounds, boolean topLeft) {

        // If the bounds are either on the top or left of the screen, rather move it further to the
        // left/top to make it more offscreen. If they are on the bottom or right, push them off the
        // screen by moving it even more to the bottom/right.
        if (topLeft) {
            if (bounds.left >= bounds.right) {
                bounds.left = bounds.right - 1;
            }
            if (bounds.top >= bounds.bottom) {
                bounds.top = bounds.bottom - 1;
            }
        } else {
            if (bounds.right <= bounds.left) {
                bounds.right = bounds.left + 1;
            }
@@ -65,16 +79,17 @@ public class DockedDividerUtils {
                bounds.bottom = bounds.top + 1;
            }
        }
    }

    public static int calculatePositionForBounds(Rect bounds, int dockSide, int dividerSize) {
        switch (dockSide) {
            case WindowManager.DOCKED_LEFT:
            case DOCKED_LEFT:
                return bounds.right;
            case WindowManager.DOCKED_TOP:
            case DOCKED_TOP:
                return bounds.bottom;
            case WindowManager.DOCKED_RIGHT:
            case DOCKED_RIGHT:
                return bounds.left - dividerSize;
            case WindowManager.DOCKED_BOTTOM:
            case DOCKED_BOTTOM:
                return bounds.top - dividerSize;
            default:
                return 0;
@@ -109,16 +124,16 @@ public class DockedDividerUtils {

    public static int invertDockSide(int dockSide) {
        switch (dockSide) {
            case WindowManager.DOCKED_LEFT:
                return WindowManager.DOCKED_RIGHT;
            case WindowManager.DOCKED_TOP:
                return WindowManager.DOCKED_BOTTOM;
            case WindowManager.DOCKED_RIGHT:
                return WindowManager.DOCKED_LEFT;
            case WindowManager.DOCKED_BOTTOM:
                return WindowManager.DOCKED_TOP;
            case DOCKED_LEFT:
                return DOCKED_RIGHT;
            case DOCKED_TOP:
                return DOCKED_BOTTOM;
            case DOCKED_RIGHT:
                return DOCKED_LEFT;
            case DOCKED_BOTTOM:
                return DOCKED_TOP;
            default:
                return WindowManager.DOCKED_INVALID;
                return DOCKED_INVALID;
        }
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -56,6 +56,10 @@
         calculate the bounds of the stacks-->
    <dimen name="docked_stack_divider_insets">19dp</dimen>

    <!-- To how much the docked stack gets reduced when we decide to minimize the docked stack, i.e.
         when the user opens homescreen. -->
    <dimen name="docked_stack_minimize_thickness">8dp</dimen>

    <!-- Min width for a tablet device -->
    <dimen name="min_xlarge_screen_width">800dp</dimen>

+1 −0
Original line number Diff line number Diff line
@@ -1506,6 +1506,7 @@
  <java-symbol type="bool" name="target_honeycomb_needs_options_menu" />
  <java-symbol type="dimen" name="docked_stack_divider_thickness" />
  <java-symbol type="dimen" name="docked_stack_divider_insets" />
  <java-symbol type="dimen" name="docked_stack_minimize_thickness" />
  <java-symbol type="integer" name="config_dockedStackDividerSnapMode" />
  <java-symbol type="fraction" name="docked_stack_divider_fixed_ratio" />
  <java-symbol type="dimen" name="navigation_bar_height" />
+28 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ public class Divider extends SystemUI {
    private DividerView mView;
    private DockDividerVisibilityListener mDockDividerVisibilityListener;
    private boolean mVisible = false;
    private boolean mMinimized = false;

    @Override
    public void start() {
@@ -81,6 +82,10 @@ public class Divider extends SystemUI {
    private void update(Configuration configuration) {
        removeDivider();
        addDivider(configuration);
        if (mMinimized) {
            mView.setMinimizedDockStack(true);
            mWindowManager.setTouchable(false);
        }
    }

    private void updateVisibility(final boolean visible) {
@@ -95,6 +100,23 @@ public class Divider extends SystemUI {
        });
    }

    private void updateMinimizedDockedStack(final boolean minimized, final long animDuration) {
        mView.post(new Runnable() {
            @Override
            public void run() {
                if (mMinimized != minimized) {
                    mMinimized = minimized;
                    mWindowManager.setTouchable(!minimized);
                    if (animDuration > 0) {
                        mView.setMinimizedDockStack(minimized, animDuration);
                    } else {
                        mView.setMinimizedDockStack(minimized);
                    }
                }
            }
        });
    }

    class DockDividerVisibilityListener extends IDockedStackListener.Stub {

        @Override
@@ -105,5 +127,11 @@ public class Divider extends SystemUI {
        @Override
        public void onDockedStackExistsChanged(boolean exists) throws RemoteException {
        }

        @Override
        public void onDockedStackMinimizedChanged(boolean minimized, long animDuration)
                throws RemoteException {
            updateMinimizedDockedStack(minimized, animDuration);
        }
    }
}
Loading