From 58561d4fd7c6d2b8d8fa9445a11d032a92bb8034 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Wed, 17 Mar 2021 10:51:54 -0400 Subject: [PATCH 01/11] Dump DeviceProfile to help with debugging grid changes Some of these internal values are not exposed in hierarchy viewer Bug: 175329686 Test: Take bug report and verify output Change-Id: Ic39be510682fe5aeb03b7436858f6442895c796f --- src/com/android/launcher3/DeviceProfile.java | 106 +++++++++++++++++-- src/com/android/launcher3/Launcher.java | 1 + 2 files changed, 99 insertions(+), 8 deletions(-) diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 90cc384e86..27fae4f5ac 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -17,6 +17,7 @@ package com.android.launcher3; import static com.android.launcher3.ResourceUtils.pxFromDp; +import static com.android.launcher3.Utilities.dpiFromPx; import android.content.Context; import android.content.res.Configuration; @@ -38,6 +39,8 @@ import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.DisplayController.Info; import com.android.launcher3.util.WindowBounds; +import java.io.PrintWriter; + public class DeviceProfile { private static final float TABLET_MIN_DPS = 600; @@ -91,8 +94,10 @@ public class DeviceProfile { public float workspaceSpringLoadShrinkFactor; public final int workspaceSpringLoadedBottomSpace; + private final int extraSpace; public int workspaceTopPadding; public int workspaceBottomPadding; + public int extraHotseatBottomPadding; // Workspace page indicator public final int workspacePageIndicatorHeight; @@ -109,7 +114,6 @@ public class DeviceProfile { public int workspaceCellPaddingXPx; public int cellYPaddingPx; - public int cellYPaddingOriginalPx; // Folder public float folderLabelTextScale; @@ -199,8 +203,7 @@ public class DeviceProfile { mInfo = info; // Constants from resources - float swDPs = Utilities.dpiFromPx( - Math.min(info.smallestSize.x, info.smallestSize.y), info.metrics); + float swDPs = dpiFromPx(Math.min(info.smallestSize.x, info.smallestSize.y), info.metrics); boolean allowRotation = context.getResources().getBoolean(R.bool.allow_rotation); // Tablet UI is built with assumption that simulated landscape is disabled. isTablet = allowRotation && swDPs >= TABLET_MIN_DPS; @@ -290,22 +293,22 @@ public class DeviceProfile { + (isScalableGrid ? 0 : hotseatExtraVerticalSize))); // Calculate all of the remaining variables. - int extraSpace = updateAvailableDimensions(res); + extraSpace = updateAvailableDimensions(res); // Now that we have all of the variables calculated, we can tune certain sizes. if (isScalableGrid) { DevicePadding padding = inv.devicePaddings.getDevicePadding(extraSpace); workspaceTopPadding = padding.getWorkspaceTopPadding(extraSpace); workspaceBottomPadding = padding.getWorkspaceBottomPadding(extraSpace); - float hotseatBarBottomPadding = padding.getHotseatBottomPadding(extraSpace); - hotseatBarSizePx += hotseatBarBottomPadding; - hotseatBarBottomPaddingPx += hotseatBarBottomPadding; + extraHotseatBottomPadding = padding.getHotseatBottomPadding(extraSpace); + hotseatBarSizePx += extraHotseatBottomPadding; + hotseatBarBottomPaddingPx += extraHotseatBottomPadding; } else if (!isVerticalBarLayout() && isPhone && isTallDevice) { // We increase the hotseat size when there is extra space. // ie. For a display with a large aspect ratio, we can keep the icons on the workspace // in portrait mode closer together by adding more height to the hotseat. // Note: This calculation was created after noticing a pattern in the design spec. - extraSpace = getCellSize().y - iconSizePx - iconDrawablePaddingPx * 2 + int extraSpace = getCellSize().y - iconSizePx - iconDrawablePaddingPx * 2 - workspacePageIndicatorHeight; hotseatBarSizePx += extraSpace; hotseatBarBottomPaddingPx += extraSpace; @@ -785,6 +788,93 @@ public class DeviceProfile { } } + private String pxToDpStr(String name, float value) { + return "\t" + name + ": " + value + "px (" + dpiFromPx(value, mInfo.metrics) + "dp)"; + } + + public void dump(String prefix, PrintWriter writer) { + writer.println(prefix + "DeviceProfile:"); + writer.println(prefix + "\t1 dp = " + mInfo.metrics.density + " px"); + + writer.println(prefix + "\tisTablet:" + isTablet); + writer.println(prefix + "\tisLargeTablet:" + isLargeTablet); + writer.println(prefix + "\tisPhone:" + isPhone); + writer.println(prefix + "\ttransposeLayoutWithOrientation:" + + transposeLayoutWithOrientation); + + writer.println(prefix + "\tisLandscape:" + isLandscape); + writer.println(prefix + "\tisMultiWindowMode:" + isMultiWindowMode); + + writer.println(prefix + pxToDpStr("windowX", windowX)); + writer.println(prefix + pxToDpStr("windowY", windowY)); + writer.println(prefix + pxToDpStr("widthPx", widthPx)); + writer.println(prefix + pxToDpStr("heightPx", heightPx)); + + writer.println(prefix + pxToDpStr("availableWidthPx", availableWidthPx)); + writer.println(prefix + pxToDpStr("availableHeightPx", availableHeightPx)); + + writer.println(prefix + "\taspectRatio:" + aspectRatio); + + writer.println(prefix + "\tisScalableGrid:" + isScalableGrid); + + writer.println(prefix + "\tinv.minCellWidth:" + inv.minCellWidth + "dp"); + writer.println(prefix + "\tinv.minCellHeight:" + inv.minCellHeight + "dp"); + + writer.println(prefix + pxToDpStr("cellWidthPx", cellWidthPx)); + writer.println(prefix + pxToDpStr("cellHeightPx", cellHeightPx)); + + writer.println(prefix + pxToDpStr("getCellSize().x", getCellSize().x)); + writer.println(prefix + pxToDpStr("getCellSize().y", getCellSize().y)); + + writer.println(prefix + "\tinv.iconSize:" + inv.iconSize + "dp"); + writer.println(prefix + pxToDpStr("iconSizePx", iconSizePx)); + writer.println(prefix + pxToDpStr("iconTextSizePx", iconTextSizePx)); + writer.println(prefix + pxToDpStr("iconDrawablePaddingPx", iconDrawablePaddingPx)); + + writer.println(prefix + pxToDpStr("folderCellWidthPx", folderCellWidthPx)); + writer.println(prefix + pxToDpStr("folderCellHeightPx", folderCellHeightPx)); + writer.println(prefix + pxToDpStr("folderChildIconSizePx", folderChildIconSizePx)); + writer.println(prefix + pxToDpStr("folderChildTextSizePx", folderChildTextSizePx)); + writer.println(prefix + pxToDpStr("folderChildDrawablePaddingPx", + folderChildDrawablePaddingPx)); + + writer.println(prefix + pxToDpStr("cellLayoutBorderSpacingPx", + cellLayoutBorderSpacingPx)); + writer.println(prefix + pxToDpStr("desiredWorkspaceLeftRightMarginPx", + desiredWorkspaceLeftRightMarginPx)); + + writer.println(prefix + pxToDpStr("allAppsIconSizePx", allAppsIconSizePx)); + writer.println(prefix + pxToDpStr("allAppsIconTextSizePx", allAppsIconTextSizePx)); + writer.println(prefix + pxToDpStr("allAppsIconDrawablePaddingPx", + allAppsIconDrawablePaddingPx)); + writer.println(prefix + pxToDpStr("allAppsCellHeightPx", allAppsCellHeightPx)); + + writer.println(prefix + pxToDpStr("hotseatBarSizePx", hotseatBarSizePx)); + writer.println(prefix + pxToDpStr("hotseatCellHeightPx", hotseatCellHeightPx)); + writer.println(prefix + pxToDpStr("hotseatBarTopPaddingPx", hotseatBarTopPaddingPx)); + writer.println(prefix + pxToDpStr("hotseatBarBottomPaddingPx", hotseatBarBottomPaddingPx)); + writer.println(prefix + pxToDpStr("hotseatBarSidePaddingStartPx", + hotseatBarSidePaddingStartPx)); + writer.println(prefix + pxToDpStr("hotseatBarSidePaddingEndPx", + hotseatBarSidePaddingEndPx)); + + writer.println(prefix + "\tisTaskbarPresent:" + isTaskbarPresent); + + writer.println(prefix + pxToDpStr("taskbarSize", taskbarSize)); + writer.println(prefix + pxToDpStr("nonOverlappingTaskbarInset", + nonOverlappingTaskbarInset)); + + writer.println(prefix + pxToDpStr("workspacePadding.left", workspacePadding.left)); + writer.println(prefix + pxToDpStr("workspacePadding.top", workspacePadding.top)); + writer.println(prefix + pxToDpStr("workspacePadding.right", workspacePadding.right)); + writer.println(prefix + pxToDpStr("workspacePadding.bottom", workspacePadding.bottom)); + + writer.println(prefix + pxToDpStr("extraSpace", extraSpace)); + writer.println(prefix + pxToDpStr("workspaceTopPadding", workspaceTopPadding)); + writer.println(prefix + pxToDpStr("workspaceBottomPadding", workspaceBottomPadding)); + writer.println(prefix + pxToDpStr("extraHotseatBottomPadding", extraHotseatBottomPadding)); + } + private static Context getContext(Context c, Info info, int orientation) { Configuration config = new Configuration(c.getResources().getConfiguration()); config.orientation = orientation; diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index c57f62171e..89c0f6697e 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2634,6 +2634,7 @@ public class Launcher extends StatefulActivity implements Launche mDragLayer.dump(prefix, writer); mStateManager.dump(prefix, writer); mPopupDataProvider.dump(prefix, writer); + mDeviceProfile.dump(prefix, writer); try { FileLog.flushAll(writer); From e31af6264d00a996af5fa59b63ed622a6c74c6c3 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Fri, 19 Mar 2021 11:04:11 -0700 Subject: [PATCH 02/11] Don't go to NORMAL after task launches if animation in progress Test: Swipe down on a task, swipe up immediately as it launches; state stays as BACKGROUND_APP instead of NORMAL Fixes: 171757635 Change-Id: Ia38774c01190bd184e229ff532ea9df2a75abcb4 --- .../src/com/android/quickstep/views/LauncherRecentsView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java index e042b35653..a0af68a9bf 100644 --- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java +++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java @@ -101,7 +101,7 @@ public class LauncherRecentsView extends RecentsView @Override protected void onTaskLaunchAnimationEnd(boolean success) { if (success) { - mActivity.getStateManager().goToState(NORMAL, false /* animate */); + mActivity.getStateManager().moveToRestState(); } else { LauncherState state = mActivity.getStateManager().getState(); mActivity.getAllAppsController().setState(state); From 147527229b0c7100f8ce2015c7855a4088417fef Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Fri, 19 Mar 2021 09:52:37 -0500 Subject: [PATCH 03/11] [Search] Tie quick-launch and focus highlight Highlight and quick-launch item should be determined by Search service pipeline based on quick_launch flag on SearchTarget Bug: 183083807 Bug: 183083682 Test: Manual Change-Id: I0191474653deca7e1ecd01fa92c90efcdbb9a8dc --- .../allapps/AllAppsContainerView.java | 36 ++----------------- .../allapps/AllAppsSectionDecorator.java | 6 ++-- .../search/AllAppsSearchBarController.java | 29 ++++----------- .../search/DefaultSearchAdapterProvider.java | 26 +++++++++----- .../allapps/search/SearchAdapterProvider.java | 13 +++++-- .../allapps/search/SectionDecorationInfo.java | 11 ------ 6 files changed, 41 insertions(+), 80 deletions(-) diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index 78c404f061..591de043d2 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -15,7 +15,6 @@ */ package com.android.launcher3.allapps; -import static com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_TAP_ON_PERSONAL_TAB; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_TAP_ON_WORK_TAB; import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_HAS_SHORTCUT_PERMISSION; @@ -63,7 +62,6 @@ import com.android.launcher3.allapps.search.SearchAdapterProvider; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.keyboard.FocusedItemDecorator; import com.android.launcher3.model.data.AppInfo; -import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.MultiValueAlpha; @@ -564,37 +562,9 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo /** * Handles selection on focused view and returns success */ - public boolean selectFocusedView(View v) { - ItemInfo headerItem = getHighlightedItemFromHeader(); - if (headerItem != null) { - return mLauncher.startActivitySafely(v, headerItem.getIntent(), headerItem); - } - AdapterItem focusedItem = getActiveRecyclerView().getApps().getFocusedChild(); - if (focusedItem != null) { - View focusedView = getActiveRecyclerView().getLayoutManager() - .findViewByPosition(focusedItem.position); - if (focusedView != null && mSearchAdapterProvider.onAdapterItemSelected(focusedItem, - focusedView)) { - return true; - } - } - if (focusedItem != null && focusedItem.appInfo != null) { - ItemInfo itemInfo = focusedItem.appInfo; - return mLauncher.startActivitySafely(v, itemInfo.getIntent(), itemInfo); - } - return false; - } - - /** - * Returns the ItemInfo of a focused view inside {@link FloatingHeaderView} - */ - public ItemInfo getHighlightedItemFromHeader() { - View view = getFloatingHeaderView().getFocusedChild(); - if (view != null && view.getTag() instanceof ItemInfo) { - return ((ItemInfo) view.getTag()); - } - - return null; + public boolean launchHighlightedItem() { + if (mSearchAdapterProvider == null) return false; + return mSearchAdapterProvider.launchHighlightedItem(); } public SearchAdapterProvider getSearchAdapterProvider() { diff --git a/src/com/android/launcher3/allapps/AllAppsSectionDecorator.java b/src/com/android/launcher3/allapps/AllAppsSectionDecorator.java index 269e3905c8..7fcd6ec16f 100644 --- a/src/com/android/launcher3/allapps/AllAppsSectionDecorator.java +++ b/src/com/android/launcher3/allapps/AllAppsSectionDecorator.java @@ -29,6 +29,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.android.launcher3.R; import com.android.launcher3.allapps.AllAppsGridAdapter.AppsGridLayoutManager; +import com.android.launcher3.allapps.search.SearchAdapterProvider; import com.android.launcher3.allapps.search.SectionDecorationInfo; import com.android.launcher3.util.Themes; @@ -48,6 +49,7 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration { @Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { List adapterItems = mAppsView.getApps().getAdapterItems(); + SearchAdapterProvider adapterProvider = mAppsView.getSearchAdapterProvider(); for (int i = 0; i < parent.getChildCount(); i++) { View view = parent.getChildAt(i); int position = parent.getChildAdapterPosition(view); @@ -56,7 +58,7 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration { SectionDecorationInfo sectionInfo = adapterItem.sectionDecorationInfo; SectionDecorationHandler decorationHandler = sectionInfo.getDecorationHandler(); if (decorationHandler != null) { - if (sectionInfo.isFocusedView()) { + if (view.equals(adapterProvider.getHighlightedItem())) { decorationHandler.onFocusDraw(c, view); } else { decorationHandler.onGroupDraw(c, view); @@ -102,7 +104,7 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration { private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); private final boolean mIsTopRound; private final boolean mIsBottomRound; - private float [] mCorners; + private float[] mCorners; private float mFillSpacing; public SectionDecorationHandler(Context context, boolean isFullWidth, int fillAlpha, diff --git a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java index d3c9993579..79718fb6df 100644 --- a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java +++ b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java @@ -35,7 +35,6 @@ import com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.search.SearchAlgorithm; import com.android.launcher3.search.SearchCallback; -import com.android.launcher3.util.PackageManagerHelper; /** * An interface to a search box that AllApps can command. @@ -105,30 +104,14 @@ public class AllAppsSearchBarController @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { - if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_GO) { - mLauncher.getStatsLogManager().logger() - .log(LAUNCHER_ALLAPPS_FOCUSED_ITEM_SELECTED_WITH_IME); - // selectFocusedView should return SearchTargetEvent that is passed onto onClick - if (Launcher.getLauncher(mLauncher).getAppsView().selectFocusedView(v)) { - return true; - } - } - } - // Skip if it's not the right action - if (actionId != EditorInfo.IME_ACTION_SEARCH) { - return false; + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_GO) { + mLauncher.getStatsLogManager().logger() + .log(LAUNCHER_ALLAPPS_FOCUSED_ITEM_SELECTED_WITH_IME); + // selectFocusedView should return SearchTargetEvent that is passed onto onClick + return Launcher.getLauncher(mLauncher).getAppsView().launchHighlightedItem(); } - - // Skip if the query is empty - String query = v.getText().toString(); - if (query.isEmpty()) { - return false; - } - return mLauncher.startActivitySafely(v, - PackageManagerHelper.getMarketSearchIntent(mLauncher, query), null - ); + return false; } @Override diff --git a/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java b/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java index e268f567ae..ba895ed5d4 100644 --- a/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java +++ b/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java @@ -15,31 +15,31 @@ */ package com.android.launcher3.allapps.search; -import android.net.Uri; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.android.launcher3.BaseDraggingActivity; +import com.android.launcher3.BubbleTextView; import com.android.launcher3.allapps.AllAppsGridAdapter; +import com.android.launcher3.model.data.ItemInfo; /** * Provides views for local search results */ public class DefaultSearchAdapterProvider extends SearchAdapterProvider { + private View mHighlightedView; + public DefaultSearchAdapterProvider(BaseDraggingActivity launcher) { super(launcher); } @Override public void onBindView(AllAppsGridAdapter.ViewHolder holder, int position) { - - } - - @Override - public void onSliceStatusUpdate(Uri sliceUri) { - + if (position == 0) { + mHighlightedView = holder.itemView; + } } @Override @@ -54,7 +54,17 @@ public class DefaultSearchAdapterProvider extends SearchAdapterProvider { } @Override - public boolean onAdapterItemSelected(AllAppsGridAdapter.AdapterItem adapterItem, View view) { + public boolean launchHighlightedItem() { + if (mHighlightedView instanceof BubbleTextView + && mHighlightedView.getTag() instanceof ItemInfo) { + ItemInfo itemInfo = (ItemInfo) mHighlightedView.getTag(); + return mLauncher.startActivitySafely(mHighlightedView, itemInfo.getIntent(), itemInfo); + } return false; } + + @Override + public View getHighlightedItem() { + return mHighlightedView; + } } diff --git a/src/com/android/launcher3/allapps/search/SearchAdapterProvider.java b/src/com/android/launcher3/allapps/search/SearchAdapterProvider.java index 0864090ade..a650a7d947 100644 --- a/src/com/android/launcher3/allapps/search/SearchAdapterProvider.java +++ b/src/com/android/launcher3/allapps/search/SearchAdapterProvider.java @@ -43,7 +43,8 @@ public abstract class SearchAdapterProvider { /** * Called from LiveSearchManager to notify slice status updates. */ - public abstract void onSliceStatusUpdate(Uri sliceUri); + public void onSliceStatusUpdate(Uri sliceUri) { + } /** * Returns whether or not viewType can be handled by searchProvider @@ -74,6 +75,12 @@ public abstract class SearchAdapterProvider { * handles selection event on search adapter item. Returns false if provider can not handle * event */ - public abstract boolean onAdapterItemSelected(AllAppsGridAdapter.AdapterItem adapterItem, - View view); + public abstract boolean launchHighlightedItem(); + + /** + * Returns the current highlighted view + */ + public abstract View getHighlightedItem(); + + } diff --git a/src/com/android/launcher3/allapps/search/SectionDecorationInfo.java b/src/com/android/launcher3/allapps/search/SectionDecorationInfo.java index 0b64fcaece..56dd63ccc1 100644 --- a/src/com/android/launcher3/allapps/search/SectionDecorationInfo.java +++ b/src/com/android/launcher3/allapps/search/SectionDecorationInfo.java @@ -21,22 +21,11 @@ import com.android.launcher3.allapps.AllAppsSectionDecorator.SectionDecorationHa * Info class for a search section that is primarily used for decoration. */ public class SectionDecorationInfo { - - public static final int QUICK_LAUNCH = 1 << 0; public static final int GROUPING = 1 << 1; private String mSectionId; - private boolean mFocused; private SectionDecorationHandler mDecorationHandler; - public boolean isFocusedView() { - return mFocused; - } - - public void setFocusedView(boolean focused) { - mFocused = focused; - } - public SectionDecorationInfo() { this(null); } From e85b5565c6d5595de945059579e7b57644588c83 Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Fri, 19 Mar 2021 23:52:12 +0000 Subject: [PATCH 04/11] A11y fix for all widgets tray (Part 2 / n) Fix the focus change when expanding / collapsing an app in the all widgets tray by adding stable ids and disable item animator. Item animator is also disable even accessibility isn't enabled because the default item animator also disrupts the header padding. It also makes the expansion / collapsing of widgets table very unpredicible. Test: Navigate all widgets tray with talkback on. Bug: 183120145 Change-Id: Ib1e2ea4d543757248e635a834204db688532cbfa --- .../android/launcher3/widget/picker/WidgetsFullSheet.java | 3 +++ .../android/launcher3/widget/picker/WidgetsListAdapter.java | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java index dc375ca414..c1709f64f6 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java @@ -515,6 +515,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet apps.getIconCache(), /* iconClickListener= */ WidgetsFullSheet.this, /* iconLongClickListener= */ WidgetsFullSheet.this); + mWidgetsListAdapter.setHasStableIds(true); switch (mAdapterType) { case PRIMARY: mWidgetsListAdapter.setFilter(mPrimaryWidgetsFilter); @@ -530,6 +531,8 @@ public class WidgetsFullSheet extends BaseWidgetSheet void setup(WidgetsRecyclerView recyclerView) { mWidgetsRecyclerView = recyclerView; mWidgetsRecyclerView.setAdapter(mWidgetsListAdapter); + // Disables animation because it disrupts the item focus upon adapter item change. + mWidgetsRecyclerView.setItemAnimator(null); mWidgetsRecyclerView.setHeaderViewDimensionsProvider(WidgetsFullSheet.this); mWidgetsRecyclerView.setEdgeEffectFactory( ((TopRoundedCornerView) mContent).createEdgeEffectFactory()); diff --git a/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java b/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java index cab1e02d9a..d841c64a3c 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java +++ b/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java @@ -43,6 +43,7 @@ import com.android.launcher3.widget.model.WidgetsListHeaderEntry; import com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry; import java.util.ArrayList; +import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.function.Predicate; @@ -216,7 +217,9 @@ public class WidgetsListAdapter extends Adapter implements OnHeaderC @Override public long getItemId(int pos) { - return pos; + return Arrays.hashCode(new Object[]{ + mVisibleEntries.get(pos).mPkgItem.hashCode(), + getItemViewType(pos)}); } @Override From 554a1bee3994469cdf383498dbb36dced24f0d19 Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Tue, 16 Mar 2021 19:47:39 -0700 Subject: [PATCH 05/11] Apply new color scheme Bug: 173553055 Test: manual Test: atest SystemPalette Test: atest ThemeOverlayControllerTest Test: atest DeviceDefaultThemeTest Change-Id: Ie06160ed322ceac2e1078c24db287dd1f26a0a65 --- res/values-v31/colors.xml | 22 +++++++++---------- .../test_layout_appwidget_dynamic_colors.xml | 6 ++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/res/values-v31/colors.xml b/res/values-v31/colors.xml index 6baf39e034..24aac10a26 100644 --- a/res/values-v31/colors.xml +++ b/res/values-v31/colors.xml @@ -17,17 +17,17 @@ */ --> - @android:color/system_primary_50 - @android:color/system_primary_100 - @android:color/system_primary_300 - @android:color/system_primary_800 - @android:color/system_primary_900 - @android:color/system_primary_700 + @android:color/system_neutral1_50 + @android:color/system_neutral2_100 + @android:color/system_neutral2_300 + @android:color/system_neutral1_800 + @android:color/system_neutral1_900 + @android:color/system_neutral2_700 - @android:color/system_primary_50 - @android:color/system_primary_900 + @android:color/system_neutral1_50 + @android:color/system_neutral1_900 - @android:color/system_primary_50 - @android:color/system_primary_200 - @android:color/system_primary_400 + @android:color/system_neutral1_50 + @android:color/system_neutral2_200 + @android:color/system_neutral2_400 \ No newline at end of file diff --git a/tests/res/layout/test_layout_appwidget_dynamic_colors.xml b/tests/res/layout/test_layout_appwidget_dynamic_colors.xml index c5ab030d11..21625c643d 100644 --- a/tests/res/layout/test_layout_appwidget_dynamic_colors.xml +++ b/tests/res/layout/test_layout_appwidget_dynamic_colors.xml @@ -18,7 +18,7 @@ + android:background="@android:color/system_neutral1_500"/> + android:background="@android:color/system_accent1_500"/> + android:background="@android:color/system_neutral2_500"/> \ No newline at end of file From 6a2acfaa59b949fa8bb9a11e22f3836a09289e2f Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Fri, 19 Mar 2021 13:23:53 +0000 Subject: [PATCH 06/11] Add an 65% opacity for workspace elements drag over button drop target Also remove the draggable item hover top button color change. Test: Manual Bug: 183193201 Change-Id: Id80622b8c0152180c47c0c9ebff8aa8bc2a5c2be --- .../android/launcher3/ButtonDropTarget.java | 56 ++----------------- .../android/launcher3/DeleteDropTarget.java | 3 - .../launcher3/SecondaryDropTarget.java | 4 -- 3 files changed, 4 insertions(+), 59 deletions(-) diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java index 459b9a841e..4740079f9d 100644 --- a/src/com/android/launcher3/ButtonDropTarget.java +++ b/src/com/android/launcher3/ButtonDropTarget.java @@ -21,14 +21,9 @@ import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import static com.android.launcher3.LauncherState.NORMAL; import android.animation.AnimatorSet; -import android.animation.FloatArrayEvaluator; -import android.animation.ObjectAnimator; -import android.animation.ValueAnimator; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; -import android.graphics.ColorMatrix; -import android.graphics.ColorMatrixColorFilter; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.text.TextUtils; @@ -45,10 +40,7 @@ import com.android.launcher3.anim.Interpolators; import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.dragndrop.DragOptions; -import com.android.launcher3.dragndrop.DragView; import com.android.launcher3.model.data.ItemInfo; -import com.android.launcher3.util.Themes; -import com.android.launcher3.util.Thunk; /** * Implements a DropTarget. @@ -72,6 +64,7 @@ public abstract class ButtonDropTarget extends TextView private static final int[] sTempCords = new int[2]; private static final int DRAG_VIEW_DROP_DURATION = 285; + private static final float DRAG_VIEW_HOVER_OVER_OPACITY = 0.65f; public static final int TOOLTIP_DEFAULT = 0; public static final int TOOLTIP_LEFT = 1; @@ -89,9 +82,6 @@ public abstract class ButtonDropTarget extends TextView /** An item must be dragged at least this many pixels before this drop target is enabled. */ private final int mDragDistanceThreshold; - /** The paint applied to the drag view on hover */ - protected int mHoverColor = 0; - protected CharSequence mText; protected ColorStateList mOriginalTextColor; protected Drawable mDrawable; @@ -101,7 +91,6 @@ public abstract class ButtonDropTarget extends TextView private int mToolTipLocation; private AnimatorSet mCurrentColorAnim; - @Thunk ColorMatrix mSrcFilter, mDstFilter, mCurrentFilter; public ButtonDropTarget(Context context, AttributeSet attrs) { this(context, attrs, 0); @@ -177,8 +166,7 @@ public abstract class ButtonDropTarget extends TextView mToolTip.showAsDropDown(this, x, y); } - d.dragView.setColor(mHoverColor); - animateTextColor(mHoverColor); + d.dragView.setAlpha(DRAG_VIEW_HOVER_OVER_OPACITY); if (d.stateAnnouncer != null) { d.stateAnnouncer.cancel(); } @@ -190,51 +178,15 @@ public abstract class ButtonDropTarget extends TextView // Do nothing } - protected void resetHoverColor() { - animateTextColor(mOriginalTextColor.getDefaultColor()); - } - - private void animateTextColor(int targetColor) { - if (mCurrentColorAnim != null) { - mCurrentColorAnim.cancel(); - } - - mCurrentColorAnim = new AnimatorSet(); - mCurrentColorAnim.setDuration(DragView.COLOR_CHANGE_DURATION); - - if (mSrcFilter == null) { - mSrcFilter = new ColorMatrix(); - mDstFilter = new ColorMatrix(); - mCurrentFilter = new ColorMatrix(); - } - - int defaultTextColor = mOriginalTextColor.getDefaultColor(); - Themes.setColorChangeOnMatrix(defaultTextColor, getTextColor(), mSrcFilter); - Themes.setColorChangeOnMatrix(defaultTextColor, targetColor, mDstFilter); - - ValueAnimator anim1 = ValueAnimator.ofObject( - new FloatArrayEvaluator(mCurrentFilter.getArray()), - mSrcFilter.getArray(), mDstFilter.getArray()); - anim1.addUpdateListener((anim) -> { - mDrawable.setColorFilter(new ColorMatrixColorFilter(mCurrentFilter)); - invalidate(); - }); - - mCurrentColorAnim.play(anim1); - mCurrentColorAnim.play(ObjectAnimator.ofArgb(this, TEXT_COLOR, targetColor)); - mCurrentColorAnim.start(); - } - @Override public final void onDragExit(DragObject d) { hideTooltip(); if (!d.dragComplete) { d.dragView.setColor(0); - resetHoverColor(); + d.dragView.setAlpha(1f); } else { - // Restore the hover color - d.dragView.setColor(mHoverColor); + d.dragView.setAlpha(DRAG_VIEW_HOVER_OVER_OPACITY); } } diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java index cc119c9361..e46aad2bcf 100644 --- a/src/com/android/launcher3/DeleteDropTarget.java +++ b/src/com/android/launcher3/DeleteDropTarget.java @@ -53,9 +53,6 @@ public class DeleteDropTarget extends ButtonDropTarget { @Override protected void onFinishInflate() { super.onFinishInflate(); - // Get the hover color - mHoverColor = getResources().getColor(R.color.delete_target_hover_tint); - setDrawable(R.drawable.ic_remove_shadow); } diff --git a/src/com/android/launcher3/SecondaryDropTarget.java b/src/com/android/launcher3/SecondaryDropTarget.java index 8bc5ad0eb1..858b72eb18 100644 --- a/src/com/android/launcher3/SecondaryDropTarget.java +++ b/src/com/android/launcher3/SecondaryDropTarget.java @@ -44,7 +44,6 @@ import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.LauncherAppWidgetInfo; import com.android.launcher3.util.PackageManagerHelper; -import com.android.launcher3.util.Themes; import com.android.launcher3.widget.LauncherAppWidgetProviderInfo; import java.net.URISyntaxException; @@ -109,15 +108,12 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList mCurrentAccessibilityAction = action; if (action == UNINSTALL) { - mHoverColor = getResources().getColor(R.color.uninstall_target_hover_tint); setDrawable(R.drawable.ic_uninstall_shadow); updateText(R.string.uninstall_drop_target_label); } else if (action == DISMISS_PREDICTION) { - mHoverColor = Themes.getColorAccent(getContext()); setDrawable(R.drawable.ic_block_shadow); updateText(R.string.dismiss_prediction_label); } else if (action == RECONFIGURE) { - mHoverColor = Themes.getColorAccent(getContext()); setDrawable(R.drawable.ic_setup_shadow); updateText(R.string.gadget_setup_text); } From 267270e859bef22abb598d20b174dee9289b361c Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Mon, 22 Mar 2021 15:26:13 +0000 Subject: [PATCH 07/11] Align widgets previews top to the table layout Test: Manual Bug: 179797520 Change-Id: I0716432e72327b825619bc35d55cb74d9621ee6a --- src/com/android/launcher3/widget/WidgetsBottomSheet.java | 2 +- .../widget/picker/WidgetsListTableViewHolderBinder.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java index e6d54a9435..267f9f72c0 100644 --- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java +++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java @@ -140,7 +140,7 @@ public class WidgetsBottomSheet extends BaseWidgetSheet implements Insettable { WidgetsTableUtils.groupWidgetItemsIntoTable(widgets, mMaxHorizontalSpan).forEach(row -> { TableRow tableRow = new TableRow(getContext()); - tableRow.setGravity(Gravity.CENTER_VERTICAL); + tableRow.setGravity(Gravity.TOP); row.forEach(widgetItem -> { WidgetCell widget = addItemCell(tableRow); widget.setPreviewSize(widgetItem.spanX, widgetItem.spanY); diff --git a/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinder.java b/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinder.java index d0be35df52..c1d64b1c74 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinder.java +++ b/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinder.java @@ -158,7 +158,7 @@ public final class WidgetsListTableViewHolderBinder tableRow = (TableRow) table.getChildAt(i); } else { tableRow = new TableRow(table.getContext()); - tableRow.setGravity(Gravity.CENTER_VERTICAL); + tableRow.setGravity(Gravity.TOP); table.addView(tableRow); } if (tableRow.getChildCount() > widgetItems.size()) { From 85a8da02908440db00d2eb15d92688e2c11090b8 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Mon, 22 Mar 2021 09:30:18 -0700 Subject: [PATCH 08/11] Dump input monitor and input event receiver to bug reports Test: adb shell dumpsys activity service TouchInteractionService Bug: 180915942 Change-Id: Ic1155b323cd3f9cef164ce4d663cadc4b29a0893 --- .../src/com/android/quickstep/TouchInteractionService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 4747f1898d..1fb946550e 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -887,6 +887,9 @@ public class TouchInteractionService extends Service implements PluginListener Date: Mon, 22 Mar 2021 16:30:24 +0000 Subject: [PATCH 09/11] Fix corner radius for single item in the widgets tray. If there is only one item, corner radius at 4 corners should be 28dp. Test: Corner radius of one item is correctly shown in the widgets picker. Bug: 183382610 Change-Id: Ief46af8c41ce944792d08212e93f7d68c6278d05 --- .../widgets_list_single_item_ripple.xml | 41 +++++++++++++++++++ .../WidgetsListHeaderViewHolderBinder.java | 4 +- ...dgetsListSearchHeaderViewHolderBinder.java | 4 +- 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 res/drawable/widgets_list_single_item_ripple.xml diff --git a/res/drawable/widgets_list_single_item_ripple.xml b/res/drawable/widgets_list_single_item_ripple.xml new file mode 100644 index 0000000000..b8b6f42523 --- /dev/null +++ b/res/drawable/widgets_list_single_item_ripple.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinder.java b/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinder.java index f126321b73..e57f4d8811 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinder.java +++ b/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinder.java @@ -52,7 +52,9 @@ public final class WidgetsListHeaderViewHolderBinder implements public void bindViewHolder(WidgetsListHeaderHolder viewHolder, WidgetsListHeaderEntry data, int position) { WidgetsListHeader widgetsListHeader = viewHolder.mWidgetsListHeader; - if (position == 0) { + if (mWidgetsListAdapter.getItemCount() == 1) { + widgetsListHeader.setBackgroundResource(R.drawable.widgets_list_single_item_ripple); + } else if (position == 0) { widgetsListHeader.setBackgroundResource(R.drawable.widgets_list_top_ripple); } else if (position == mWidgetsListAdapter.getItemCount() - 1) { widgetsListHeader.setBackgroundResource(R.drawable.widgets_list_bottom_ripple); diff --git a/src/com/android/launcher3/widget/picker/WidgetsListSearchHeaderViewHolderBinder.java b/src/com/android/launcher3/widget/picker/WidgetsListSearchHeaderViewHolderBinder.java index 37713e1018..b98f5e18eb 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsListSearchHeaderViewHolderBinder.java +++ b/src/com/android/launcher3/widget/picker/WidgetsListSearchHeaderViewHolderBinder.java @@ -53,7 +53,9 @@ public final class WidgetsListSearchHeaderViewHolderBinder implements public void bindViewHolder(WidgetsListSearchHeaderHolder viewHolder, WidgetsListSearchHeaderEntry data, int position) { WidgetsListHeader widgetsListHeader = viewHolder.mWidgetsListHeader; - if (position == 0) { + if (mWidgetsListAdapter.getItemCount() == 1) { + widgetsListHeader.setBackgroundResource(R.drawable.widgets_list_single_item_ripple); + } else if (position == 0) { widgetsListHeader.setBackgroundResource(R.drawable.widgets_list_top_ripple); } else if (position == mWidgetsListAdapter.getItemCount() - 1) { widgetsListHeader.setBackgroundResource(R.drawable.widgets_list_bottom_ripple); From 2bb5134413309246b383b6ccedf6369650d1a47f Mon Sep 17 00:00:00 2001 From: Andras Kloczl Date: Sat, 20 Mar 2021 01:13:45 +0100 Subject: [PATCH 10/11] Fix widget scrolling issue on right panel Since we added support for multiple panels on the home screen, we need to call cancelLongPress on all the visible pages not just on the leftmost visible page. Test: manual Bug: 178582378 Change-Id: I88ded543a16b1bbf2a53a627e5725f68b42e742b --- src/com/android/launcher3/PagedView.java | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index b084eb1b9b..72eff620d7 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -63,6 +63,7 @@ import com.android.launcher3.util.Thunk; import com.android.launcher3.views.ActivityContext; import java.util.ArrayList; +import java.util.List; /** * An abstraction of the original Workspace which supports browsing through a @@ -303,6 +304,21 @@ public abstract class PagedView extends ViewGrou return 1; } + /** + * Returns the currently visible pages. + */ + protected Iterable getVisiblePages() { + int panelCount = getPanelCount(); + List visiblePages = new ArrayList<>(panelCount); + for (int i = mCurrentPage; i < mCurrentPage + panelCount; i++) { + View page = getPageAt(i); + if (page != null) { + visiblePages.add(page); + } + } + return visiblePages; + } + /** * Returns true if the view is on one of the current pages, false otherwise. */ @@ -1052,10 +1068,7 @@ public abstract class PagedView extends ViewGrou // Try canceling the long press. It could also have been scheduled // by a distant descendant, so use the mAllowLongPress flag to block // everything - final View currentPage = getPageAt(mCurrentPage); - if (currentPage != null) { - currentPage.cancelLongPress(); - } + getVisiblePages().forEach(View::cancelLongPress); } protected float getScrollProgress(int screenCenter, View v, int page) { From ef45cc95b5868f24e824216cc2d5d37d653d40be Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Sun, 21 Mar 2021 11:40:33 -0700 Subject: [PATCH 11/11] Support live tile with OVERVIEW_GRID Test: turn on both ENABLE_QUICKSTEP_LIVE_TILE and OVERVIEW_GRID. Swipe up from app to overview Fixes: 183231362 Change-Id: Ic918e1fad423295d532cefce13c85e622ff8116c --- quickstep/src/com/android/quickstep/views/RecentsView.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 7adfc1c780..f216985a94 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1018,6 +1018,7 @@ public abstract class RecentsView extends PagedView mLiveTileTaskViewSimulator.taskSecondaryTranslation.value = 0; mLiveTileTaskViewSimulator.fullScreenProgress.value = 0; mLiveTileTaskViewSimulator.recentsViewScale.value = 1; + mLiveTileTaskViewSimulator.gridProgress.value = 0; } if (mRunningTaskTileHidden) { setRunningTaskHidden(mRunningTaskTileHidden); @@ -1740,6 +1741,7 @@ public abstract class RecentsView extends PagedView for (int i = 0; i < taskCount; i++) { getTaskViewAt(i).setGridProgress(gridProgress); } + mLiveTileTaskViewSimulator.gridProgress.value = gridProgress; mClearAllButton.setGridProgress(gridProgress); }