From 0f12b6013da4a53b911dedd1e70a4783994a405b Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Wed, 26 Aug 2020 19:08:18 -0700 Subject: [PATCH 01/31] Delays removal of extra screen when dropping an app. This prevents a conflict between the scroll animation and layout transition caused by removing the screen. Since the extra screen is at the end of the workspace, this most commonly (only?) causes issues in RTL, as everything shifts to the left to fill the void of the empty screen. See bug for example video of the issue. With this change, the removal of the empty screen happens after Launcher finishes transitioning back to NORMAL state after dropping an icon/widget, rather than in onDragEnd. Note: There is a similar issue when placing a widget in RTL (even if not switching screens), but it's not made worse by this CL. Filed b/166531479. Demo: https://drive.google.com/file/d/1JTP81syjoBFe3_N2SOZHP5r5_RoCUWan/view?usp=sharing Fixes: 163382092 Change-Id: I55ed5af8e1d80dcc0d1b6502c3c5b068dc6f8722 --- src/com/android/launcher3/Workspace.java | 20 ++++++++++++++----- .../launcher3/WorkspaceLayoutManager.java | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 3be9ac7e07..3ef4bf6604 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -93,6 +93,7 @@ import com.android.launcher3.model.data.LauncherAppWidgetInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.pageindicators.WorkspacePageIndicator; import com.android.launcher3.popup.PopupContainerWithArrow; +import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.statemanager.StateManager.StateHandler; import com.android.launcher3.states.StateAnimationConfig; import com.android.launcher3.touch.WorkspaceTouchListener; @@ -437,10 +438,6 @@ public class Workspace extends PagedView enforceDragParity("onDragEnd", 0, 0); } - if (!mDeferRemoveExtraEmptyScreen) { - removeExtraEmptyScreen(mDragSourceInternal != null); - } - updateChildrenLayersEnabled(); mDragInfo = null; mOutlineProvider = null; @@ -658,6 +655,7 @@ public class Workspace extends PagedView convertFinalScreenToEmptyScreenIfNecessary(); if (hasExtraEmptyScreen()) { removeView(mWorkspaceScreens.get(EXTRA_EMPTY_SCREEN_ID)); + setCurrentPage(getNextPage()); mWorkspaceScreens.remove(EXTRA_EMPTY_SCREEN_ID); mScreenOrder.removeValue(EXTRA_EMPTY_SCREEN_ID); @@ -1873,6 +1871,18 @@ public class Workspace extends PagedView }; } } + StateManager stateManager = mLauncher.getStateManager(); + stateManager.addStateListener(new StateManager.StateListener() { + @Override + public void onStateTransitionComplete(LauncherState finalState) { + if (finalState == NORMAL) { + if (!mDeferRemoveExtraEmptyScreen) { + removeExtraEmptyScreen(true /* stripEmptyScreens */); + } + stateManager.removeStateListener(this); + } + } + }); mLauncher.getModelWriter().modifyItemInDatabase(info, container, screenId, lp.cellX, lp.cellY, item.spanX, item.spanY); @@ -2453,7 +2463,7 @@ public class Workspace extends PagedView Runnable onAnimationCompleteRunnable = new Runnable() { @Override public void run() { - // Normally removeExtraEmptyScreen is called in Workspace#onDragEnd, but when + // Normally removeExtraEmptyScreen is called in Workspace#onDrop, but when // adding an item that may not be dropped right away (due to a config activity) // we defer the removal until the activity returns. deferRemoveExtraEmptyScreen(); diff --git a/src/com/android/launcher3/WorkspaceLayoutManager.java b/src/com/android/launcher3/WorkspaceLayoutManager.java index c3d4aeb745..ea887cc5eb 100644 --- a/src/com/android/launcher3/WorkspaceLayoutManager.java +++ b/src/com/android/launcher3/WorkspaceLayoutManager.java @@ -28,7 +28,7 @@ public interface WorkspaceLayoutManager { String TAG = "Launcher.Workspace"; - // The screen id used for the empty screen always present to the right. + // The screen id used for the empty screen always present at the end. int EXTRA_EMPTY_SCREEN_ID = -201; // The is the first screen. It is always present, even if its empty. int FIRST_SCREEN_ID = 0; From 90faa282f1016c7629f0fbb02b2780baee031dbc Mon Sep 17 00:00:00 2001 From: Sreyas Date: Thu, 27 Aug 2020 15:48:00 -0700 Subject: [PATCH 02/31] Implementing TouchDelegate to make full chip clickable. Merging to ub-launcher3-master manually as automerger failed. Tested: Manual Change-Id: I1b8b43de7f04e1e13cb283c88f95a7c6fea84ea6 --- .../android/quickstep/views/RecentsView.java | 10 ++---- .../com/android/quickstep/views/TaskView.java | 36 +++++++++++++++++-- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 982a7c432c..6ae91b69b8 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -79,7 +79,6 @@ import android.view.HapticFeedbackConstants; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MotionEvent; -import android.view.TouchDelegate; import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; @@ -706,12 +705,9 @@ public abstract class RecentsView extends PagedView super.onTouchEvent(ev); TaskView taskView = getCurrentPageTaskView(); - if (taskView != null) { - TouchDelegate mChildTouchDelegate = taskView.getIconTouchDelegate(ev); - if (mChildTouchDelegate != null && mChildTouchDelegate.onTouchEvent(ev)) { - // Keep consuming events to pass to delegate - return true; - } + if (taskView != null && taskView.offerTouchToChildren(ev)) { + // Keep consuming events to pass to delegate + return true; } final int x = (int) ev.getX(); diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index 259cd4dbfd..321821b573 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -135,6 +135,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { * delegated bounds only to be updated. */ private TransformingTouchDelegate mIconTouchDelegate; + private TransformingTouchDelegate mChipTouchDelegate; private static final List SYSTEM_GESTURE_EXCLUSION_RECT = Collections.singletonList(new Rect()); @@ -200,6 +201,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { private View mContextualChipWrapper; private View mContextualChip; private final float[] mIconCenterCoords = new float[2]; + private final float[] mChipCenterCoords = new float[2]; public TaskView(Context context) { this(context, null); @@ -259,11 +261,22 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { mIconTouchDelegate = new TransformingTouchDelegate(mIconView); } - public TouchDelegate getIconTouchDelegate(MotionEvent event) { + /** + * Whether the taskview should take the touch event from parent. Events passed to children + * that might require special handling. + */ + public boolean offerTouchToChildren(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { computeAndSetIconTouchDelegate(); + computeAndSetChipTouchDelegate(); } - return mIconTouchDelegate; + if (mIconTouchDelegate != null && mIconTouchDelegate.onTouchEvent(event)) { + return true; + } + if (mChipTouchDelegate != null && mChipTouchDelegate.onTouchEvent(event)) { + return true; + } + return false; } private void computeAndSetIconTouchDelegate() { @@ -278,6 +291,23 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { (int) (mIconCenterCoords[1] + iconHalfSize)); } + private void computeAndSetChipTouchDelegate() { + if (mContextualChipWrapper != null) { + float chipHalfWidth = mContextualChipWrapper.getWidth() / 2f; + float chipHalfHeight = mContextualChipWrapper.getHeight() / 2f; + mChipCenterCoords[0] = chipHalfWidth; + mChipCenterCoords[1] = chipHalfHeight; + getDescendantCoordRelativeToAncestor(mContextualChipWrapper, mActivity.getDragLayer(), + mChipCenterCoords, + false); + mChipTouchDelegate.setBounds( + (int) (mChipCenterCoords[0] - chipHalfWidth), + (int) (mChipCenterCoords[1] - chipHalfHeight), + (int) (mChipCenterCoords[0] + chipHalfWidth), + (int) (mChipCenterCoords[1] + chipHalfHeight)); + } + } + /** * The modalness of this view is how it should be displayed when it is shown on its own in the * modal state of overview. @@ -712,6 +742,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { mContextualChip.animate().scaleX(1f).scaleY(1f).setDuration(50); } if (mContextualChipWrapper != null) { + mChipTouchDelegate = new TransformingTouchDelegate(mContextualChipWrapper); mContextualChipWrapper.animate().alpha(1f).setDuration(50); } } @@ -733,6 +764,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { View oldContextualChipWrapper = mContextualChipWrapper; mContextualChipWrapper = null; mContextualChip = null; + mChipTouchDelegate = null; return oldContextualChipWrapper; } From 734be27f9b2a63bfa7fc33d6488993a4811ced9c Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Fri, 28 Aug 2020 13:23:10 -0700 Subject: [PATCH 03/31] Intercept touch events from anywhere while all apps is closing Previously we did this only from a settled state, but now we also do it during the transition to NORMAL. Test: open all apps. Then, swipe down to home and back up to all apps (from above the top of all apps). Fixes: 159856104 Change-Id: Ib78c6a41d5fa17dd26a7df4e9069e0ada1f46dd0 --- .../touchcontrollers/PortraitStatesTouchController.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java index 1208c6c79b..059a703075 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java @@ -89,13 +89,16 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr @Override protected boolean canInterceptTouch(MotionEvent ev) { + // If we are swiping to all apps instead of overview, allow it from anywhere. + boolean interceptAnywhere = mLauncher.isInState(NORMAL) && !mAllowDragToOverview; if (mCurrentAnimation != null) { if (mFinishFastOnSecondTouch) { mCurrentAnimation.getAnimationPlayer().end(); } AllAppsTransitionController allAppsController = mLauncher.getAllAppsController(); - if (ev.getY() >= allAppsController.getShiftRange() * allAppsController.getProgress()) { + if (ev.getY() >= allAppsController.getShiftRange() * allAppsController.getProgress() + || interceptAnywhere) { // If we are already animating from a previous state, we can intercept as long as // the touch is below the current all apps progress (to allow for double swipe). return true; @@ -117,9 +120,7 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr return false; } } else { - // If we are swiping to all apps instead of overview, allow it from anywhere. - boolean interceptAnywhere = mLauncher.isInState(NORMAL) && !mAllowDragToOverview; - // For all other states, only listen if the event originated below the hotseat height + // For non-normal states, only listen if the event originated below the hotseat height if (!interceptAnywhere && !isTouchOverHotseat(mLauncher, ev)) { return false; } From 5191fe9ba04f141a95692a242ec499a53f93b117 Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Mon, 24 Aug 2020 16:38:02 -0700 Subject: [PATCH 04/31] SearchTarget/SearchTargetEvent API Bug: 165869384 Bug: 161599758 TL;DR;; Also introduce some additional methods for - all apps start and stop - metrics logging Change-Id: I666ff5a27a5f8befdb0db483ebb07344a90e96bc --- quickstep/res/values/override.xml | 2 - .../search/AllAppsSearchBarController.java | 8 +- .../systemui/plugins/AllAppsSearchPlugin.java | 25 +++-- .../com/android/systemui/plugins/OWNERS | 4 - .../systemui/plugins/shared/SearchTarget.java | 99 +++++++++++++++++++ .../plugins/shared/SearchTargetEvent.java | 39 ++++++++ 6 files changed, 164 insertions(+), 13 deletions(-) delete mode 100644 src_plugins/com/android/systemui/plugins/OWNERS create mode 100644 src_plugins/com/android/systemui/plugins/shared/SearchTarget.java create mode 100644 src_plugins/com/android/systemui/plugins/shared/SearchTargetEvent.java diff --git a/quickstep/res/values/override.xml b/quickstep/res/values/override.xml index 8f4ce4343b..605774dd9c 100644 --- a/quickstep/res/values/override.xml +++ b/quickstep/res/values/override.xml @@ -25,8 +25,6 @@ com.android.quickstep.QuickstepProcessInitializer - com.android.quickstep.logging.UserEventDispatcherExtension - com.android.launcher3.model.QuickstepModelDelegate diff --git a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java index 2e5ed3ec35..29e340480d 100644 --- a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java +++ b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java @@ -79,7 +79,7 @@ public class AllAppsSearchBarController public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { if (mSearchAlgorithm instanceof PluginWrapper) { ((PluginWrapper) mSearchAlgorithm).runOnPluginIfConnected( - AllAppsSearchPlugin::startedTyping); + AllAppsSearchPlugin::startedSearchSession); } } @@ -113,7 +113,13 @@ public class AllAppsSearchBarController public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { + // selectFocusedView should return SearchTargetEvent that is passed onto onClick if (Launcher.getLauncher(mLauncher).getAppsView().selectFocusedView(v)) { + if (mSearchAlgorithm instanceof PluginWrapper) { + ((PluginWrapper) mSearchAlgorithm).runOnPluginIfConnected(plugin -> { + plugin.onClick(false, null); + }); + } return true; } } diff --git a/src_plugins/com/android/systemui/plugins/AllAppsSearchPlugin.java b/src_plugins/com/android/systemui/plugins/AllAppsSearchPlugin.java index be20e2dbe6..9949678458 100644 --- a/src_plugins/com/android/systemui/plugins/AllAppsSearchPlugin.java +++ b/src_plugins/com/android/systemui/plugins/AllAppsSearchPlugin.java @@ -16,9 +16,9 @@ package com.android.systemui.plugins; -import android.os.Bundle; - import com.android.systemui.plugins.annotations.ProvidesInterface; +import com.android.systemui.plugins.shared.SearchTarget; +import com.android.systemui.plugins.shared.SearchTargetEvent; import java.util.List; import java.util.function.Consumer; @@ -29,15 +29,28 @@ import java.util.function.Consumer; @ProvidesInterface(action = AllAppsSearchPlugin.ACTION, version = AllAppsSearchPlugin.VERSION) public interface AllAppsSearchPlugin extends Plugin { String ACTION = "com.android.systemui.action.PLUGIN_ALL_APPS_SEARCH_ACTIONS"; - int VERSION = 4; + int VERSION = 5; + + + /** + * Send signal when user enters all apps. + */ + void startAllAppsSession(); /** * Send signal when user starts typing. */ - void startedTyping(); + void startedSearchSession(); /** * Send over the query and get the search results. */ - void performSearch(String query, Consumer> results); -} + void performSearch(String query, Consumer> results); + + void onClick(boolean isTouch, SearchTargetEvent event); + + /** + * Send signal when user exits all apps. + */ + void endAllAppsSession(); +} \ No newline at end of file diff --git a/src_plugins/com/android/systemui/plugins/OWNERS b/src_plugins/com/android/systemui/plugins/OWNERS deleted file mode 100644 index 0514999392..0000000000 --- a/src_plugins/com/android/systemui/plugins/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# When changing interface for this plugin OR when increasing version code, please add Alex -# Only add other owners if Alex is not available -per-file AllAppsSearchPlugin.java, globs = set noparent -per-file AllAppsSearchPlugin.java = alexmang@google.com, hyunyoungs@google.com, sunnygoyal@google.com, twickham@google.com diff --git a/src_plugins/com/android/systemui/plugins/shared/SearchTarget.java b/src_plugins/com/android/systemui/plugins/shared/SearchTarget.java new file mode 100644 index 0000000000..913fc0ed7c --- /dev/null +++ b/src_plugins/com/android/systemui/plugins/shared/SearchTarget.java @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.systemui.plugins.shared; + +import android.content.pm.ShortcutInfo; +import android.os.Bundle; + +import java.util.List; + +/** + * Used to return all apps search targets. + */ +public class SearchTarget implements Comparable { + + public enum ViewType { + TOP_HIT(0), + HERO(1), + DETAIL(2), + ROW(3), + ROW_WITH_BUTTON(4), + SLICE(5); + + private final int mId; + ViewType(int id) { + mId = id; + } + + public int get() { + return mId; + } + } + + public enum ItemType { + PLAY_RESULTS(0, "Play Store", ViewType.DETAIL), + SETTINGS_ROW(1, "Settings", ViewType.ROW), + SETTINGS_SLICE(2, "Settings", ViewType.SLICE), + APP(3, "", ViewType.TOP_HIT), + APP_HERO(4, "", ViewType.HERO); + + private final int mId; + private final String mTitle; + private final ViewType mViewType; + + ItemType(int id, String title, ViewType type) { + mId = id; + mTitle = title; + mViewType = type; + } + + public ViewType getViewType() { + return mViewType; + } + + public String getTitle() { + return mTitle; + } + + public int getId() { + return mId; + } + } + + public ItemType type; + public List shortcuts; + public Bundle bundle; + public float score; + + /** + * Constructor to create the search target. Bundle is currently temporary to hold + * search target primitives that cannot be expressed as java primitive objects + * or AOSP native objects. + * + */ + public SearchTarget(ItemType itemType, List shortcuts, + Bundle bundle, float score) { + this.type = itemType; + this.shortcuts = shortcuts; + this.bundle = bundle; + this.score = score; + } + + @Override + public int compareTo(SearchTarget o) { + return Float.compare(o.score, score); + } +} diff --git a/src_plugins/com/android/systemui/plugins/shared/SearchTargetEvent.java b/src_plugins/com/android/systemui/plugins/shared/SearchTargetEvent.java new file mode 100644 index 0000000000..00aacd0543 --- /dev/null +++ b/src_plugins/com/android/systemui/plugins/shared/SearchTargetEvent.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.systemui.plugins.shared; + +import android.content.pm.ShortcutInfo; +import android.os.Bundle; + +/** + * Event used for the feedback loop to the plugin. (and future aiai) + */ +public class SearchTargetEvent { + public SearchTarget.ItemType type; + public ShortcutInfo shortcut; + public Bundle bundle; + public float score; + + public SearchTargetEvent(SearchTarget.ItemType itemType, + ShortcutInfo shortcut, + Bundle bundle, + float score) { + this.type = itemType; + this.shortcut = shortcut; + this.bundle = bundle; + this.score = score; + } +} From 486fad2c44696d93d4b7ffe8a069d1a6d8fe377e Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 5 Aug 2020 23:18:59 -0700 Subject: [PATCH 05/31] Migrate trace proto from nano to lite Bug: 166630570 Change-Id: I0567d0f71dd78e5dab87bb5878417c99c9bbe306 --- .../RecentsAnimationDeviceState.java | 1 + .../quickstep/TouchInteractionService.java | 30 ++++---- .../android/quickstep/util/ProtoTracer.java | 76 ++++++++++--------- 3 files changed, 59 insertions(+), 48 deletions(-) diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java index e9fc42328b..d8064a2153 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java @@ -569,6 +569,7 @@ public class RecentsAnimationDeviceState implements pw.println(" isUserUnlocked=" + mIsUserUnlocked); pw.println(" isOneHandedModeEnabled=" + mIsOneHandedModeEnabled); pw.println(" isSwipeToNotificationEnabled=" + mIsSwipeToNotificationEnabled); + pw.println(" deferredGestureRegion=" + mDeferredGestureRegion); mRotationTouchHelper.dump(pw); } } diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 5b4a2395cd..ebdc867190 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -64,8 +64,8 @@ import com.android.launcher3.provider.RestoreDbTask; import com.android.launcher3.statemanager.StatefulActivity; import com.android.launcher3.testing.TestLogging; import com.android.launcher3.testing.TestProtocol; -import com.android.launcher3.tracing.nano.LauncherTraceProto; -import com.android.launcher3.tracing.nano.TouchInteractionServiceProto; +import com.android.launcher3.tracing.LauncherTraceProto; +import com.android.launcher3.tracing.TouchInteractionServiceProto; import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper; import com.android.launcher3.util.OnboardingPrefs; import com.android.launcher3.util.TraceHelper; @@ -105,7 +105,7 @@ import java.util.LinkedList; */ @TargetApi(Build.VERSION_CODES.R) public class TouchInteractionService extends Service implements PluginListener, - ProtoTraceable { + ProtoTraceable { private static final String TAG = "TouchInteractionService"; @@ -368,9 +368,12 @@ public class TouchInteractionService extends Service implements PluginListener mProtoTracer; + private final FrameProtoTracer mProtoTracer; public ProtoTracer(Context context) { mContext = context; @@ -65,40 +66,47 @@ public class ProtoTracer implements ProtoTraceParams> traceables) { - LauncherTraceEntryProto proto = reuseObj != null - ? reuseObj - : new LauncherTraceEntryProto(); - proto.elapsedRealtimeNanos = SystemClock.elapsedRealtimeNanos(); - proto.launcher = proto.launcher != null ? proto.launcher : new LauncherTraceProto(); + public LauncherTraceEntryProto.Builder updateBufferProto( + LauncherTraceEntryProto.Builder reuseObj, + ArrayList> traceables) { + Trace.beginSection("ProtoTracer.updateBufferProto"); + LauncherTraceEntryProto.Builder proto = LauncherTraceEntryProto.newBuilder(); + proto.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); + LauncherTraceProto.Builder launcherProto = LauncherTraceProto.newBuilder(); for (ProtoTraceable t : traceables) { - t.writeToProto(proto.launcher); + t.writeToProto(launcherProto); } + proto.setLauncher(launcherProto); + Trace.endSection(); return proto; } @Override - public byte[] serializeEncapsulatingProto(LauncherTraceFileProto encapsulatingProto, - Queue buffer) { - encapsulatingProto.magicNumber = MAGIC_NUMBER_VALUE; - encapsulatingProto.entry = buffer.toArray(new LauncherTraceEntryProto[0]); - return MessageNano.toByteArray(encapsulatingProto); + public byte[] serializeEncapsulatingProto(LauncherTraceFileProto.Builder encapsulatingProto, + Queue buffer) { + Trace.beginSection("ProtoTracer.serializeEncapsulatingProto"); + encapsulatingProto.setMagicNumber(MAGIC_NUMBER_VALUE); + for (LauncherTraceEntryProto.Builder entry : buffer) { + encapsulatingProto.addEntry(entry); + } + byte[] bytes = encapsulatingProto.build().toByteArray(); + Trace.endSection(); + return bytes; } @Override - public byte[] getProtoBytes(MessageNano proto) { - return MessageNano.toByteArray(proto); + public byte[] getProtoBytes(MessageLite.Builder proto) { + return proto.build().toByteArray(); } @Override - public int getProtoSize(MessageNano proto) { - return proto.getCachedSize(); + public int getProtoSize(MessageLite.Builder proto) { + return proto.build().getSerializedSize(); } public void start() { @@ -109,11 +117,11 @@ public class ProtoTracer implements ProtoTraceParams traceable) { + public void add(ProtoTraceable traceable) { mProtoTracer.add(traceable); } - public void remove(ProtoTraceable traceable) { + public void remove(ProtoTraceable traceable) { mProtoTracer.remove(traceable); } From 639505c23b32b8d478d884fc57cccb6df1ee6278 Mon Sep 17 00:00:00 2001 From: Sreyas Date: Fri, 28 Aug 2020 10:20:05 -0700 Subject: [PATCH 06/31] Scale down chip proportional to TaskView becoming fullscreen. Merging into ub-launcher3-master manually as automerger failed. Tested: Manual Change-Id: Ic8e6dd6ba83206d67ee27d4af9d56639e9e43ff9 --- quickstep/src/com/android/quickstep/views/TaskView.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index 321821b573..b87d770d7b 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -563,7 +563,11 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { .getInterpolation(progress); mIconView.setScaleX(scale); mIconView.setScaleY(scale); - + if (mContextualChip != null && mContextualChipWrapper != null) { + mContextualChipWrapper.setAlpha(scale); + mContextualChip.setScaleX(scale); + mContextualChip.setScaleY(scale); + } updateFooterVerticalOffset(1.0f - scale); } From ed5e43bd254eb3434a4f5bb20ad07168e6e374d5 Mon Sep 17 00:00:00 2001 From: Sreyas Date: Fri, 28 Aug 2020 10:59:00 -0700 Subject: [PATCH 07/31] Make modal based UI changes in TaskView only if modalness changes. Fixes issue with jittery displaying of suggestion chip, when entering overview. Merging into master manually as automerger failed. Tested:Manual Change-Id: I8228c51b22d550cb8f0aa559f997060b571763f1 --- quickstep/src/com/android/quickstep/views/TaskView.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index 321821b573..950f66ff6e 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -315,6 +315,9 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { * @param modalness [0, 1] 0 being in context with other tasks, 1 being shown on its own. */ public void setModalness(float modalness) { + if (mModalness == modalness) { + return; + } mModalness = modalness; mIconView.setAlpha(comp(modalness)); if (mContextualChip != null) { @@ -324,7 +327,6 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { if (mContextualChipWrapper != null) { mContextualChipWrapper.setAlpha(comp(modalness)); } - updateFooterVerticalOffset(mFooterVerticalOffset); } From 3a89e422375278bb6a5eafcaaa8968a8fe73c7a9 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Thu, 27 Aug 2020 18:05:46 -0700 Subject: [PATCH 08/31] Don't detach recents from app window after motion pause - Update MotionPauseListener to have 2 methods: the existing onMotionPauseChanged(isPaused) and onMotionPauseDetected() - onMotionPauseDetected is the default as most listeners only care about the first detected pause - AbsSwipeUpHandler still listens to pause changes, to help determine the end target at the end of the gesture Bug: 159089437 Change-Id: I6d14f106cdcbe4e07d8dddba1cee909a963615b1 --- ...ButtonNavbarToOverviewTouchController.java | 4 +-- .../NoButtonQuickSwitchTouchController.java | 7 +++--- .../android/quickstep/AbsSwipeUpHandler.java | 25 +++++++++++++------ .../OtherActivityInputConsumer.java | 4 +-- .../ScreenPinnedInputConsumer.java | 20 +++++++-------- .../interaction/NavBarGestureHandler.java | 9 +++---- .../quickstep/util/MotionPauseDetector.java | 9 ++++++- 7 files changed, 44 insertions(+), 34 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java index 591d3ca1f9..a0f6dc5821 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java @@ -128,7 +128,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch mMotionPauseDetector.clear(); if (handlingOverviewAnim()) { - mMotionPauseDetector.setOnMotionPauseListener(this::onMotionPauseChanged); + mMotionPauseDetector.setOnMotionPauseListener(this::onMotionPauseDetected); } if (mFromState == NORMAL && mToState == HINT_STATE) { @@ -185,7 +185,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch } } - private void onMotionPauseChanged(boolean isPaused) { + private void onMotionPauseDetected() { if (mCurrentAnimation == null) { return; } diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java index 4b0642fab7..87c246f2c7 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java @@ -80,7 +80,7 @@ import com.android.quickstep.views.LauncherRecentsView; * the user as possible, also handles swipe up and hold to go to overview and swiping back home. */ public class NoButtonQuickSwitchTouchController implements TouchController, - BothAxesSwipeDetector.Listener, MotionPauseDetector.OnMotionPauseListener { + BothAxesSwipeDetector.Listener { /** The minimum progress of the scale/translationY animation until drag end. */ private static final float Y_ANIM_MIN_PROGRESS = 0.25f; @@ -167,7 +167,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController, if (start) { mStartState = mLauncher.getStateManager().getState(); - mMotionPauseDetector.setOnMotionPauseListener(this); + mMotionPauseDetector.setOnMotionPauseListener(this::onMotionPauseDetected); // We have detected horizontal drag start, now allow swipe up as well. mSwipeDetector.setDetectableScrollConditions(DIRECTION_RIGHT | DIRECTION_UP, @@ -177,8 +177,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController, } } - @Override - public void onMotionPauseChanged(boolean isPaused) { + private void onMotionPauseDetected() { VibratorWrapper.INSTANCE.get(mLauncher).vibrate(OVERVIEW_HAPTIC); } diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index aaa2720047..a932b30dac 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -89,6 +89,7 @@ import com.android.quickstep.util.ActiveGestureLog; import com.android.quickstep.util.ActivityInitListener; import com.android.quickstep.util.AnimatorControllerWithResistance; import com.android.quickstep.util.InputConsumerProxy; +import com.android.quickstep.util.MotionPauseDetector; import com.android.quickstep.util.RectFSpringAnim; import com.android.quickstep.util.SurfaceTransactionApplier; import com.android.quickstep.util.TransformParams; @@ -201,6 +202,7 @@ public abstract class AbsSwipeUpHandler, Q extends // Either RectFSpringAnim (if animating home) or ObjectAnimator (from mCurrentShift) otherwise private RunningWindowAnim mRunningWindowAnim; private boolean mIsMotionPaused; + private boolean mHasMotionEverBeenPaused; private boolean mContinuingLastGesture; @@ -482,13 +484,20 @@ public abstract class AbsSwipeUpHandler, Q extends .getHighResLoadingState().setVisible(true); } - /** - * Called when motion pause is detected - */ - public void onMotionPauseChanged(boolean isPaused) { - mIsMotionPaused = isPaused; - maybeUpdateRecentsAttachedState(); - performHapticFeedback(); + public MotionPauseDetector.OnMotionPauseListener getMotionPauseListener() { + return new MotionPauseDetector.OnMotionPauseListener() { + @Override + public void onMotionPauseDetected() { + mHasMotionEverBeenPaused = true; + maybeUpdateRecentsAttachedState(); + performHapticFeedback(); + } + + @Override + public void onMotionPauseChanged(boolean isPaused) { + mIsMotionPaused = isPaused; + } + }; } public void maybeUpdateRecentsAttachedState() { @@ -519,7 +528,7 @@ public abstract class AbsSwipeUpHandler, Q extends // The window is going away so make sure recents is always visible in this case. recentsAttachedToAppWindow = true; } else { - recentsAttachedToAppWindow = mIsMotionPaused || mIsLikelyToStartNewTask; + recentsAttachedToAppWindow = mHasMotionEverBeenPaused || mIsLikelyToStartNewTask; } mAnimationFactory.setRecentsAttachedToAppWindow(recentsAttachedToAppWindow, animate); diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java index f02e5e6d61..0e1364a9ec 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java @@ -52,9 +52,9 @@ import com.android.launcher3.testing.TestLogging; import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.util.Preconditions; import com.android.launcher3.util.TraceHelper; -import com.android.quickstep.BaseActivityInterface; import com.android.quickstep.AbsSwipeUpHandler; import com.android.quickstep.AbsSwipeUpHandler.Factory; +import com.android.quickstep.BaseActivityInterface; import com.android.quickstep.GestureState; import com.android.quickstep.InputConsumer; import com.android.quickstep.RecentsAnimationCallbacks; @@ -365,7 +365,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC mInteractionHandler = mHandlerFactory.newHandler(mGestureState, touchTimeMs, mTaskAnimationManager.isRecentsAnimationRunning()); mInteractionHandler.setGestureEndCallback(this::onInteractionGestureFinished); - mMotionPauseDetector.setOnMotionPauseListener(mInteractionHandler::onMotionPauseChanged); + mMotionPauseDetector.setOnMotionPauseListener(mInteractionHandler.getMotionPauseListener()); Intent intent = new Intent(mInteractionHandler.getLaunchIntent()); mInteractionHandler.initWhenReady(intent); diff --git a/quickstep/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java index b9827fff1d..a8bf333567 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java @@ -42,18 +42,16 @@ public class ScreenPinnedInputConsumer implements InputConsumer { mMotionPauseMinDisplacement = context.getResources().getDimension( R.dimen.motion_pause_detector_min_displacement_from_app); mMotionPauseDetector = new MotionPauseDetector(context, true /* makePauseHarderToTrigger*/); - mMotionPauseDetector.setOnMotionPauseListener(isPaused -> { - if (isPaused) { - SystemUiProxy.INSTANCE.get(context).stopScreenPinning(); - BaseDraggingActivity launcherActivity = gestureState.getActivityInterface() - .getCreatedActivity(); - if (launcherActivity != null) { - launcherActivity.getRootView().performHapticFeedback( - HapticFeedbackConstants.LONG_PRESS, - HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); - } - mMotionPauseDetector.clear(); + mMotionPauseDetector.setOnMotionPauseListener(() -> { + SystemUiProxy.INSTANCE.get(context).stopScreenPinning(); + BaseDraggingActivity launcherActivity = gestureState.getActivityInterface() + .getCreatedActivity(); + if (launcherActivity != null) { + launcherActivity.getRootView().performHapticFeedback( + HapticFeedbackConstants.LONG_PRESS, + HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); } + mMotionPauseDetector.clear(); }); } diff --git a/quickstep/src/com/android/quickstep/interaction/NavBarGestureHandler.java b/quickstep/src/com/android/quickstep/interaction/NavBarGestureHandler.java index 81c4d0c7c8..8925235d94 100644 --- a/quickstep/src/com/android/quickstep/interaction/NavBarGestureHandler.java +++ b/quickstep/src/com/android/quickstep/interaction/NavBarGestureHandler.java @@ -182,7 +182,7 @@ public class NavBarGestureHandler implements OnTouchListener, mLaunchedAssistant = false; mSwipeUpTouchTracker.init(); mMotionPauseDetector.clear(); - mMotionPauseDetector.setOnMotionPauseListener(this::onMotionPauseChanged); + mMotionPauseDetector.setOnMotionPauseListener(this::onMotionPauseDetected); break; case MotionEvent.ACTION_MOVE: mLastPos.set(event.getX(), event.getY()); @@ -220,7 +220,6 @@ public class NavBarGestureHandler implements OnTouchListener, case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mMotionPauseDetector.clear(); - mMotionPauseDetector.setOnMotionPauseListener(null); if (mGestureCallback != null && !intercepted && mTouchCameFromNavBar) { mGestureCallback.onNavBarGestureAttempted( HOME_OR_OVERVIEW_NOT_STARTED_WRONG_SWIPE_DIRECTION, new PointF()); @@ -252,10 +251,8 @@ public class NavBarGestureHandler implements OnTouchListener, return intercepted; } - protected void onMotionPauseChanged(boolean isPaused) { - if (isPaused) { - VibratorWrapper.INSTANCE.get(mContext).vibrate(OVERVIEW_HAPTIC); - } + protected void onMotionPauseDetected() { + VibratorWrapper.INSTANCE.get(mContext).vibrate(OVERVIEW_HAPTIC); } /** diff --git a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java index b86293607e..d0f6879b70 100644 --- a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java +++ b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java @@ -184,11 +184,15 @@ public class MotionPauseDetector { } if (mIsPaused != isPaused) { mIsPaused = isPaused; + boolean isFirstDetectedPause = !mHasEverBeenPaused && mIsPaused; if (mIsPaused) { AccessibilityManagerCompat.sendPauseDetectedEventToTest(mContext); mHasEverBeenPaused = true; } if (mOnMotionPauseListener != null) { + if (isFirstDetectedPause) { + mOnMotionPauseListener.onMotionPauseDetected(); + } mOnMotionPauseListener.onMotionPauseChanged(mIsPaused); } } @@ -211,7 +215,10 @@ public class MotionPauseDetector { } public interface OnMotionPauseListener { - void onMotionPauseChanged(boolean isPaused); + /** Called only the first time motion pause is detected. */ + void onMotionPauseDetected(); + /** Called every time motion changes from paused to not paused and vice versa. */ + default void onMotionPauseChanged(boolean isPaused) { } } /** From 61e8ae1d9d1610c21782743f188057b756c6f2bf Mon Sep 17 00:00:00 2001 From: Pinyao Ting Date: Wed, 2 Sep 2020 17:46:27 -0700 Subject: [PATCH 09/31] Refrain from overwriting shortcut icon with default icon Invert the condition check in IconCache so that, if a shortcut is already using a non-default icon, do not replace it with default icon again. Bug: 162783875 Test: add weather shortcut, backup, restore, verify its icon is not replaced by default droid icon Change-Id: Idaf4ce4afa84d21f7192a2f4ce41a6f8daa8d3f2 --- src/com/android/launcher3/icons/IconCache.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/android/launcher3/icons/IconCache.java b/src/com/android/launcher3/icons/IconCache.java index 444c2dab81..80135571b2 100644 --- a/src/com/android/launcher3/icons/IconCache.java +++ b/src/com/android/launcher3/icons/IconCache.java @@ -67,8 +67,8 @@ public class IconCache extends BaseIconCache { private static final String TAG = "Launcher.IconCache"; - private final Predicate mIsUsingFallbackIconCheck = w -> w.bitmap != null - && w.bitmap.isNullOrLowRes() && !isDefaultIcon(w.bitmap, w.user); + private final Predicate mIsUsingFallbackOrNonDefaultIconCheck = w -> + w.bitmap != null && (w.bitmap.isNullOrLowRes() || !isDefaultIcon(w.bitmap, w.user)); private final CachingLogic mComponentWithLabelCachingLogic; private final CachingLogic mLauncherActivityInfoCachingLogic; @@ -192,14 +192,14 @@ public class IconCache extends BaseIconCache { * Fill in {@param info} with the icon for {@param si} */ public void getShortcutIcon(ItemInfoWithIcon info, ShortcutInfo si) { - getShortcutIcon(info, si, true, mIsUsingFallbackIconCheck); + getShortcutIcon(info, si, true, mIsUsingFallbackOrNonDefaultIconCheck); } /** * Fill in {@param info} with an unbadged icon for {@param si} */ public void getUnbadgedShortcutIcon(ItemInfoWithIcon info, ShortcutInfo si) { - getShortcutIcon(info, si, false, mIsUsingFallbackIconCheck); + getShortcutIcon(info, si, false, mIsUsingFallbackOrNonDefaultIconCheck); } /** From 01e4070836deef941570cdeb41137a8047db4e10 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Mon, 31 Aug 2020 21:00:59 -0700 Subject: [PATCH 10/31] Standardize quickstep velocities - Compute velocities as px/ms from VelocityTracker, instead of computing px/s and dividing by 1000 in various places - Use quickstep_fling_threshold_speed in TriggerSwipeUpTouchTracker instead of ViewConfiguration#getScaledMinimumFlingVelocity - Check MotionPauseDetector to determine whether a fling is sufficient to escape after pause, in additon to above threshold Bug: 159089437 Change-Id: Ib0fae7804e1f008f3b6ab37d6c463352c224b0e4 --- quickstep/res/values/dimens.xml | 5 +--- ...ButtonNavbarToOverviewTouchController.java | 16 +++++------ .../android/quickstep/AbsSwipeUpHandler.java | 20 ++++++------- .../DeviceLockedInputConsumer.java | 7 ++--- .../OtherActivityInputConsumer.java | 4 +-- .../interaction/NavBarGestureHandler.java | 1 - .../util/TriggerSwipeUpTouchTracker.java | 8 ++++-- .../android/launcher3/util/VelocityUtils.java | 28 +++++++++++++++++++ 8 files changed, 56 insertions(+), 33 deletions(-) create mode 100644 src/com/android/launcher3/util/VelocityUtils.java diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index 313db8ccaf..c85fe6ca35 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -35,16 +35,13 @@ loading full resolution screenshots. --> 600dp - - 500dp - 250dp - 0.0285dp 0.15dp 0.285dp 1.4dp 36dp + 0.5dp 50dp diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java index a0f6dc5821..c78d4741d8 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java @@ -75,6 +75,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch private final float mMotionPauseMinDisplacement; private boolean mDidTouchStartInNavBar; + private boolean mStartedOverview; private boolean mReachedOverview; // The last recorded displacement before we reached overview. private PointF mStartDisplacement = new PointF(); @@ -138,6 +139,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch mFromState.getOverviewScrimAlpha(mLauncher), mToState.getOverviewScrimAlpha(mLauncher)); } + mStartedOverview = false; mReachedOverview = false; mOverviewResistYAnim = null; } @@ -152,7 +154,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch @Override public void onDragEnd(float velocity) { - if (mMotionPauseDetector.isPaused() && handlingOverviewAnim()) { + if (mStartedOverview) { goToOverviewOrHomeOnDragEnd(velocity); } else { super.onDragEnd(velocity); @@ -199,6 +201,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch maybeSwipeInteractionToOverviewComplete(); }); }); + mStartedOverview = true; VibratorWrapper.INSTANCE.get(mLauncher).vibrate(OVERVIEW_HAPTIC); } @@ -219,7 +222,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch if (TestProtocol.sDebugTracing) { Log.d(TestProtocol.PAUSE_NOT_DETECTED, "NoButtonNavbarToOverviewTouchController"); } - if (mMotionPauseDetector.isPaused()) { + if (mStartedOverview) { if (!mReachedOverview) { mStartDisplacement.set(xDisplacement, yDisplacement); mStartY = event.getY(); @@ -234,8 +237,6 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch * OVERVIEW_MOVEMENT_FACTOR); } } - // Stay in Overview. - return true; } float upDisplacement = -yDisplacement; @@ -243,13 +244,12 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch || upDisplacement < mMotionPauseMinDisplacement); mMotionPauseDetector.addPosition(event); - return super.onDrag(yDisplacement, xDisplacement, event); + // Stay in Overview. + return mStartedOverview || super.onDrag(yDisplacement, xDisplacement, event); } private void goToOverviewOrHomeOnDragEnd(float velocity) { - float velocityDp = dpiFromPx(velocity); - boolean isFling = Math.abs(velocityDp) > 1; - boolean goToHomeInsteadOfOverview = isFling; + boolean goToHomeInsteadOfOverview = !mMotionPauseDetector.isPaused(); if (goToHomeInsteadOfOverview) { new OverviewToHomeAnim(mLauncher, ()-> onSwipeInteractionCompleted(NORMAL, Touch.FLING)) .animateWithVelocity(velocity); diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index a932b30dac..4bdc59e0c2 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -751,8 +751,9 @@ public abstract class AbsSwipeUpHandler, Q extends @UiThread public void onGestureEnded(float endVelocity, PointF velocity, PointF downPos) { float flingThreshold = mContext.getResources() - .getDimension(R.dimen.quickstep_fling_threshold_velocity); - boolean isFling = mGestureStarted && Math.abs(endVelocity) > flingThreshold; + .getDimension(R.dimen.quickstep_fling_threshold_speed); + boolean isFling = mGestureStarted && !mIsMotionPaused + && Math.abs(endVelocity) > flingThreshold; mStateCallback.setStateOnUiThread(STATE_GESTURE_COMPLETED); mLogAction = isFling ? Touch.FLING : Touch.SWIPE; @@ -867,7 +868,7 @@ public abstract class AbsSwipeUpHandler, Q extends if (mDeviceState.isFullyGesturalNavMode() && isSwipeUp && !willGoToNewTaskOnSwipeUp) { endTarget = HOME; - } else if (mDeviceState.isFullyGesturalNavMode() && isSwipeUp && !mIsMotionPaused) { + } else if (mDeviceState.isFullyGesturalNavMode() && isSwipeUp) { // If swiping at a diagonal, base end target on the faster velocity. endTarget = NEW_TASK; } else if (isSwipeUp) { @@ -887,7 +888,6 @@ public abstract class AbsSwipeUpHandler, Q extends @UiThread private void handleNormalGestureEnd(float endVelocity, boolean isFling, PointF velocity, boolean isCancel) { - PointF velocityPxPerMs = new PointF(velocity.x / 1000, velocity.y / 1000); long duration = MAX_SWIPE_DURATION; float currentShift = mCurrentShift.value; final GestureEndTarget endTarget = calculateEndTarget(velocity, endVelocity, @@ -902,14 +902,12 @@ public abstract class AbsSwipeUpHandler, Q extends startShift = currentShift; interpolator = endTarget == RECENTS ? OVERSHOOT_1_2 : DEACCEL; } else { - startShift = Utilities.boundToRange(currentShift - velocityPxPerMs.y + startShift = Utilities.boundToRange(currentShift - velocity.y * getSingleFrameMs(mContext) / mTransitionDragLength, 0, mDragLengthFactor); - float minFlingVelocity = mContext.getResources() - .getDimension(R.dimen.quickstep_fling_min_velocity); - if (Math.abs(endVelocity) > minFlingVelocity && mTransitionDragLength > 0) { + if (mTransitionDragLength > 0) { if (endTarget == RECENTS && !mDeviceState.isFullyGesturalNavMode()) { Interpolators.OvershootParams overshoot = new Interpolators.OvershootParams( - startShift, endShift, endShift, endVelocity / 1000, + startShift, endShift, endShift, endVelocity, mTransitionDragLength, mContext); endShift = overshoot.end; interpolator = overshoot.interpolator; @@ -921,7 +919,7 @@ public abstract class AbsSwipeUpHandler, Q extends // we want the page's snap velocity to approximately match the velocity at // which the user flings, so we scale the duration by a value near to the // derivative of the scroll interpolator at zero, ie. 2. - long baseDuration = Math.round(Math.abs(distanceToTravel / velocityPxPerMs.y)); + long baseDuration = Math.round(Math.abs(distanceToTravel / velocity.y)); duration = Math.min(MAX_SWIPE_DURATION, 2 * baseDuration); if (endTarget == RECENTS) { @@ -961,7 +959,7 @@ public abstract class AbsSwipeUpHandler, Q extends mGestureState.setState(STATE_RECENTS_SCROLLING_FINISHED); } - animateToProgress(startShift, endShift, duration, interpolator, endTarget, velocityPxPerMs); + animateToProgress(startShift, endShift, duration, interpolator, endTarget, velocity); } private void doLogGesture(GestureEndTarget endTarget, @Nullable TaskView targetTask) { diff --git a/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java index 584ff28fdb..5aaea0009e 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java @@ -21,6 +21,7 @@ import static android.view.MotionEvent.ACTION_UP; import static com.android.launcher3.Utilities.squaredHypot; import static com.android.launcher3.Utilities.squaredTouchSlop; +import static com.android.launcher3.util.VelocityUtils.PX_PER_MS; import static com.android.quickstep.AbsSwipeUpHandler.MIN_PROGRESS_FOR_OVERVIEW; import static com.android.quickstep.MultiStateCallback.DEBUG_STATES; import static com.android.quickstep.util.ActiveGestureLog.INTENT_EXTRA_LOG_TRACE_ID; @@ -35,7 +36,6 @@ import android.graphics.Point; import android.graphics.PointF; import android.view.MotionEvent; import android.view.VelocityTracker; -import android.view.ViewConfiguration; import com.android.launcher3.R; import com.android.launcher3.anim.Interpolators; @@ -180,12 +180,11 @@ public class DeviceLockedInputConsumer implements InputConsumer, */ private void finishTouchTracking(MotionEvent ev) { if (mThresholdCrossed && ev.getAction() == ACTION_UP) { - mVelocityTracker.computeCurrentVelocity(1000, - ViewConfiguration.get(mContext).getScaledMaximumFlingVelocity()); + mVelocityTracker.computeCurrentVelocity(PX_PER_MS); float velocityY = mVelocityTracker.getYVelocity(); float flingThreshold = mContext.getResources() - .getDimension(R.dimen.quickstep_fling_threshold_velocity); + .getDimension(R.dimen.quickstep_fling_threshold_speed); boolean dismissTask; if (Math.abs(velocityY) > flingThreshold) { diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java index 0e1364a9ec..b1a1133885 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java @@ -28,6 +28,7 @@ import static com.android.launcher3.PagedView.DEBUG_FAILED_QUICKSWITCH; import static com.android.launcher3.Utilities.EDGE_NAV_BAR; import static com.android.launcher3.Utilities.squaredHypot; import static com.android.launcher3.util.TraceHelper.FLAG_CHECK_FOR_RACE_CONDITIONS; +import static com.android.launcher3.util.VelocityUtils.PX_PER_MS; import static com.android.quickstep.GestureState.STATE_OVERSCROLL_WINDOW_CREATED; import static com.android.quickstep.util.ActiveGestureLog.INTENT_EXTRA_LOG_TRACE_ID; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; @@ -393,8 +394,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC if (ev.getActionMasked() == ACTION_CANCEL) { mInteractionHandler.onGestureCancelled(); } else { - mVelocityTracker.computeCurrentVelocity(1000, - ViewConfiguration.get(this).getScaledMaximumFlingVelocity()); + mVelocityTracker.computeCurrentVelocity(PX_PER_MS); float velocityX = mVelocityTracker.getXVelocity(mActivePointerId); float velocityY = mVelocityTracker.getYVelocity(mActivePointerId); float velocity = mNavBarPosition.isRightEdge() diff --git a/quickstep/src/com/android/quickstep/interaction/NavBarGestureHandler.java b/quickstep/src/com/android/quickstep/interaction/NavBarGestureHandler.java index 8925235d94..f897ecc01a 100644 --- a/quickstep/src/com/android/quickstep/interaction/NavBarGestureHandler.java +++ b/quickstep/src/com/android/quickstep/interaction/NavBarGestureHandler.java @@ -144,7 +144,6 @@ public class NavBarGestureHandler implements OnTouchListener, if (mGestureCallback == null || mAssistantGestureActive) { return; } - finalVelocity.set(finalVelocity.x / 1000, finalVelocity.y / 1000); if (mTouchCameFromNavBar) { mGestureCallback.onNavBarGestureAttempted(wasFling ? HOME_GESTURE_COMPLETED : OVERVIEW_GESTURE_COMPLETED, finalVelocity); diff --git a/quickstep/src/com/android/quickstep/util/TriggerSwipeUpTouchTracker.java b/quickstep/src/com/android/quickstep/util/TriggerSwipeUpTouchTracker.java index 29b95589f3..7bbde30df8 100644 --- a/quickstep/src/com/android/quickstep/util/TriggerSwipeUpTouchTracker.java +++ b/quickstep/src/com/android/quickstep/util/TriggerSwipeUpTouchTracker.java @@ -21,13 +21,14 @@ import static android.view.MotionEvent.ACTION_MOVE; import static android.view.MotionEvent.ACTION_UP; import static com.android.launcher3.Utilities.squaredHypot; +import static com.android.launcher3.util.VelocityUtils.PX_PER_MS; import android.content.Context; import android.graphics.PointF; import android.view.MotionEvent; import android.view.VelocityTracker; -import android.view.ViewConfiguration; +import com.android.launcher3.R; import com.android.launcher3.Utilities; /** @@ -50,7 +51,8 @@ public class TriggerSwipeUpTouchTracker { NavBarPosition navBarPosition, Runnable onInterceptTouch, OnSwipeUpListener onSwipeUp) { mSquaredTouchSlop = Utilities.squaredTouchSlop(context); - mMinFlingVelocity = ViewConfiguration.get(context).getScaledMinimumFlingVelocity(); + mMinFlingVelocity = context.getResources().getDimension( + R.dimen.quickstep_fling_threshold_speed); mNavBarPosition = navBarPosition; mDisableHorizontalSwipe = disableHorizontalSwipe; mOnInterceptTouch = onInterceptTouch; @@ -130,7 +132,7 @@ public class TriggerSwipeUpTouchTracker { } private void onGestureEnd(MotionEvent ev) { - mVelocityTracker.computeCurrentVelocity(1000); + mVelocityTracker.computeCurrentVelocity(PX_PER_MS); float velocityX = mVelocityTracker.getXVelocity(); float velocityY = mVelocityTracker.getYVelocity(); float velocity = mNavBarPosition.isRightEdge() diff --git a/src/com/android/launcher3/util/VelocityUtils.java b/src/com/android/launcher3/util/VelocityUtils.java new file mode 100644 index 0000000000..d5962ed0dc --- /dev/null +++ b/src/com/android/launcher3/util/VelocityUtils.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 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.launcher3.util; + +/** + * Contains some constants and functions to standardize velocity usage. + */ +public class VelocityUtils { + + /** + * Unit to pass to {@link android.view.VelocityTracker#computeCurrentVelocity(int)}. + */ + public static final int PX_PER_MS = 1; + +} From 8a35c76427c8cc1619addaba91d47c4976b9eae0 Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Thu, 3 Sep 2020 14:30:10 -0700 Subject: [PATCH 11/31] Add folder UI animation. Test: manual Fixing b/144948355. The entire launcher was panning up when the user would try to edit a folder name if that folder's name field would have otherwise been obscured by the keyboard. This had the effect of obscuring the smartspace. Added an animation to the folder UI to bring it above the keyboard during text editing. Change-Id: I0f95aae27fc7426f1025135ea6d4fa142a21cf43 --- src/com/android/launcher3/Launcher.java | 5 ++ src/com/android/launcher3/folder/Folder.java | 95 ++++++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index cacd3fbe7f..2e36bc01dd 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -88,6 +88,7 @@ import android.view.Menu; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.view.WindowManager; import android.view.accessibility.AccessibilityEvent; import android.view.animation.OvershootInterpolator; import android.widget.Toast; @@ -466,6 +467,10 @@ public class Launcher extends StatefulActivity implements Launche mUserChangedCallbackCloseable = UserCache.INSTANCE.get(this).addUserChangeListener( () -> getStateManager().goToState(NORMAL)); + + if (Utilities.ATLEAST_R) { + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); + } } protected LauncherOverlayManager getDefaultOverlay() { diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index f1606ea747..c841b7b0f3 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -17,6 +17,7 @@ package com.android.launcher3.folder; import static android.text.TextUtils.isEmpty; +import static android.view.WindowInsetsAnimation.Callback.DISPATCH_MODE_STOP; import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY; import static com.android.launcher3.LauncherState.NORMAL; @@ -34,8 +35,10 @@ import android.annotation.SuppressLint; import android.appwidget.AppWidgetHostView; import android.content.Context; import android.graphics.Canvas; +import android.graphics.Insets; import android.graphics.Path; import android.graphics.Rect; +import android.os.Build; import android.text.InputType; import android.text.Selection; import android.text.TextUtils; @@ -47,11 +50,16 @@ import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.ViewDebug; +import android.view.WindowInsets; +import android.view.WindowInsetsAnimation; import android.view.accessibility.AccessibilityEvent; import android.view.animation.AnimationUtils; import android.view.inputmethod.EditorInfo; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.RequiresApi; + import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.Alarm; import com.android.launcher3.BubbleTextView; @@ -252,6 +260,13 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo int measureSpec = MeasureSpec.UNSPECIFIED; mFooter.measure(measureSpec, measureSpec); mFooterHeight = mFooter.getMeasuredHeight(); + + if (Utilities.ATLEAST_R) { + WindowInsetsAnimation.Callback cb = new FolderWindowInsetsAnimationCallback( + DISPATCH_MODE_STOP, this); + + setWindowInsetsAnimationCallback(cb); + } } public boolean onLongClick(View v) { @@ -373,6 +388,26 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo return false; } + @Override + public WindowInsets onApplyWindowInsets(WindowInsets windowInsets) { + if (Utilities.ATLEAST_R) { + this.setTranslationY(0); + + if (windowInsets.isVisible(WindowInsets.Type.ime())) { + Insets keyboardInsets = windowInsets.getInsets(WindowInsets.Type.ime()); + int folderHeightFromBottom = getHeightFromBottom(); + + if (keyboardInsets.bottom > folderHeightFromBottom) { + // Translate this folder above the keyboard, then add the folder name's padding + this.setTranslationY(folderHeightFromBottom - keyboardInsets.bottom + - mFolderName.getPaddingBottom()); + } + } + } + + return windowInsets; + } + public FolderIcon getFolderIcon() { return mFolderIcon; } @@ -1646,4 +1681,64 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo mLauncher.getUserEventDispatcher() .logLauncherEvent(mInfo.getFolderLabelStateLauncherEvent(fromState, toState)); } + + /** Returns the height of the current folder's bottom edge from the bottom of the screen. */ + private int getHeightFromBottom() { + DragLayer.LayoutParams layoutParams = (DragLayer.LayoutParams) getLayoutParams(); + int folderBottomPx = layoutParams.y + layoutParams.height; + int windowBottomPx = mLauncher.getDeviceProfile().heightPx; + + return windowBottomPx - folderBottomPx; + } + + /** Callback that animates a folder sliding up above the ime. */ + @RequiresApi(api = Build.VERSION_CODES.R) + private static class FolderWindowInsetsAnimationCallback + extends WindowInsetsAnimation.Callback { + + private final Folder mFolder; + float mFolderTranslationStart; + float mFolderTranslationEnd; + + FolderWindowInsetsAnimationCallback(int dispatchMode, Folder folder) { + super(dispatchMode); + + mFolder = folder; + } + + @Override + public void onPrepare(@NonNull WindowInsetsAnimation animation) { + mFolderTranslationStart = mFolder.getTranslationY(); + } + + @NonNull + @Override + public WindowInsetsAnimation.Bounds onStart( + @NonNull WindowInsetsAnimation animation, + @NonNull WindowInsetsAnimation.Bounds bounds) { + mFolderTranslationEnd = mFolder.getTranslationY(); + + mFolder.setTranslationY(mFolderTranslationStart); + + return super.onStart(animation, bounds); + } + + @NonNull + @Override + public WindowInsets onProgress(@NonNull WindowInsets windowInsets, + @NonNull List list) { + if (list.size() == 0) { + mFolder.setTranslationY(0); + + return windowInsets; + } + float progress = list.get(0).getInterpolatedFraction(); + + mFolder.setTranslationY( + Utilities.mapRange(progress, mFolderTranslationStart, mFolderTranslationEnd)); + + return windowInsets; + } + + } } From 4307781a101b1030c456f94ae6f2ba97fd6d1715 Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Sat, 5 Sep 2020 18:47:07 +0000 Subject: [PATCH 12/31] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: If9d4e92299ac6d5952ff7d07db10b0d74d9a3e34 --- quickstep/res/values-es-rUS/strings.xml | 4 ++-- quickstep/res/values-hu/strings.xml | 2 +- quickstep/res/values-in/strings.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/quickstep/res/values-es-rUS/strings.xml b/quickstep/res/values-es-rUS/strings.xml index 1191becfa1..d1ae0fe437 100644 --- a/quickstep/res/values-es-rUS/strings.xml +++ b/quickstep/res/values-es-rUS/strings.xml @@ -33,9 +33,9 @@ "Todas las apps" "Predicción de tus apps" "Obtén sugerencias de aplicaciones en la fila inferior de la pantalla principal" - "Obtén sugerencias de apps en la fila de favoritos de la Pantalla principal" + "Obtén sugerencias de apps en la fila de favoritos de la pantalla principal" "Accede fácilmente en la pantalla principal a las apps que más usas. Las sugerencias cambiarán según tus rutinas. Las apps de la fila inferior se desplazarán hacia arriba en la pantalla principal." - "Accede fácilmente en la pantalla principal a las apps que más usas. Las sugerencias cambiarán según tus rutinas. Se moverán a la Pantalla principal las apps que estén en la fila de favoritos." + "Accede fácilmente en la pantalla principal a las apps que más usas. Las sugerencias cambiarán según tus rutinas. Se moverán a la pantalla principal las apps que estén en la fila de favoritos." "Accede fácilmente a las apps que más usas en la pantalla principal. Las sugerencias cambiarán según tus rutinas. Las apps de la fila inferior se moverán a una nueva carpeta." "Obtén sugerencias de aplicaciones" "No, gracias" diff --git a/quickstep/res/values-hu/strings.xml b/quickstep/res/values-hu/strings.xml index 75983c4313..f81355eccf 100644 --- a/quickstep/res/values-hu/strings.xml +++ b/quickstep/res/values-hu/strings.xml @@ -20,7 +20,7 @@ "Osztott képernyő" - "Rögzítés" + "Kitűzés" "Szabad forma" "Nincsenek mostanában használt elemek" "Alkalmazáshasználati beállítások" diff --git a/quickstep/res/values-in/strings.xml b/quickstep/res/values-in/strings.xml index a85ea4e2e3..d7437d0ddb 100644 --- a/quickstep/res/values-in/strings.xml +++ b/quickstep/res/values-in/strings.xml @@ -25,7 +25,7 @@ "Tidak ada item yang baru dibuka" "Setelan penggunaan aplikasi" "Hapus semua" - "Aplikasi baru-baru ini" + "Aplikasi terbaru" "%1$s, %2$s" "< 1 menit" "%1$s tersisa hari ini" From a16a23bfdc345db79395f771434805a4fd084517 Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Sat, 5 Sep 2020 18:47:35 +0000 Subject: [PATCH 13/31] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: I937d1c6fe5f15090699b1cbb57b8271e5f70e90d --- quickstep/res/values-es-rUS/strings.xml | 4 ++-- quickstep/res/values-hu/strings.xml | 2 +- quickstep/res/values-in/strings.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/quickstep/res/values-es-rUS/strings.xml b/quickstep/res/values-es-rUS/strings.xml index 1191becfa1..d1ae0fe437 100644 --- a/quickstep/res/values-es-rUS/strings.xml +++ b/quickstep/res/values-es-rUS/strings.xml @@ -33,9 +33,9 @@ "Todas las apps" "Predicción de tus apps" "Obtén sugerencias de aplicaciones en la fila inferior de la pantalla principal" - "Obtén sugerencias de apps en la fila de favoritos de la Pantalla principal" + "Obtén sugerencias de apps en la fila de favoritos de la pantalla principal" "Accede fácilmente en la pantalla principal a las apps que más usas. Las sugerencias cambiarán según tus rutinas. Las apps de la fila inferior se desplazarán hacia arriba en la pantalla principal." - "Accede fácilmente en la pantalla principal a las apps que más usas. Las sugerencias cambiarán según tus rutinas. Se moverán a la Pantalla principal las apps que estén en la fila de favoritos." + "Accede fácilmente en la pantalla principal a las apps que más usas. Las sugerencias cambiarán según tus rutinas. Se moverán a la pantalla principal las apps que estén en la fila de favoritos." "Accede fácilmente a las apps que más usas en la pantalla principal. Las sugerencias cambiarán según tus rutinas. Las apps de la fila inferior se moverán a una nueva carpeta." "Obtén sugerencias de aplicaciones" "No, gracias" diff --git a/quickstep/res/values-hu/strings.xml b/quickstep/res/values-hu/strings.xml index 75983c4313..f81355eccf 100644 --- a/quickstep/res/values-hu/strings.xml +++ b/quickstep/res/values-hu/strings.xml @@ -20,7 +20,7 @@ "Osztott képernyő" - "Rögzítés" + "Kitűzés" "Szabad forma" "Nincsenek mostanában használt elemek" "Alkalmazáshasználati beállítások" diff --git a/quickstep/res/values-in/strings.xml b/quickstep/res/values-in/strings.xml index a85ea4e2e3..d7437d0ddb 100644 --- a/quickstep/res/values-in/strings.xml +++ b/quickstep/res/values-in/strings.xml @@ -25,7 +25,7 @@ "Tidak ada item yang baru dibuka" "Setelan penggunaan aplikasi" "Hapus semua" - "Aplikasi baru-baru ini" + "Aplikasi terbaru" "%1$s, %2$s" "< 1 menit" "%1$s tersisa hari ini" From 5ad2a690894ce7a4a74b189370243ba038ab048a Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Sat, 5 Sep 2020 18:49:09 +0000 Subject: [PATCH 14/31] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: I561a389ed45dce75d1f929c77d4f1de2aafb5d52 --- res/values-af/strings.xml | 2 +- res/values-as/strings.xml | 2 +- res/values-hi/strings.xml | 2 +- res/values-hy/strings.xml | 6 +++--- res/values-ja/strings.xml | 2 +- res/values-kn/strings.xml | 2 +- res/values-ml/strings.xml | 2 +- res/values-mn/strings.xml | 2 +- res/values-mr/strings.xml | 2 +- res/values-nl/strings.xml | 2 +- res/values-or/strings.xml | 2 +- res/values-te/strings.xml | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml index f19d121e7f..c39a9dc9ab 100644 --- a/res/values-af/strings.xml +++ b/res/values-af/strings.xml @@ -53,7 +53,7 @@ "Programinligting" "Installeer" "Moenie program voorstel nie" - "PIN-voorspelling" + "Vasspeldvoorspelling" "installeer kortpaaie" "Laat \'n program toe om kortpaaie by te voeg sonder gebruikerinmenging." "lees Tuis-instellings en -kortpaaie" diff --git a/res/values-as/strings.xml b/res/values-as/strings.xml index a6967b758b..8e9aafc651 100644 --- a/res/values-as/strings.xml +++ b/res/values-as/strings.xml @@ -98,7 +98,7 @@ "নতুন এপসমূহৰ বাবে" "অজ্ঞাত" "আঁতৰাওক" - "সন্ধান কৰক" + "Search" "এই এপটো ইনষ্টল কৰা হোৱা নাই" "এই আইকনৰ এপটো ইনষ্টল কৰা হোৱা নাই। আপুনি এইটো আঁতৰাব পাৰে অথবা এপটো বিচাৰি মেনুৱেলভাৱে ইনষ্টল কৰিব পাৰে।" "%1$s ডাউনল’ড কৰি থকা হৈছে, %2$s সম্পূৰ্ণ হ’ল" diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml index af3dcdb8b2..0cec9a324f 100644 --- a/res/values-hi/strings.xml +++ b/res/values-hi/strings.xml @@ -98,7 +98,7 @@ "नए ऐप्लिकेशन के लिए" "अज्ञात" "निकालें" - "सर्च करें" + "खोजें" "यह ऐप्लिकेशन इंस्टॉल नहीं है" "इस आइकॉन का ऐप इंस्टॉल नहीं है. आप उसे निकाल सकते हैं या ऐप को खोज कर उसे मैन्युअल रूप से इंस्टॉल कर सकते हैं." "%1$s डाउनलोड हो रहा है, %2$s पूरी हुई" diff --git a/res/values-hy/strings.xml b/res/values-hy/strings.xml index 99b582b0b2..c098bb3f4b 100644 --- a/res/values-hy/strings.xml +++ b/res/values-hy/strings.xml @@ -48,8 +48,8 @@ "Անձնական հավելվածների ցանկ" "Աշխատանքային հավելվածների ցանկ" "Հիմնական" - "Ապատեղադրել" - "Հեռացնել" + "Հեռացնել" + "Ապատեղադրել" "Հավելվածի մասին" "Տեղադրել" "Թաքցնել առաջարկը" @@ -97,7 +97,7 @@ "Ավելացնել պատկերակները հիմնական էկրանին" "Նոր հավելվածների համար" "Անհայտ է" - "Ապատեղադրել" + "Հեռացնել" "Գտնել" "Այս ծրագիրը տեղադրված չէ:" "Այս պատկերակի ծրագիրը տեղադրված չէ: Դուք կարող եք հեռացնել այն կամ գտնել ծրագիրը և տեղադրել այն ձեռքով:" diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index a6e37c4fb4..4e0181c58d 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -53,7 +53,7 @@ "アプリ情報" "インストール" "アプリの候補を表示しない" - "アプリの候補を固定表示" + "アプリの候補を固定" "ショートカットのインストール" "ユーザー操作なしでショートカットを追加することをアプリに許可します。" "ホームの設定とショートカットの読み取り" diff --git a/res/values-kn/strings.xml b/res/values-kn/strings.xml index 1990e9e64e..09c115211c 100644 --- a/res/values-kn/strings.xml +++ b/res/values-kn/strings.xml @@ -98,7 +98,7 @@ "ಹೊಸ ಅಪ್ಲಿಕೇಶನ್‌ಗಳಿಗೆ" "ಅಪರಿಚಿತ" "ತೆಗೆದುಹಾಕಿ" - "ಹುಡುಕಿ" + "Search" "ಈ ಅಪ್ಲಿಕೇಶನ್ ಸ್ಥಾಪನೆಗೊಂಡಿಲ್ಲ" "ಈ ಐಕಾನ್ ಅಪ್ಲಿಕೇಶನ್ ಸ್ಥಾಪನೆಗೊಂಡಿಲ್ಲ. ನೀವು ಅದನ್ನು ತೆಗೆದುಹಾಕಬಹುದು ಅಥವಾ ಅಪ್ಲಿಕೇಶನ್ ಹುಡುಕಬಹುದು ಮತ್ತು ಹಸ್ತಚಾಲಿತವಾಗಿ ಅದನ್ನು ಸ್ಥಾಪಿಸಬಹುದು." "%1$s ಡೌನ್‌ಲೋಡ್‌ ಮಾಡಲಾಗುತ್ತಿದೆ, %2$s ಪೂರ್ಣಗೊಂಡಿದೆ" diff --git a/res/values-ml/strings.xml b/res/values-ml/strings.xml index 01d8935672..8156318199 100644 --- a/res/values-ml/strings.xml +++ b/res/values-ml/strings.xml @@ -98,7 +98,7 @@ "പുതിയ ആപ്പുകൾക്ക്" "അജ്ഞാതം" "നീക്കംചെയ്യുക" - "തിരയുക" + "Search" "ഈ അപ്ലിക്കേഷൻ ഇൻസ്റ്റാളുചെയ്‌തിട്ടില്ല" "ഈ ഐക്കണുവേണ്ടി അപ്ലിക്കേഷൻ ഇൻസ്റ്റാളുചെയ്‌തിട്ടില്ല. നിങ്ങൾക്കത് നീക്കംചെയ്യാനാകും അല്ലെങ്കിൽ അപ്ലിക്കേഷനുവേണ്ടി തിരഞ്ഞുകൊണ്ട് അത് സ്വമേധയാ ഇൻസ്റ്റാളുചെയ്യുക." "%1$s ഡൗൺലോഡ് ചെയ്യുന്നു, %2$s പൂർത്തിയായി" diff --git a/res/values-mn/strings.xml b/res/values-mn/strings.xml index 027e78042a..1d680ab914 100644 --- a/res/values-mn/strings.xml +++ b/res/values-mn/strings.xml @@ -35,7 +35,7 @@ "Гараар байршуулахын тулд дараад хүлээнэ үү" "Автоматаар нэмэх" "Апп хайх" - "Аппыг ачааллаж байна..." + "Аппыг ачаалж байна..." "\"%1$s\"-д тохирох апп олдсонгүй" "Бусад апп-г хайх" "Апп" diff --git a/res/values-mr/strings.xml b/res/values-mr/strings.xml index 488f911e32..6f50f055e6 100644 --- a/res/values-mr/strings.xml +++ b/res/values-mr/strings.xml @@ -98,7 +98,7 @@ "नवीन ॲप्ससाठी" "अज्ञात" "काढा" - "शोधा" + "Search" "हा अ‍ॅप इंस्टॉल केलेला नाही" "या चिन्हासाठी अ‍ॅप इंस्टॉल केलेला नाही. तुम्ही ते काढू शकता किंवा अ‍ॅपचा शोध घेऊ शकता आणि त्यास व्यक्तिचलितपणे इंस्टॉल करू शकता." "%1$s डाउनलोड होत आहे , %2$s पूर्ण झाले" diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index 76f1ecb0e5..ded05b099e 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -100,7 +100,7 @@ "Verwijderen" "Zoeken" "Deze app is niet geïnstalleerd" - "De app voor dit pictogram is niet geïnstalleerd. Je kunt het pictogram verwijderen of de app zoeken en handmatig installeren." + "De app voor dit icoon is niet geïnstalleerd. Je kunt het icoon verwijderen of de app zoeken en handmatig installeren." "%1$s wordt gedownload, %2$s voltooid" "%1$s wacht op installatie" "%1$s-widgets" diff --git a/res/values-or/strings.xml b/res/values-or/strings.xml index c6e2ba1dfe..994b620203 100644 --- a/res/values-or/strings.xml +++ b/res/values-or/strings.xml @@ -98,7 +98,7 @@ "ନୂଆ ଆପ୍‌ ପାଇଁ" "ଅଜଣା" "ବାହାର କରନ୍ତୁ" - "ସର୍ଚ୍ଚ କରନ୍ତୁ" + "Search" "ଏହି ଆପ୍‌ ଇନଷ୍ଟଲ୍‌ ହୋଇନାହିଁ" "ଏହି ଆଇକନ୍‌ ପାଇଁ ଆପ୍‌ ଇନଷ୍ଟଲ୍‌ ହୋଇନାହିଁ। ଏହାକୁ ଆପଣ ଆପ୍‌ ପାଇଁ ବାହାର କରିପାରିବେ କିମ୍ୱା ସର୍ଚ୍ଚ କରି ପାରିବେ ଏବଂ ଏହାକୁ ମାନୁଆଲ୍‌ ଭାବରେ ଇନଷ୍ଟଲ୍‌ କରିପାରିବେ।" "%1$s ଡାଉନଲୋଡ୍‌ ହେଉଛି, %2$s ସମ୍ପୂର୍ଣ୍ଣ" diff --git a/res/values-te/strings.xml b/res/values-te/strings.xml index 9816896fd6..3f6f9a63ab 100644 --- a/res/values-te/strings.xml +++ b/res/values-te/strings.xml @@ -98,7 +98,7 @@ "కొత్త యాప్‌ల కోసం" "తెలియదు" "తీసివేయి" - "వెతుకు" + "సెర్చ్" "ఈ యాప్ ఇన్‌స్టాల్ చేయబడలేదు" "ఈ చిహ్నం యొక్క యాప్ ఇన్‌స్టాల్ చేయబడలేదు. మీరు దీన్ని తీసివేయవచ్చు లేదా ఆ యాప్ కోసం శోధించి దాన్ని మాన్యువల్‌గా ఇన్‌స్టాల్ చేయవచ్చు." "%1$s డౌన్‌లోడ్ అవుతోంది, %2$s పూర్తయింది" From c4a8e0548415e79c9e68bef1149ed54a3deaaed6 Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Sat, 5 Sep 2020 18:49:41 +0000 Subject: [PATCH 15/31] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: If5df1f7ce4c804632081cbc9d0e3050a87b2aeef --- res/values-af/strings.xml | 2 +- res/values-as/strings.xml | 2 +- res/values-hi/strings.xml | 2 +- res/values-hy/strings.xml | 6 +++--- res/values-ja/strings.xml | 2 +- res/values-kn/strings.xml | 2 +- res/values-ml/strings.xml | 2 +- res/values-mn/strings.xml | 2 +- res/values-mr/strings.xml | 2 +- res/values-nl/strings.xml | 2 +- res/values-or/strings.xml | 2 +- res/values-te/strings.xml | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml index f19d121e7f..c39a9dc9ab 100644 --- a/res/values-af/strings.xml +++ b/res/values-af/strings.xml @@ -53,7 +53,7 @@ "Programinligting" "Installeer" "Moenie program voorstel nie" - "PIN-voorspelling" + "Vasspeldvoorspelling" "installeer kortpaaie" "Laat \'n program toe om kortpaaie by te voeg sonder gebruikerinmenging." "lees Tuis-instellings en -kortpaaie" diff --git a/res/values-as/strings.xml b/res/values-as/strings.xml index a6967b758b..8e9aafc651 100644 --- a/res/values-as/strings.xml +++ b/res/values-as/strings.xml @@ -98,7 +98,7 @@ "নতুন এপসমূহৰ বাবে" "অজ্ঞাত" "আঁতৰাওক" - "সন্ধান কৰক" + "Search" "এই এপটো ইনষ্টল কৰা হোৱা নাই" "এই আইকনৰ এপটো ইনষ্টল কৰা হোৱা নাই। আপুনি এইটো আঁতৰাব পাৰে অথবা এপটো বিচাৰি মেনুৱেলভাৱে ইনষ্টল কৰিব পাৰে।" "%1$s ডাউনল’ড কৰি থকা হৈছে, %2$s সম্পূৰ্ণ হ’ল" diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml index af3dcdb8b2..0cec9a324f 100644 --- a/res/values-hi/strings.xml +++ b/res/values-hi/strings.xml @@ -98,7 +98,7 @@ "नए ऐप्लिकेशन के लिए" "अज्ञात" "निकालें" - "सर्च करें" + "खोजें" "यह ऐप्लिकेशन इंस्टॉल नहीं है" "इस आइकॉन का ऐप इंस्टॉल नहीं है. आप उसे निकाल सकते हैं या ऐप को खोज कर उसे मैन्युअल रूप से इंस्टॉल कर सकते हैं." "%1$s डाउनलोड हो रहा है, %2$s पूरी हुई" diff --git a/res/values-hy/strings.xml b/res/values-hy/strings.xml index 99b582b0b2..c098bb3f4b 100644 --- a/res/values-hy/strings.xml +++ b/res/values-hy/strings.xml @@ -48,8 +48,8 @@ "Անձնական հավելվածների ցանկ" "Աշխատանքային հավելվածների ցանկ" "Հիմնական" - "Ապատեղադրել" - "Հեռացնել" + "Հեռացնել" + "Ապատեղադրել" "Հավելվածի մասին" "Տեղադրել" "Թաքցնել առաջարկը" @@ -97,7 +97,7 @@ "Ավելացնել պատկերակները հիմնական էկրանին" "Նոր հավելվածների համար" "Անհայտ է" - "Ապատեղադրել" + "Հեռացնել" "Գտնել" "Այս ծրագիրը տեղադրված չէ:" "Այս պատկերակի ծրագիրը տեղադրված չէ: Դուք կարող եք հեռացնել այն կամ գտնել ծրագիրը և տեղադրել այն ձեռքով:" diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index a6e37c4fb4..4e0181c58d 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -53,7 +53,7 @@ "アプリ情報" "インストール" "アプリの候補を表示しない" - "アプリの候補を固定表示" + "アプリの候補を固定" "ショートカットのインストール" "ユーザー操作なしでショートカットを追加することをアプリに許可します。" "ホームの設定とショートカットの読み取り" diff --git a/res/values-kn/strings.xml b/res/values-kn/strings.xml index 1990e9e64e..09c115211c 100644 --- a/res/values-kn/strings.xml +++ b/res/values-kn/strings.xml @@ -98,7 +98,7 @@ "ಹೊಸ ಅಪ್ಲಿಕೇಶನ್‌ಗಳಿಗೆ" "ಅಪರಿಚಿತ" "ತೆಗೆದುಹಾಕಿ" - "ಹುಡುಕಿ" + "Search" "ಈ ಅಪ್ಲಿಕೇಶನ್ ಸ್ಥಾಪನೆಗೊಂಡಿಲ್ಲ" "ಈ ಐಕಾನ್ ಅಪ್ಲಿಕೇಶನ್ ಸ್ಥಾಪನೆಗೊಂಡಿಲ್ಲ. ನೀವು ಅದನ್ನು ತೆಗೆದುಹಾಕಬಹುದು ಅಥವಾ ಅಪ್ಲಿಕೇಶನ್ ಹುಡುಕಬಹುದು ಮತ್ತು ಹಸ್ತಚಾಲಿತವಾಗಿ ಅದನ್ನು ಸ್ಥಾಪಿಸಬಹುದು." "%1$s ಡೌನ್‌ಲೋಡ್‌ ಮಾಡಲಾಗುತ್ತಿದೆ, %2$s ಪೂರ್ಣಗೊಂಡಿದೆ" diff --git a/res/values-ml/strings.xml b/res/values-ml/strings.xml index 01d8935672..8156318199 100644 --- a/res/values-ml/strings.xml +++ b/res/values-ml/strings.xml @@ -98,7 +98,7 @@ "പുതിയ ആപ്പുകൾക്ക്" "അജ്ഞാതം" "നീക്കംചെയ്യുക" - "തിരയുക" + "Search" "ഈ അപ്ലിക്കേഷൻ ഇൻസ്റ്റാളുചെയ്‌തിട്ടില്ല" "ഈ ഐക്കണുവേണ്ടി അപ്ലിക്കേഷൻ ഇൻസ്റ്റാളുചെയ്‌തിട്ടില്ല. നിങ്ങൾക്കത് നീക്കംചെയ്യാനാകും അല്ലെങ്കിൽ അപ്ലിക്കേഷനുവേണ്ടി തിരഞ്ഞുകൊണ്ട് അത് സ്വമേധയാ ഇൻസ്റ്റാളുചെയ്യുക." "%1$s ഡൗൺലോഡ് ചെയ്യുന്നു, %2$s പൂർത്തിയായി" diff --git a/res/values-mn/strings.xml b/res/values-mn/strings.xml index 027e78042a..1d680ab914 100644 --- a/res/values-mn/strings.xml +++ b/res/values-mn/strings.xml @@ -35,7 +35,7 @@ "Гараар байршуулахын тулд дараад хүлээнэ үү" "Автоматаар нэмэх" "Апп хайх" - "Аппыг ачааллаж байна..." + "Аппыг ачаалж байна..." "\"%1$s\"-д тохирох апп олдсонгүй" "Бусад апп-г хайх" "Апп" diff --git a/res/values-mr/strings.xml b/res/values-mr/strings.xml index 488f911e32..6f50f055e6 100644 --- a/res/values-mr/strings.xml +++ b/res/values-mr/strings.xml @@ -98,7 +98,7 @@ "नवीन ॲप्ससाठी" "अज्ञात" "काढा" - "शोधा" + "Search" "हा अ‍ॅप इंस्टॉल केलेला नाही" "या चिन्हासाठी अ‍ॅप इंस्टॉल केलेला नाही. तुम्ही ते काढू शकता किंवा अ‍ॅपचा शोध घेऊ शकता आणि त्यास व्यक्तिचलितपणे इंस्टॉल करू शकता." "%1$s डाउनलोड होत आहे , %2$s पूर्ण झाले" diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index 76f1ecb0e5..ded05b099e 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -100,7 +100,7 @@ "Verwijderen" "Zoeken" "Deze app is niet geïnstalleerd" - "De app voor dit pictogram is niet geïnstalleerd. Je kunt het pictogram verwijderen of de app zoeken en handmatig installeren." + "De app voor dit icoon is niet geïnstalleerd. Je kunt het icoon verwijderen of de app zoeken en handmatig installeren." "%1$s wordt gedownload, %2$s voltooid" "%1$s wacht op installatie" "%1$s-widgets" diff --git a/res/values-or/strings.xml b/res/values-or/strings.xml index c6e2ba1dfe..994b620203 100644 --- a/res/values-or/strings.xml +++ b/res/values-or/strings.xml @@ -98,7 +98,7 @@ "ନୂଆ ଆପ୍‌ ପାଇଁ" "ଅଜଣା" "ବାହାର କରନ୍ତୁ" - "ସର୍ଚ୍ଚ କରନ୍ତୁ" + "Search" "ଏହି ଆପ୍‌ ଇନଷ୍ଟଲ୍‌ ହୋଇନାହିଁ" "ଏହି ଆଇକନ୍‌ ପାଇଁ ଆପ୍‌ ଇନଷ୍ଟଲ୍‌ ହୋଇନାହିଁ। ଏହାକୁ ଆପଣ ଆପ୍‌ ପାଇଁ ବାହାର କରିପାରିବେ କିମ୍ୱା ସର୍ଚ୍ଚ କରି ପାରିବେ ଏବଂ ଏହାକୁ ମାନୁଆଲ୍‌ ଭାବରେ ଇନଷ୍ଟଲ୍‌ କରିପାରିବେ।" "%1$s ଡାଉନଲୋଡ୍‌ ହେଉଛି, %2$s ସମ୍ପୂର୍ଣ୍ଣ" diff --git a/res/values-te/strings.xml b/res/values-te/strings.xml index 9816896fd6..3f6f9a63ab 100644 --- a/res/values-te/strings.xml +++ b/res/values-te/strings.xml @@ -98,7 +98,7 @@ "కొత్త యాప్‌ల కోసం" "తెలియదు" "తీసివేయి" - "వెతుకు" + "సెర్చ్" "ఈ యాప్ ఇన్‌స్టాల్ చేయబడలేదు" "ఈ చిహ్నం యొక్క యాప్ ఇన్‌స్టాల్ చేయబడలేదు. మీరు దీన్ని తీసివేయవచ్చు లేదా ఆ యాప్ కోసం శోధించి దాన్ని మాన్యువల్‌గా ఇన్‌స్టాల్ చేయవచ్చు." "%1$s డౌన్‌లోడ్ అవుతోంది, %2$s పూర్తయింది" From b0277191f386b0fb5eeaaff9cbcf1854676f1da3 Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Tue, 8 Sep 2020 00:51:00 -0700 Subject: [PATCH 16/31] Improve AA+ Search UI, fix IME double close Bug: 167573256 Change-Id: If0d76177a8589bee3283d8c06529cedc8aab6c31 --- res/values/strings.xml | 2 ++ .../launcher3/allapps/AllAppsTransitionController.java | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index ad3e2b79f4..6ab81501f4 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -58,6 +58,8 @@ Search apps + + Search this phone and more... Loading apps… diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 0268b9638f..4195a056fe 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -270,11 +270,7 @@ public class AllAppsTransitionController implements StateHandler, editText.requestFocus(); } } - if (Float.compare(mProgress, 1f) == 0) { - // Called when home gesture closes all apps container. - // TODO: should make the controller hide synchronously - mInsetController.hide(); - } + // TODO: should make the controller hide synchronously } } } From 7aa577d8836c624abd876ff3914b14c232cca860 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Thu, 3 Sep 2020 09:42:54 -0700 Subject: [PATCH 17/31] Show independent shortcuts from Hero view Test: Manual Screenshot: https://screenshot.googleplex.com/6iQGEZADXf9PtWz Bug: 165320033 Change-Id: Ib8db1fc34da4adc39f3bec5557223a1e283380dd --- res/layout/search_result_shortcut.xml | 42 ++++++++ .../launcher3/allapps/AllAppsGridAdapter.java | 9 +- .../launcher3/views/SearchResultShortcut.java | 98 +++++++++++++++++++ .../systemui/plugins/shared/SearchTarget.java | 8 +- 4 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 res/layout/search_result_shortcut.xml create mode 100644 src/com/android/launcher3/views/SearchResultShortcut.java diff --git a/res/layout/search_result_shortcut.xml b/res/layout/search_result_shortcut.xml new file mode 100644 index 0000000000..c350c973da --- /dev/null +++ b/res/layout/search_result_shortcut.xml @@ -0,0 +1,42 @@ + + + + + + + + \ No newline at end of file diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java index da161ac1cc..ad6aa63371 100644 --- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java +++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java @@ -89,6 +89,8 @@ public class AllAppsGridAdapter extends public static final int VIEW_TYPE_SEARCH_SLICE = 1 << 9; + public static final int VIEW_TYPE_SEARCH_SHORTCUT = 1 << 10; + // Common view type masks public static final int VIEW_TYPE_MASK_DIVIDER = VIEW_TYPE_ALL_APPS_DIVIDER; public static final int VIEW_TYPE_MASK_ICON = VIEW_TYPE_ICON; @@ -179,7 +181,8 @@ public class AllAppsGridAdapter extends || viewType == VIEW_TYPE_SEARCH_HERO_APP || viewType == VIEW_TYPE_SEARCH_ROW_WITH_BUTTON || viewType == VIEW_TYPE_SEARCH_SLICE - || viewType == VIEW_TYPE_SEARCH_ROW; + || viewType == VIEW_TYPE_SEARCH_ROW + || viewType == VIEW_TYPE_SEARCH_SHORTCUT; } } @@ -426,6 +429,9 @@ public class AllAppsGridAdapter extends case VIEW_TYPE_SEARCH_SLICE: return new ViewHolder(mLayoutInflater.inflate( R.layout.search_result_slice, parent, false)); + case VIEW_TYPE_SEARCH_SHORTCUT: + return new ViewHolder(mLayoutInflater.inflate( + R.layout.search_result_shortcut, parent, false)); default: throw new RuntimeException("Unexpected view type"); } @@ -468,6 +474,7 @@ public class AllAppsGridAdapter extends case VIEW_TYPE_SEARCH_ROW_WITH_BUTTON: case VIEW_TYPE_SEARCH_HERO_APP: case VIEW_TYPE_SEARCH_ROW: + case VIEW_TYPE_SEARCH_SHORTCUT: PayloadResultHandler payloadResultView = (PayloadResultHandler) holder.itemView; payloadResultView.applyAdapterInfo( (AdapterItemWithPayload) mApps.getAdapterItems().get(position)); diff --git a/src/com/android/launcher3/views/SearchResultShortcut.java b/src/com/android/launcher3/views/SearchResultShortcut.java new file mode 100644 index 0000000000..a402719e76 --- /dev/null +++ b/src/com/android/launcher3/views/SearchResultShortcut.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2020 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.launcher3.views; + +import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; + +import android.content.Context; +import android.content.pm.ShortcutInfo; +import android.util.AttributeSet; +import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.android.launcher3.BubbleTextView; +import com.android.launcher3.DeviceProfile; +import com.android.launcher3.Launcher; +import com.android.launcher3.LauncherAppState; +import com.android.launcher3.R; +import com.android.launcher3.allapps.AllAppsGridAdapter; +import com.android.launcher3.allapps.search.AllAppsSearchBarController; +import com.android.launcher3.model.data.WorkspaceItemInfo; +import com.android.launcher3.touch.ItemClickHandler; +import com.android.systemui.plugins.shared.SearchTarget; + +/** + * A view representing a stand alone shortcut search result + */ +public class SearchResultShortcut extends FrameLayout implements + AllAppsSearchBarController.PayloadResultHandler { + + BubbleTextView mBubbleTextView; + View mIconView; + + public SearchResultShortcut(@NonNull Context context) { + super(context); + } + + public SearchResultShortcut(@NonNull Context context, + @Nullable AttributeSet attrs) { + super(context, attrs); + } + + public SearchResultShortcut(@NonNull Context context, @Nullable AttributeSet attrs, + int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + Launcher launcher = Launcher.getLauncher(getContext()); + DeviceProfile grid = launcher.getDeviceProfile(); + mIconView = findViewById(R.id.icon); + ViewGroup.LayoutParams iconParams = mIconView.getLayoutParams(); + iconParams.height = grid.allAppsIconSizePx; + iconParams.width = grid.allAppsIconSizePx; + mBubbleTextView = findViewById(R.id.bubble_text); + setOnClickListener(v -> handleSelection()); + } + + @Override + public void applyAdapterInfo( + AllAppsGridAdapter.AdapterItemWithPayload adapterItemWithPayload) { + SearchTarget payload = adapterItemWithPayload.getPayload(); + ShortcutInfo si = payload.shortcuts.get(0); + WorkspaceItemInfo workspaceItemInfo = new WorkspaceItemInfo(si, getContext()); + mBubbleTextView.applyFromWorkspaceItem(workspaceItemInfo); + mIconView.setBackground(mBubbleTextView.getIcon()); + LauncherAppState launcherAppState = LauncherAppState.getInstance(getContext()); + MODEL_EXECUTOR.execute(() -> { + launcherAppState.getIconCache().getShortcutIcon(workspaceItemInfo, si); + mBubbleTextView.applyFromWorkspaceItem(workspaceItemInfo); + mIconView.setBackground(mBubbleTextView.getIcon()); + }); + adapterItemWithPayload.setSelectionHandler(this::handleSelection); + } + + private void handleSelection() { + ItemClickHandler.onClickAppShortcut(this, (WorkspaceItemInfo) mBubbleTextView.getTag(), + Launcher.getLauncher(getContext())); + } +} diff --git a/src_plugins/com/android/systemui/plugins/shared/SearchTarget.java b/src_plugins/com/android/systemui/plugins/shared/SearchTarget.java index 913fc0ed7c..c6b8300499 100644 --- a/src_plugins/com/android/systemui/plugins/shared/SearchTarget.java +++ b/src_plugins/com/android/systemui/plugins/shared/SearchTarget.java @@ -31,7 +31,9 @@ public class SearchTarget implements Comparable { DETAIL(2), ROW(3), ROW_WITH_BUTTON(4), - SLICE(5); + SLICE(5), + SHORTCUT(6), + PEOPLE(7); private final int mId; ViewType(int id) { @@ -48,7 +50,9 @@ public class SearchTarget implements Comparable { SETTINGS_ROW(1, "Settings", ViewType.ROW), SETTINGS_SLICE(2, "Settings", ViewType.SLICE), APP(3, "", ViewType.TOP_HIT), - APP_HERO(4, "", ViewType.HERO); + APP_HERO(4, "", ViewType.HERO), + SHORTCUT(5, "Shortcuts", ViewType.SHORTCUT), + PEOPLE(6, "People", ViewType.PEOPLE); private final int mId; private final String mTitle; From 70dc1066b6939ef7b106a0c587bd78ba341168ed Mon Sep 17 00:00:00 2001 From: vadimt Date: Thu, 3 Sep 2020 13:34:17 -0700 Subject: [PATCH 18/31] Annotating open-Launcher transition in trace files Currently, in trace files, it's hard to find the exact set of frames for this transition. Change-Id: I17ac201f9f9bc357ba42003776ec7a20ddef033d --- .../QuickstepAppTransitionManagerImpl.java | 17 +++++++++++++++++ .../android/quickstep/AbsSwipeUpHandler.java | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java index f3d543405d..e2449a4d8a 100644 --- a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java +++ b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java @@ -57,6 +57,7 @@ import android.graphics.drawable.Drawable; import android.os.CancellationSignal; import android.os.Handler; import android.os.Looper; +import android.os.Trace; import android.util.Pair; import android.view.View; @@ -137,6 +138,7 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans // 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; + public static final String TRANSITION_OPEN_LAUNCHER = "transition:OpenLauncher"; protected final BaseQuickstepLauncher mLauncher; @@ -853,6 +855,21 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans // is initialized. if (launcherIsATargetWithMode(appTargets, MODE_OPENING) || mLauncher.isForceInvisible()) { + if (Trace.isEnabled()) { + anim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animation) { + Trace.beginAsyncSection(TRANSITION_OPEN_LAUNCHER, 0); + super.onAnimationStart(animation); + } + + @Override + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); + Trace.endAsyncSection(TRANSITION_OPEN_LAUNCHER, 0); + } + }); + } // Only register the content animation for cancellation when state changes mLauncher.getStateManager().setCurrentAnimation(anim); diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index aaa2720047..2d18b6f1e4 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -19,6 +19,7 @@ import static android.widget.Toast.LENGTH_SHORT; import static com.android.launcher3.BaseActivity.INVISIBLE_BY_STATE_HANDLER; import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS; +import static com.android.launcher3.QuickstepAppTransitionManagerImpl.TRANSITION_OPEN_LAUNCHER; import static com.android.launcher3.anim.Interpolators.DEACCEL; import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2; import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; @@ -53,6 +54,7 @@ import android.graphics.PointF; import android.graphics.Rect; import android.os.Build; import android.os.SystemClock; +import android.os.Trace; import android.util.Log; import android.view.MotionEvent; import android.view.View; @@ -1135,6 +1137,7 @@ public abstract class AbsSwipeUpHandler, Q extends anim.addAnimatorListener(new AnimationSuccessListener() { @Override public void onAnimationStart(Animator animation) { + Trace.beginAsyncSection(TRANSITION_OPEN_LAUNCHER, 0); if (mActivity != null) { removeLiveTileOverlay(); } @@ -1149,6 +1152,12 @@ public abstract class AbsSwipeUpHandler, Q extends maybeUpdateRecentsAttachedState(false); mActivityInterface.onSwipeUpToHomeComplete(mDeviceState); } + + @Override + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); + Trace.endAsyncSection(TRANSITION_OPEN_LAUNCHER, 0); + } }); if (mRecentsAnimationTargets != null) { mRecentsAnimationTargets.addReleaseCheck(anim); From 4484015f482772e2a493cc1dda525c929398b4f2 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Tue, 25 Aug 2020 23:22:18 -0700 Subject: [PATCH 19/31] Simplifying AppFilter Change-Id: I36217a42aa67f2b3bc3a3226ace2ef7e194956a6 --- res/values/config.xml | 3 ++- src/com/android/launcher3/AppFilter.java | 20 ++++++++++++++----- .../android/launcher3/LauncherAppState.java | 2 +- .../android/launcher3/model/WidgetsModel.java | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/res/values/config.xml b/res/values/config.xml index fc0a5e10dc..325b62f9dc 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -59,7 +59,6 @@ true - @@ -187,4 +186,6 @@ + + diff --git a/src/com/android/launcher3/AppFilter.java b/src/com/android/launcher3/AppFilter.java index 9b6166ffcf..3db456cbdb 100644 --- a/src/com/android/launcher3/AppFilter.java +++ b/src/com/android/launcher3/AppFilter.java @@ -3,15 +3,25 @@ package com.android.launcher3; import android.content.ComponentName; import android.content.Context; -import com.android.launcher3.util.ResourceBasedOverride; +import java.util.Arrays; +import java.util.Set; +import java.util.stream.Collectors; -public class AppFilter implements ResourceBasedOverride { +/** + * Utility class to filter out components from various lists + */ +public class AppFilter { - public static AppFilter newInstance(Context context) { - return Overrides.getObject(AppFilter.class, context, R.string.app_filter_class); + private final Set mFilteredComponents; + + public AppFilter(Context context) { + mFilteredComponents = Arrays.stream( + context.getResources().getStringArray(R.array.filtered_components)) + .map(ComponentName::unflattenFromString) + .collect(Collectors.toSet()); } public boolean shouldShowApp(ComponentName app) { - return true; + return !mFilteredComponents.contains(app); } } diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java index b278e81655..bfe327e40d 100644 --- a/src/com/android/launcher3/LauncherAppState.java +++ b/src/com/android/launcher3/LauncherAppState.java @@ -122,7 +122,7 @@ public class LauncherAppState { mInvariantDeviceProfile = InvariantDeviceProfile.INSTANCE.get(context); mIconCache = new IconCache(mContext, mInvariantDeviceProfile, iconCacheFileName); mWidgetCache = new WidgetPreviewLoader(mContext, mIconCache); - mModel = new LauncherModel(context, this, mIconCache, AppFilter.newInstance(mContext)); + mModel = new LauncherModel(context, this, mIconCache, new AppFilter(mContext)); } protected void onNotificationSettingsChanged(boolean areNotificationDotsEnabled) { diff --git a/src_shortcuts_overrides/com/android/launcher3/model/WidgetsModel.java b/src_shortcuts_overrides/com/android/launcher3/model/WidgetsModel.java index 34ebbac59a..b4e45f835a 100644 --- a/src_shortcuts_overrides/com/android/launcher3/model/WidgetsModel.java +++ b/src_shortcuts_overrides/com/android/launcher3/model/WidgetsModel.java @@ -234,7 +234,7 @@ public class WidgetsModel { WidgetValidityCheck(LauncherAppState app) { mIdp = app.getInvariantDeviceProfile(); - mAppFilter = AppFilter.newInstance(app.getContext()); + mAppFilter = new AppFilter(app.getContext()); } @Override From f367ced932e802b411d36d9c702bd02db54e8dec Mon Sep 17 00:00:00 2001 From: vadimt Date: Tue, 8 Sep 2020 15:36:07 -0700 Subject: [PATCH 20/31] Annotating open-app transitions in trace files Change-Id: I2461186321b7c33dbabca34c066b61f2169010f3 --- .../QuickstepAppTransitionManagerImpl.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java index e2449a4d8a..dddcc865fa 100644 --- a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java +++ b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java @@ -904,6 +904,9 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans */ private class AppLaunchAnimationRunner implements WrappedAnimationRunnerImpl { + private static final String TRANSITION_LAUNCH_FROM_RECENTS = "transition:LaunchFromRecents"; + private static final String TRANSITION_LAUNCH_FROM_ICON = "transition:LaunchFromIcon"; + private final Handler mHandler; private final View mV; @@ -926,7 +929,8 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans boolean launcherClosing = launcherIsATargetWithMode(appTargets, MODE_CLOSING); - if (isLaunchingFromRecents(mV, appTargets)) { + final boolean launchingFromRecents = isLaunchingFromRecents(mV, appTargets); + if (launchingFromRecents) { composeRecentsLaunchAnimator(anim, mV, appTargets, wallpaperTargets, launcherClosing); } else { @@ -934,6 +938,26 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans launcherClosing); } + if (Trace.isEnabled()) { + final String section = + launchingFromRecents + ? TRANSITION_LAUNCH_FROM_RECENTS : TRANSITION_LAUNCH_FROM_ICON; + + anim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animation) { + Trace.beginAsyncSection(section, 0); + super.onAnimationStart(animation); + } + + @Override + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); + Trace.endAsyncSection(section, 0); + } + }); + } + if (launcherClosing) { anim.addListener(mForceInvisibleListener); } From 35f9150a677b6c29bcf8a3befd47b50ea5665b71 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Tue, 8 Sep 2020 14:00:56 -0700 Subject: [PATCH 21/31] Support People search result in launcher NOTE: this uses PackageManager and should be removed after people<>shortcut mapping in search provider. Bug: 166337069 Test: Manual Change-Id: I016ff0d5e6ada1599cce3d75bdcd55347c85193e --- res/layout/search_result_people_item.xml | 62 +++++++ .../launcher3/allapps/AllAppsGridAdapter.java | 7 + .../views/SearchResultPeopleView.java | 156 ++++++++++++++++++ 3 files changed, 225 insertions(+) create mode 100644 res/layout/search_result_people_item.xml create mode 100644 src/com/android/launcher3/views/SearchResultPeopleView.java diff --git a/res/layout/search_result_people_item.xml b/res/layout/search_result_people_item.xml new file mode 100644 index 0000000000..a505e4a968 --- /dev/null +++ b/res/layout/search_result_people_item.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java index ad6aa63371..4e801a7cc8 100644 --- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java +++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java @@ -91,6 +91,8 @@ public class AllAppsGridAdapter extends public static final int VIEW_TYPE_SEARCH_SHORTCUT = 1 << 10; + public static final int VIEW_TYPE_SEARCH_PEOPLE = 1 << 11; + // Common view type masks public static final int VIEW_TYPE_MASK_DIVIDER = VIEW_TYPE_ALL_APPS_DIVIDER; public static final int VIEW_TYPE_MASK_ICON = VIEW_TYPE_ICON; @@ -182,6 +184,7 @@ public class AllAppsGridAdapter extends || viewType == VIEW_TYPE_SEARCH_ROW_WITH_BUTTON || viewType == VIEW_TYPE_SEARCH_SLICE || viewType == VIEW_TYPE_SEARCH_ROW + || viewType == VIEW_TYPE_SEARCH_PEOPLE || viewType == VIEW_TYPE_SEARCH_SHORTCUT; } } @@ -432,6 +435,9 @@ public class AllAppsGridAdapter extends case VIEW_TYPE_SEARCH_SHORTCUT: return new ViewHolder(mLayoutInflater.inflate( R.layout.search_result_shortcut, parent, false)); + case VIEW_TYPE_SEARCH_PEOPLE: + return new ViewHolder(mLayoutInflater.inflate( + R.layout.search_result_people_item, parent, false)); default: throw new RuntimeException("Unexpected view type"); } @@ -475,6 +481,7 @@ public class AllAppsGridAdapter extends case VIEW_TYPE_SEARCH_HERO_APP: case VIEW_TYPE_SEARCH_ROW: case VIEW_TYPE_SEARCH_SHORTCUT: + case VIEW_TYPE_SEARCH_PEOPLE: PayloadResultHandler payloadResultView = (PayloadResultHandler) holder.itemView; payloadResultView.applyAdapterInfo( (AdapterItemWithPayload) mApps.getAdapterItems().get(position)); diff --git a/src/com/android/launcher3/views/SearchResultPeopleView.java b/src/com/android/launcher3/views/SearchResultPeopleView.java new file mode 100644 index 0000000000..d1e34fa65f --- /dev/null +++ b/src/com/android/launcher3/views/SearchResultPeopleView.java @@ -0,0 +1,156 @@ +/* + * Copyright (C) 2020 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.launcher3.views; + +import static android.content.Intent.URI_ALLOW_UNSAFE; +import static android.content.Intent.URI_ANDROID_APP_SCHEME; + +import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; + +import android.content.Context; +import android.content.Intent; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.graphics.Bitmap; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; +import android.net.Uri; +import android.os.Bundle; +import android.util.AttributeSet; +import android.view.View; +import android.widget.ImageButton; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.Nullable; +import androidx.core.graphics.drawable.RoundedBitmapDrawable; +import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory; + +import com.android.launcher3.DeviceProfile; +import com.android.launcher3.Launcher; +import com.android.launcher3.R; +import com.android.launcher3.allapps.AllAppsGridAdapter; +import com.android.launcher3.allapps.search.AllAppsSearchBarController; +import com.android.launcher3.util.Themes; + +import java.net.URISyntaxException; +import java.util.ArrayList; + +/** + * A view representing a single people search result in all apps + */ +public class SearchResultPeopleView extends LinearLayout implements + AllAppsSearchBarController.PayloadResultHandler { + + private final int mIconSize; + private final int mButtonSize; + private final PackageManager mPackageManager; + View mIconView; + TextView mTitleView; + ImageButton[] mProviderButtons = new ImageButton[3]; + + public SearchResultPeopleView(Context context) { + this(context, null, 0); + } + + public SearchResultPeopleView(Context context, + @Nullable AttributeSet attrs) { + this(context, attrs, 0); + } + + public SearchResultPeopleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + DeviceProfile deviceProfile = Launcher.getLauncher(getContext()).getDeviceProfile(); + mPackageManager = getContext().getPackageManager(); + mIconSize = deviceProfile.iconSizePx; + mButtonSize = (int) (deviceProfile.iconSizePx / 1.5f); + } + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + mIconView = findViewById(R.id.icon); + mIconView.getLayoutParams().height = mIconSize; + mIconView.getLayoutParams().width = mIconSize; + mTitleView = findViewById(R.id.title); + mProviderButtons[0] = findViewById(R.id.provider_0); + mProviderButtons[1] = findViewById(R.id.provider_1); + mProviderButtons[2] = findViewById(R.id.provider_2); + for (ImageButton button : mProviderButtons) { + button.getLayoutParams().width = mButtonSize; + button.getLayoutParams().height = mButtonSize; + } + setOnClickListener(v -> handleSelection()); + } + + @Override + public void applyAdapterInfo( + AllAppsGridAdapter.AdapterItemWithPayload adapterItemWithPayload) { + Launcher launcher = Launcher.getLauncher(getContext()); + Bundle payload = adapterItemWithPayload.getPayload(); + mTitleView.setText(payload.getString("title")); + mContactUri = payload.getParcelable("contact_uri"); + Bitmap icon = payload.getParcelable("icon"); + if (icon != null) { + RoundedBitmapDrawable d = RoundedBitmapDrawableFactory.create(getResources(), icon); + float radius = Themes.getDialogCornerRadius(getContext()); + d.setCornerRadius(radius); + d.setBounds(0, 0, mIconSize, mIconSize); + BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), + Bitmap.createScaledBitmap(icon, mIconSize, mIconSize, false)); + mIconView.setBackground(d); + } + + ArrayList providers = payload.getParcelableArrayList("providers"); + for (int i = 0; i < mProviderButtons.length; i++) { + ImageButton button = mProviderButtons[i]; + if (providers != null && i < providers.size()) { + try { + Bundle provider = providers.get(i); + Intent intent = Intent.parseUri(provider.getString("intent_uri_str"), + URI_ANDROID_APP_SCHEME | URI_ALLOW_UNSAFE); + String pkg = provider.getString("package_name"); + button.setOnClickListener(b -> launcher.startActivitySafely(b, intent, null)); + UI_HELPER_EXECUTOR.post(() -> { + try { + ApplicationInfo applicationInfo = mPackageManager.getApplicationInfo( + pkg, 0); + Drawable appIcon = applicationInfo.loadIcon(mPackageManager); + button.setImageDrawable(appIcon); + } catch (PackageManager.NameNotFoundException ignored) { + } + + }); + } catch (URISyntaxException ex) { + button.setVisibility(GONE); + } + } else { + button.setVisibility(GONE); + } + } + adapterItemWithPayload.setSelectionHandler(this::handleSelection); + } + + Uri mContactUri; + + private void handleSelection() { + if (mContactUri != null) { + Launcher launcher = Launcher.getLauncher(getContext()); + launcher.startActivitySafely(this, new Intent(Intent.ACTION_VIEW, mContactUri).setFlags( + Intent.FLAG_ACTIVITY_NEW_TASK), null); + } + } +} From 4318324ab4dfd583f97f5f93448cfd02df4fdeda Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 9 Sep 2020 17:12:49 -0700 Subject: [PATCH 22/31] Allow pause during quick switch for any horizontal displacement The shelf no longer exists in 0 button mode, so it's not necessary to wait for workspace to be invisible before allowing the pause. Change-Id: I202ed9991b18f5e7cb2e4f0aa6be7a0d66b8ffd7 --- .../NoButtonQuickSwitchTouchController.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java index 4b0642fab7..8285850c7e 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java @@ -271,11 +271,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController, mIsHomeScreenVisible = FADE_OUT_INTERPOLATOR.getInterpolation(xProgress) <= 1 - ALPHA_CUTOFF_THRESHOLD; - - // Only allow motion pause if the home screen is invisible, since some - // home screen elements will appear in the shelf on motion pause. - mMotionPauseDetector.setDisallowPause(mIsHomeScreenVisible - || -displacement.y < mMotionPauseMinDisplacement); + mMotionPauseDetector.setDisallowPause(-displacement.y < mMotionPauseMinDisplacement); mMotionPauseDetector.addPosition(ev); if (mXOverviewAnim != null) { From 248a7f89ac0b46157e145ae3df836fb8ad23138a Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Fri, 28 Aug 2020 14:53:31 -0700 Subject: [PATCH 23/31] Only set live target if there is a target to set Fixes: 166143722 Change-Id: I10c5bf384f6cee02cc55c035647911672f638e48 --- quickstep/src/com/android/quickstep/views/RecentsView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 6ae91b69b8..0362377399 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -2251,7 +2251,7 @@ public abstract class RecentsView extends PagedView public void setRecentsAnimationTargets(RecentsAnimationController recentsAnimationController, RecentsAnimationTargets recentsAnimationTargets) { mRecentsAnimationController = recentsAnimationController; - if (recentsAnimationTargets != null) { + if (recentsAnimationTargets != null && recentsAnimationTargets.apps.length > 0) { mLiveTileTaskViewSimulator.setPreview( recentsAnimationTargets.apps[recentsAnimationTargets.apps.length - 1]); mLiveTileParams.setTargetSet(recentsAnimationTargets); From 46aba2a46ef98f5c24ed495d766b4b2b8c4b7129 Mon Sep 17 00:00:00 2001 From: Sreyas Date: Wed, 9 Sep 2020 16:36:35 -0700 Subject: [PATCH 24/31] Adding content push button behind flag to OAV. Tested: TaplTestsNexus:testOverviewActions() Change-Id: I83bc6e5033e2292776c927fba363214f347e01ce --- .../res/layout/overview_actions_container.xml | 2 +- .../QuickstepTestInformationHandler.java | 6 ++++++ .../quickstep/views/OverviewActionsView.java | 2 +- .../launcher3/config/FeatureFlags.java | 3 +++ .../launcher3/testing/TestProtocol.java | 2 ++ .../tapl/LauncherInstrumentation.java | 5 +++++ .../launcher3/tapl/OverviewActions.java | 21 +++++++++++++++++++ 7 files changed, 39 insertions(+), 2 deletions(-) diff --git a/quickstep/res/layout/overview_actions_container.xml b/quickstep/res/layout/overview_actions_container.xml index 258f24a54e..d15a2d2ab6 100644 --- a/quickstep/res/layout/overview_actions_container.xml +++ b/quickstep/res/layout/overview_actions_container.xml @@ -56,7 +56,7 @@ android:visibility="gone" /> extends FrameLayo findViewById(R.id.action_screenshot).setOnClickListener(this); if (ENABLE_OVERVIEW_SHARE.get()) { share.setVisibility(VISIBLE); - findViewById(R.id.share_space).setVisibility(VISIBLE); + findViewById(R.id.oav_three_button_space).setVisibility(VISIBLE); } } diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index d8fca1da5e..2627149167 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -149,6 +149,9 @@ public final class FeatureFlags { public static final BooleanFlag ENABLE_OVERVIEW_SHARE = getDebugFlag( "ENABLE_OVERVIEW_SHARE", false, "Show Share button in Overview Actions"); + public static final BooleanFlag ENABLE_OVERVIEW_CONTENT_PUSH = getDebugFlag( + "ENABLE_OVERVIEW_CONTENT_PUSH", false, "Show Content Push button in Overview Actions"); + public static final BooleanFlag ENABLE_DATABASE_RESTORE = getDebugFlag( "ENABLE_DATABASE_RESTORE", true, "Enable database restore when new restore session is created"); diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java index 30f8fb02a0..b2d008119e 100644 --- a/src/com/android/launcher3/testing/TestProtocol.java +++ b/src/com/android/launcher3/testing/TestProtocol.java @@ -96,6 +96,8 @@ public final class TestProtocol { public static final String REQUEST_DISABLE_DEBUG_TRACING = "disable-debug-tracing"; public static final String REQUEST_OVERVIEW_SHARE_ENABLED = "overview-share-enabled"; + public static final String REQUEST_OVERVIEW_CONTENT_PUSH_ENABLED = + "overview-content-push-enabled"; public static boolean sDisableSensorRotation; public static final String REQUEST_MOCK_SENSOR_ROTATION = "mock-sensor-rotation"; diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 80adf05c2b..22833ec16d 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -1313,6 +1313,11 @@ public final class LauncherInstrumentation { TestProtocol.TEST_INFO_RESPONSE_FIELD); } + boolean overviewContentPushEnabled() { + return getTestInfo(TestProtocol.REQUEST_OVERVIEW_CONTENT_PUSH_ENABLED).getBoolean( + TestProtocol.TEST_INFO_RESPONSE_FIELD); + } + private void disableSensorRotation() { getTestInfo(TestProtocol.REQUEST_MOCK_SENSOR_ROTATION); } diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewActions.java b/tests/tapl/com/android/launcher3/tapl/OverviewActions.java index a30a404764..e3e0f4209d 100644 --- a/tests/tapl/com/android/launcher3/tapl/OverviewActions.java +++ b/tests/tapl/com/android/launcher3/tapl/OverviewActions.java @@ -33,6 +33,27 @@ public class OverviewActions { this.mLauncher = launcherInstrumentation; } + /** + * Clicks content push button. + */ + @NonNull + public Overview clickAndDismissContentPush() { + if (mLauncher.overviewContentPushEnabled()) { + try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck(); + LauncherInstrumentation.Closable c = mLauncher.addContextLayer( + "want to click content push button and exit screenshot ui")) { + UiObject2 exo = mLauncher.waitForObjectInContainer(mOverviewActions, + "action_content_push"); + mLauncher.clickLauncherObject(exo); + try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( + "clicked content push button")) { + return new Overview(mLauncher); + } + } + } + return new Overview(mLauncher); + } + /** * Clicks screenshot button and closes screenshot ui. */ From ef9596d4c19fed7d635c40d26bb0cb37e1003a46 Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Mon, 3 Aug 2020 12:07:50 -0700 Subject: [PATCH 25/31] Only load the first page in grid preview Bug: 160662425 Test: manual (verified correctness) Change-Id: I9dc3b7d7b84924ffb588470d4b6b20431a62b6cd --- .../graphics/LauncherPreviewRenderer.java | 5 +- .../android/launcher3/model/LoaderTask.java | 59 ++++++++++--------- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java index 0f1432a9b6..cd84c96171 100644 --- a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java +++ b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java @@ -599,7 +599,10 @@ public class LauncherPreviewRenderer extends ContextThemeWrapper @Override public WorkspaceResult call() { List allShortcuts = new ArrayList<>(); - loadWorkspace(allShortcuts, LauncherSettings.Favorites.PREVIEW_CONTENT_URI); + loadWorkspace(allShortcuts, LauncherSettings.Favorites.PREVIEW_CONTENT_URI, + LauncherSettings.Favorites.SCREEN + " = 0 or " + + LauncherSettings.Favorites.CONTAINER + " = " + + LauncherSettings.Favorites.CONTAINER_HOTSEAT); return new WorkspaceResult(mBgDataModel, null, mWidgetProvidersMap); } } diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java index a9e385fcc2..2b4520b613 100644 --- a/src/com/android/launcher3/model/LoaderTask.java +++ b/src/com/android/launcher3/model/LoaderTask.java @@ -127,6 +127,7 @@ public class LoaderTask implements Runnable { private boolean mStopped; + private final Set mPendingPackages = new HashSet<>(); private boolean mItemsDeleted = false; public LoaderTask(LauncherAppState app, AllAppsList bgAllAppsList, BgDataModel dataModel, @@ -294,16 +295,17 @@ public class LoaderTask implements Runnable { } private void loadWorkspace(List allDeepShortcuts) { - loadWorkspace(allDeepShortcuts, LauncherSettings.Favorites.CONTENT_URI); + loadWorkspace(allDeepShortcuts, LauncherSettings.Favorites.CONTENT_URI, + null /* selection */); } - protected void loadWorkspace(List allDeepShortcuts, Uri contentUri) { + protected void loadWorkspace(List allDeepShortcuts, Uri contentUri, + String selection) { final Context context = mApp.getContext(); final ContentResolver contentResolver = context.getContentResolver(); final PackageManagerHelper pmHelper = new PackageManagerHelper(context); final boolean isSafeMode = pmHelper.isSafeMode(); final boolean isSdCardReady = Utilities.isBootCompleted(); - final Set pendingPackages = new HashSet<>(); boolean clearDb = false; try { @@ -332,6 +334,7 @@ public class LoaderTask implements Runnable { synchronized (mBgDataModel) { mBgDataModel.clear(); + mPendingPackages.clear(); final HashMap installingPkgs = mSessionHelper.getActiveSessions(); @@ -342,8 +345,8 @@ public class LoaderTask implements Runnable { Map shortcutKeyToPinnedShortcuts = new HashMap<>(); final LoaderCursor c = new LoaderCursor( - contentResolver.query(contentUri, null, null, null, null), contentUri, mApp, - mUserManagerState); + contentResolver.query(contentUri, null, selection, null, null), contentUri, + mApp, mUserManagerState); try { final int appWidgetIdIndex = c.getColumnIndexOrThrow( @@ -484,7 +487,7 @@ public class LoaderTask implements Runnable { // SdCard is not ready yet. Package might get available, // once it is ready. Log.d(TAG, "Missing pkg, will check later: " + targetPkg); - pendingPackages.add(new PackageUserKey(targetPkg, c.user)); + mPendingPackages.add(new PackageUserKey(targetPkg, c.user)); // Add the icon on the workspace anyway. allowMissingTarget = true; } else { @@ -768,20 +771,7 @@ public class LoaderTask implements Runnable { } // Remove dead items - if (c.commitDeleted()) { - // Remove any empty folder - int[] deletedFolderIds = LauncherSettings.Settings - .call(contentResolver, - LauncherSettings.Settings.METHOD_DELETE_EMPTY_FOLDERS) - .getIntArray(LauncherSettings.Settings.EXTRA_VALUE); - for (int folderId : deletedFolderIds) { - mBgDataModel.workspaceItems.remove(mBgDataModel.folders.get(folderId)); - mBgDataModel.folders.remove(folderId); - mBgDataModel.itemsIdMap.remove(folderId); - } - - mItemsDeleted = true; - } + mItemsDeleted = c.commitDeleted(); // Sort the folder items, update ranks, and make sure all preview items are high res. FolderGridOrganizer verifier = @@ -807,13 +797,6 @@ public class LoaderTask implements Runnable { } c.commitRestoredItems(); - if (!isSdCardReady && !pendingPackages.isEmpty()) { - context.registerReceiver( - new SdCardAvailableReceiver(mApp, pendingPackages), - new IntentFilter(Intent.ACTION_BOOT_COMPLETED), - null, - MODEL_EXECUTOR.getHandler()); - } } } @@ -840,14 +823,34 @@ public class LoaderTask implements Runnable { private void sanitizeData() { Context context = mApp.getContext(); + ContentResolver contentResolver = context.getContentResolver(); if (mItemsDeleted) { + // Remove any empty folder + int[] deletedFolderIds = LauncherSettings.Settings + .call(contentResolver, + LauncherSettings.Settings.METHOD_DELETE_EMPTY_FOLDERS) + .getIntArray(LauncherSettings.Settings.EXTRA_VALUE); + for (int folderId : deletedFolderIds) { + mBgDataModel.workspaceItems.remove(mBgDataModel.folders.get(folderId)); + mBgDataModel.folders.remove(folderId); + mBgDataModel.itemsIdMap.remove(folderId); + } + // Remove any ghost widgets - LauncherSettings.Settings.call(context.getContentResolver(), + LauncherSettings.Settings.call(contentResolver, LauncherSettings.Settings.METHOD_REMOVE_GHOST_WIDGETS); } // Update pinned state of model shortcuts mBgDataModel.updateShortcutPinnedState(context); + + if (!Utilities.isBootCompleted() && !mPendingPackages.isEmpty()) { + context.registerReceiver( + new SdCardAvailableReceiver(mApp, mPendingPackages), + new IntentFilter(Intent.ACTION_BOOT_COMPLETED), + null, + MODEL_EXECUTOR.getHandler()); + } } private List loadAllApps() { From 312cf438633088c3657da6ac7e06937186dca9ea Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Mon, 3 Aug 2020 12:07:50 -0700 Subject: [PATCH 26/31] Only load the first page in grid preview Bug: 160662425 Test: manual (verified correctness) Merged-In: I9dc3b7d7b84924ffb588470d4b6b20431a62b6cd Change-Id: I9dc3b7d7b84924ffb588470d4b6b20431a62b6cd --- .../graphics/LauncherPreviewRenderer.java | 5 +- .../android/launcher3/model/LoaderTask.java | 62 ++++++++++--------- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java index a424f8458a..7b769b8299 100644 --- a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java +++ b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java @@ -595,7 +595,10 @@ public class LauncherPreviewRenderer { @Override public WorkspaceResult call() throws Exception { List allShortcuts = new ArrayList<>(); - loadWorkspace(allShortcuts, LauncherSettings.Favorites.PREVIEW_CONTENT_URI); + loadWorkspace(allShortcuts, LauncherSettings.Favorites.PREVIEW_CONTENT_URI, + LauncherSettings.Favorites.SCREEN + " = 0 or " + + LauncherSettings.Favorites.CONTAINER + " = " + + LauncherSettings.Favorites.CONTAINER_HOTSEAT); return new WorkspaceResult(mBgDataModel.workspaceItems, mBgDataModel.appWidgets, mBgDataModel.cachedPredictedItems, null, mWidgetProvidersMap); } diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java index 4a64522c65..d62f8d5dbb 100644 --- a/src/com/android/launcher3/model/LoaderTask.java +++ b/src/com/android/launcher3/model/LoaderTask.java @@ -293,10 +293,12 @@ public class LoaderTask implements Runnable { } private void loadWorkspace(List allDeepShortcuts) { - loadWorkspace(allDeepShortcuts, LauncherSettings.Favorites.CONTENT_URI); + loadWorkspace(allDeepShortcuts, LauncherSettings.Favorites.CONTENT_URI, + null /* selection */); } - protected void loadWorkspace(List allDeepShortcuts, Uri contentUri) { + protected void loadWorkspace(List allDeepShortcuts, Uri contentUri, + String selection) { final Context context = mApp.getContext(); final ContentResolver contentResolver = context.getContentResolver(); final PackageManagerHelper pmHelper = new PackageManagerHelper(context); @@ -341,8 +343,8 @@ public class LoaderTask implements Runnable { Map shortcutKeyToPinnedShortcuts = new HashMap<>(); final LoaderCursor c = new LoaderCursor( - contentResolver.query(contentUri, null, null, null, null), contentUri, mApp, - mUserManagerState); + contentResolver.query(contentUri, null, selection, null, null), contentUri, + mApp, mUserManagerState); try { final int appWidgetIdIndex = c.getColumnIndexOrThrow( @@ -776,33 +778,35 @@ public class LoaderTask implements Runnable { return; } - // Remove dead items - if (c.commitDeleted()) { - // Remove any empty folder - int[] deletedFolderIds = LauncherSettings.Settings - .call(contentResolver, - LauncherSettings.Settings.METHOD_DELETE_EMPTY_FOLDERS) - .getIntArray(LauncherSettings.Settings.EXTRA_VALUE); - for (int folderId : deletedFolderIds) { - mBgDataModel.workspaceItems.remove(mBgDataModel.folders.get(folderId)); - mBgDataModel.folders.remove(folderId); - mBgDataModel.itemsIdMap.remove(folderId); + if (contentUri == LauncherSettings.Favorites.CONTENT_URI) { + // Remove dead items + if (c.commitDeleted()) { + // Remove any empty folder + int[] deletedFolderIds = LauncherSettings.Settings + .call(contentResolver, + LauncherSettings.Settings.METHOD_DELETE_EMPTY_FOLDERS) + .getIntArray(LauncherSettings.Settings.EXTRA_VALUE); + for (int folderId : deletedFolderIds) { + mBgDataModel.workspaceItems.remove(mBgDataModel.folders.get(folderId)); + mBgDataModel.folders.remove(folderId); + mBgDataModel.itemsIdMap.remove(folderId); + } + + // Remove any ghost widgets + LauncherSettings.Settings.call(contentResolver, + LauncherSettings.Settings.METHOD_REMOVE_GHOST_WIDGETS); } - // Remove any ghost widgets - LauncherSettings.Settings.call(contentResolver, - LauncherSettings.Settings.METHOD_REMOVE_GHOST_WIDGETS); - } - - // Unpin shortcuts that don't exist on the workspace. - HashSet pendingShortcuts = - InstallShortcutReceiver.getPendingShortcuts(context); - for (ShortcutKey key : shortcutKeyToPinnedShortcuts.keySet()) { - MutableInt numTimesPinned = mBgDataModel.pinnedShortcutCounts.get(key); - if ((numTimesPinned == null || numTimesPinned.value == 0) - && !pendingShortcuts.contains(key)) { - // Shortcut is pinned but doesn't exist on the workspace; unpin it. - mBgDataModel.unpinShortcut(context, key); + // Unpin shortcuts that don't exist on the workspace. + HashSet pendingShortcuts = + InstallShortcutReceiver.getPendingShortcuts(context); + for (ShortcutKey key : shortcutKeyToPinnedShortcuts.keySet()) { + MutableInt numTimesPinned = mBgDataModel.pinnedShortcutCounts.get(key); + if ((numTimesPinned == null || numTimesPinned.value == 0) + && !pendingShortcuts.contains(key)) { + // Shortcut is pinned but doesn't exist on the workspace; unpin it. + mBgDataModel.unpinShortcut(context, key); + } } } From f4eb70c96edcdb368efd05d9f6895438d742079e Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Thu, 10 Sep 2020 12:05:19 -0700 Subject: [PATCH 27/31] Setup logging pipeline for search results Bug: 168121204 Test: Manual Change-Id: I4abb6c75aa0f22416616a713733bef2802b703d1 --- .../allapps/AllAppsContainerView.java | 28 +++--- .../launcher3/allapps/AllAppsGridAdapter.java | 99 ++++++++++++++++--- .../search/AllAppsSearchBarController.java | 5 - .../launcher3/views/HeroSearchResultView.java | 57 ++++++++++- .../views/SearchResultPeopleView.java | 44 +++++++-- .../launcher3/views/SearchResultPlayItem.java | 21 +++- .../launcher3/views/SearchResultShortcut.java | 30 ++++-- .../views/SearchSettingsRowView.java | 21 +++- .../systemui/plugins/AllAppsSearchPlugin.java | 5 +- .../plugins/shared/SearchTargetEvent.java | 15 +-- 10 files changed, 264 insertions(+), 61 deletions(-) diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index 1f515669a6..5079469f4a 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -67,6 +67,9 @@ import com.android.launcher3.util.MultiValueAlpha.AlphaProperty; import com.android.launcher3.util.Themes; import com.android.launcher3.views.RecyclerViewFastScroller; import com.android.launcher3.views.SpringRelativeLayout; +import com.android.systemui.plugins.shared.SearchTargetEvent; + +import java.util.function.IntConsumer; /** * The all apps view container. @@ -538,34 +541,35 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo * Handles selection on focused view and returns success */ public boolean selectFocusedView(View v) { - ItemInfo itemInfo = getHighlightedItemInfo(); - if (itemInfo != null) { - return mLauncher.startActivitySafely(v, itemInfo.getIntent(), itemInfo); + ItemInfo headerItem = getHighlightedItemFromHeader(); + if (headerItem != null) { + return mLauncher.startActivitySafely(v, headerItem.getIntent(), headerItem); } AdapterItem focusedItem = getActiveRecyclerView().getApps().getFocusedChild(); if (focusedItem instanceof AdapterItemWithPayload) { - Runnable onSelection = ((AdapterItemWithPayload) focusedItem).getSelectionHandler(); + IntConsumer onSelection = + ((AdapterItemWithPayload) focusedItem).getSelectionHandler(); if (onSelection != null) { - onSelection.run(); + onSelection.accept(SearchTargetEvent.QUICK_SELECT); return true; } } + if (focusedItem.appInfo != null) { + ItemInfo itemInfo = focusedItem.appInfo; + return mLauncher.startActivitySafely(v, itemInfo.getIntent(), itemInfo); + } return false; } /** - * Returns the ItemInfo of a view that is in focus, ready to be launched by an IME. + * Returns the ItemInfo of a focused view inside {@link FloatingHeaderView} */ - public ItemInfo getHighlightedItemInfo() { + public ItemInfo getHighlightedItemFromHeader() { View view = getFloatingHeaderView().getFocusedChild(); if (view != null && view.getTag() instanceof ItemInfo) { return ((ItemInfo) view.getTag()); } - if (getActiveRecyclerView().getApps().getFocusedChild() != null) { - // TODO: when new pipelines are included, getSearchResults - // should be supported at recycler view level and not apps list level. - return getActiveRecyclerView().getApps().getFocusedChild().appInfo; - } + return null; } diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java index 4e801a7cc8..f077173c0a 100644 --- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java +++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java @@ -21,6 +21,7 @@ import android.content.Context; import android.content.Intent; import android.content.res.Resources; import android.net.Uri; +import android.os.Bundle; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; @@ -54,8 +55,13 @@ import com.android.launcher3.allapps.search.SearchSectionInfo; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.util.PackageManagerHelper; +import com.android.launcher3.views.HeroSearchResultView; +import com.android.systemui.plugins.AllAppsSearchPlugin; +import com.android.systemui.plugins.shared.SearchTarget; +import com.android.systemui.plugins.shared.SearchTargetEvent; import java.util.List; +import java.util.function.IntConsumer; /** * The grid view adapter of all the apps. @@ -196,18 +202,28 @@ public class AllAppsGridAdapter extends */ public static class AdapterItemWithPayload extends AdapterItem { private T mPayload; - private Runnable mSelectionHandler; + private AllAppsSearchPlugin mPlugin; + private IntConsumer mSelectionHandler; - public AdapterItemWithPayload(T payload, int type) { - mPayload = payload; - viewType = type; + public AllAppsSearchPlugin getPlugin() { + return mPlugin; } - public void setSelectionHandler(Runnable runnable) { + public void setPlugin(AllAppsSearchPlugin plugin) { + mPlugin = plugin; + } + + public AdapterItemWithPayload(T payload, int type, AllAppsSearchPlugin plugin) { + mPayload = payload; + viewType = type; + mPlugin = plugin; + } + + public void setSelectionHandler(IntConsumer runnable) { mSelectionHandler = runnable; } - public Runnable getSelectionHandler() { + public IntConsumer getSelectionHandler() { return mSelectionHandler; } @@ -396,10 +412,12 @@ public class AllAppsGridAdapter extends case VIEW_TYPE_ICON: BubbleTextView icon = (BubbleTextView) mLayoutInflater.inflate( R.layout.all_apps_icon, parent, false); - icon.setOnClickListener(mOnIconClickListener); - icon.setOnLongClickListener(mOnIconLongClickListener); icon.setLongPressTimeoutFactor(1f); icon.setOnFocusChangeListener(mIconFocusListener); + if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { + icon.setOnClickListener(mOnIconClickListener); + icon.setOnLongClickListener(mOnIconLongClickListener); + } // Ensure the all apps icon height matches the workspace icons in portrait mode. icon.getLayoutParams().height = mLauncher.getDeviceProfile().allAppsCellHeightPx; @@ -419,7 +437,6 @@ public class AllAppsGridAdapter extends case VIEW_TYPE_SEARCH_CORPUS_TITLE: return new ViewHolder( mLayoutInflater.inflate(R.layout.search_section_title, parent, false)); - case VIEW_TYPE_SEARCH_HERO_APP: return new ViewHolder(mLayoutInflater.inflate( R.layout.search_result_hero_app, parent, false)); @@ -447,10 +464,36 @@ public class AllAppsGridAdapter extends public void onBindViewHolder(ViewHolder holder, int position) { switch (holder.getItemViewType()) { case VIEW_TYPE_ICON: - AppInfo info = mApps.getAdapterItems().get(position).appInfo; + AdapterItem adapterItem = mApps.getAdapterItems().get(position); + AppInfo info = adapterItem.appInfo; BubbleTextView icon = (BubbleTextView) holder.itemView; icon.reset(); icon.applyFromApplicationInfo(info); + if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { + break; + } + //TODO: replace with custom TopHitBubbleTextView with support for both shortcut + // and apps + if (adapterItem instanceof AdapterItemWithPayload) { + AdapterItemWithPayload withPayload = (AdapterItemWithPayload) adapterItem; + IntConsumer selectionHandler = type -> { + SearchTargetEvent e = new SearchTargetEvent(SearchTarget.ItemType.APP, + type); + e.bundle = HeroSearchResultView.getAppBundle(info); + if (withPayload.getPlugin() != null) { + withPayload.getPlugin().notifySearchTargetEvent(e); + } + }; + icon.setOnClickListener(view -> { + selectionHandler.accept(SearchTargetEvent.SELECT); + mOnIconClickListener.onClick(view); + }); + icon.setOnLongClickListener(view -> { + selectionHandler.accept(SearchTargetEvent.LONG_PRESS); + return mOnIconLongClickListener.onLongClick(view); + }); + withPayload.setSelectionHandler(selectionHandler); + } break; case VIEW_TYPE_EMPTY_SEARCH: TextView emptyViewText = (TextView) holder.itemView; @@ -468,11 +511,22 @@ public class AllAppsGridAdapter extends break; case VIEW_TYPE_SEARCH_SLICE: SliceView sliceView = (SliceView) holder.itemView; - Uri uri = ((AdapterItemWithPayload) mApps.getAdapterItems().get(position)) - .getPayload(); + AdapterItemWithPayload item = + (AdapterItemWithPayload) mApps.getAdapterItems().get(position); + sliceView.setOnSliceActionListener((info1, s) -> { + if (item.getPlugin() != null) { + SearchTargetEvent searchTargetEvent = new SearchTargetEvent( + SearchTarget.ItemType.SETTINGS_SLICE, + SearchTargetEvent.CHILD_SELECT); + searchTargetEvent.bundle = new Bundle(); + searchTargetEvent.bundle.putParcelable("uri", item.getPayload()); + item.getPlugin().notifySearchTargetEvent(searchTargetEvent); + } + }); try { - LiveData liveData = SliceLiveData.fromUri(mLauncher, uri); + LiveData liveData = SliceLiveData.fromUri(mLauncher, item.getPayload()); liveData.observe(this::getLifecycle, sliceView); + sliceView.setTag(liveData); } catch (Exception ignored) { } break; @@ -492,6 +546,25 @@ public class AllAppsGridAdapter extends } } + @Override + public void onViewRecycled(@NonNull ViewHolder holder) { + super.onViewRecycled(holder); + if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) return; + if (holder.itemView instanceof BubbleTextView) { + BubbleTextView icon = (BubbleTextView) holder.itemView; + icon.setOnClickListener(mOnIconClickListener); + icon.setOnLongClickListener(mOnIconLongClickListener); + } else if (holder.itemView instanceof SliceView) { + SliceView sliceView = (SliceView) holder.itemView; + sliceView.setOnSliceActionListener(null); + if (sliceView.getTag() instanceof LiveData) { + LiveData sliceLiveData = (LiveData) sliceView.getTag(); + sliceLiveData.removeObservers(this::getLifecycle); + } + } + } + + @Override public boolean onFailedToRecycleView(ViewHolder holder) { // Always recycle and we will reset the view when it is bound diff --git a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java index 29e340480d..3320189a1d 100644 --- a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java +++ b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java @@ -115,11 +115,6 @@ public class AllAppsSearchBarController if (actionId == EditorInfo.IME_ACTION_SEARCH) { // selectFocusedView should return SearchTargetEvent that is passed onto onClick if (Launcher.getLauncher(mLauncher).getAppsView().selectFocusedView(v)) { - if (mSearchAlgorithm instanceof PluginWrapper) { - ((PluginWrapper) mSearchAlgorithm).runOnPluginIfConnected(plugin -> { - plugin.onClick(false, null); - }); - } return true; } } diff --git a/src/com/android/launcher3/views/HeroSearchResultView.java b/src/com/android/launcher3/views/HeroSearchResultView.java index 761ef0d639..a8e1c6b30c 100644 --- a/src/com/android/launcher3/views/HeroSearchResultView.java +++ b/src/com/android/launcher3/views/HeroSearchResultView.java @@ -18,7 +18,9 @@ package com.android.launcher3.views; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_ALL_APPS; import android.content.Context; +import android.content.Intent; import android.graphics.Point; +import android.os.Bundle; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; @@ -41,6 +43,9 @@ import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.shortcuts.ShortcutDragPreviewProvider; import com.android.launcher3.touch.ItemLongClickListener; +import com.android.systemui.plugins.AllAppsSearchPlugin; +import com.android.systemui.plugins.shared.SearchTarget; +import com.android.systemui.plugins.shared.SearchTargetEvent; import java.util.List; @@ -54,6 +59,7 @@ public class HeroSearchResultView extends LinearLayout implements DragSource, BubbleTextView mBubbleTextView; View mIconView; BubbleTextView[] mDeepShortcutTextViews = new BubbleTextView[2]; + AllAppsSearchPlugin mPlugin; public HeroSearchResultView(Context context) { super(context); @@ -79,7 +85,10 @@ public class HeroSearchResultView extends LinearLayout implements DragSource, mBubbleTextView = findViewById(R.id.bubble_text); - mBubbleTextView.setOnClickListener(launcher.getItemOnClickListener()); + mBubbleTextView.setOnClickListener(view -> { + handleSelection(SearchTargetEvent.SELECT); + launcher.getItemOnClickListener().onClick(view); + }); mBubbleTextView.setOnLongClickListener(new HeroItemDragHandler(getContext(), this)); setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, grid.allAppsCellHeightPx)); @@ -91,7 +100,18 @@ public class HeroSearchResultView extends LinearLayout implements DragSource, bubbleTextView.setLayoutParams( new LinearLayout.LayoutParams(grid.allAppsIconSizePx, grid.allAppsIconSizePx)); - bubbleTextView.setOnClickListener(launcher.getItemOnClickListener()); + bubbleTextView.setOnClickListener(view -> { + WorkspaceItemInfo itemInfo = (WorkspaceItemInfo) bubbleTextView.getTag(); + SearchTargetEvent event = new SearchTargetEvent( + SearchTarget.ItemType.APP_HERO, + SearchTargetEvent.CHILD_SELECT); + event.bundle = getAppBundle(itemInfo); + event.bundle.putString("shortcut_id", itemInfo.getDeepShortcutId()); + if (mPlugin != null) { + mPlugin.notifySearchTargetEvent(event); + } + launcher.getItemOnClickListener().onClick(view); + }); } } @@ -110,6 +130,8 @@ public class HeroSearchResultView extends LinearLayout implements DragSource, mDeepShortcutTextViews[i].applyFromItemInfoWithIcon(shorcutInfos.get(i)); } } + mPlugin = adapterItem.getPlugin(); + adapterItem.setSelectionHandler(this::handleSelection); } @Override @@ -147,7 +169,38 @@ public class HeroSearchResultView extends LinearLayout implements DragSource, mLauncher.getWorkspace().beginDragShared(mContainer.mBubbleTextView, draggableView, mContainer, itemInfo, previewProvider, new DragOptions()); + SearchTargetEvent event = new SearchTargetEvent( + SearchTarget.ItemType.APP_HERO, SearchTargetEvent.LONG_PRESS); + event.bundle = getAppBundle(itemInfo); + if (mContainer.mPlugin != null) { + mContainer.mPlugin.notifySearchTargetEvent(event); + } + return false; } } + + private void handleSelection(int eventType) { + ItemInfo itemInfo = (ItemInfo) mBubbleTextView.getTag(); + if (itemInfo == null) return; + Launcher launcher = Launcher.getLauncher(getContext()); + launcher.startActivitySafely(this, itemInfo.getIntent(), itemInfo); + + SearchTargetEvent event = new SearchTargetEvent( + SearchTarget.ItemType.APP_HERO, eventType); + event.bundle = getAppBundle(itemInfo); + if (mPlugin != null) { + mPlugin.notifySearchTargetEvent(event); + } + } + + /** + * Helper method to generate {@link SearchTargetEvent} bundle from {@link ItemInfo} + */ + public static Bundle getAppBundle(ItemInfo itemInfo) { + Bundle b = new Bundle(); + b.putParcelable(Intent.EXTRA_COMPONENT_NAME, itemInfo.getTargetComponent()); + b.putParcelable(Intent.EXTRA_USER, itemInfo.user); + return b; + } } diff --git a/src/com/android/launcher3/views/SearchResultPeopleView.java b/src/com/android/launcher3/views/SearchResultPeopleView.java index d1e34fa65f..78e9841d36 100644 --- a/src/com/android/launcher3/views/SearchResultPeopleView.java +++ b/src/com/android/launcher3/views/SearchResultPeopleView.java @@ -45,6 +45,9 @@ import com.android.launcher3.R; import com.android.launcher3.allapps.AllAppsGridAdapter; import com.android.launcher3.allapps.search.AllAppsSearchBarController; import com.android.launcher3.util.Themes; +import com.android.systemui.plugins.AllAppsSearchPlugin; +import com.android.systemui.plugins.shared.SearchTarget; +import com.android.systemui.plugins.shared.SearchTargetEvent; import java.net.URISyntaxException; import java.util.ArrayList; @@ -58,9 +61,12 @@ public class SearchResultPeopleView extends LinearLayout implements private final int mIconSize; private final int mButtonSize; private final PackageManager mPackageManager; - View mIconView; - TextView mTitleView; - ImageButton[] mProviderButtons = new ImageButton[3]; + private View mIconView; + private TextView mTitleView; + private ImageButton[] mProviderButtons = new ImageButton[3]; + private AllAppsSearchPlugin mPlugin; + private Uri mContactUri; + public SearchResultPeopleView(Context context) { this(context, null, 0); @@ -93,14 +99,14 @@ public class SearchResultPeopleView extends LinearLayout implements button.getLayoutParams().width = mButtonSize; button.getLayoutParams().height = mButtonSize; } - setOnClickListener(v -> handleSelection()); + setOnClickListener(v -> handleSelection(SearchTargetEvent.SELECT)); } @Override public void applyAdapterInfo( AllAppsGridAdapter.AdapterItemWithPayload adapterItemWithPayload) { - Launcher launcher = Launcher.getLauncher(getContext()); Bundle payload = adapterItemWithPayload.getPayload(); + mPlugin = adapterItemWithPayload.getPlugin(); mTitleView.setText(payload.getString("title")); mContactUri = payload.getParcelable("contact_uri"); Bitmap icon = payload.getParcelable("icon"); @@ -122,8 +128,8 @@ public class SearchResultPeopleView extends LinearLayout implements Bundle provider = providers.get(i); Intent intent = Intent.parseUri(provider.getString("intent_uri_str"), URI_ANDROID_APP_SCHEME | URI_ALLOW_UNSAFE); + setupProviderButton(button, provider, intent); String pkg = provider.getString("package_name"); - button.setOnClickListener(b -> launcher.startActivitySafely(b, intent, null)); UI_HELPER_EXECUTOR.post(() -> { try { ApplicationInfo applicationInfo = mPackageManager.getApplicationInfo( @@ -144,13 +150,35 @@ public class SearchResultPeopleView extends LinearLayout implements adapterItemWithPayload.setSelectionHandler(this::handleSelection); } - Uri mContactUri; + private void setupProviderButton(ImageButton button, Bundle provider, Intent intent) { + Launcher launcher = Launcher.getLauncher(getContext()); + button.setOnClickListener(b -> { + launcher.startActivitySafely(b, intent, null); + SearchTargetEvent searchTargetEvent = new SearchTargetEvent( + SearchTarget.ItemType.PEOPLE, + SearchTargetEvent.CHILD_SELECT); + searchTargetEvent.bundle = new Bundle(); + searchTargetEvent.bundle.putParcelable("contact_uri", mContactUri); + searchTargetEvent.bundle.putBundle("provider", provider); + if (mPlugin != null) { + mPlugin.notifySearchTargetEvent(searchTargetEvent); + } + }); + } - private void handleSelection() { + + private void handleSelection(int eventType) { if (mContactUri != null) { Launcher launcher = Launcher.getLauncher(getContext()); launcher.startActivitySafely(this, new Intent(Intent.ACTION_VIEW, mContactUri).setFlags( Intent.FLAG_ACTIVITY_NEW_TASK), null); + SearchTargetEvent searchTargetEvent = new SearchTargetEvent( + SearchTarget.ItemType.PEOPLE, eventType); + searchTargetEvent.bundle = new Bundle(); + searchTargetEvent.bundle.putParcelable("contact_uri", mContactUri); + if (mPlugin != null) { + mPlugin.notifySearchTargetEvent(searchTargetEvent); + } } } } diff --git a/src/com/android/launcher3/views/SearchResultPlayItem.java b/src/com/android/launcher3/views/SearchResultPlayItem.java index 19a4c5d84c..8624609f80 100644 --- a/src/com/android/launcher3/views/SearchResultPlayItem.java +++ b/src/com/android/launcher3/views/SearchResultPlayItem.java @@ -38,6 +38,9 @@ import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItemWithPayload; import com.android.launcher3.allapps.search.AllAppsSearchBarController; +import com.android.systemui.plugins.AllAppsSearchPlugin; +import com.android.systemui.plugins.shared.SearchTarget; +import com.android.systemui.plugins.shared.SearchTargetEvent; import java.io.IOException; import java.net.URL; @@ -54,6 +57,7 @@ public class SearchResultPlayItem extends LinearLayout implements private Button mPreviewButton; private String mPackageName; private boolean mIsInstantGame; + private AllAppsSearchPlugin mPlugin; public SearchResultPlayItem(Context context) { this(context, null, 0); @@ -84,13 +88,14 @@ public class SearchResultPlayItem extends LinearLayout implements ViewGroup.LayoutParams iconParams = mIconView.getLayoutParams(); iconParams.height = mDeviceProfile.allAppsIconSizePx; iconParams.width = mDeviceProfile.allAppsIconSizePx; - setOnClickListener(view -> handleSelection()); + setOnClickListener(view -> handleSelection(SearchTargetEvent.SELECT)); } @Override public void applyAdapterInfo(AdapterItemWithPayload adapterItemWithPayload) { Bundle bundle = adapterItemWithPayload.getPayload(); + mPlugin = adapterItemWithPayload.getPlugin(); adapterItemWithPayload.setSelectionHandler(this::handleSelection); if (bundle.getString("package", "").equals(mPackageName)) { return; @@ -129,13 +134,14 @@ public class SearchResultPlayItem extends LinearLayout implements } } - private void handleSelection() { + private void handleSelection(int eventType) { if (mPackageName == null) return; Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse( "https://play.google.com/store/apps/details?id=" + mPackageName)); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getContext().startActivity(i); + logSearchEvent(eventType); } private void launchInstantGame() { @@ -150,5 +156,16 @@ public class SearchResultPlayItem extends LinearLayout implements intent.putExtra("callerId", getContext().getPackageName()); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getContext().startActivity(intent); + logSearchEvent(SearchTargetEvent.CHILD_SELECT); + } + + private void logSearchEvent(int eventType) { + SearchTargetEvent searchTargetEvent = new SearchTargetEvent( + SearchTarget.ItemType.PLAY_RESULTS, eventType); + searchTargetEvent.bundle = new Bundle(); + searchTargetEvent.bundle.putString("package_name", mPackageName); + if (mPlugin != null) { + mPlugin.notifySearchTargetEvent(searchTargetEvent); + } } } diff --git a/src/com/android/launcher3/views/SearchResultShortcut.java b/src/com/android/launcher3/views/SearchResultShortcut.java index a402719e76..307cf34c7d 100644 --- a/src/com/android/launcher3/views/SearchResultShortcut.java +++ b/src/com/android/launcher3/views/SearchResultShortcut.java @@ -36,7 +36,9 @@ import com.android.launcher3.allapps.AllAppsGridAdapter; import com.android.launcher3.allapps.search.AllAppsSearchBarController; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.touch.ItemClickHandler; +import com.android.systemui.plugins.AllAppsSearchPlugin; import com.android.systemui.plugins.shared.SearchTarget; +import com.android.systemui.plugins.shared.SearchTargetEvent; /** * A view representing a stand alone shortcut search result @@ -44,8 +46,10 @@ import com.android.systemui.plugins.shared.SearchTarget; public class SearchResultShortcut extends FrameLayout implements AllAppsSearchBarController.PayloadResultHandler { - BubbleTextView mBubbleTextView; - View mIconView; + private BubbleTextView mBubbleTextView; + private View mIconView; + private ShortcutInfo mShortcutInfo; + private AllAppsSearchPlugin mPlugin; public SearchResultShortcut(@NonNull Context context) { super(context); @@ -71,28 +75,36 @@ public class SearchResultShortcut extends FrameLayout implements iconParams.height = grid.allAppsIconSizePx; iconParams.width = grid.allAppsIconSizePx; mBubbleTextView = findViewById(R.id.bubble_text); - setOnClickListener(v -> handleSelection()); + setOnClickListener(v -> handleSelection(SearchTargetEvent.SELECT)); } @Override public void applyAdapterInfo( AllAppsGridAdapter.AdapterItemWithPayload adapterItemWithPayload) { SearchTarget payload = adapterItemWithPayload.getPayload(); - ShortcutInfo si = payload.shortcuts.get(0); - WorkspaceItemInfo workspaceItemInfo = new WorkspaceItemInfo(si, getContext()); + mPlugin = adapterItemWithPayload.getPlugin(); + mShortcutInfo = payload.shortcuts.get(0); + WorkspaceItemInfo workspaceItemInfo = new WorkspaceItemInfo(mShortcutInfo, getContext()); mBubbleTextView.applyFromWorkspaceItem(workspaceItemInfo); mIconView.setBackground(mBubbleTextView.getIcon()); LauncherAppState launcherAppState = LauncherAppState.getInstance(getContext()); MODEL_EXECUTOR.execute(() -> { - launcherAppState.getIconCache().getShortcutIcon(workspaceItemInfo, si); + launcherAppState.getIconCache().getShortcutIcon(workspaceItemInfo, mShortcutInfo); mBubbleTextView.applyFromWorkspaceItem(workspaceItemInfo); mIconView.setBackground(mBubbleTextView.getIcon()); }); adapterItemWithPayload.setSelectionHandler(this::handleSelection); } - private void handleSelection() { - ItemClickHandler.onClickAppShortcut(this, (WorkspaceItemInfo) mBubbleTextView.getTag(), - Launcher.getLauncher(getContext())); + private void handleSelection(int eventType) { + WorkspaceItemInfo itemInfo = (WorkspaceItemInfo) mBubbleTextView.getTag(); + ItemClickHandler.onClickAppShortcut(this, itemInfo, Launcher.getLauncher(getContext())); + + SearchTargetEvent searchTargetEvent = new SearchTargetEvent( + SearchTarget.ItemType.SHORTCUT, eventType); + searchTargetEvent.shortcut = mShortcutInfo; + if (mPlugin != null) { + mPlugin.notifySearchTargetEvent(searchTargetEvent); + } } } diff --git a/src/com/android/launcher3/views/SearchSettingsRowView.java b/src/com/android/launcher3/views/SearchSettingsRowView.java index 08c78ffc3a..93bcee2585 100644 --- a/src/com/android/launcher3/views/SearchSettingsRowView.java +++ b/src/com/android/launcher3/views/SearchSettingsRowView.java @@ -31,6 +31,9 @@ import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.allapps.AllAppsGridAdapter; import com.android.launcher3.allapps.search.AllAppsSearchBarController; +import com.android.systemui.plugins.AllAppsSearchPlugin; +import com.android.systemui.plugins.shared.SearchTarget; +import com.android.systemui.plugins.shared.SearchTargetEvent; import java.util.ArrayList; @@ -44,6 +47,7 @@ public class SearchSettingsRowView extends LinearLayout implements private TextView mDescriptionView; private TextView mBreadcrumbsView; private Intent mIntent; + private AllAppsSearchPlugin mPlugin; public SearchSettingsRowView(@NonNull Context context) { super(context); @@ -72,6 +76,7 @@ public class SearchSettingsRowView extends LinearLayout implements public void applyAdapterInfo( AllAppsGridAdapter.AdapterItemWithPayload adapterItemWithPayload) { Bundle bundle = adapterItemWithPayload.getPayload(); + mPlugin = adapterItemWithPayload.getPlugin(); mIntent = bundle.getParcelable("intent"); showIfAvailable(mTitleView, bundle.getString("title")); showIfAvailable(mDescriptionView, bundle.getString("description")); @@ -79,7 +84,7 @@ public class SearchSettingsRowView extends LinearLayout implements //TODO: implement RTL friendly breadcrumbs view showIfAvailable(mBreadcrumbsView, breadcrumbs != null ? String.join(" > ", breadcrumbs) : null); - adapterItemWithPayload.setSelectionHandler(() -> onClick(this)); + adapterItemWithPayload.setSelectionHandler(this::handleSelection); } private void showIfAvailable(TextView view, @Nullable String string) { @@ -93,10 +98,22 @@ public class SearchSettingsRowView extends LinearLayout implements @Override public void onClick(View view) { + handleSelection(SearchTargetEvent.SELECT); + } + + private void handleSelection(int eventType) { if (mIntent == null) return; // TODO: create ItemInfo object and then use it to call startActivityForResult for proper // WW logging - Launcher launcher = Launcher.getLauncher(view.getContext()); + Launcher launcher = Launcher.getLauncher(getContext()); launcher.startActivityForResult(mIntent, 0); + + SearchTargetEvent searchTargetEvent = new SearchTargetEvent( + SearchTarget.ItemType.SETTINGS_ROW, eventType); + searchTargetEvent.bundle = new Bundle(); + searchTargetEvent.bundle.putParcelable("intent", mIntent); + if (mPlugin != null) { + mPlugin.notifySearchTargetEvent(searchTargetEvent); + } } } diff --git a/src_plugins/com/android/systemui/plugins/AllAppsSearchPlugin.java b/src_plugins/com/android/systemui/plugins/AllAppsSearchPlugin.java index 9949678458..437cf3cfe5 100644 --- a/src_plugins/com/android/systemui/plugins/AllAppsSearchPlugin.java +++ b/src_plugins/com/android/systemui/plugins/AllAppsSearchPlugin.java @@ -47,7 +47,10 @@ public interface AllAppsSearchPlugin extends Plugin { */ void performSearch(String query, Consumer> results); - void onClick(boolean isTouch, SearchTargetEvent event); + /** + * Send over search target interaction events to Plugin + */ + void notifySearchTargetEvent(SearchTargetEvent event); /** * Send signal when user exits all apps. diff --git a/src_plugins/com/android/systemui/plugins/shared/SearchTargetEvent.java b/src_plugins/com/android/systemui/plugins/shared/SearchTargetEvent.java index 00aacd0543..ac4bc333c6 100644 --- a/src_plugins/com/android/systemui/plugins/shared/SearchTargetEvent.java +++ b/src_plugins/com/android/systemui/plugins/shared/SearchTargetEvent.java @@ -22,18 +22,19 @@ import android.os.Bundle; * Event used for the feedback loop to the plugin. (and future aiai) */ public class SearchTargetEvent { + public static final int SELECT = 0; + public static final int QUICK_SELECT = 1; + public static final int LONG_PRESS = 2; + public static final int CHILD_SELECT = 3; + public SearchTarget.ItemType type; public ShortcutInfo shortcut; + public int eventType; public Bundle bundle; public float score; - public SearchTargetEvent(SearchTarget.ItemType itemType, - ShortcutInfo shortcut, - Bundle bundle, - float score) { + public SearchTargetEvent(SearchTarget.ItemType itemType, int eventType) { this.type = itemType; - this.shortcut = shortcut; - this.bundle = bundle; - this.score = score; + this.eventType = eventType; } } From 1c3150fa1fb1482606bf0957b67d1cab91906a15 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 9 Sep 2020 17:35:47 -0700 Subject: [PATCH 28/31] Inline INDEX_PAUSE_TO_OVERVIEW_ANIM It is only used by NoButtonQuickSwitchTouchController. Also removed the interpolator overrides that are no longer needed since we don't animate the shelf into overview mode. Change-Id: I358a6020caaee859c6b22179591ab1d11a432f1d --- .../QuickstepAtomicAnimationFactory.java | 25 +------------------ .../NoButtonQuickSwitchTouchController.java | 8 +++--- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java b/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java index 94af134de5..77fd103a6c 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java @@ -36,13 +36,10 @@ import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_7; import static com.android.launcher3.anim.Interpolators.clampToProgress; import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE; import static com.android.launcher3.states.StateAnimationConfig.ANIM_DEPTH; -import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_SCALE; -import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_TRANSLATE; import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_FADE; import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SCALE; import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_X; import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_Y; -import static com.android.launcher3.states.StateAnimationConfig.ANIM_VERTICAL_PROGRESS; import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_FADE; import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCALE; import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_TRANSLATE; @@ -64,7 +61,6 @@ import com.android.launcher3.LauncherState.ScaleAndTranslation; import com.android.launcher3.Workspace; import com.android.launcher3.allapps.AllAppsContainerView; import com.android.launcher3.allapps.AllAppsTransitionController; -import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.states.StateAnimationConfig; import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.quickstep.SysUINavigationMode; @@ -81,10 +77,8 @@ public class QuickstepAtomicAnimationFactory extends private static final float RECENTS_PREPARE_SCALE = 1.33f; public static final int INDEX_SHELF_ANIM = RecentsAtomicAnimationFactory.NEXT_INDEX + 0; - public static final int INDEX_PAUSE_TO_OVERVIEW_ANIM = - RecentsAtomicAnimationFactory.NEXT_INDEX + 1; - private static final int MY_ANIM_COUNT = 2; + private static final int MY_ANIM_COUNT = 1; protected static final int NEXT_INDEX = RecentsAtomicAnimationFactory.NEXT_INDEX + MY_ANIM_COUNT; @@ -92,8 +86,6 @@ public class QuickstepAtomicAnimationFactory extends // cache the value. private int mHintToNormalDuration = -1; - public static final long ATOMIC_DURATION_FROM_PAUSED_TO_OVERVIEW = 300; - public QuickstepAtomicAnimationFactory(QuickstepLauncher activity) { super(activity, MY_ANIM_COUNT); } @@ -132,21 +124,6 @@ public class QuickstepAtomicAnimationFactory extends return springAnim; } - case INDEX_PAUSE_TO_OVERVIEW_ANIM: { - StateAnimationConfig config = new StateAnimationConfig(); - config.duration = ATOMIC_DURATION_FROM_PAUSED_TO_OVERVIEW; - - config.setInterpolator(ANIM_VERTICAL_PROGRESS, OVERSHOOT_1_2); - config.setInterpolator(ANIM_ALL_APPS_FADE, DEACCEL_3); - if ((OVERVIEW.getVisibleElements(mActivity) & HOTSEAT_ICONS) != 0) { - config.setInterpolator(ANIM_HOTSEAT_SCALE, OVERSHOOT_1_2); - config.setInterpolator(ANIM_HOTSEAT_TRANSLATE, OVERSHOOT_1_2); - } - - StateManager stateManager = mActivity.getStateManager(); - return stateManager.createAtomicAnimation( - stateManager.getCurrentStableState(), OVERVIEW, config); - } default: return super.createStateElementAnimation(index, values); } diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java index 8285850c7e..34d5f7313a 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java @@ -35,7 +35,6 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_T import static com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW; import static com.android.launcher3.touch.BothAxesSwipeDetector.DIRECTION_RIGHT; import static com.android.launcher3.touch.BothAxesSwipeDetector.DIRECTION_UP; -import static com.android.launcher3.uioverrides.states.QuickstepAtomicAnimationFactory.INDEX_PAUSE_TO_OVERVIEW_ANIM; import static com.android.launcher3.util.DisplayController.getSingleFrameMs; import static com.android.launcher3.util.VibratorWrapper.OVERVIEW_HAPTIC; import static com.android.quickstep.views.RecentsView.ADJACENT_PAGE_OFFSET; @@ -87,6 +86,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController, private static final Interpolator FADE_OUT_INTERPOLATOR = DEACCEL_5; private static final Interpolator TRANSLATE_OUT_INTERPOLATOR = ACCEL_0_75; private static final Interpolator SCALE_DOWN_INTERPOLATOR = LINEAR; + private static final long ATOMIC_DURATION_FROM_PAUSED_TO_OVERVIEW = 300; private final BaseQuickstepLauncher mLauncher; private final BothAxesSwipeDetector mSwipeDetector; @@ -292,8 +292,10 @@ public class NoButtonQuickSwitchTouchController implements TouchController, if (mMotionPauseDetector.isPaused() && noFling) { cancelAnimations(); - Animator overviewAnim = mLauncher.createAtomicAnimationFactory() - .createStateElementAnimation(INDEX_PAUSE_TO_OVERVIEW_ANIM); + StateAnimationConfig config = new StateAnimationConfig(); + config.duration = ATOMIC_DURATION_FROM_PAUSED_TO_OVERVIEW; + Animator overviewAnim = mLauncher.getStateManager().createAtomicAnimation( + mStartState, OVERVIEW, config); overviewAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { From 5f1de1ad29db20b5cab3e500e40aa2d3c26f621f Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Fri, 11 Sep 2020 11:33:14 -0700 Subject: [PATCH 29/31] set people icon on main thread Change-Id: I23435e41677efc6f262b464bfb5d9db6c057abb8 --- src/com/android/launcher3/views/SearchResultPeopleView.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/views/SearchResultPeopleView.java b/src/com/android/launcher3/views/SearchResultPeopleView.java index d1e34fa65f..2dd1c5c278 100644 --- a/src/com/android/launcher3/views/SearchResultPeopleView.java +++ b/src/com/android/launcher3/views/SearchResultPeopleView.java @@ -18,6 +18,7 @@ package com.android.launcher3.views; import static android.content.Intent.URI_ALLOW_UNSAFE; import static android.content.Intent.URI_ANDROID_APP_SCHEME; +import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import android.content.Context; @@ -129,7 +130,7 @@ public class SearchResultPeopleView extends LinearLayout implements ApplicationInfo applicationInfo = mPackageManager.getApplicationInfo( pkg, 0); Drawable appIcon = applicationInfo.loadIcon(mPackageManager); - button.setImageDrawable(appIcon); + MAIN_EXECUTOR.post(()-> button.setImageDrawable(appIcon)); } catch (PackageManager.NameNotFoundException ignored) { } From d099d24807bd1a416c464d8a22f87dcbfa81b1f0 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Mon, 14 Sep 2020 09:23:12 -0700 Subject: [PATCH 30/31] resolve invalid size variable issue for people view Change-Id: I176a4de9536a7724a07c4e953f124b0c1691fe1b --- res/layout/search_result_people_item.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/res/layout/search_result_people_item.xml b/res/layout/search_result_people_item.xml index a505e4a968..a603941dfa 100644 --- a/res/layout/search_result_people_item.xml +++ b/res/layout/search_result_people_item.xml @@ -22,8 +22,8 @@ + android:layout_width="@dimen/deep_shortcut_icon_size" + android:layout_height="@dimen/deep_shortcut_icon_size" /> + android:layout_width="@dimen/deep_shortcut_icon_size" + android:layout_height="@dimen/deep_shortcut_icon_size" /> + android:layout_width="@dimen/deep_shortcut_icon_size" + android:layout_height="@dimen/deep_shortcut_icon_size" /> + android:layout_width="@dimen/deep_shortcut_icon_size" + android:layout_height="@dimen/deep_shortcut_icon_size" /> \ No newline at end of file From 2fa2e0ae230cb960bc4f16aa69e5847080949a5a Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Fri, 11 Sep 2020 13:34:25 -0700 Subject: [PATCH 31/31] Fix launcher leaks Follow up of: ag/12558751 Bug: 168121204 Change-Id: I381284a5e1cd9568ed14ec7a357ff150e35c18c6 --- src/com/android/launcher3/Launcher.java | 23 ++++++++++++++++- .../launcher3/allapps/AllAppsGridAdapter.java | 25 +++---------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 2e36bc01dd..90566f3ce8 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -94,9 +94,13 @@ import android.view.animation.OvershootInterpolator; import android.widget.Toast; import androidx.annotation.CallSuper; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.annotation.VisibleForTesting; +import androidx.lifecycle.Lifecycle; +import androidx.lifecycle.LifecycleOwner; +import androidx.lifecycle.LifecycleRegistry; import com.android.launcher3.DropTarget.DragObject; import com.android.launcher3.accessibility.LauncherAccessibilityDelegate; @@ -206,7 +210,8 @@ import java.util.stream.Stream; * Default launcher application. */ public class Launcher extends StatefulActivity implements LauncherExterns, - Callbacks, InvariantDeviceProfile.OnIDPChangeListener, PluginListener { + Callbacks, InvariantDeviceProfile.OnIDPChangeListener, PluginListener, + LifecycleOwner { public static final String TAG = "Launcher"; public static final ActivityTracker ACTIVITY_TRACKER = new ActivityTracker<>(); @@ -267,6 +272,8 @@ public class Launcher extends StatefulActivity implements Launche private LauncherAppTransitionManager mAppTransitionManager; private Configuration mOldConfig; + private LifecycleRegistry mLifecycleRegistry; + @Thunk Workspace mWorkspace; @Thunk @@ -471,6 +478,15 @@ public class Launcher extends StatefulActivity implements Launche if (Utilities.ATLEAST_R) { getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); } + + mLifecycleRegistry = new LifecycleRegistry(this); + mLifecycleRegistry.setCurrentState(Lifecycle.State.CREATED); + } + + @NonNull + @Override + public Lifecycle getLifecycle() { + return mLifecycleRegistry; } protected LauncherOverlayManager getDefaultOverlay() { @@ -886,6 +902,7 @@ public class Launcher extends StatefulActivity implements Launche @Override protected void onStop() { + mLifecycleRegistry.setCurrentState(Lifecycle.State.CREATED); super.onStop(); if (mDeferOverlayCallbacks) { checkIfOverlayStillDeferred(); @@ -909,6 +926,7 @@ public class Launcher extends StatefulActivity implements Launche mAppWidgetHost.setListenIfResumed(true); TraceHelper.INSTANCE.endSection(traceToken); + mLifecycleRegistry.setCurrentState(Lifecycle.State.STARTED); } @Override @@ -1068,6 +1086,7 @@ public class Launcher extends StatefulActivity implements Launche } TraceHelper.INSTANCE.endSection(traceToken); + mLifecycleRegistry.setCurrentState(Lifecycle.State.RESUMED); } @Override @@ -1075,6 +1094,7 @@ public class Launcher extends StatefulActivity implements Launche // Ensure that items added to Launcher are queued until Launcher returns ItemInstallQueue.INSTANCE.get(this).pauseModelPush(FLAG_ACTIVITY_PAUSED); + mLifecycleRegistry.setCurrentState(Lifecycle.State.STARTED); super.onPause(); mDragController.cancelDrag(); mLastTouchUpTime = -1; @@ -1557,6 +1577,7 @@ public class Launcher extends StatefulActivity implements Launche mOverlayManager.onActivityDestroyed(this); mAppTransitionManager.unregisterRemoteAnimations(); mUserChangedCallbackCloseable.close(); + mLifecycleRegistry.setCurrentState(Lifecycle.State.DESTROYED); } public LauncherAccessibilityDelegate getAccessibilityDelegate() { diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java index f077173c0a..d1340faf23 100644 --- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java +++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java @@ -37,9 +37,6 @@ import androidx.annotation.Nullable; import androidx.core.view.accessibility.AccessibilityEventCompat; import androidx.core.view.accessibility.AccessibilityNodeInfoCompat; import androidx.core.view.accessibility.AccessibilityRecordCompat; -import androidx.lifecycle.Lifecycle; -import androidx.lifecycle.LifecycleOwner; -import androidx.lifecycle.LifecycleRegistry; import androidx.lifecycle.LiveData; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -49,6 +46,7 @@ import androidx.slice.widget.SliceView; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.BubbleTextView; +import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.allapps.search.AllAppsSearchBarController.PayloadResultHandler; import com.android.launcher3.allapps.search.SearchSectionInfo; @@ -67,8 +65,7 @@ import java.util.function.IntConsumer; * The grid view adapter of all the apps. */ public class AllAppsGridAdapter extends - RecyclerView.Adapter implements - LifecycleOwner { + RecyclerView.Adapter { public static final String TAG = "AppsGridAdapter"; @@ -103,8 +100,6 @@ public class AllAppsGridAdapter extends public static final int VIEW_TYPE_MASK_DIVIDER = VIEW_TYPE_ALL_APPS_DIVIDER; public static final int VIEW_TYPE_MASK_ICON = VIEW_TYPE_ICON; - private final LifecycleRegistry mLifecycleRegistry; - /** * ViewHolder for each icon. */ @@ -353,12 +348,6 @@ public class AllAppsGridAdapter extends mOnIconClickListener = launcher.getItemOnClickListener(); setAppsPerRow(mLauncher.getDeviceProfile().inv.numAllAppsColumns); - if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { - mLifecycleRegistry = new LifecycleRegistry(this); - mLifecycleRegistry.setCurrentState(Lifecycle.State.STARTED); - } else { - mLifecycleRegistry = null; - } } public void setAppsPerRow(int appsPerRow) { @@ -525,7 +514,7 @@ public class AllAppsGridAdapter extends }); try { LiveData liveData = SliceLiveData.fromUri(mLauncher, item.getPayload()); - liveData.observe(this::getLifecycle, sliceView); + liveData.observe((Launcher) mLauncher, sliceView); sliceView.setTag(liveData); } catch (Exception ignored) { } @@ -559,7 +548,7 @@ public class AllAppsGridAdapter extends sliceView.setOnSliceActionListener(null); if (sliceView.getTag() instanceof LiveData) { LiveData sliceLiveData = (LiveData) sliceView.getTag(); - sliceLiveData.removeObservers(this::getLifecycle); + sliceLiveData.removeObservers((Launcher) mLauncher); } } } @@ -581,10 +570,4 @@ public class AllAppsGridAdapter extends AdapterItem item = mApps.getAdapterItems().get(position); return item.viewType; } - - @NonNull - @Override - public Lifecycle getLifecycle() { - return mLifecycleRegistry; - } }