From 2461d61e14f245546effa00f76d49c3a17d2af0f Mon Sep 17 00:00:00 2001 From: Perumaal S Date: Mon, 3 Jun 2019 10:21:47 -0700 Subject: [PATCH 1/4] Re-enable chips in qt-r1-dev Fixes: 134164918 Change-Id: Ib5441a40ad8043afbe32d6c4c40808676cdcdb20 --- src/com/android/launcher3/config/BaseFlags.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/launcher3/config/BaseFlags.java b/src/com/android/launcher3/config/BaseFlags.java index 7e20d11c2b..54d0db1006 100644 --- a/src/com/android/launcher3/config/BaseFlags.java +++ b/src/com/android/launcher3/config/BaseFlags.java @@ -105,7 +105,7 @@ abstract class BaseFlags { "ENABLE_QUICKSTEP_LIVE_TILE", false, "Enable live tile in Quickstep overview"); public static final TogglableFlag ENABLE_HINTS_IN_OVERVIEW = new TogglableFlag( - "ENABLE_HINTS_IN_OVERVIEW", false, + "ENABLE_HINTS_IN_OVERVIEW", true, "Show chip hints and gleams on the overview screen"); public static final TogglableFlag FAKE_LANDSCAPE_UI = new TogglableFlag( From f3231f417db08185ec204b247d331dba6a9b0383 Mon Sep 17 00:00:00 2001 From: Zak Cohen Date: Mon, 3 Jun 2019 14:58:18 -0700 Subject: [PATCH 2/4] Remove unused hints code. This layout is handled by the provider of the hints now. Test: manual Change-Id: Ifc0db2395a7503b1b03dcb796961ef6647c0413b --- .../RecentsViewStateController.java | 18 ----- .../com/android/quickstep/hints/HintUtil.java | 78 ------------------- .../com/android/quickstep/hints/HintView.java | 71 ----------------- .../hints/ProactiveHintsContainer.java | 55 ------------- .../hints/UiHintListenerConstants.java | 28 ------- .../quickstep/hints/UiInterfaceConstants.java | 34 -------- .../quickstep/views/LauncherRecentsView.java | 65 ---------------- res/layout/launcher.xml | 5 -- res/layout/proactive_hints_container.xml | 20 ----- res/values/dimens.xml | 5 -- src/com/android/launcher3/DeviceProfile.java | 7 -- 11 files changed, 386 deletions(-) delete mode 100644 quickstep/recents_ui_overrides/src/com/android/quickstep/hints/HintUtil.java delete mode 100644 quickstep/recents_ui_overrides/src/com/android/quickstep/hints/HintView.java delete mode 100644 quickstep/recents_ui_overrides/src/com/android/quickstep/hints/ProactiveHintsContainer.java delete mode 100644 quickstep/recents_ui_overrides/src/com/android/quickstep/hints/UiHintListenerConstants.java delete mode 100644 quickstep/recents_ui_overrides/src/com/android/quickstep/hints/UiInterfaceConstants.java delete mode 100644 res/layout/proactive_hints_container.xml diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsViewStateController.java index 1d36d1aae8..b5d84247a8 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsViewStateController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsViewStateController.java @@ -32,7 +32,6 @@ import com.android.launcher3.LauncherState; import com.android.launcher3.LauncherStateManager.AnimationConfig; import com.android.launcher3.anim.AnimatorSetBuilder; import com.android.launcher3.anim.PropertySetter; -import com.android.quickstep.hints.ProactiveHintsContainer; import com.android.quickstep.views.ClearAllButton; import com.android.quickstep.views.LauncherRecentsView; import com.android.quickstep.views.RecentsView; @@ -55,14 +54,6 @@ public final class RecentsViewStateController extends if (state.overviewUi) { mRecentsView.updateEmptyMessage(); mRecentsView.resetTaskVisuals(); - mRecentsView.setHintVisibility(1f); - } else { - mRecentsView.setHintVisibility(0f); - ProactiveHintsContainer - proactiveHintsContainer = mRecentsView.getProactiveHintsContainer(); - if (proactiveHintsContainer != null) { - proactiveHintsContainer.removeAllViews(); - } } setAlphas(PropertySetter.NO_ANIM_PROPERTY_SETTER, state.getVisibleElements(mLauncher)); mRecentsView.setFullscreenProgress(state.getOverviewFullscreenProgress()); @@ -75,14 +66,6 @@ public final class RecentsViewStateController extends if (!toState.overviewUi) { builder.addOnFinishRunnable(mRecentsView::resetTaskVisuals); - mRecentsView.setHintVisibility(0f); - builder.addOnFinishRunnable(() -> { - ProactiveHintsContainer - proactiveHintsContainer = mRecentsView.getProactiveHintsContainer(); - if (proactiveHintsContainer != null) { - proactiveHintsContainer.removeAllViews(); - } - }); } if (toState.overviewUi) { @@ -94,7 +77,6 @@ public final class RecentsViewStateController extends updateAnim.setDuration(config.duration); builder.play(updateAnim); mRecentsView.updateEmptyMessage(); - builder.addOnFinishRunnable(() -> mRecentsView.setHintVisibility(1f)); } PropertySetter propertySetter = config.getPropertySetter(builder); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/hints/HintUtil.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/hints/HintUtil.java deleted file mode 100644 index f2d40ecc4d..0000000000 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/hints/HintUtil.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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.hints; - -import android.app.PendingIntent; -import android.graphics.drawable.Icon; -import android.os.Bundle; - -public final class HintUtil { - - public static final String ID_KEY = "id"; - public static final String ICON_KEY = "icon"; - public static final String TEXT_KEY = "text"; - public static final String TAP_ACTION_KEY = "tap_action"; - - private HintUtil() {} - - public static Bundle makeHint(String id, Icon icon, CharSequence text) { - Bundle hint = new Bundle(); - hint.putString(ID_KEY, id); - hint.putParcelable(ICON_KEY, icon); - hint.putCharSequence(TEXT_KEY, text); - return hint; - } - - public static Bundle makeHint(Icon icon, CharSequence text, PendingIntent tapAction) { - Bundle hint = new Bundle(); - hint.putParcelable(ICON_KEY, icon); - hint.putCharSequence(TEXT_KEY, text); - hint.putParcelable(TAP_ACTION_KEY, tapAction); - return hint; - } - - public static String getId(Bundle hint) { - String id = hint.getString(ID_KEY); - if (id == null) { - throw new IllegalArgumentException("Hint does not contain an ID"); - } - return id; - } - - public static Icon getIcon(Bundle hint) { - Icon icon = hint.getParcelable(ICON_KEY); - if (icon == null) { - throw new IllegalArgumentException("Hint does not contain an icon"); - } - return icon; - } - - public static CharSequence getText(Bundle hint) { - CharSequence text = hint.getCharSequence(TEXT_KEY); - if (text == null) { - throw new IllegalArgumentException("Hint does not contain text"); - } - return text; - } - - public static PendingIntent getTapAction(Bundle hint) { - PendingIntent tapAction = hint.getParcelable(TAP_ACTION_KEY); - if (tapAction == null) { - throw new IllegalArgumentException("Hint does not contain a tap action"); - } - return tapAction; - } -} diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/hints/HintView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/hints/HintView.java deleted file mode 100644 index 5399cc4efc..0000000000 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/hints/HintView.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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.hints; - -import static com.android.quickstep.hints.HintUtil.getIcon; -import static com.android.quickstep.hints.HintUtil.getText; - -import android.content.Context; -import android.graphics.drawable.Icon; -import android.os.Bundle; -import android.util.AttributeSet; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; - -import androidx.annotation.Nullable; - -import com.android.launcher3.R; - -public class HintView extends LinearLayout { - private ImageView mIconView; - private TextView mLabelView; - - public HintView(Context context) { - super(context); - } - - public HintView(Context context, @Nullable AttributeSet attrs) { - super(context, attrs); - } - - public HintView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - } - - public HintView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); - } - - public void setHint(Bundle hint) { - mLabelView.setText(getText(hint)); - - Icon icon = getIcon(hint); - if (icon == null) { - mIconView.setVisibility(GONE); - } else { - mIconView.setImageIcon(icon); - mIconView.setVisibility(VISIBLE); - } - } - - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - mIconView = findViewById(R.id.icon); - mLabelView = findViewById(R.id.label); - } -} diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/hints/ProactiveHintsContainer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/hints/ProactiveHintsContainer.java deleted file mode 100644 index 74a48517b2..0000000000 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/hints/ProactiveHintsContainer.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.android.quickstep.hints; - -import android.content.Context; -import android.util.AttributeSet; -import android.util.FloatProperty; -import android.view.View; -import android.widget.FrameLayout; - -public class ProactiveHintsContainer extends FrameLayout { - - public static final FloatProperty HINT_VISIBILITY = - new FloatProperty("hint_visibility") { - @Override - public void setValue(ProactiveHintsContainer proactiveHintsContainer, float v) { - proactiveHintsContainer.setHintVisibility(v); - } - - @Override - public Float get(ProactiveHintsContainer proactiveHintsContainer) { - return proactiveHintsContainer.mHintVisibility; - } - }; - - private float mHintVisibility; - - public ProactiveHintsContainer(Context context) { - super(context); - } - - public ProactiveHintsContainer(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public ProactiveHintsContainer(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - } - - public ProactiveHintsContainer(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); - } - - public void setView(View v) { - removeAllViews(); - addView(v); - } - - public void setHintVisibility(float v) { - if (v == 1) { - setVisibility(VISIBLE); - } else { - setVisibility(GONE); - } - mHintVisibility = v; - } -} diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/hints/UiHintListenerConstants.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/hints/UiHintListenerConstants.java deleted file mode 100644 index 420033dd61..0000000000 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/hints/UiHintListenerConstants.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.hints; - -public final class UiHintListenerConstants { - - private UiHintListenerConstants() {} - - // Operations - public static final int ON_HINTS_RETURNED_CODE = 5; - - // Keys - public static final String SESSION_ID_KEY = "session_id"; - public static final String HINTS_KEY = "hints"; -} diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/hints/UiInterfaceConstants.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/hints/UiInterfaceConstants.java deleted file mode 100644 index 01406130fb..0000000000 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/hints/UiInterfaceConstants.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.hints; - -public final class UiInterfaceConstants { - - private UiInterfaceConstants() {} - - // Operations - public static final int ON_HINT_TAP_CODE = 4; - - public static final int REQUEST_HINTS_CODE = 7; - - // Keys - public static final String SESSION_ID_KEY = "session_id"; - public static final String HINT_ID_KEY = "hint_id"; - public static final String WIDTH_PX_KEY = "width_px"; - public static final String HEIGHT_PX_KEY = "height_px"; - public static final String HINT_SPACE_WIDTH_PX_KEY = "hint_space_width_px"; - public static final String HINT_SPACE_HEIGHT_PX_KEY = "hint_space_height_px"; -} 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 deedd21adb..3b23bd1095 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 @@ -30,13 +30,10 @@ import android.annotation.TargetApi; import android.content.Context; import android.graphics.Canvas; import android.graphics.Rect; -import android.graphics.RectF; import android.os.Build; import android.util.AttributeSet; import android.view.View; -import androidx.annotation.Nullable; - import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; @@ -44,11 +41,8 @@ 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.util.PendingAnimation; -import com.android.launcher3.views.BaseDragLayer; import com.android.launcher3.views.ScrimView; import com.android.quickstep.SysUINavigationMode; -import com.android.quickstep.hints.ProactiveHintsContainer; import com.android.quickstep.util.ClipAnimationHelper; import com.android.quickstep.util.ClipAnimationHelper.TransformParams; import com.android.quickstep.util.LayoutUtils; @@ -60,8 +54,6 @@ import com.android.quickstep.util.LayoutUtils; public class LauncherRecentsView extends RecentsView { private final TransformParams mTransformParams = new TransformParams(); - private final int mChipOverhang; - @Nullable private ProactiveHintsContainer mProactiveHintsContainer; public LauncherRecentsView(Context context) { this(context, null); @@ -74,16 +66,6 @@ public class LauncherRecentsView extends RecentsView { public LauncherRecentsView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setContentAlpha(0); - mChipOverhang = (int) context.getResources().getDimension(R.dimen.chip_hint_overhang); - } - - @Override - protected void onAttachedToWindow() { - super.onAttachedToWindow(); - View hintContainer = mActivity.findViewById(R.id.hints); - mProactiveHintsContainer = - hintContainer instanceof ProactiveHintsContainer - ? (ProactiveHintsContainer) hintContainer : null; } @Override @@ -102,11 +84,6 @@ public class LauncherRecentsView extends RecentsView { } } - @Nullable - public ProactiveHintsContainer getProactiveHintsContainer() { - return mProactiveHintsContainer; - } - @Override public void draw(Canvas canvas) { maybeDrawEmptyMessage(canvas); @@ -160,23 +137,6 @@ public class LauncherRecentsView extends RecentsView { @Override protected void getTaskSize(DeviceProfile dp, Rect outRect) { LayoutUtils.calculateLauncherTaskSize(getContext(), dp, outRect); - if (mProactiveHintsContainer != null) { - BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) mProactiveHintsContainer.getLayoutParams(); - params.bottomMargin = getHeight() - outRect.bottom - mChipOverhang; - params.width = outRect.width(); - } - } - - @Override - public PendingAnimation createTaskLauncherAnimation(TaskView tv, long duration) { - PendingAnimation anim = super.createTaskLauncherAnimation(tv, duration); - - if (mProactiveHintsContainer != null) { - anim.anim.play(ObjectAnimator.ofFloat( - mProactiveHintsContainer, ProactiveHintsContainer.HINT_VISIBILITY, 0)); - } - - return anim; } @Override @@ -194,31 +154,6 @@ public class LauncherRecentsView extends RecentsView { } } - @Override - public PendingAnimation createTaskDismissAnimation(TaskView taskView, boolean animateTaskView, - boolean shouldRemoveTask, long duration) { - PendingAnimation anim = super.createTaskDismissAnimation(taskView, animateTaskView, - shouldRemoveTask, duration); - - if (mProactiveHintsContainer != null) { - anim.anim.play(ObjectAnimator.ofFloat( - mProactiveHintsContainer, ProactiveHintsContainer.HINT_VISIBILITY, 0)); - anim.addEndListener(onEndListener -> { - if (!onEndListener.isSuccess) { - mProactiveHintsContainer.setHintVisibility(1); - } - }); - } - - return anim; - } - - public void setHintVisibility(float v) { - if (mProactiveHintsContainer != null) { - mProactiveHintsContainer.setHintVisibility(v); - } - } - @Override protected void onTaskLaunched(boolean success) { if (success) { diff --git a/res/layout/launcher.xml b/res/layout/launcher.xml index 9cab9c2a5e..cca899bda8 100644 --- a/res/layout/launcher.xml +++ b/res/layout/launcher.xml @@ -48,11 +48,6 @@ layout="@layout/overview_panel" android:visibility="gone" /> - - - - \ No newline at end of file diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 0da56dafb9..4bcb8a7f43 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -232,11 +232,6 @@ 12sp 14sp - - 26dp - 194dp - 15dp - 8dp diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index c1f898c5d0..883e8c642b 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -99,10 +99,6 @@ public class DeviceProfile { public int folderChildTextSizePx; public int folderChildDrawablePaddingPx; - // Hints - public int chipHintHeightPx; - public int chipHintBottomMarginPx; - // Hotseat public int hotseatCellHeightPx; // In portrait: size = height, in landscape: size = width @@ -200,9 +196,6 @@ public class DeviceProfile { workspaceCellPaddingXPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_padding_x); - chipHintHeightPx = res.getDimensionPixelSize(R.dimen.chip_hint_height); - chipHintBottomMarginPx = res.getDimensionPixelSize(R.dimen.chip_hint_bottom_margin); - hotseatBarTopPaddingPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_top_padding); hotseatBarBottomPaddingPx = (isTallDevice ? 0 From d4c90e12e9b6b61d3c0374ee5899425c84ffe65b Mon Sep 17 00:00:00 2001 From: vadimt Date: Tue, 4 Jun 2019 13:59:43 -0700 Subject: [PATCH 3/4] Freezing all apps updates during certain tests This CL adds a very low risk because most (but not all) changes affect only Launcher behavior during the test. This should fix a lab-only flake when all apps keeps changing while the test is working with it. Example: test figures out which icon to click, by the moment it clicks there, there is another icon there, or the icon is under the search box, and clicking opens IME. Switching test devices to airplane mode didn't help. The earlier change that prevents popup menu cancellation is not general enough. Now the tests are given an API to explicitly freeze and unfreeze all-apps, which should be a final solution. Bug: 132900132 Bug: 133765434 Change-Id: I8b81cc9be004482beb6cdcdd05406e2d9b4c7629 --- src/com/android/launcher3/Launcher.java | 6 +- .../allapps/AllAppsContainerView.java | 5 +- .../launcher3/allapps/AllAppsStore.java | 31 ++-- .../testing/TestInformationHandler.java | 30 ++++ .../launcher3/testing/TestProtocol.java | 5 + .../launcher3/ui/TaplTestsLauncher3.java | 170 +++++++++++------- .../com/android/launcher3/tapl/AllApps.java | 22 +++ .../tapl/LauncherInstrumentation.java | 6 + 8 files changed, 194 insertions(+), 81 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 855535b0f3..67086a578d 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -80,6 +80,7 @@ import android.widget.Toast; import com.android.launcher3.DropTarget.DragObject; import com.android.launcher3.accessibility.LauncherAccessibilityDelegate; import com.android.launcher3.allapps.AllAppsContainerView; +import com.android.launcher3.allapps.AllAppsStore; import com.android.launcher3.allapps.AllAppsTransitionController; import com.android.launcher3.allapps.DiscoveryBounce; import com.android.launcher3.anim.PropertyListBuilder; @@ -2238,8 +2239,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, } mPendingExecutor = executor; if (!isInState(ALL_APPS)) { - mAppsView.getAppsStore().setDeferUpdates(true); - mPendingExecutor.execute(() -> mAppsView.getAppsStore().setDeferUpdates(false)); + mAppsView.getAppsStore().enableDeferUpdates(AllAppsStore.DEFER_UPDATES_NEXT_DRAW); + mPendingExecutor.execute(() -> mAppsView.getAppsStore().disableDeferUpdates( + AllAppsStore.DEFER_UPDATES_NEXT_DRAW)); } executor.attachTo(this); diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index 0d43e214ef..d68ff4451d 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -628,11 +628,12 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo final boolean result = super.dispatchTouchEvent(ev); switch (ev.getActionMasked()) { case MotionEvent.ACTION_DOWN: - if (result) mAllAppsStore.setDeferUpdates(true); + if (result) mAllAppsStore.enableDeferUpdates( + AllAppsStore.DEFER_UPDATES_USER_INTERACTION); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: - mAllAppsStore.setDeferUpdates(false); + mAllAppsStore.disableDeferUpdates(AllAppsStore.DEFER_UPDATES_USER_INTERACTION); break; } return result; diff --git a/src/com/android/launcher3/allapps/AllAppsStore.java b/src/com/android/launcher3/allapps/AllAppsStore.java index 8e7fec863b..160042e692 100644 --- a/src/com/android/launcher3/allapps/AllAppsStore.java +++ b/src/com/android/launcher3/allapps/AllAppsStore.java @@ -29,7 +29,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; -import java.util.Set; import java.util.function.Consumer; import java.util.function.Predicate; @@ -38,12 +37,19 @@ import java.util.function.Predicate; */ public class AllAppsStore { + // Defer updates flag used to defer all apps updates to the next draw. + public static final int DEFER_UPDATES_NEXT_DRAW = 1 << 0; + // Defer updates flag used to defer all apps updates while the user interacts with all apps. + public static final int DEFER_UPDATES_USER_INTERACTION = 1 << 1; + // Defer updates flag used to defer all apps updates by a test's request. + public static final int DEFER_UPDATES_TEST = 1 << 2; + private PackageUserKey mTempKey = new PackageUserKey(null, null); private final HashMap mComponentToAppMap = new HashMap<>(); private final List mUpdateListeners = new ArrayList<>(); private final ArrayList mIconContainers = new ArrayList<>(); - private boolean mDeferUpdates = false; + private int mDeferUpdatesFlags = 0; private boolean mUpdatePending = false; public Collection getApps() { @@ -62,17 +68,22 @@ public class AllAppsStore { return mComponentToAppMap.get(key); } - public void setDeferUpdates(boolean deferUpdates) { - if (mDeferUpdates != deferUpdates) { - mDeferUpdates = deferUpdates; + public void enableDeferUpdates(int flag) { + mDeferUpdatesFlags |= flag; + } - if (!mDeferUpdates && mUpdatePending) { - notifyUpdate(); - mUpdatePending = false; - } + public void disableDeferUpdates(int flag) { + mDeferUpdatesFlags &= ~flag; + if (mDeferUpdatesFlags == 0 && mUpdatePending) { + notifyUpdate(); + mUpdatePending = false; } } + public int getDeferUpdatesFlags() { + return mDeferUpdatesFlags; + } + /** * Adds or updates existing apps in the list */ @@ -95,7 +106,7 @@ public class AllAppsStore { private void notifyUpdate() { - if (mDeferUpdates) { + if (mDeferUpdatesFlags != 0) { mUpdatePending = true; return; } diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index b8476aa1da..d2e196138c 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -23,9 +23,13 @@ import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherState; +import com.android.launcher3.MainThreadExecutor; import com.android.launcher3.R; +import com.android.launcher3.allapps.AllAppsStore; import com.android.launcher3.util.ResourceBasedOverride; +import java.util.concurrent.ExecutionException; + public class TestInformationHandler implements ResourceBasedOverride { public static TestInformationHandler newInstance(Context context) { @@ -77,6 +81,32 @@ public class TestInformationHandler implements ResourceBasedOverride { case TestProtocol.REQUEST_DISABLE_DEBUG_TRACING: TestProtocol.sDebugTracing = false; break; + + case TestProtocol.REQUEST_FREEZE_APP_LIST: + new MainThreadExecutor().execute(() -> + mLauncher.getAppsView().getAppsStore().enableDeferUpdates( + AllAppsStore.DEFER_UPDATES_TEST)); + break; + + case TestProtocol.REQUEST_UNFREEZE_APP_LIST: + new MainThreadExecutor().execute(() -> + mLauncher.getAppsView().getAppsStore().disableDeferUpdates( + AllAppsStore.DEFER_UPDATES_TEST)); + break; + + case TestProtocol.REQUEST_APP_LIST_FREEZE_FLAGS: { + try { + final int deferUpdatesFlags = new MainThreadExecutor().submit(() -> + mLauncher.getAppsView().getAppsStore().getDeferUpdatesFlags()).get(); + response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, + deferUpdatesFlags); + } catch (ExecutionException e) { + throw new RuntimeException(e); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + break; + } } return response; } diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java index 99efb22cf1..e60b665eaa 100644 --- a/src/com/android/launcher3/testing/TestProtocol.java +++ b/src/com/android/launcher3/testing/TestProtocol.java @@ -57,6 +57,7 @@ public final class TestProtocol { } public static final String TEST_INFO_RESPONSE_FIELD = "response"; + public static final String REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT = "home-to-overview-swipe-height"; public static final String REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT = @@ -65,6 +66,10 @@ public final class TestProtocol { "all-apps-to-overview-swipe-height"; public static final String REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT = "home-to-all-apps-swipe-height"; + public static final String REQUEST_FREEZE_APP_LIST = "freeze-app-list"; + public static final String REQUEST_UNFREEZE_APP_LIST = "unfreeze-app-list"; + public static final String REQUEST_APP_LIST_FREEZE_FLAGS = "app-list-freeze-flags"; + public static boolean sDebugTracing = false; public static final String REQUEST_ENABLE_DEBUG_TRACING = "enable-debug-tracing"; public static final String REQUEST_DISABLE_DEBUG_TRACING = "disable-debug-tracing"; diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java index 4f8b87c519..d171004fc1 100644 --- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java @@ -108,47 +108,63 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { @Test @Ignore public void testPressHomeOnAllAppsContextMenu() throws Exception { - mLauncher.getWorkspace().switchToAllApps().getAppIcon("TestActivity7").openMenu(); + final AllApps allApps = mLauncher.getWorkspace().switchToAllApps(); + allApps.freeze(); + try { + allApps.getAppIcon("TestActivity7").openMenu(); + } finally { + allApps.unfreeze(); + } mLauncher.pressHome(); } public static void runAllAppsTest(AbstractLauncherUiTest test, AllApps allApps) { - assertNotNull("allApps parameter is null", allApps); + allApps.freeze(); + try { + assertNotNull("allApps parameter is null", allApps); - assertTrue( - "Launcher internal state is not All Apps", test.isInState(LauncherState.ALL_APPS)); + assertTrue( + "Launcher internal state is not All Apps", + test.isInState(LauncherState.ALL_APPS)); - // Test flinging forward and backward. - test.executeOnLauncher(launcher -> assertEquals( - "All Apps started in already scrolled state", 0, test.getAllAppsScroll(launcher))); + // Test flinging forward and backward. + test.executeOnLauncher(launcher -> assertEquals( + "All Apps started in already scrolled state", 0, + test.getAllAppsScroll(launcher))); - allApps.flingForward(); - assertTrue("Launcher internal state is not All Apps", - test.isInState(LauncherState.ALL_APPS)); - final Integer flingForwardY = test.getFromLauncher( - launcher -> test.getAllAppsScroll(launcher)); - test.executeOnLauncher( - launcher -> assertTrue("flingForward() didn't scroll App Apps", flingForwardY > 0)); + allApps.flingForward(); + assertTrue("Launcher internal state is not All Apps", + test.isInState(LauncherState.ALL_APPS)); + final Integer flingForwardY = test.getFromLauncher( + launcher -> test.getAllAppsScroll(launcher)); + test.executeOnLauncher( + launcher -> assertTrue("flingForward() didn't scroll App Apps", + flingForwardY > 0)); - allApps.flingBackward(); - assertTrue( - "Launcher internal state is not All Apps", test.isInState(LauncherState.ALL_APPS)); - final Integer flingBackwardY = test.getFromLauncher( - launcher -> test.getAllAppsScroll(launcher)); - test.executeOnLauncher(launcher -> assertTrue("flingBackward() didn't scroll App Apps", - flingBackwardY < flingForwardY)); + allApps.flingBackward(); + assertTrue( + "Launcher internal state is not All Apps", + test.isInState(LauncherState.ALL_APPS)); + final Integer flingBackwardY = test.getFromLauncher( + launcher -> test.getAllAppsScroll(launcher)); + test.executeOnLauncher(launcher -> assertTrue("flingBackward() didn't scroll App Apps", + flingBackwardY < flingForwardY)); - // Test scrolling down to YouTube. - assertNotNull("All apps: can't fine YouTube", allApps.getAppIcon("YouTube")); - // Test scrolling up to Camera. - assertNotNull("All apps: can't fine Camera", allApps.getAppIcon("Camera")); - // Test failing to find a non-existing app. - final AllApps allAppsFinal = allApps; - expectFail("All apps: could find a non-existing app", - () -> allAppsFinal.getAppIcon("NO APP")); + // Test scrolling down to YouTube. + assertNotNull("All apps: can't fine YouTube", allApps.getAppIcon("YouTube")); + // Test scrolling up to Camera. + assertNotNull("All apps: can't fine Camera", allApps.getAppIcon("Camera")); + // Test failing to find a non-existing app. + final AllApps allAppsFinal = allApps; + expectFail("All apps: could find a non-existing app", + () -> allAppsFinal.getAppIcon("NO APP")); - assertTrue( - "Launcher internal state is not All Apps", test.isInState(LauncherState.ALL_APPS)); + assertTrue( + "Launcher internal state is not All Apps", + test.isInState(LauncherState.ALL_APPS)); + } finally { + allApps.unfreeze(); + } } @Test @@ -199,12 +215,17 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { } public static void runIconLaunchFromAllAppsTest(AbstractLauncherUiTest test, AllApps allApps) { - final AppIcon app = allApps.getAppIcon("TestActivity7"); - assertNotNull("AppIcon.launch returned null", app.launch(getAppPackageName())); - test.executeOnLauncher(launcher -> assertTrue( - "Launcher activity is the top activity; expecting another activity to be the top " - + "one", - test.isInBackground(launcher))); + allApps.freeze(); + try { + final AppIcon app = allApps.getAppIcon("TestActivity7"); + assertNotNull("AppIcon.launch returned null", app.launch(getAppPackageName())); + test.executeOnLauncher(launcher -> assertTrue( + "Launcher activity is the top activity; expecting another activity to be the top " + + "one", + test.isInBackground(launcher))); + } finally { + allApps.unfreeze(); + } } @Test @@ -260,20 +281,23 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { public void testLaunchMenuItem() throws Exception { if (!TestHelpers.isInLauncherProcess()) return; - final AppIconMenu menu = mLauncher. + final AllApps allApps = mLauncher. getWorkspace(). - switchToAllApps(). - getAppIcon(APP_NAME). - openMenu(); + switchToAllApps(); + allApps.freeze(); + try { + final AppIconMenu menu = allApps. + getAppIcon(APP_NAME). + openMenu(); - executeOnLauncher( - launcher -> assertTrue("Launcher internal state didn't switch to Showing Menu", - isOptionsPopupVisible(launcher))); + executeOnLauncher( + launcher -> assertTrue("Launcher internal state didn't switch to Showing Menu", + isOptionsPopupVisible(launcher))); - final AppIconMenuItem menuItem = menu.getMenuItem(1); - final String itemName = menuItem.getText(); - - menuItem.launch(getAppPackageName()); + menu.getMenuItem(1).launch(getAppPackageName()); + } finally { + allApps.unfreeze(); + } } @Test @@ -282,12 +306,18 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { // 1. Open all apps and wait for load complete. // 2. Drag icon to homescreen. // 3. Verify that the icon works on homescreen. - mLauncher.getWorkspace(). - switchToAllApps(). - getAppIcon(APP_NAME). - dragToWorkspace(). - getWorkspaceAppIcon(APP_NAME). - launch(getAppPackageName()); + final AllApps allApps = mLauncher.getWorkspace(). + switchToAllApps(); + allApps.freeze(); + try { + allApps. + getAppIcon(APP_NAME). + dragToWorkspace(). + getWorkspaceAppIcon(APP_NAME). + launch(getAppPackageName()); + } finally { + allApps.unfreeze(); + } executeOnLauncher(launcher -> assertTrue( "Launcher activity is the top activity; expecting another activity to be the top " + "one", @@ -302,21 +332,27 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { // 1. Open all apps and wait for load complete. // 2. Find the app and long press it to show shortcuts. // 3. Press icon center until shortcuts appear - final AppIconMenuItem menuItem = mLauncher. + final AllApps allApps = mLauncher. getWorkspace(). - switchToAllApps(). - getAppIcon(APP_NAME). - openMenu(). - getMenuItem(0); - final String shortcutName = menuItem.getText(); + switchToAllApps(); + allApps.freeze(); + try { + final AppIconMenuItem menuItem = allApps. + getAppIcon(APP_NAME). + openMenu(). + getMenuItem(0); + final String shortcutName = menuItem.getText(); - // 4. Drag the first shortcut to the home screen. - // 5. Verify that the shortcut works on home screen - // (the app opens and has the same text as the shortcut). - menuItem. - dragToWorkspace(). - getWorkspaceAppIcon(shortcutName). - launch(getAppPackageName()); + // 4. Drag the first shortcut to the home screen. + // 5. Verify that the shortcut works on home screen + // (the app opens and has the same text as the shortcut). + menuItem. + dragToWorkspace(). + getWorkspaceAppIcon(shortcutName). + launch(getAppPackageName()); + } finally { + allApps.unfreeze(); + } } public static String getAppPackageName() { diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java index d03035a871..21d763e30e 100644 --- a/tests/tapl/com/android/launcher3/tapl/AllApps.java +++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java @@ -48,6 +48,7 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { "apps_list_view"); // Wait for the recycler to populate. mLauncher.waitForObjectInContainer(appListRecycler, By.clazz(TextView.class)); + verifyNotFrozen("All apps freeze flags upon opening all apps"); } @Override @@ -210,4 +211,25 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { verifyActiveContainer(); } } + + /** + * Freezes updating app list upon app install/uninstall/update. + */ + public void freeze() { + mLauncher.getTestInfo(TestProtocol.REQUEST_FREEZE_APP_LIST); + } + + /** + * Resumes updating app list upon app install/uninstall/update. + */ + public void unfreeze() { + mLauncher.getTestInfo(TestProtocol.REQUEST_UNFREEZE_APP_LIST); + verifyNotFrozen("All apps freeze flags upon unfreezing"); + } + + private void verifyNotFrozen(String message) { + mLauncher.assertEquals(message, 0, mLauncher.getTestInfo( + TestProtocol.REQUEST_APP_LIST_FREEZE_FLAGS). + getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD)); + } } diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index e45fca8c0f..8ebe525657 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -292,6 +292,12 @@ public final class LauncherInstrumentation { } } + void assertEquals(String message, long expected, long actual) { + if (expected != actual) { + fail(message + " expected: " + expected + " but was: " + actual); + } + } + void assertNotEquals(String message, int unexpected, int actual) { if (unexpected == actual) { failEquals(message, actual); From f1128d9f5efb051cd5c068e42304e240bb29063e Mon Sep 17 00:00:00 2001 From: Zak Cohen Date: Wed, 5 Jun 2019 16:01:16 -0700 Subject: [PATCH 4/4] Task footer - use temporary motion for show and hide. Bug: 125844074 Test: manual Change-Id: I9a26760f4bd976d0c3475db1322ee0da639d8209 --- .../src/com/android/quickstep/views/TaskView.java | 2 ++ quickstep/res/layout/task.xml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java index bf3e91ff68..726d798747 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java @@ -498,6 +498,8 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { mSnapshotView.setDimAlpha(curveInterpolation * MAX_PAGE_SCRIM_ALPHA); setCurveScale(getCurveScaleForCurveInterpolation(curveInterpolation)); + float fade = Utilities.boundToRange(1.0f - 2 * scrollState.linearInterpolation, 0f, 1f); + mTaskFooterContainer.setAlpha(fade); if (mMenuView != null) { mMenuView.setPosition(getX() - getRecentsView().getScrollX(), getY()); mMenuView.setScaleX(getScaleX()); diff --git a/quickstep/res/layout/task.xml b/quickstep/res/layout/task.xml index 18691889ff..6a595a16e5 100644 --- a/quickstep/res/layout/task.xml +++ b/quickstep/res/layout/task.xml @@ -40,6 +40,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" + android:animateLayoutChanges="true" + android:forceHasOverlappingRendering="true" android:layout_gravity="bottom|center_horizontal">