From 8a1ba838f4a75a19623dcaf41bf2dd581af06ac3 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Tue, 24 Sep 2019 13:58:07 -0700 Subject: Move offscreenTranslation calculation to LauncherRecentsView Couple of benefits here: - Doesn't rely on having a measured TaskView, since it already knows how to calculate the task size - Code can be shared (planning to use this for quick switch from home) Bug: Change-Id: I517a78506ac95fcc37d9225a074427941d691903 --- .../quickstep/views/LauncherRecentsView.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java') diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java index 03441c87e..b601834f3 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java @@ -57,6 +57,8 @@ import com.android.quickstep.util.LayoutUtils; @TargetApi(Build.VERSION_CODES.O) public class LauncherRecentsView extends RecentsView implements StateListener { + private static final Rect sTempRect = new Rect(); + private final TransformParams mTransformParams = new TransformParams(); public LauncherRecentsView(Context context) { @@ -144,6 +146,25 @@ public class LauncherRecentsView extends RecentsView implements StateL LayoutUtils.calculateLauncherTaskSize(getContext(), dp, outRect); } + /** + * @return The translationX to apply to this view so that the first task is just offscreen. + */ + public float getOffscreenTranslationX(float recentsScale) { + float offscreenX = NORMAL.getOverviewScaleAndTranslation(mActivity).translationX; + // Offset since scale pushes tasks outwards. + getTaskSize(sTempRect); + int taskWidth = sTempRect.width(); + offscreenX += taskWidth * (recentsScale - 1) / 2; + if (mRunningTaskTileHidden) { + // The first task is hidden, so offset by its width. + offscreenX -= (taskWidth + getPageSpacing()) * recentsScale; + } + if (isRtl()) { + offscreenX = -offscreenX; + } + return offscreenX; + } + @Override protected void onTaskLaunchAnimationUpdate(float progress, TaskView tv) { if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { -- cgit v1.2.3 From 8e02d17fa2ef0708cae4daa0f6c5124fa06a719f Mon Sep 17 00:00:00 2001 From: Sreyas Date: Fri, 27 Sep 2019 17:12:07 -0700 Subject: 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 --- .../quickstep/views/LauncherRecentsView.java | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) (limited to 'quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java') diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java index b601834f3..c2cb720ae 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java @@ -35,6 +35,7 @@ import android.os.Build; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; +import android.widget.FrameLayout; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Hotseat; @@ -45,11 +46,14 @@ import com.android.launcher3.R; import com.android.launcher3.anim.Interpolators; import com.android.launcher3.appprediction.PredictionUiStateManager; import com.android.launcher3.appprediction.PredictionUiStateManager.Client; +import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper; import com.android.launcher3.views.ScrimView; import com.android.quickstep.SysUINavigationMode; import com.android.quickstep.util.ClipAnimationHelper; import com.android.quickstep.util.ClipAnimationHelper.TransformParams; import com.android.quickstep.util.LayoutUtils; +import com.android.systemui.plugins.PluginListener; +import com.android.systemui.plugins.RecentsExtraCard; /** * {@link RecentsView} used in Launcher activity @@ -61,6 +65,25 @@ public class LauncherRecentsView extends RecentsView implements StateL private final TransformParams mTransformParams = new TransformParams(); + private RecentsExtraCard mRecentsExtraCardPlugin; + private RecentsExtraViewContainer mRecentsExtraViewContainer; + private PluginListener mRecentsExtraCardPluginListener = + new PluginListener() { + @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); } @@ -285,4 +308,66 @@ public class LauncherRecentsView extends RecentsView implements StateL } 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); + } + } } -- cgit v1.2.3