Merge "Adding an optional QSB in hotseat" into sc-dev

This commit is contained in:
Sunny Goyal authored and Android (Google) Code Review committed 2021-03-18 16:07:45 +00:00
commit fa699566f5
24 files changed
+107 -292

No files matched your search

@@ -27,7 +27,6 @@ import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.BACKGROUND_APP;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE;
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7;
import static com.android.launcher3.anim.Interpolators.EXAGGERATED_EASE;
@@ -67,7 +66,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.shortcuts.DeepShortcutView;
@@ -148,9 +146,6 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
public static final int CONTENT_ALPHA_DURATION = 217;
protected static final int CONTENT_TRANSLATION_DURATION = 350;
// Progress = 0: All apps is fully pulled up, Progress = 1: All apps is fully pulled down.
public static final float ALL_APPS_PROGRESS_OFF_SCREEN = 1.3059858f;
private static final int MAX_NUM_TASKS = 5;
protected final BaseQuickstepLauncher mLauncher;
@@ -429,9 +424,6 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
appsView.setLayerType(View.LAYER_TYPE_NONE, null);
};
} else if (mLauncher.isInState(OVERVIEW)) {
AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
launcherAnimator.play(ObjectAnimator.ofFloat(allAppsController, ALL_APPS_PROGRESS,
allAppsController.getProgress(), ALL_APPS_PROGRESS_OFF_SCREEN));
endListener = composeViewContentAnimator(launcherAnimator, alphas, trans);
} else {
mDragLayerAlpha.setValue(alphas[0]);
@@ -16,7 +16,6 @@
package com.android.launcher3.appprediction;
import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
import static com.android.launcher3.LauncherState.ALL_APPS;
import android.annotation.TargetApi;
@@ -30,7 +29,6 @@ import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.Interpolator;
import androidx.annotation.ColorInt;
import androidx.core.content.ContextCompat;
@@ -41,7 +39,6 @@ import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.allapps.FloatingHeaderRow;
import com.android.launcher3.allapps.FloatingHeaderView;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.statemanager.StateManager.StateListener;
import com.android.launcher3.util.Themes;
@@ -286,13 +283,6 @@ public class AppsDividerView extends View implements StateListener<LauncherState
setPadding(leftRightPadding, getPaddingTop(), leftRightPadding, getPaddingBottom());
}
@Override
public void setContentVisibility(boolean hasHeaderExtra, boolean hasAllAppsContent,
PropertySetter setter, Interpolator headerFade, Interpolator allAppsFade) {
// Don't use setViewAlpha as we want to control the visibility ourselves.
setter.setFloat(this, VIEW_ALPHA, hasAllAppsContent ? 1 : 0, allAppsFade);
}
@Override
public void setVerticalScroll(int scroll, boolean isScrolledOut) {
setTranslationY(scroll);
@@ -16,20 +16,14 @@
package com.android.launcher3.appprediction;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Build;
import android.util.AttributeSet;
import android.util.IntProperty;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Interpolator;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
@@ -44,7 +38,6 @@ import com.android.launcher3.R;
import com.android.launcher3.allapps.FloatingHeaderRow;
import com.android.launcher3.allapps.FloatingHeaderView;
import com.android.launcher3.anim.AlphaUpdateListener;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.keyboard.FocusIndicatorHelper;
import com.android.launcher3.keyboard.FocusIndicatorHelper.SimpleFocusIndicatorHelper;
@@ -53,8 +46,6 @@ import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.touch.ItemClickHandler;
import com.android.launcher3.touch.ItemLongClickListener;
import com.android.launcher3.util.Themes;
import com.android.quickstep.AnimatedFloat;
import java.util.ArrayList;
import java.util.List;
@@ -63,22 +54,6 @@ import java.util.List;
public class PredictionRowView extends LinearLayout implements
OnDeviceProfileChangeListener, FloatingHeaderRow {
private static final IntProperty<PredictionRowView> TEXT_ALPHA =
new IntProperty<PredictionRowView>("textAlpha") {
@Override
public void setValue(PredictionRowView view, int alpha) {
view.setTextAlpha(alpha);
}
@Override
public Integer get(PredictionRowView view) {
return view.mIconLastSetTextAlpha;
}
};
private static final Interpolator ALPHA_FACTOR_INTERPOLATOR =
(t) -> (t < 0.8f) ? 0 : (t - 0.8f) / 0.2f;
private final Launcher mLauncher;
private int mNumPredictedAppsPerRow;
@@ -88,21 +63,9 @@ public class PredictionRowView extends LinearLayout implements
// The set of predicted apps resolved from the component names and the current set of apps
private final List<WorkspaceItemInfo> mPredictedApps = new ArrayList<>();
private final int mIconTextColor;
private final int mIconFullTextAlpha;
private int mIconLastSetTextAlpha;
// Might use mIconFullTextAlpha instead of mIconLastSetTextAlpha if we are translucent.
private int mIconCurrentTextAlpha;
private FloatingHeaderView mParent;
private boolean mScrolledOut;
private float mScrollTranslation = 0;
private final AnimatedFloat mContentAlphaFactor =
new AnimatedFloat(this::updateTranslationAndAlpha);
private final AnimatedFloat mOverviewScrollFactor =
new AnimatedFloat(this::updateTranslationAndAlpha);
private boolean mPredictionsEnabled = false;
@Nullable
@@ -117,15 +80,9 @@ public class PredictionRowView extends LinearLayout implements
setOrientation(LinearLayout.HORIZONTAL);
mFocusHelper = new SimpleFocusIndicatorHelper(this);
mNumPredictedAppsPerRow = LauncherAppState.getIDP(context).numAllAppsColumns;
mLauncher = Launcher.getLauncher(context);
mLauncher.addOnDeviceProfileChangeListener(this);
mIconTextColor = Themes.getAttrColor(context, android.R.attr.textColorSecondary);
mIconFullTextAlpha = Color.alpha(mIconTextColor);
mIconCurrentTextAlpha = mIconFullTextAlpha;
updateVisibility();
}
@@ -246,7 +203,6 @@ public class PredictionRowView extends LinearLayout implements
}
int predictionCount = mPredictedApps.size();
int iconColor = setColorAlphaBound(mIconTextColor, mIconCurrentTextAlpha);
for (int i = 0; i < getChildCount(); i++) {
BubbleTextView icon = (BubbleTextView) getChildAt(i);
@@ -254,7 +210,6 @@ public class PredictionRowView extends LinearLayout implements
if (predictionCount > i) {
icon.setVisibility(View.VISIBLE);
icon.applyFromWorkspaceItem(mPredictedApps.get(i));
icon.setTextColor(iconColor);
} else {
icon.setVisibility(predictionCount == 0 ? GONE : INVISIBLE);
}
@@ -269,27 +224,6 @@ public class PredictionRowView extends LinearLayout implements
mParent.onHeightUpdated();
}
public void setTextAlpha(int textAlpha) {
mIconLastSetTextAlpha = textAlpha;
if (getAlpha() < 1 && textAlpha > 0) {
// If the entire header is translucent, make sure the text is at full opacity so it's
// not double-translucent. However, we support keeping the text invisible (alpha == 0).
textAlpha = mIconFullTextAlpha;
}
mIconCurrentTextAlpha = textAlpha;
int iconColor = setColorAlphaBound(mIconTextColor, mIconCurrentTextAlpha);
for (int i = 0; i < getChildCount(); i++) {
((BubbleTextView) getChildAt(i)).setTextColor(iconColor);
}
}
@Override
public void setAlpha(float alpha) {
super.setAlpha(alpha);
// Reapply text alpha so that we update it to be full alpha if the row is now translucent.
setTextAlpha(mIconLastSetTextAlpha);
}
@Override
public boolean hasOverlappingRendering() {
return false;
@@ -299,34 +233,11 @@ public class PredictionRowView extends LinearLayout implements
@Override
public void setVerticalScroll(int scroll, boolean isScrolledOut) {
mScrolledOut = isScrolledOut;
updateTranslationAndAlpha();
if (!isScrolledOut) {
mScrollTranslation = scroll;
updateTranslationAndAlpha();
setTranslationY(scroll);
}
}
private void updateTranslationAndAlpha() {
if (mPredictionsEnabled) {
setTranslationY((1 - mOverviewScrollFactor.value) * mScrollTranslation);
float factor = ALPHA_FACTOR_INTERPOLATOR.getInterpolation(mOverviewScrollFactor.value);
float endAlpha = factor + (1 - factor) * (mScrolledOut ? 0 : 1);
setAlpha(mContentAlphaFactor.value * endAlpha);
AlphaUpdateListener.updateVisibility(this);
}
}
@Override
public void setContentVisibility(boolean hasHeaderExtra, boolean hasAllAppsContent,
PropertySetter setter, Interpolator headerFade, Interpolator allAppsFade) {
// Text follows all apps visibility
int textAlpha = hasHeaderExtra && hasAllAppsContent ? mIconFullTextAlpha : 0;
setter.setInt(this, TEXT_ALPHA, textAlpha, allAppsFade);
setter.setFloat(mOverviewScrollFactor, AnimatedFloat.VALUE,
(hasHeaderExtra && !hasAllAppsContent) ? 1 : 0, LINEAR);
setter.setFloat(mContentAlphaFactor, AnimatedFloat.VALUE, hasHeaderExtra ? 1 : 0,
headerFade);
setAlpha(mScrolledOut ? 0 : 1);
AlphaUpdateListener.updateVisibility(this);
}
@Override
@@ -42,6 +42,7 @@ import androidx.annotation.Nullable;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Hotseat;
import com.android.launcher3.LauncherState;
import com.android.launcher3.QuickstepTransitionManager;
@@ -470,8 +471,12 @@ public class TaskbarController {
*/
public void alignRealHotseatWithTaskbar() {
Rect hotseatBounds = new Rect();
DeviceProfile grid = mLauncher.getDeviceProfile();
int hotseatHeight = grid.workspacePadding.bottom + grid.getInsets().bottom;
int hotseatTopDiff = hotseatHeight - grid.taskbarSize;
mTaskbarView.getHotseatBoundsAtScale(getTaskbarScaleOnHome()).roundOut(hotseatBounds);
mLauncher.getHotseat().setPadding(hotseatBounds.left, hotseatBounds.top,
mLauncher.getHotseat().setPadding(hotseatBounds.left, hotseatBounds.top + hotseatTopDiff,
mTaskbarView.getWidth() - hotseatBounds.right,
mTaskbarView.getHeight() - hotseatBounds.bottom);
}
@@ -234,7 +234,7 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
@Override
public void onDestroy() {
super.onDestroy();
getAppsView().getSearchUiManager().destroy();
getAppsView().getSearchUiManager().destroySearch();
mHotseatPredictionController.destroy();
}
@@ -78,7 +78,7 @@ public class AllAppsState extends LauncherState {
@Override
public int getVisibleElements(Launcher launcher) {
return ALL_APPS_HEADER | ALL_APPS_HEADER_EXTRA | ALL_APPS_CONTENT;
return ALL_APPS_CONTENT;
}
@Override
@@ -155,7 +155,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch
super.onDragEnd(velocity);
}
View searchView = mLauncher.getAppsView().getSearchView();
View searchView = mLauncher.getHotseat().getQsb();
if (searchView instanceof FeedbackHandler) {
((FeedbackHandler) searchView).resetFeedback();
}
@@ -37,6 +37,7 @@ import android.view.ViewGroup;
import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.CellLayout;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Hotseat;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
@@ -84,7 +85,7 @@ public class StaggeredWorkspaceAnim {
Workspace workspace = launcher.getWorkspace();
CellLayout cellLayout = (CellLayout) workspace.getChildAt(workspace.getCurrentPage());
ShortcutAndWidgetContainer currentPage = cellLayout.getShortcutsAndWidgets();
ViewGroup hotseat = launcher.getHotseat();
Hotseat hotseat = launcher.getHotseat();
boolean workspaceClipChildren = workspace.getClipChildren();
boolean workspaceClipToPadding = workspace.getClipToPadding();
@@ -124,11 +125,7 @@ public class StaggeredWorkspaceAnim {
addStaggeredAnimationForView(child, grid.inv.numRows + 1, totalRows);
}
if (launcher.getAppsView().getSearchUiManager()
.isQsbVisible(NORMAL.getVisibleElements(launcher))) {
addStaggeredAnimationForView(launcher.getAppsView().getSearchView(),
grid.inv.numRows + 2, totalRows);
}
addStaggeredAnimationForView(hotseat.getQsb(), grid.inv.numRows + 2, totalRows);
}
if (animateOverviewScrim) {
@@ -15,18 +15,13 @@
*/
package com.android.quickstep.views;
import static com.android.launcher3.LauncherState.ALL_APPS_HEADER_EXTRA;
import static com.android.launcher3.LauncherState.CLEAR_ALL_BUTTON;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherState.OVERVIEW_MODAL_TASK;
import static com.android.launcher3.LauncherState.SPRING_LOADED;
import static com.android.launcher3.QuickstepTransitionManager.ALL_APPS_PROGRESS_OFF_SCREEN;
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
@@ -41,7 +36,6 @@ import com.android.launcher3.statehandlers.DepthController;
import com.android.launcher3.statemanager.StateManager.StateListener;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
import com.android.quickstep.LauncherActivityInterface;
import com.android.quickstep.SysUINavigationMode;
import com.android.quickstep.util.OverviewToHomeAnim;
import com.android.systemui.plugins.PluginListener;
import com.android.systemui.plugins.RecentsExtraCard;
@@ -104,31 +98,6 @@ public class LauncherRecentsView extends RecentsView<BaseQuickstepLauncher>
}
}
/**
* Animates adjacent tasks and translate hotseat off screen as well.
*/
@Override
public AnimatorSet createAdjacentPageAnimForTaskLaunch(TaskView tv) {
AnimatorSet anim = super.createAdjacentPageAnimForTaskLaunch(tv);
if (!SysUINavigationMode.getMode(mActivity).hasGestures) {
// Hotseat doesn't move when opening recents with the button,
// so don't animate it here either.
return anim;
}
float allAppsProgressOffscreen = ALL_APPS_PROGRESS_OFF_SCREEN;
LauncherState state = mActivity.getStateManager().getState();
if ((state.getVisibleElements(mActivity) & ALL_APPS_HEADER_EXTRA) != 0) {
float maxShiftRange = mActivity.getDeviceProfile().heightPx;
float currShiftRange = mActivity.getAllAppsController().getShiftRange();
allAppsProgressOffscreen = 1f + (maxShiftRange - currShiftRange) / maxShiftRange;
}
anim.play(ObjectAnimator.ofFloat(
mActivity.getAllAppsController(), ALL_APPS_PROGRESS, allAppsProgressOffscreen));
return anim;
}
@Override
protected void onTaskLaunchAnimationEnd(boolean success) {
if (success) {
-1
View File
@@ -44,7 +44,6 @@
</com.android.launcher3.allapps.FloatingHeaderView>
<include
android:id="@id/search_container_all_apps"
layout="@layout/search_container_all_apps"/>
<include layout="@layout/all_apps_fast_scroller" />
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2021 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.
-->
<View
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="0dp" />
+52 -3
View File
@@ -20,6 +20,7 @@ import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewDebug;
@@ -42,6 +43,9 @@ public class Hotseat extends CellLayout implements Insettable {
private static final int ALPHA_INDEX_REPLACE_TASKBAR = 1;
private static final int NUM_ALPHA_CHANNELS = 2;
// Ratio of empty space, qsb should take up to appear visually centered.
public static final float QSB_CENTER_FACTOR = .325f;
@ViewDebug.ExportedProperty(category = "launcher")
private boolean mHasVerticalHotseat;
private Workspace mWorkspace;
@@ -50,6 +54,8 @@ public class Hotseat extends CellLayout implements Insettable {
private Consumer<Boolean> mOnVisibilityAggregatedCallback;
private final MultiValueAlpha mMultiValueAlpha;
private final View mQsb;
private final int mQsbHeight;
public Hotseat(Context context) {
this(context, null);
@@ -63,6 +69,10 @@ public class Hotseat extends CellLayout implements Insettable {
super(context, attrs, defStyle);
mMultiValueAlpha = new MultiValueAlpha(this, NUM_ALPHA_CHANNELS, MultiValueAlpha.Mode.MAX);
mMultiValueAlpha.setUpdateVisibility(true);
mQsb = LayoutInflater.from(context).inflate(R.layout.search_container_hotseat, this, false);
mQsbHeight = mQsb.getLayoutParams().height;
addView(mQsb);
}
/**
@@ -97,6 +107,7 @@ public class Hotseat extends CellLayout implements Insettable {
DeviceProfile grid = mActivity.getDeviceProfile();
if (grid.isVerticalBarLayout()) {
mQsb.setVisibility(View.GONE);
lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
if (grid.isSeascape()) {
lp.gravity = Gravity.LEFT;
@@ -106,12 +117,15 @@ public class Hotseat extends CellLayout implements Insettable {
lp.width = grid.hotseatBarSizePx + insets.right;
}
} else {
mQsb.setVisibility(View.VISIBLE);
lp.gravity = Gravity.BOTTOM;
lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
lp.height = grid.isTaskbarPresent
? grid.taskbarSize
: grid.hotseatBarSizePx + insets.bottom;
lp.height = (grid.isTaskbarPresent
? grid.workspacePadding.bottom
: grid.hotseatBarSizePx)
+ insets.bottom;
}
if (!grid.isTaskbarPresent) {
// When taskbar is present, we set the padding separately to ensure a seamless visual
// handoff between taskbar and hotseat during drag and drop.
@@ -177,6 +191,34 @@ public class Hotseat extends CellLayout implements Insettable {
//Does nothing
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int width = getShortcutsAndWidgets().getMeasuredWidth();
mQsb.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(mQsbHeight, MeasureSpec.EXACTLY));
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
int qsbWidth = mQsb.getMeasuredWidth();
int left = (r - l - qsbWidth) / 2;
int right = left + qsbWidth;
DeviceProfile dp = mActivity.getDeviceProfile();
int freeSpace = dp.isTaskbarPresent
? dp.workspacePadding.bottom
: dp.hotseatBarSizePx - dp.hotseatCellHeightPx - mQsbHeight;
int bottom = b - t
- (int) (freeSpace * QSB_CENTER_FACTOR)
- dp.getInsets().bottom;
int top = bottom - mQsbHeight;
mQsb.layout(left, top, right, bottom);
}
/**
* Returns the first View for which the given itemOperator returns true, or null.
*/
@@ -191,4 +233,11 @@ public class Hotseat extends CellLayout implements Insettable {
public MultiValueAlpha.AlphaProperty getReplaceTaskbarAlpha() {
return mMultiValueAlpha.getProperty(ALPHA_INDEX_REPLACE_TASKBAR);
}
/**
* Returns the QSB inside hotseat
*/
public View getQsb() {
return mQsb;
}
}
+7 -18
View File
@@ -30,7 +30,6 @@ import static com.android.launcher3.testing.TestProtocol.SPRING_LOADED_STATE_ORD
import android.content.Context;
import android.view.animation.Interpolator;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.statemanager.BaseState;
import com.android.launcher3.statemanager.StateManager;
import com.android.launcher3.states.HintState;
@@ -52,20 +51,13 @@ public abstract class LauncherState implements BaseState<LauncherState> {
*/
public static final int NONE = 0;
public static final int HOTSEAT_ICONS = 1 << 0;
public static final int HOTSEAT_SEARCH_BOX = 1 << 1;
public static final int ALL_APPS_HEADER = 1 << 2;
public static final int ALL_APPS_HEADER_EXTRA = 1 << 3; // e.g. app predictions
public static final int ALL_APPS_CONTENT = 1 << 4;
public static final int VERTICAL_SWIPE_INDICATOR = 1 << 5;
public static final int OVERVIEW_ACTIONS = 1 << 6;
public static final int TASKBAR = 1 << 7;
public static final int CLEAR_ALL_BUTTON = 1 << 8;
public static final int WORKSPACE_PAGE_INDICATOR = 1 << 9;
public static final int SPLIT_PLACHOLDER_VIEW = 1 << 10;
/** Mask of all the items that are contained in the apps view. */
public static final int APPS_VIEW_ITEM_MASK =
HOTSEAT_SEARCH_BOX | ALL_APPS_HEADER | ALL_APPS_HEADER_EXTRA | ALL_APPS_CONTENT;
public static final int ALL_APPS_CONTENT = 1 << 1;
public static final int VERTICAL_SWIPE_INDICATOR = 1 << 2;
public static final int OVERVIEW_ACTIONS = 1 << 3;
public static final int TASKBAR = 1 << 4;
public static final int CLEAR_ALL_BUTTON = 1 << 5;
public static final int WORKSPACE_PAGE_INDICATOR = 1 << 6;
public static final int SPLIT_PLACHOLDER_VIEW = 1 << 7;
// Flag indicating workspace has multiple pages visible.
public static final int FLAG_MULTI_PAGE = BaseState.getFlag(0);
@@ -195,9 +187,6 @@ public abstract class LauncherState implements BaseState<LauncherState> {
public int getVisibleElements(Launcher launcher) {
DeviceProfile deviceProfile = launcher.getDeviceProfile();
int flags = WORKSPACE_PAGE_INDICATOR | VERTICAL_SWIPE_INDICATOR | TASKBAR;
if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get() && !deviceProfile.isVerticalBarLayout()) {
flags |= HOTSEAT_SEARCH_BOX;
}
if (!deviceProfile.isTaskbarPresent) {
flags |= HOTSEAT_ICONS;
}
@@ -47,7 +47,6 @@ import android.view.animation.Interpolator;
import com.android.launcher3.LauncherState.PageAlphaProvider;
import com.android.launcher3.LauncherState.ScaleAndTranslation;
import com.android.launcher3.allapps.AllAppsContainerView;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.anim.SpringAnimationBuilder;
@@ -111,9 +110,6 @@ public class WorkspaceStateTransitionAnimation {
pageAlphaProvider.interpolator);
boolean playAtomicComponent = config.playAtomicOverviewScaleComponent();
Hotseat hotseat = mWorkspace.getHotseat();
// Since we set the pivot relative to mWorkspace, we need to scale a sibling of Workspace.
AllAppsContainerView qsbScaleView = mLauncher.getAppsView();
View qsbView = qsbScaleView.getSearchView();
if (playAtomicComponent) {
Interpolator scaleInterpolator = config.getInterpolator(ANIM_WORKSPACE_SCALE, ZOOM_OUT);
LauncherState fromState = mLauncher.getStateManager().getState();
@@ -127,20 +123,15 @@ public class WorkspaceStateTransitionAnimation {
}
setPivotToScaleWithWorkspace(hotseat);
setPivotToScaleWithWorkspace(qsbScaleView);
float hotseatScale = hotseatScaleAndTranslation.scale;
if (shouldSpring) {
PendingAnimation pa = (PendingAnimation) propertySetter;
pa.add(getSpringScaleAnimator(mLauncher, hotseat, hotseatScale));
pa.add(getSpringScaleAnimator(mLauncher, qsbScaleView,
qsbScaleAndTranslation.scale));
} else {
Interpolator hotseatScaleInterpolator = config.getInterpolator(ANIM_HOTSEAT_SCALE,
scaleInterpolator);
propertySetter.setFloat(hotseat, SCALE_PROPERTY, hotseatScale,
hotseatScaleInterpolator);
propertySetter.setFloat(qsbScaleView, SCALE_PROPERTY, qsbScaleAndTranslation.scale,
hotseatScaleInterpolator);
}
float hotseatIconsAlpha = (elements & HOTSEAT_ICONS) != 0 ? 1 : 0;
@@ -170,8 +161,6 @@ public class WorkspaceStateTransitionAnimation {
hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
propertySetter.setFloat(mWorkspace.getPageIndicator(), VIEW_TRANSLATE_Y,
hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
propertySetter.setFloat(qsbView, VIEW_TRANSLATE_Y,
qsbScaleAndTranslation.translationY, hotseatTranslationInterpolator);
setScrim(propertySetter, state);
}
@@ -343,7 +343,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
mSearchContainer = findViewById(R.id.search_container_all_apps);
mSearchUiManager = (SearchUiManager) mSearchContainer;
mSearchUiManager.initialize(this);
mSearchUiManager.initializeSearch(this);
}
public SearchUiManager getSearchUiManager() {
@@ -16,16 +16,11 @@
package com.android.launcher3.allapps;
import static com.android.launcher3.LauncherState.ALL_APPS_CONTENT;
import static com.android.launcher3.LauncherState.ALL_APPS_HEADER_EXTRA;
import static com.android.launcher3.LauncherState.APPS_VIEW_ITEM_MASK;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.FINAL_FRAME;
import static com.android.launcher3.anim.Interpolators.INSTANT;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_HEADER_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SCALE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_VERTICAL_PROGRESS;
import static com.android.launcher3.util.SystemUiController.UI_STATE_ALLAPPS;
@@ -194,25 +189,10 @@ public class AllAppsTransitionController
*/
public void setAlphas(LauncherState state, StateAnimationConfig config, PropertySetter setter) {
int visibleElements = state.getVisibleElements(mLauncher);
boolean hasHeaderExtra = (visibleElements & ALL_APPS_HEADER_EXTRA) != 0;
boolean hasAllAppsContent = (visibleElements & ALL_APPS_CONTENT) != 0;
boolean hasAnyVisibleItem = (visibleElements & APPS_VIEW_ITEM_MASK) != 0;
Interpolator allAppsFade = config.getInterpolator(ANIM_ALL_APPS_FADE, LINEAR);
Interpolator headerFade = config.getInterpolator(ANIM_ALL_APPS_HEADER_FADE, allAppsFade);
setter.setViewAlpha(mAppsView.getContentView(), hasAllAppsContent ? 1 : 0, allAppsFade);
setter.setViewAlpha(mAppsView.getScrollBar(), hasAllAppsContent ? 1 : 0, allAppsFade);
mAppsView.getFloatingHeaderView().setContentVisibility(hasHeaderExtra,
hasAllAppsContent, setter, headerFade, allAppsFade);
mAppsView.getSearchUiManager().setContentVisibility(visibleElements, setter, allAppsFade);
// Set visibility of the container at the very beginning or end of the transition.
setter.setViewAlpha(mAppsView, hasAnyVisibleItem ? 1 : 0,
hasAnyVisibleItem ? INSTANT : FINAL_FRAME);
setter.setViewAlpha(mAppsView, hasAllAppsContent ? 1 : 0, allAppsFade);
}
public AnimatorListenerAdapter getProgressAnimatorListener() {
@@ -17,10 +17,8 @@ package com.android.launcher3.allapps;
import android.graphics.Rect;
import android.view.View;
import android.view.animation.Interpolator;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.anim.PropertySetter;
/**
* A abstract representation of a row in all-apps view
@@ -47,9 +45,6 @@ public interface FloatingHeaderRow {
*/
boolean hasVisibleContent();
void setContentVisibility(boolean hasHeaderExtra, boolean hasAllAppsContent,
PropertySetter setter, Interpolator headerFade, Interpolator allAppsFade);
/**
* Scrolls the content vertically.
*/
@@ -15,8 +15,6 @@
*/
package com.android.launcher3.allapps;
import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Point;
@@ -26,7 +24,6 @@ import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Interpolator;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
@@ -37,7 +34,6 @@ import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
import com.android.launcher3.R;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
import com.android.systemui.plugins.AllAppsRow;
@@ -88,7 +84,6 @@ public class FloatingHeaderView extends LinearLayout implements
private int mSnappedScrolledY;
private int mTranslationY;
private boolean mAllowTouchForwarding;
private boolean mForwardToRecyclerView;
protected boolean mTabsHidden;
@@ -350,10 +345,6 @@ public class FloatingHeaderView extends LinearLayout implements
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (!mAllowTouchForwarding) {
mForwardToRecyclerView = false;
return super.onInterceptTouchEvent(ev);
}
calcOffset(mTempOffset);
ev.offsetLocation(mTempOffset.x, mTempOffset.y);
mForwardToRecyclerView = mCurrentRV.onInterceptTouchEvent(ev);
@@ -382,20 +373,6 @@ public class FloatingHeaderView extends LinearLayout implements
p.y = getTop() - mCurrentRV.getTop() - mParent.getTop();
}
public void setContentVisibility(boolean hasHeader, boolean hasAllAppsContent,
PropertySetter setter, Interpolator headerFade, Interpolator allAppsFade) {
for (FloatingHeaderRow row : mAllRows) {
row.setContentVisibility(hasHeader, hasAllAppsContent, setter, headerFade, allAppsFade);
}
allowTouchForwarding(hasAllAppsContent);
setter.setFloat(mTabLayout, VIEW_ALPHA, hasAllAppsContent ? 1 : 0, headerFade);
}
protected void allowTouchForwarding(boolean allow) {
mAllowTouchForwarding = allow;
}
public boolean hasVisibleContent() {
for (FloatingHeaderRow row : mAllRows) {
if (row.hasVisibleContent()) {
@@ -18,14 +18,10 @@ package com.android.launcher3.allapps;
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
import android.graphics.Rect;
import android.view.View;
import android.view.animation.Interpolator;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.anim.PropertySetter;
import com.android.systemui.plugins.AllAppsRow;
/**
@@ -64,13 +60,6 @@ public class PluginHeaderRow implements FloatingHeaderRow {
return true;
}
@Override
public void setContentVisibility(boolean hasHeaderExtra, boolean hasAllAppsContent,
PropertySetter setter, Interpolator headerFade, Interpolator allAppsFade) {
// Don't use setViewAlpha as we want to control the visibility ourselves.
setter.setFloat(mView, VIEW_ALPHA, hasAllAppsContent ? 1 : 0, headerFade);
}
@Override
public void setVerticalScroll(int scroll, boolean isScrolledOut) {
mView.setVisibility(isScrolledOut ? INVISIBLE : VISIBLE);
@@ -15,16 +15,12 @@
*/
package com.android.launcher3.allapps;
import static com.android.launcher3.LauncherState.ALL_APPS_HEADER;
import android.graphics.Rect;
import android.view.KeyEvent;
import android.view.animation.Interpolator;
import androidx.annotation.Nullable;
import com.android.launcher3.ExtendedEditText;
import com.android.launcher3.anim.PropertySetter;
/**
* Interface for controlling the Apps search UI.
@@ -34,7 +30,7 @@ public interface SearchUiManager {
/**
* Initializes the search manager.
*/
void initialize(AllAppsContainerView containerView);
void initializeSearch(AllAppsContainerView containerView);
/**
* Notifies the search manager to close any active search session.
@@ -45,31 +41,17 @@ public interface SearchUiManager {
* Called before dispatching a key event, in case the search manager wants to initialize
* some UI beforehand.
*/
void preDispatchKeyEvent(KeyEvent keyEvent);
default void preDispatchKeyEvent(KeyEvent keyEvent) { };
/**
* Returns the vertical shift for the all-apps view, so that it aligns with the hotseat.
*/
float getScrollRangeDelta(Rect insets);
/**
* Called as part of state transition to update the content UI
*/
void setContentVisibility(int visibleElements, PropertySetter setter,
Interpolator interpolator);
/**
* Called when activity is destroyed. Used to close search system services
*/
default void destroy() {
}
/**
* Returns true if the QSB should be visible for the given set of visible elements
*/
default boolean isQsbVisible(int visibleElements) {
return (visibleElements & ALL_APPS_HEADER) != 0;
}
default void destroySearch() { }
/**
* @return the edit text object
@@ -31,7 +31,6 @@ import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup.MarginLayoutParams;
import android.view.animation.Interpolator;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.DeviceProfile;
@@ -44,7 +43,6 @@ import com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem;
import com.android.launcher3.allapps.AllAppsStore;
import com.android.launcher3.allapps.AlphabeticalAppsList;
import com.android.launcher3.allapps.SearchUiManager;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.search.SearchCallback;
@@ -134,7 +132,7 @@ public class AppsSearchContainerLayout extends ExtendedEditText
}
@Override
public void initialize(AllAppsContainerView appsView) {
public void initializeSearch(AllAppsContainerView appsView) {
mApps = appsView.getApps();
mAppsView = appsView;
mSearchBarController.initialize(
@@ -222,12 +220,6 @@ public class AppsSearchContainerLayout extends ExtendedEditText
}
}
@Override
public void setContentVisibility(int visibleElements, PropertySetter setter,
Interpolator interpolator) {
setter.setViewAlpha(this, isQsbVisible(visibleElements) ? 1 : 0, interpolator);
}
@Override
public ExtendedEditText getEditText() {
return this;
@@ -46,25 +46,20 @@ public class MultiValueAlpha {
* Determines how each alpha should factor into the final alpha.
*/
public enum Mode {
BLEND(1f) {
BLEND() {
@Override
public float calculateNewAlpha(float currentAlpha, float otherAlpha) {
return currentAlpha * otherAlpha;
}
},
MAX(0f) {
MAX() {
@Override
public float calculateNewAlpha(float currentAlpha, float otherAlpha) {
return Math.max(currentAlpha, otherAlpha);
}
};
Mode(float startAlpha) {
mStartAlpha = startAlpha;
}
protected final float mStartAlpha;
protected abstract float calculateNewAlpha(float currentAlpha, float otherAlpha);
}
@@ -84,7 +79,6 @@ public class MultiValueAlpha {
mView = view;
mMyProperties = new AlphaProperty[size];
mMode = mode;
mView.setAlpha(mMode.mStartAlpha);
mValidMask = 0;
for (int i = 0; i < size; i++) {
@@ -112,9 +106,9 @@ public class MultiValueAlpha {
private final int mMyMask;
private float mValue = mMode.mStartAlpha;
private float mValue = 1;
// Factor of all other alpha channels, only valid if mMyMask is present in mValidMask.
private float mOthers = mMode.mStartAlpha;
private float mOthers = 1;
AlphaProperty(int myMask) {
mMyMask = myMask;
@@ -127,7 +121,7 @@ public class MultiValueAlpha {
if ((mValidMask & mMyMask) == 0) {
// Our cache value is not correct, recompute it.
mOthers = mMode.mStartAlpha;
mOthers = 1;
for (AlphaProperty prop : mMyProperties) {
if (prop != this) {
mOthers = mMode.calculateNewAlpha(mOthers, prop.mValue);
@@ -56,7 +56,7 @@ public class AllAppsState extends LauncherState {
@Override
public int getVisibleElements(Launcher launcher) {
return ALL_APPS_HEADER | ALL_APPS_CONTENT;
return ALL_APPS_CONTENT;
}
@Override
@@ -585,11 +585,7 @@ public final class LauncherInstrumentation {
"but the current state is not " + containerType.name())) {
switch (containerType) {
case WORKSPACE: {
if (mDevice.isNaturalOrientation()) {
waitForLauncherObject(APPS_RES_ID);
} else {
waitUntilLauncherObjectGone(APPS_RES_ID);
}
waitUntilLauncherObjectGone(APPS_RES_ID);
waitUntilLauncherObjectGone(OVERVIEW_RES_ID);
waitUntilLauncherObjectGone(WIDGETS_RES_ID);
return waitForLauncherObject(WORKSPACE_RES_ID);