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

Commit ba4b8e14 authored by Zak Cohen's avatar Zak Cohen Committed by Android (Google) Code Review
Browse files

Merge "Remove RecentsExtraCard plugin hook." into sc-v2-dev

parents 3fca6717 323b1e4f
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -230,9 +230,6 @@ public class OverscrollInputConsumer extends DelegateInputConsumer {

        // Make sure there isn't an app to quick switch to on our right
        int maxIndex = 0;
        if (mRecentsView != null && mRecentsView.hasRecentsExtraCard()) {
            maxIndex = 1;
        }

        boolean atRightMostApp = mRecentsView == null
                || (mRecentsView.getRunningTaskIndex() <= maxIndex);
+0 −90
Original line number Diff line number Diff line
@@ -29,18 +29,14 @@ import android.os.Build;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.Surface;
import android.widget.FrameLayout;

import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.statehandlers.DepthController;
import com.android.launcher3.statemanager.StateManager.StateListener;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.quickstep.LauncherActivityInterface;
import com.android.quickstep.util.SplitSelectStateController;
import com.android.systemui.plugins.PluginListener;
import com.android.systemui.plugins.RecentsExtraCard;

/**
 * {@link RecentsView} used in Launcher activity
@@ -49,25 +45,6 @@ import com.android.systemui.plugins.RecentsExtraCard;
public class LauncherRecentsView extends RecentsView<BaseQuickstepLauncher, LauncherState>
        implements StateListener<LauncherState> {

    private RecentsExtraCard mRecentsExtraCardPlugin;
    private RecentsExtraViewContainer mRecentsExtraViewContainer;
    private PluginListener<RecentsExtraCard> mRecentsExtraCardPluginListener =
            new PluginListener<RecentsExtraCard>() {
        @Override
        public void onPluginConnected(RecentsExtraCard recentsExtraCard, Context context) {
            createRecentsExtraCard();
            mRecentsExtraCardPlugin = recentsExtraCard;
            mRecentsExtraCardPlugin.setupView(context, mRecentsExtraViewContainer, mActivity);
        }

        @Override
        public void onPluginDisconnected(RecentsExtraCard plugin) {
            removeView(mRecentsExtraViewContainer);
            mRecentsExtraCardPlugin = null;
            mRecentsExtraViewContainer = null;
        }
    };

    public LauncherRecentsView(Context context) {
        this(context, null);
    }
@@ -147,73 +124,6 @@ public class LauncherRecentsView extends RecentsView<BaseQuickstepLauncher, Laun
        return result || mActivity.getStateManager().getState().overviewUi;
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        PluginManagerWrapper.INSTANCE.get(getContext()).addPluginListener(
                mRecentsExtraCardPluginListener, RecentsExtraCard.class);
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        PluginManagerWrapper.INSTANCE.get(getContext()).removePluginListener(
                mRecentsExtraCardPluginListener);
    }

    @Override
    protected int computeMinScroll() {
        if (canComputeScrollX() && !mIsRtl) {
            return computeScrollX();
        }
        return super.computeMinScroll();
    }

    @Override
    protected int computeMaxScroll() {
        if (canComputeScrollX() && mIsRtl) {
            return computeScrollX();
        }
        return super.computeMaxScroll();
    }

    private boolean canComputeScrollX() {
        return mRecentsExtraCardPlugin != null && getTaskViewCount() > 0
                && !mDisallowScrollToClearAll;
    }

    private int computeScrollX() {
        int scrollIndex = getTaskViewStartIndex() - 1;
        while (scrollIndex >= 0 && getChildAt(scrollIndex) instanceof RecentsExtraViewContainer
                && ((RecentsExtraViewContainer) getChildAt(scrollIndex)).isScrollable()) {
            scrollIndex--;
        }
        return getScrollForPage(scrollIndex + 1);
    }

    private void createRecentsExtraCard() {
        mRecentsExtraViewContainer = new RecentsExtraViewContainer(getContext());
        FrameLayout.LayoutParams helpCardParams =
                new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
                        FrameLayout.LayoutParams.MATCH_PARENT);
        mRecentsExtraViewContainer.setLayoutParams(helpCardParams);
        mRecentsExtraViewContainer.setScrollable(true);
        addView(mRecentsExtraViewContainer, 0);
    }

    @Override
    public boolean hasRecentsExtraCard() {
        return mRecentsExtraViewContainer != null;
    }

    @Override
    public void setContentAlpha(float alpha) {
        super.setContentAlpha(alpha);
        if (mRecentsExtraViewContainer != null) {
            mRecentsExtraViewContainer.setAlpha(alpha);
        }
    }

    @Override
    protected DepthController getDepthController() {
        return mActivity.getDepthController();
+0 −54
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.quickstep.views;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;

/**
 * Empty view to house recents overview extra card
 */
public class RecentsExtraViewContainer extends FrameLayout {

    private boolean mScrollable = false;

    public RecentsExtraViewContainer(Context context) {
        super(context);
    }

    public RecentsExtraViewContainer(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public RecentsExtraViewContainer(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    /**
     * Determine whether the view should be scrolled to in the recents overview, similar to the
     * taskviews.
     * @return true if viewed should be scrolled to, false if not
     */
    public boolean isScrollable() {
        return mScrollable;
    }

    public void setScrollable(boolean scrollable) {
        this.mScrollable = scrollable;
    }
}
+27 −64
Original line number Diff line number Diff line
@@ -611,8 +611,6 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
     */
    private TaskView mMovingTaskView;

    // Keeps track of the index where the first TaskView should be
    private int mTaskViewStartIndex = 0;
    private OverviewActionsView mActionsView;

    private MultiWindowModeChangedListener mMultiWindowModeChangedListener =
@@ -897,7 +895,6 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
            taskView.setTaskViewId(-1);
            mActionsView.updateHiddenFlags(HIDDEN_NO_TASKS, getTaskViewCount() == 0);
        }
        updateTaskStartIndex(child);
    }

    @Override
@@ -907,7 +904,6 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        // RecentsView is set to RTL in the constructor when system is using LTR. Here we set the
        // child direction back to match system settings.
        child.setLayoutDirection(mIsRtl ? View.LAYOUT_DIRECTION_LTR : View.LAYOUT_DIRECTION_RTL);
        updateTaskStartIndex(child);
        mActionsView.updateHiddenFlags(HIDDEN_NO_TASKS, false);
        updateEmptyMessage();
    }
@@ -1000,18 +996,6 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        anim.start();
    }

    private void updateTaskStartIndex(View affectingView) {
        if (!(affectingView instanceof TaskView) && !(affectingView instanceof ClearAllButton)) {
            int childCount = getChildCount();

            mTaskViewStartIndex = 0;
            while (mTaskViewStartIndex < childCount
                    && !(getChildAt(mTaskViewStartIndex) instanceof TaskView)) {
                mTaskViewStartIndex++;
            }
        }
    }

    public boolean isTaskViewVisible(TaskView tv) {
        if (showAsGrid()) {
            int screenStart = mOrientationHandler.getPrimaryScroll(this);
@@ -1076,8 +1060,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
     * @param taskIndex the index of the task
     */
    public boolean isTaskSnapped(int taskIndex) {
        return getScrollForPage(taskIndex + mTaskViewStartIndex)
                == getPagedOrientationHandler().getPrimaryScroll(this);
        return getScrollForPage(taskIndex) == getPagedOrientationHandler().getPrimaryScroll(this);
    }

    public TaskView getTaskViewByTaskId(int taskId) {
@@ -1291,7 +1274,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
            return;
        }

        if (mCurrentPage == mTaskViewStartIndex) {
        if (mCurrentPage == 0) {
            return;
        }

@@ -1303,8 +1286,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        removeView(focusedTaskView);
        mMovingTaskView = null;
        focusedTaskView.resetPersistentViewTransforms();
        addView(focusedTaskView, mTaskViewStartIndex);
        setCurrentPage(mTaskViewStartIndex);
        addView(focusedTaskView, 0);
        setCurrentPage(0);

        updateGridProperties();
    }
@@ -1322,7 +1305,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        }

        int currentTaskId = -1;
        TaskView currentTaskView = getTaskViewAtByAbsoluteIndex(mCurrentPage);
        TaskView currentTaskView = getTaskViewAt(mCurrentPage);
        if (currentTaskView != null) {
            currentTaskId = currentTaskView.getTask().key.id;
        }
@@ -1376,7 +1359,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        for (int taskViewIndex = requiredTaskViewCount - 1, taskDataIndex = tasks.size() - 1;
                taskViewIndex >= 0;
                taskViewIndex--, taskDataIndex--) {
            final int pageIndex = requiredTaskViewCount - taskViewIndex - 1 + mTaskViewStartIndex;
            final int pageIndex = requiredTaskViewCount - taskViewIndex - 1;
            final Task task = tasks.get(taskDataIndex);
            final TaskView taskView = (TaskView) getChildAt(pageIndex);
            if (taskView instanceof GroupedTaskView) {
@@ -1417,7 +1400,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
            if (newRunningTaskView == null) {
                StringBuilder sb = new StringBuilder();
                for (int i = requiredTaskViewCount - 1; i >= 0; i--) {
                    final int pageIndex = requiredTaskViewCount - i - 1 + mTaskViewStartIndex;
                    final int pageIndex = requiredTaskViewCount - i - 1;
                    final TaskView taskView = (TaskView) getChildAt(pageIndex);
                    int taskViewId = taskView.getTaskViewId();
                    sb.append(" taskViewId: " + taskViewId
@@ -1480,7 +1463,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
    }

    public int getTaskViewCount() {
        int taskViewCount = getChildCount() - mTaskViewStartIndex;
        int taskViewCount = getChildCount();
        if (indexOfChild(mClearAllButton) != -1) {
            taskViewCount--;
        }
@@ -1895,11 +1878,6 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T

    public abstract void startHome();

    /** `true` if there is a +1 space available in overview. */
    public boolean hasRecentsExtraCard() {
        return false;
    }

    public void reset() {
        setCurrentTask(-1);
        mIgnoreResetTaskId = -1;
@@ -2006,10 +1984,6 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        return tv == null ? -1 : indexOfChild(tv);
    }

    public int getTaskViewStartIndex() {
        return mTaskViewStartIndex;
    }

    /**
     * Reloads the view if anything in recents changed.
     */
@@ -2184,7 +2158,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
                        Task.from(new TaskKey(taskInfo), taskInfo, false),
                        Task.from(new TaskKey(secondaryTaskInfo), secondaryTaskInfo, false)
                };
                addView(taskView, mTaskViewStartIndex);
                addView(taskView, 0);
                // When we create a placeholder task view mSplitBoundsConfig will be null, but with
                // the actual app running we won't need to show the thumbnail until all the tasks
                // load later anyways
@@ -2192,7 +2166,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
                        mOrientationState, mSplitBoundsConfig);
            } else {
                taskView = getTaskViewFromPool(false);
                addView(taskView, mTaskViewStartIndex);
                addView(taskView, 0);
                // The temporary running task is only used for the duration between the start of the
                // gesture and the task list is loaded and applied
                mTmpRunningTasks = new Task[]{Task.from(new TaskKey(taskInfo), taskInfo, false)};
@@ -2360,7 +2334,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        int focusedTaskWidthAndSpacing = 0;
        int snappedTaskRowWidth = 0;
        int snappedPage = getNextPage();
        TaskView snappedTaskView = getTaskViewAtByAbsoluteIndex(snappedPage);
        TaskView snappedTaskView = getTaskViewAt(snappedPage);
        TaskView homeTaskView = getHomeTaskView();
        TaskView nextFocusedTaskView = null;

@@ -2473,7 +2447,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        if (snappedTaskView != null) {
            snappedTaskNonGridScrollAdjustment = snappedTaskView.getScrollAdjustment(
                    /*fullscreenEnabled=*/true, /*gridEnabled=*/false);
            snappedTaskGridTranslationX = gridTranslations[snappedPage - mTaskViewStartIndex];
            snappedTaskGridTranslationX = gridTranslations[snappedPage];
        }

        // Use the accumulated translation of the row containing the last task.
@@ -3029,7 +3003,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
                            // Get the id of the task view we will snap to based on the current
                            // page's relative position as the order of indices change over time due
                            // to dismissals.
                            TaskView snappedTaskView = getTaskViewAtByAbsoluteIndex(mCurrentPage);
                            TaskView snappedTaskView = getTaskViewAt(mCurrentPage);
                            if (snappedTaskView != null) {
                                if (snappedTaskView.getTaskViewId() == mFocusedTaskViewId) {
                                    if (finalNextFocusedTaskView != null) {
@@ -3228,10 +3202,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T

            if (isTaskViewVisible(topTask)) {
                TaskView bottomTask = getTaskViewFromTaskViewId(bottomRowIdArray.get(i));
                lastVisibleIndex = Math.max(
                        indexOfChild(topTask) - mTaskViewStartIndex,
                        indexOfChild(bottomTask) - mTaskViewStartIndex
                );
                lastVisibleIndex = Math.max(indexOfChild(topTask), indexOfChild(bottomTask));
            } else if (lastVisibleIndex < Integer.MAX_VALUE) {
                break;
            }
@@ -3504,22 +3475,22 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T

    @Nullable
    public TaskView getNextTaskView() {
        return getTaskViewAtByAbsoluteIndex(getRunningTaskIndex() + 1);
        return getTaskViewAt(getRunningTaskIndex() + 1);
    }

    @Nullable
    public TaskView getCurrentPageTaskView() {
        return getTaskViewAtByAbsoluteIndex(getCurrentPage());
        return getTaskViewAt(getCurrentPage());
    }

    @Nullable
    public TaskView getNextPageTaskView() {
        return getTaskViewAtByAbsoluteIndex(getNextPage());
        return getTaskViewAt(getNextPage());
    }

    @Nullable
    public TaskView getTaskViewNearestToCenterOfScreen() {
        return getTaskViewAtByAbsoluteIndex(getPageNearestToCenterOfScreen());
        return getTaskViewAt(getPageNearestToCenterOfScreen());
    }

    /**
@@ -3527,17 +3498,9 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
     */
    @Nullable
    public TaskView getTaskViewAt(int index) {
        return getTaskViewAtByAbsoluteIndex(index + mTaskViewStartIndex);
    }

    @Nullable
    private TaskView getTaskViewAtByAbsoluteIndex(int index) {
        if (index < getChildCount() && index >= 0) {
        View child = getChildAt(index);
        return child instanceof TaskView ? (TaskView) child : null;
    }
        return null;
    }

    public void setOnEmptyMessageUpdatedListener(OnEmptyMessageUpdatedListener listener) {
        mOnEmptyMessageUpdatedListener = listener;
@@ -4394,7 +4357,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
            } else {
                TaskView focusedTaskView = mShowAsGridLastOnLayout ? getFocusedTaskView() : null;
                return getScrollForPage(focusedTaskView != null ? indexOfChild(focusedTaskView)
                        : mTaskViewStartIndex);
                        : 0);
            }
        }
        return super.computeMinScroll();
@@ -4406,7 +4369,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
            if (mIsRtl) {
                TaskView focusedTaskView = mShowAsGridLastOnLayout ? getFocusedTaskView() : null;
                return getScrollForPage(focusedTaskView != null ? indexOfChild(focusedTaskView)
                        : mTaskViewStartIndex);
                        : 0);
            } else {
                // If we aren't showing the clear all button, use the leftmost task as the min
                // scroll.
@@ -4458,7 +4421,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        for (int i = 0; i < taskCount; i++) {
            TaskView taskView = getTaskViewAt(i);
            float scrollDiff = taskView.getScrollAdjustment(showAsFullscreen, showAsGrid);
            int pageScroll = newPageScrolls[i + mTaskViewStartIndex] + (int) scrollDiff;
            int pageScroll = newPageScrolls[i] + (int) scrollDiff;
            if ((mIsRtl && pageScroll < clearAllScroll + clearAllWidth)
                    || (!mIsRtl && pageScroll > clearAllScroll - clearAllWidth)) {
                pageScroll = clearAllScroll + (mIsRtl ? clearAllWidth : -clearAllWidth);
@@ -4487,7 +4450,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T

    @Override
    protected int getChildVisibleSize(int index) {
        final TaskView taskView = getTaskViewAtByAbsoluteIndex(index);
        final TaskView taskView = getTaskViewAt(index);
        if (taskView == null) {
            return super.getChildVisibleSize(index);
        }
@@ -4530,7 +4493,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
     * according to {@link #mGridProgress}.
     */
    public float getGridTranslationSecondary(int pageIndex) {
        TaskView taskView = getTaskViewAtByAbsoluteIndex(pageIndex);
        TaskView taskView = getTaskViewAt(pageIndex);
        if (taskView == null) {
            return 0;
        }
@@ -4571,8 +4534,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
    private void updateEnabledOverlays() {
        int overlayEnabledPage = mOverlayEnabled ? getNextPage() : -1;
        int taskCount = getTaskViewCount();
        for (int i = mTaskViewStartIndex; i < mTaskViewStartIndex + taskCount; i++) {
            getTaskViewAtByAbsoluteIndex(i).setOverlayEnabled(i == overlayEnabledPage);
        for (int i = 0; i < taskCount; i++) {
            getTaskViewAt(i).setOverlayEnabled(i == overlayEnabledPage);
        }
    }

+0 −42
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.systemui.plugins;

import android.app.Activity;
import android.content.Context;
import android.widget.FrameLayout;

import com.android.systemui.plugins.annotations.ProvidesInterface;

/**
 * Implement this interface to allow extra card on recents overview.
 */
@ProvidesInterface(action = RecentsExtraCard.ACTION, version = RecentsExtraCard.VERSION)
public interface RecentsExtraCard extends Plugin {

    String ACTION = "com.android.systemui.action.PLUGIN_RECENTS_EXTRA_CARD";
    int VERSION = 1;

    /**
     * Sets up the recents overview extra card and fills in data.
     *
     * @param context     Plugin context
     * @param frameLayout PlaceholderView
     * @param activity    Recents activity to hold extra view
     */
    void setupView(Context context, FrameLayout frameLayout, Activity activity);
}