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

Commit f9ae1a83 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fixing fallback recents not getting proper insets on configuration...

Merge "Fixing fallback recents not getting proper insets on configuration change" into ub-launcher3-rvc-dev
parents bb825734 9d89f75c
Loading
Loading
Loading
Loading
+18 −13
Original line number Diff line number Diff line
@@ -13,14 +13,18 @@
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<com.android.quickstep.fallback.RecentsRootView
<com.android.launcher3.LauncherRootView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drag_layer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipChildren="false"
    android:fitsSystemWindows="true">

    <com.android.quickstep.fallback.RecentsDragLayer
        android:id="@+id/drag_layer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipChildren="false">

        <com.android.quickstep.fallback.FallbackRecentsView
            android:id="@id/overview_panel"
            android:layout_width="match_parent"
@@ -34,4 +38,5 @@
            android:id="@+id/overview_actions_view"
            layout="@layout/overview_actions_container" />

</com.android.quickstep.fallback.RecentsRootView>
    </com.android.quickstep.fallback.RecentsDragLayer>
</com.android.launcher3.LauncherRootView>
+12 −21
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ import com.android.launcher3.util.Themes;
import com.android.launcher3.views.BaseDragLayer;
import com.android.quickstep.fallback.FallbackRecentsStateController;
import com.android.quickstep.fallback.FallbackRecentsView;
import com.android.quickstep.fallback.RecentsRootView;
import com.android.quickstep.fallback.RecentsDragLayer;
import com.android.quickstep.fallback.RecentsState;
import com.android.quickstep.util.RecentsAtomicAnimationFactory;
import com.android.quickstep.views.OverviewActionsView;
@@ -78,7 +78,8 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {
            new ActivityTracker<>();

    private Handler mUiHandler = new Handler(Looper.getMainLooper());
    private RecentsRootView mRecentsRootView;

    private RecentsDragLayer mDragLayer;
    private FallbackRecentsView mFallbackRecentsView;
    private OverviewActionsView mActionsView;

@@ -89,13 +90,14 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {
    /**
     * Init drag layer and overview panel views.
     */
    protected void initViews() {
        setContentView(R.layout.fallback_recents_activity);
        mRecentsRootView = findViewById(R.id.drag_layer);
    protected void setupViews() {
        inflateRootView(R.layout.fallback_recents_activity);
        setContentView(getRootView());
        mDragLayer = findViewById(R.id.drag_layer);
        mFallbackRecentsView = findViewById(R.id.overview_panel);
        mActionsView = findViewById(R.id.overview_actions_view);

        mRecentsRootView.recreateControllers();
        mDragLayer.recreateControllers();
        mFallbackRecentsView.init(mActionsView);
    }

@@ -105,12 +107,6 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {
        super.onMultiWindowModeChanged(isInMultiWindowMode, newConfig);
    }

    public void onRootViewSizeChanged() {
        if (isInMultiWindowMode()) {
            onHandleConfigChanged();
        }
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
@@ -130,7 +126,7 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {
        dispatchDeviceProfileChanged();

        reapplyUi();
        mRecentsRootView.recreateControllers();
        mDragLayer.recreateControllers();
    }

    /**
@@ -142,19 +138,14 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {

        // In case we are reusing IDP, create a copy so that we don't conflict with Launcher
        // activity.
        return (mRecentsRootView != null) && isInMultiWindowMode()
        return (mDragLayer != null) && isInMultiWindowMode()
                ? dp.getMultiWindowProfile(this, getMultiWindowDisplaySize())
                : dp.copy(this);
    }

    @Override
    public BaseDragLayer getDragLayer() {
        return mRecentsRootView;
    }

    @Override
    public View getRootView() {
        return mRecentsRootView;
        return mDragLayer;
    }

    @Override
@@ -252,7 +243,7 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {

        mOldConfig = new Configuration(getResources().getConfiguration());
        initDeviceProfile();
        initViews();
        setupViews();

        getSystemUiController().updateUiState(SystemUiController.UI_STATE_BASE_WINDOW,
                Themes.getAttrBoolean(this, R.attr.isWorkspaceDarkText));
+12 −1
Original line number Diff line number Diff line
@@ -106,12 +106,23 @@ public class FallbackRecentsView extends RecentsView<RecentsActivity>
        }
    }

    @Override
    protected boolean shouldAddDummyTaskView(int runningTaskId) {
        if (mHomeTaskInfo != null && mHomeTaskInfo.taskId == runningTaskId
                && getTaskViewCount() == 0) {
            // Do not add a dummy task if we are running over home with empty recents, so that we
            // show the empty recents message instead of showing a dummy task and later removing it.
            return false;
        }
        return super.shouldAddDummyTaskView(runningTaskId);
    }

    @Override
    protected void applyLoadPlan(ArrayList<Task> tasks) {
        // When quick-switching on 3p-launcher, we add a "dummy" tile corresponding to Launcher
        // as well. This tile is never shown as we have setCurrentTaskHidden, but allows use to
        // track the index of the next task appropriately, as if we are switching on any other app.
        if (mHomeTaskInfo != null && mHomeTaskInfo.taskId == mRunningTaskId) {
        if (mHomeTaskInfo != null && mHomeTaskInfo.taskId == mRunningTaskId && !tasks.isEmpty()) {
            // Check if the task list has running task
            boolean found = false;
            for (Task t : tasks) {
+52 −0
Original line number Diff line number Diff line
@@ -15,9 +15,7 @@
 */
package com.android.quickstep.fallback;

import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
import android.util.AttributeSet;

@@ -27,21 +25,13 @@ import com.android.launcher3.util.TouchController;
import com.android.launcher3.views.BaseDragLayer;
import com.android.quickstep.RecentsActivity;

public class RecentsRootView extends BaseDragLayer<RecentsActivity> {

    private static final int MIN_SIZE = 10;

    private final Point mLastKnownSize = new Point(MIN_SIZE, MIN_SIZE);
/**
 * Drag layer for fallback recents activity
 */
public class RecentsDragLayer extends BaseDragLayer<RecentsActivity> {

    public RecentsRootView(Context context, AttributeSet attrs) {
    public RecentsDragLayer(Context context, AttributeSet attrs) {
        super(context, attrs, 1 /* alphaChannelCount */);
        setSystemUiVisibility(SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | SYSTEM_UI_FLAG_LAYOUT_STABLE);
    }

    public Point getLastKnownSize() {
        return mLastKnownSize;
    }

    @Override
@@ -52,42 +42,11 @@ public class RecentsRootView extends BaseDragLayer<RecentsActivity> {
        };
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        // Check size changes before the actual measure, to avoid multiple measure calls.
        int width = Math.max(MIN_SIZE, MeasureSpec.getSize(widthMeasureSpec));
        int height = Math.max(MIN_SIZE, MeasureSpec.getSize(heightMeasureSpec));
        if (mLastKnownSize.x != width || mLastKnownSize.y != height) {
            mLastKnownSize.set(width, height);
            mActivity.onRootViewSizeChanged();
        }

        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

    @TargetApi(23)
    @Override
    protected boolean fitSystemWindows(Rect insets) {
        // Update device profile before notifying the children.
        mActivity.getDeviceProfile().updateInsets(insets);
        setInsets(insets);
        return false; // Let children get the full insets
    }

    @Override
    public void setInsets(Rect insets) {
        // If the insets haven't changed, this is a no-op. Avoid unnecessary layout caused by
        // modifying child layout params.
        if (!insets.equals(mInsets)) {
        super.setInsets(insets);
        }
        setBackground(insets.top == 0  || !mAllowSysuiScrims
                ? null
                : Themes.getAttrDrawable(getContext(), R.attr.workspaceStatusBarScrim));
    }

    public void dispatchInsets() {
        mActivity.getDeviceProfile().updateInsets(mInsets);
        super.setInsets(mInsets);
    }
}
+12 −4
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ import com.android.launcher3.anim.SpringProperty;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.statehandlers.DepthController;
import com.android.launcher3.statemanager.StatefulActivity;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.touch.PagedOrientationHandler.CurveProperties;
import com.android.launcher3.userevent.nano.LauncherLogProto;
@@ -146,8 +147,8 @@ import java.util.function.Consumer;
 * A list of recent tasks.
 */
@TargetApi(Build.VERSION_CODES.P)
public abstract class RecentsView<T extends BaseActivity> extends PagedView implements Insettable,
        TaskThumbnailCache.HighResLoadingState.HighResLoadingStateChangedCallback,
public abstract class RecentsView<T extends StatefulActivity> extends PagedView implements
        Insettable, TaskThumbnailCache.HighResLoadingState.HighResLoadingStateChangedCallback,
        InvariantDeviceProfile.OnIDPChangeListener, TaskVisualsChangeListener,
        SplitScreenBounds.OnChangeListener {

@@ -389,12 +390,12 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        setPageSpacing(getResources().getDimensionPixelSize(R.dimen.recents_page_spacing));
        setEnableFreeScroll(true);
        mSizeStrategy = sizeStrategy;
        mActivity = BaseActivity.fromContext(context);
        mOrientationState = new RecentsOrientedState(
                context, mSizeStrategy, this::animateRecentsRotationInPlace);

        mFastFlingVelocity = getResources()
                .getDimensionPixelSize(R.dimen.recents_fast_fling_velocity);
        mActivity = BaseActivity.fromContext(context);
        mModel = RecentsModel.INSTANCE.get(context);
        mIdp = InvariantDeviceProfile.INSTANCE.get(context);

@@ -1114,6 +1115,13 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        animateActionsViewIn();
    }

    /**
     * Returns true if we should add a dummy taskView for the running task id
     */
    protected boolean shouldAddDummyTaskView(int runningTaskId) {
        return getTaskView(runningTaskId) == null;
    }

    /**
     * Creates a task view (if necessary) to represent the task with the {@param runningTaskId}.
     *
@@ -1121,7 +1129,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
     * is called.  Also scrolls the view to this task.
     */
    public void showCurrentTask(int runningTaskId) {
        if (getTaskView(runningTaskId) == null) {
        if (shouldAddDummyTaskView(runningTaskId)) {
            boolean wasEmpty = getChildCount() == 0;
            // Add an empty view for now until the task plan is loaded and applied
            final TaskView taskView = mTaskViewPool.getView();
Loading