Create hooks for Recents Card plugin.
This adds another card in the Recents Overview space which can show various items. Change-Id: Ifc36639ece8aa6b554bdbd3256f4195b1b220d68 Merged-In: Ifc36639ece8aa6b554bdbd3256f4195b1b220d68
This commit is contained in:
parent
f2d486e5b0
commit
8e02d17fa2
|
@ -35,6 +35,7 @@ import android.os.Build;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
import com.android.launcher3.DeviceProfile;
|
import com.android.launcher3.DeviceProfile;
|
||||||
import com.android.launcher3.Hotseat;
|
import com.android.launcher3.Hotseat;
|
||||||
|
@ -45,11 +46,14 @@ import com.android.launcher3.R;
|
||||||
import com.android.launcher3.anim.Interpolators;
|
import com.android.launcher3.anim.Interpolators;
|
||||||
import com.android.launcher3.appprediction.PredictionUiStateManager;
|
import com.android.launcher3.appprediction.PredictionUiStateManager;
|
||||||
import com.android.launcher3.appprediction.PredictionUiStateManager.Client;
|
import com.android.launcher3.appprediction.PredictionUiStateManager.Client;
|
||||||
|
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
|
||||||
import com.android.launcher3.views.ScrimView;
|
import com.android.launcher3.views.ScrimView;
|
||||||
import com.android.quickstep.SysUINavigationMode;
|
import com.android.quickstep.SysUINavigationMode;
|
||||||
import com.android.quickstep.util.ClipAnimationHelper;
|
import com.android.quickstep.util.ClipAnimationHelper;
|
||||||
import com.android.quickstep.util.ClipAnimationHelper.TransformParams;
|
import com.android.quickstep.util.ClipAnimationHelper.TransformParams;
|
||||||
import com.android.quickstep.util.LayoutUtils;
|
import com.android.quickstep.util.LayoutUtils;
|
||||||
|
import com.android.systemui.plugins.PluginListener;
|
||||||
|
import com.android.systemui.plugins.RecentsExtraCard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link RecentsView} used in Launcher activity
|
* {@link RecentsView} used in Launcher activity
|
||||||
|
@ -61,6 +65,25 @@ public class LauncherRecentsView extends RecentsView<Launcher> implements StateL
|
||||||
|
|
||||||
private final TransformParams mTransformParams = new TransformParams();
|
private final TransformParams mTransformParams = new TransformParams();
|
||||||
|
|
||||||
|
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) {
|
public LauncherRecentsView(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
}
|
}
|
||||||
|
@ -285,4 +308,66 @@ public class LauncherRecentsView extends RecentsView<Launcher> implements StateL
|
||||||
}
|
}
|
||||||
return super.shouldStealTouchFromSiblingsBelow(ev);
|
return super.shouldStealTouchFromSiblingsBelow(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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 computeMinScrollX() {
|
||||||
|
if (canComputeScrollX() && !mIsRtl) {
|
||||||
|
return computeScrollX();
|
||||||
|
}
|
||||||
|
return super.computeMinScrollX();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int computeMaxScrollX() {
|
||||||
|
if (canComputeScrollX() && mIsRtl) {
|
||||||
|
return computeScrollX();
|
||||||
|
}
|
||||||
|
return super.computeMaxScrollX();
|
||||||
|
}
|
||||||
|
|
||||||
|
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 void resetTaskVisuals() {
|
||||||
|
super.resetTaskVisuals();
|
||||||
|
if (mRecentsExtraViewContainer != null) {
|
||||||
|
mRecentsExtraViewContainer.setAlpha(mContentAlpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* 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 implements RecentsView.PageCallbacks {
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,6 +17,7 @@
|
||||||
package com.android.quickstep.views;
|
package com.android.quickstep.views;
|
||||||
|
|
||||||
import static androidx.dynamicanimation.animation.DynamicAnimation.MIN_VISIBLE_CHANGE_PIXELS;
|
import static androidx.dynamicanimation.animation.DynamicAnimation.MIN_VISIBLE_CHANGE_PIXELS;
|
||||||
|
|
||||||
import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS;
|
import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS;
|
||||||
import static com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_ICON_PARAMS;
|
import static com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_ICON_PARAMS;
|
||||||
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
|
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
|
||||||
|
@ -186,7 +187,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
|
||||||
private final ViewPool<TaskView> mTaskViewPool;
|
private final ViewPool<TaskView> mTaskViewPool;
|
||||||
|
|
||||||
private boolean mDwbToastShown;
|
private boolean mDwbToastShown;
|
||||||
private boolean mDisallowScrollToClearAll;
|
protected boolean mDisallowScrollToClearAll;
|
||||||
private boolean mOverlayEnabled;
|
private boolean mOverlayEnabled;
|
||||||
private boolean mFreezeViewVisibility;
|
private boolean mFreezeViewVisibility;
|
||||||
|
|
||||||
|
@ -288,7 +289,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
|
||||||
private LayoutTransition mLayoutTransition;
|
private LayoutTransition mLayoutTransition;
|
||||||
|
|
||||||
@ViewDebug.ExportedProperty(category = "launcher")
|
@ViewDebug.ExportedProperty(category = "launcher")
|
||||||
private float mContentAlpha = 1;
|
protected float mContentAlpha = 1;
|
||||||
@ViewDebug.ExportedProperty(category = "launcher")
|
@ViewDebug.ExportedProperty(category = "launcher")
|
||||||
protected float mFullscreenProgress = 0;
|
protected float mFullscreenProgress = 0;
|
||||||
|
|
||||||
|
@ -1821,4 +1822,25 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
|
||||||
final WindowInsets insets = getRootWindowInsets();
|
final WindowInsets insets = getRootWindowInsets();
|
||||||
return Math.max(insets.getSystemGestureInsets().right, insets.getSystemWindowInsetRight());
|
return Math.max(insets.getSystemGestureInsets().right, insets.getSystemWindowInsetRight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addView(View child, int index) {
|
||||||
|
super.addView(child, index);
|
||||||
|
if (isExtraCardView(child, index)) {
|
||||||
|
mTaskViewStartIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeView(View view) {
|
||||||
|
if (isExtraCardView(view, indexOfChild(view))) {
|
||||||
|
mTaskViewStartIndex--;
|
||||||
|
}
|
||||||
|
super.removeView(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isExtraCardView(View view, int index) {
|
||||||
|
return !(view instanceof TaskView) && !(view instanceof ClearAllButton)
|
||||||
|
&& index <= mTaskViewStartIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
}
|
Loading…
Reference in New Issue