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

Commit c6c89a82 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Fix transition to recents in docked mode

Transition for non-compatible apps will be handled in a separate CL.

Change-Id: I9c474f7aa394e4f3eacd1845c78bee5874bd8a59
parent e909802b
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -381,4 +381,9 @@ interface IWindowManager
     * @param receiver The receiver to deliver the results to.
     */
    void requestAppKeyboardShortcuts(IResultReceiver receiver);

    /**
     * Retrieves the current stable insets from the primary display.
     */
    void getStableInsets(out Rect outInsets);
}
+13 −0
Original line number Diff line number Diff line
@@ -321,6 +321,19 @@ public final class Rect implements Parcelable {
        bottom -= dy;
    }

    /**
     * Insets the rectangle on all sides specified by the dimensions of the {@code insets}
     * rectangle.
     * @hide
     * @param insets The rectangle specifying the insets on all side.
     */
    public void inset(Rect insets) {
        left += insets.left;
        top += insets.top;
        right -= insets.right;
        bottom -= insets.bottom;
    }

    /**
     * Returns true if (x,y) is inside the rectangle. The left and top are
     * considered to be inside, while the right and bottom are not. This means
+3 −6
Original line number Diff line number Diff line
@@ -103,12 +103,9 @@ public class RecentsConfiguration {
    /**
     * Updates the configuration based on the current state of the system
     */
    void update(Rect windowRect) {
        // Recompute some values based on the given state, since we can not rely on the resource
        // system to get certain values.
        boolean isLandscape = windowRect.width() > windowRect.height();
        hasTransposedNavBar = isLandscape && !isXLargeScreen;
        hasTransposedSearchBar = isLandscape && !isXLargeScreen;
    void update(Rect systemInsets) {
        hasTransposedNavBar = systemInsets.right > 0;
        hasTransposedSearchBar = systemInsets.right > 0;
    }

    /**
+29 −7
Original line number Diff line number Diff line
@@ -599,10 +599,14 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
            TaskStack stack) {
        RecentsConfiguration config = Recents.getConfiguration();
        SystemServicesProxy ssp = Recents.getSystemServices();
        Rect systemInsets = new Rect();
        ssp.getStableInsets(systemInsets);
        Rect windowRect = ssp.getWindowRect();
        calculateWindowStableInsets(systemInsets, windowRect);
        windowRect.offsetTo(0, 0);

        // Update the configuration for the current state
        config.update(windowRect);
        config.update(systemInsets);

        if (RecentsDebugFlags.Static.EnableSearchBar && tryAndBindSearchWidget) {
            // Try and pre-emptively bind the search widget on startup to ensure that we
@@ -612,9 +616,6 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
                config.getSearchBarBounds(windowRect, mStatusBarHeight, mSearchBarBounds);
            }
        }
        Rect systemInsets = new Rect(0, mStatusBarHeight,
                (config.hasTransposedNavBar ? mNavBarWidth : 0),
                (config.hasTransposedNavBar ? 0 : mNavBarHeight));
        config.getTaskStackBounds(windowRect, systemInsets.top, systemInsets.right,
                mSearchBarBounds, mTaskStackBounds);

@@ -640,6 +641,26 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
        }
    }

    /**
     * Given the stable insets and the rect for our window, calculates the insets that affect our
     * window.
     */
    private void calculateWindowStableInsets(Rect inOutInsets, Rect windowRect) {
        Rect displayRect = Recents.getSystemServices().getDisplayRect();

        // Display rect without insets - available app space
        Rect appRect = new Rect(displayRect);
        appRect.inset(inOutInsets);

        // Our window intersected with available app space
        Rect windowRectWithInsets = new Rect(windowRect);
        windowRectWithInsets.intersect(appRect);
        inOutInsets.left = windowRectWithInsets.left - windowRect.left;
        inOutInsets.top = windowRectWithInsets.top - windowRect.top;
        inOutInsets.right = windowRect.right - windowRectWithInsets.right;
        inOutInsets.bottom = windowRect.bottom - windowRectWithInsets.bottom;
    }

    /**
     * Preloads the icon of a task.
     */
@@ -721,7 +742,8 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
            for (int i = tasks.size() - 1; i >= 0; i--) {
                Task task = tasks.get(i);
                if (task.isFreeformTask()) {
                    mTmpTransform = stackView.getStackAlgorithm().getStackTransform(task,
                    mTmpTransform = stackView.getStackAlgorithm()
                            .getStackTransformScreenCoordinates(task,
                                    stackView.getScroller().getStackScroll(), mTmpTransform, null);
                    Rect toTaskRect = new Rect();
                    mTmpTransform.rect.round(toTaskRect);
@@ -783,7 +805,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener

        // Get the transform for the running task
        stackView.getScroller().setStackScrollToInitialState();
        mTmpTransform = stackView.getStackAlgorithm().getStackTransform(launchTask,
        mTmpTransform = stackView.getStackAlgorithm().getStackTransformScreenCoordinates(launchTask,
                stackView.getScroller().getStackScroll(), mTmpTransform, null);
        return mTmpTransform;
    }
+11 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.hardware.display.DisplayManager;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
@@ -977,6 +978,16 @@ public class SystemServicesProxy {
        mWm.requestAppKeyboardShortcuts(receiver);
    }

    public void getStableInsets(Rect outStableInsets) {
        if (mWm == null) return;

        try {
            WindowManagerGlobal.getWindowManagerService().getStableInsets(outStableInsets);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public void focusPinnedStack() {
        try {
            mIam.setFocusedStack(PINNED_STACK_ID);
Loading