Merge "Cancel the recents animation for locked gesture[2/2]" into tm-qpr-dev
diff --git a/Android.bp b/Android.bp
index 0a55675..4adbf53 100644
--- a/Android.bp
+++ b/Android.bp
@@ -313,3 +313,138 @@
baseline_filename: "lint-baseline-launcher3.xml",
},
}
+
+// Build rule for Launcher3 Go app for Android Go devices.
+android_app {
+ name: "Launcher3Go",
+
+ static_libs: ["Launcher3CommonDepsLib"],
+
+ srcs: [
+ "src/**/*.java",
+ "src_ui_overrides/**/*.java",
+ "go/src/**/*.java",
+ ],
+
+ resource_dirs: ["go/res"],
+
+ optimize: {
+ proguard_flags_files: ["proguard.flags"],
+ },
+
+ sdk_version: "current",
+ min_sdk_version: "current",
+ target_sdk_version: "current",
+ privileged: true,
+ system_ext_specific: true,
+ overrides: [
+ "Home",
+ "Launcher2",
+ "Launcher3",
+ "Launcher3QuickStep",
+ ],
+ required: ["privapp_whitelist_com.android.launcher3"],
+
+ additional_manifests: [
+ "AndroidManifest.xml",
+ "AndroidManifest-common.xml",
+ ],
+
+ manifest: "go/AndroidManifest.xml",
+ jacoco: {
+ include_filter: ["com.android.launcher3.*"],
+ }
+
+}
+
+// Build rule for Quickstep app.
+android_app {
+ name: "Launcher3QuickStep",
+
+ static_libs: ["Launcher3QuickStepLib"],
+ optimize: {
+ enabled: false,
+ },
+
+ platform_apis: true,
+ min_sdk_version: "current",
+ target_sdk_version: "current",
+
+ privileged: true,
+ system_ext_specific: true,
+ overrides: [
+ "Home",
+ "Launcher2",
+ "Launcher3",
+ ],
+ required: ["privapp_whitelist_com.android.launcher3"],
+
+ resource_dirs: ["quickstep/res"],
+
+ additional_manifests: [
+ "quickstep/AndroidManifest-launcher.xml",
+ "AndroidManifest-common.xml",
+ ],
+
+ manifest: "quickstep/AndroidManifest.xml",
+ jacoco: {
+ include_filter: ["com.android.launcher3.*"],
+ }
+
+}
+
+// Build rule for Launcher3 Go app with quickstep for Android Go devices.
+android_app {
+ name: "Launcher3QuickStepGo",
+
+ static_libs: [
+ "SystemUI-statsd",
+ "SystemUISharedLib",
+ "LauncherGoResLib",
+ ],
+
+ platform_apis: true,
+ min_sdk_version: "current",
+ target_sdk_version: "current",
+
+ srcs: [
+ "src/**/*.java",
+ "quickstep/src/**/*.java",
+ "go/src/**/*.java",
+ "go/quickstep/src/**/*.java",
+ ],
+
+ resource_dirs: [
+ "go/quickstep/res",
+ "go/res",
+ "quickstep/res",
+ ],
+
+ optimize: {
+ proguard_flags_files: ["proguard.flags"],
+ enabled: true,
+ },
+
+ privileged: true,
+ system_ext_specific: true,
+ overrides: [
+ "Home",
+ "Launcher2",
+ "Launcher3",
+ "Launcher3QuickStep",
+ ],
+ required: ["privapp_whitelist_com.android.launcher3"],
+
+ additional_manifests: [
+ "go/AndroidManifest.xml",
+ "go/AndroidManifest-launcher.xml",
+ "AndroidManifest-common.xml",
+ ],
+
+ manifest: "quickstep/AndroidManifest.xml",
+ jacoco: {
+ include_filter: ["com.android.launcher3.*"],
+ }
+
+}
+
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index 1bc8b28..0000000
--- a/Android.mk
+++ /dev/null
@@ -1,147 +0,0 @@
-#
-# Copyright (C) 2013 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-#
-# Build rule for Launcher3 Go app for Android Go devices.
-#
-include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
-LOCAL_MODULE_TAGS := optional
-LOCAL_STATIC_ANDROID_LIBRARIES := Launcher3CommonDepsLib
-
-LOCAL_SRC_FILES := \
- $(call all-java-files-under, src) \
- $(call all-java-files-under, src_ui_overrides) \
- $(call all-java-files-under, go/src)
-
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/go/res
-
-LOCAL_PROGUARD_FLAG_FILES := proguard.flags
-
-LOCAL_SDK_VERSION := current
-LOCAL_MIN_SDK_VERSION := 26
-LOCAL_PACKAGE_NAME := Launcher3Go
-LOCAL_PRIVILEGED_MODULE := true
-LOCAL_SYSTEM_EXT_MODULE := true
-LOCAL_OVERRIDES_PACKAGES := Home Launcher2 Launcher3 Launcher3QuickStep
-LOCAL_REQUIRED_MODULES := privapp_whitelist_com.android.launcher3
-
-LOCAL_FULL_LIBS_MANIFEST_FILES := \
- $(LOCAL_PATH)/AndroidManifest.xml \
- $(LOCAL_PATH)/AndroidManifest-common.xml
-
-LOCAL_MANIFEST_FILE := go/AndroidManifest.xml
-LOCAL_JACK_COVERAGE_INCLUDE_FILTER := com.android.launcher3.*
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_LICENSE_PACKAGE_NAME := Android Launcher3
-LOCAL_NOTICE_FILE := build/soong/licenses/LICENSE
-include $(BUILD_PACKAGE)
-
-#
-# Build rule for Quickstep app.
-#
-include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_STATIC_ANDROID_LIBRARIES := Launcher3QuickStepLib
-LOCAL_PROGUARD_ENABLED := disabled
-
-ifneq (,$(wildcard frameworks/base))
- LOCAL_PRIVATE_PLATFORM_APIS := true
-else
- LOCAL_SDK_VERSION := system_current
- LOCAL_MIN_SDK_VERSION := 26
-endif
-LOCAL_PACKAGE_NAME := Launcher3QuickStep
-LOCAL_PRIVILEGED_MODULE := true
-LOCAL_SYSTEM_EXT_MODULE := true
-LOCAL_OVERRIDES_PACKAGES := Home Launcher2 Launcher3
-LOCAL_REQUIRED_MODULES := privapp_whitelist_com.android.launcher3
-
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/quickstep/res
-
-LOCAL_FULL_LIBS_MANIFEST_FILES := \
- $(LOCAL_PATH)/quickstep/AndroidManifest-launcher.xml \
- $(LOCAL_PATH)/AndroidManifest-common.xml
-
-LOCAL_MANIFEST_FILE := quickstep/AndroidManifest.xml
-LOCAL_JACK_COVERAGE_INCLUDE_FILTER := com.android.launcher3.*
-
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_LICENSE_PACKAGE_NAME := Android Launcher3
-LOCAL_NOTICE_FILE := build/soong/licenses/LICENSE
-include $(BUILD_PACKAGE)
-
-
-#
-# Build rule for Launcher3 Go app with quickstep for Android Go devices.
-#
-include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
- SystemUI-statsd \
- SystemUISharedLib
-ifneq (,$(wildcard frameworks/base))
- LOCAL_PRIVATE_PLATFORM_APIS := true
-else
- LOCAL_SDK_VERSION := system_current
- LOCAL_MIN_SDK_VERSION := 26
-endif
-LOCAL_STATIC_ANDROID_LIBRARIES := LauncherGoResLib
-
-LOCAL_SRC_FILES := \
- $(call all-java-files-under, src) \
- $(call all-java-files-under, quickstep/src) \
- $(call all-java-files-under, go/src) \
- $(call all-java-files-under, go/quickstep/src)
-
-LOCAL_RESOURCE_DIR := \
- $(LOCAL_PATH)/go/quickstep/res \
- $(LOCAL_PATH)/go/res \
- $(LOCAL_PATH)/quickstep/res
-
-LOCAL_PROGUARD_FLAG_FILES := proguard.flags
-LOCAL_PROGUARD_ENABLED := full
-
-LOCAL_PACKAGE_NAME := Launcher3QuickStepGo
-LOCAL_PRIVILEGED_MODULE := true
-LOCAL_SYSTEM_EXT_MODULE := true
-LOCAL_OVERRIDES_PACKAGES := Home Launcher2 Launcher3 Launcher3QuickStep
-LOCAL_REQUIRED_MODULES := privapp_whitelist_com.android.launcher3
-
-LOCAL_FULL_LIBS_MANIFEST_FILES := \
- $(LOCAL_PATH)/go/AndroidManifest.xml \
- $(LOCAL_PATH)/go/AndroidManifest-launcher.xml \
- $(LOCAL_PATH)/AndroidManifest-common.xml
-
-LOCAL_MANIFEST_FILE := quickstep/AndroidManifest.xml
-LOCAL_JACK_COVERAGE_INCLUDE_FILTER := com.android.launcher3.*
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_LICENSE_PACKAGE_NAME := Android Launcher3
-LOCAL_NOTICE_FILE := build/soong/licenses/LICENSE
-include $(BUILD_PACKAGE)
-
-
-# ==================================================
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/quickstep/res/layout/taskbar_all_apps.xml b/quickstep/res/layout/taskbar_all_apps.xml
index d402469..34d4b23 100644
--- a/quickstep/res/layout/taskbar_all_apps.xml
+++ b/quickstep/res/layout/taskbar_all_apps.xml
@@ -34,6 +34,10 @@
android:visibility="gone" />
<include
+ layout="@layout/search_results_rv_layout"
+ android:visibility="gone" />
+
+ <include
layout="@layout/all_apps_rv_layout"
android:visibility="gone" />
diff --git a/quickstep/src/com/android/launcher3/taskbar/BaseTaskbarContext.java b/quickstep/src/com/android/launcher3/taskbar/BaseTaskbarContext.java
index 4e1f54c..b4052e3 100644
--- a/quickstep/src/com/android/launcher3/taskbar/BaseTaskbarContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/BaseTaskbarContext.java
@@ -19,7 +19,6 @@
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
-import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile.DeviceProfileListenable;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.util.Themes;
@@ -36,8 +35,6 @@
protected final LayoutInflater mLayoutInflater;
private final List<OnDeviceProfileChangeListener> mDPChangeListeners = new ArrayList<>();
- protected DeviceProfile mDeviceProfile;
-
public BaseTaskbarContext(Context windowContext) {
super(windowContext, Themes.getActivityThemeRes(windowContext));
mLayoutInflater = LayoutInflater.from(this).cloneInContext(this);
@@ -49,18 +46,10 @@
}
@Override
- public final DeviceProfile getDeviceProfile() {
- return mDeviceProfile;
- }
-
- @Override
public final List<OnDeviceProfileChangeListener> getOnDeviceProfileChangeListeners() {
return mDPChangeListeners;
}
- /** Updates the {@link DeviceProfile} instance to the latest representation of the screen. */
- public abstract void updateDeviceProfile(DeviceProfile dp);
-
/** Callback invoked when a drag is initiated within this context. */
public abstract void onDragStart();
diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
index cbdbdb9..5d576f7 100644
--- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
@@ -522,7 +522,7 @@
if (button.getVisibility() == View.VISIBLE) {
parent.getDescendantRectRelativeToSelf(button, mTempRect);
if (mHitboxExtender.extendedHitboxEnabled()) {
- mTempRect.bottom += mContext.mDeviceProfile.getTaskbarOffsetY();
+ mTempRect.bottom += mContext.getDeviceProfile().getTaskbarOffsetY();
}
outRegion.op(mTempRect, Op.UNION);
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index ed1001c..95da118 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -111,6 +111,7 @@
private final WindowManager mWindowManager;
private final @Nullable RoundedCorner mLeftCorner, mRightCorner;
+ private DeviceProfile mDeviceProfile;
private WindowManager.LayoutParams mWindowLayoutParams;
private boolean mIsFullscreen;
// The size we should return to when we call setTaskbarWindowFullscreen(false)
@@ -135,7 +136,7 @@
TaskbarNavButtonController buttonController, ScopedUnfoldTransitionProgressProvider
unfoldTransitionProgressProvider) {
super(windowContext);
- mDeviceProfile = dp;
+ mDeviceProfile = dp.copy(this);
final Resources resources = getResources();
@@ -198,7 +199,7 @@
new TaskbarAutohideSuspendController(this),
new TaskbarPopupController(this),
new TaskbarForceVisibleImmersiveController(this),
- new TaskbarAllAppsController(this),
+ new TaskbarAllAppsController(this, dp),
new TaskbarInsetsController(this));
}
@@ -214,8 +215,14 @@
}
@Override
+ public DeviceProfile getDeviceProfile() {
+ return mDeviceProfile;
+ }
+
+ /** Updates {@link DeviceProfile} instances for any Taskbar windows. */
public void updateDeviceProfile(DeviceProfile dp) {
- mDeviceProfile = dp;
+ mControllers.taskbarAllAppsController.updateDeviceProfile(dp);
+ mDeviceProfile = dp.copy(this);
updateIconSize(getResources());
AbstractFloatingView.closeAllOpenViewsExcept(this, false, TYPE_REBIND_SAFE);
@@ -230,7 +237,6 @@
mDeviceProfile.updateIconSize(1, resources);
float iconScale = taskbarIconSize / mDeviceProfile.iconSizePx;
mDeviceProfile.updateIconSize(iconScale, resources);
- mDeviceProfile.updateAllAppsIconSize(1, resources); // Leave all apps unscaled.
}
@VisibleForTesting
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt
index 21d7af9..6a6a693 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt
@@ -21,6 +21,7 @@
import android.view.WindowManager
import com.android.launcher3.AbstractFloatingView
import com.android.launcher3.AbstractFloatingView.TYPE_TASKBAR_ALL_APPS
+import com.android.launcher3.DeviceProfile
import com.android.launcher3.anim.AlphaUpdateListener
import com.android.launcher3.taskbar.TaskbarControllers.LoggableTaskbarController
import com.android.quickstep.KtR
@@ -38,6 +39,9 @@
val taskbarHeightForIme: Int = context.resources.getDimensionPixelSize(
KtR.dimen.taskbar_ime_size)
private val contentRegion: Region = Region()
+ private val deviceProfileChangeListener = { _: DeviceProfile ->
+ onTaskbarWindowHeightOrInsetsChanged()
+ }
// Initialized in init.
private lateinit var controllers: TaskbarControllers
@@ -63,16 +67,19 @@
onTaskbarWindowHeightOrInsetsChanged()
windowLayoutParams.insetsRoundedCornerFrame = true
+ context.addOnDeviceProfileChangeListener(deviceProfileChangeListener)
}
- fun onDestroy() {}
+ fun onDestroy() {
+ context.removeOnDeviceProfileChangeListener(deviceProfileChangeListener)
+ }
fun onTaskbarWindowHeightOrInsetsChanged() {
var reducingSize = getReducingInsetsForTaskbarInsetsHeight(
controllers.taskbarStashController.contentHeightToReportToApps)
contentRegion.set(0, reducingSize.top,
- context.dragLayer.width, windowLayoutParams.height)
+ context.deviceProfile.widthPx, windowLayoutParams.height)
windowLayoutParams.providedInternalInsets[ITYPE_EXTRA_NAVIGATION_BAR] = reducingSize
windowLayoutParams.providedInternalInsets[ITYPE_BOTTOM_MANDATORY_GESTURES] = reducingSize
reducingSize = getReducingInsetsForTaskbarInsetsHeight(
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
index ef7bab9..06262c0 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
@@ -148,7 +148,7 @@
// Config change might be handled without re-creating the taskbar
if (mTaskbarActivityContext != null) {
if (dp != null && dp.isTaskbarPresent) {
- mTaskbarActivityContext.updateDeviceProfile(dp.copy(mContext));
+ mTaskbarActivityContext.updateDeviceProfile(dp);
}
mTaskbarActivityContext.onConfigurationChanged(configDiff);
}
@@ -274,8 +274,8 @@
return;
}
- mTaskbarActivityContext = new TaskbarActivityContext(mContext, dp.copy(mContext),
- mNavButtonController, mUnfoldProgressProvider);
+ mTaskbarActivityContext = new TaskbarActivityContext(mContext, dp, mNavButtonController,
+ mUnfoldProgressProvider);
mTaskbarActivityContext.init(mSharedState);
if (mActivity != null) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java
index 0ea2aa0..51fa4d9 100644
--- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java
@@ -44,9 +44,10 @@
}
@Override
- protected BaseAllAppsAdapter getAdapter(AlphabeticalAppsList<TaskbarAllAppsContext> mAppsList,
+ protected BaseAllAppsAdapter<TaskbarAllAppsContext> createAdapter(
+ AlphabeticalAppsList<TaskbarAllAppsContext> appsList,
BaseAdapterProvider[] adapterProviders) {
- return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), mAppsList,
+ return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), appsList,
adapterProviders);
}
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java
index 1cdbdb2..e2f7522 100644
--- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java
@@ -19,7 +19,6 @@
import static android.view.KeyEvent.KEYCODE_BACK;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
-import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE;
import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_REGION;
import android.content.Context;
@@ -78,14 +77,13 @@
TaskbarStashController taskbarStashController) {
super(taskbarContext.createWindowContext(TYPE_APPLICATION_OVERLAY, null));
mTaskbarContext = taskbarContext;
- mDeviceProfile = taskbarContext.getDeviceProfile();
+ mWindowController = windowController;
mDragController = new TaskbarDragController(this);
mOnboardingPrefs = new OnboardingPrefs<>(this, Utilities.getPrefs(this));
mDragLayer = new TaskbarAllAppsDragLayer(this);
TaskbarAllAppsSlideInView slideInView = (TaskbarAllAppsSlideInView) mLayoutInflater.inflate(
R.layout.taskbar_all_apps, mDragLayer, false);
- mWindowController = windowController;
mAllAppsViewController = new TaskbarAllAppsViewController(
this,
slideInView,
@@ -102,6 +100,11 @@
}
@Override
+ public DeviceProfile getDeviceProfile() {
+ return mWindowController.getDeviceProfile();
+ }
+
+ @Override
public TaskbarDragController getDragController() {
return mDragController;
}
@@ -142,15 +145,6 @@
}
@Override
- public void updateDeviceProfile(DeviceProfile dp) {
- mDeviceProfile = dp;
-
- AbstractFloatingView.closeAllOpenViewsExcept(this, false, TYPE_REBIND_SAFE);
-
- dispatchDeviceProfileChanged();
- }
-
- @Override
public void onDragStart() {}
@Override
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java
index eaf9384..6fd98db 100644
--- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java
@@ -19,6 +19,7 @@
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
+import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE;
import android.content.Context;
import android.graphics.PixelFormat;
@@ -31,7 +32,6 @@
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
-import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.appprediction.PredictionRowView;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.data.AppInfo;
@@ -55,7 +55,7 @@
* Application data may be bound while the window does not exist, so this controller will store
* the models for the next all apps session.
*/
-public final class TaskbarAllAppsController implements OnDeviceProfileChangeListener {
+public final class TaskbarAllAppsController {
private static final String WINDOW_TITLE = "Taskbar All Apps";
@@ -70,6 +70,7 @@
}
};
+ private DeviceProfile mDeviceProfile;
private TaskbarControllers mControllers;
/** Window context for all apps if it is open. */
private @Nullable TaskbarAllAppsContext mAllAppsContext;
@@ -79,7 +80,8 @@
private int mAppsModelFlags;
private List<ItemInfo> mPredictedApps;
- public TaskbarAllAppsController(TaskbarActivityContext context) {
+ public TaskbarAllAppsController(TaskbarActivityContext context, DeviceProfile dp) {
+ mDeviceProfile = dp;
mTaskbarContext = context;
mProxyView = new TaskbarAllAppsProxyView(mTaskbarContext);
mLayoutParams = createLayoutParams();
@@ -146,7 +148,6 @@
this,
mControllers.taskbarStashController);
mAllAppsContext.getDragController().init(mControllers);
- mTaskbarContext.addOnDeviceProfileChangeListener(this);
TaskStackChangeListeners.getInstance().registerTaskStackListener(mTaskStackListener);
Optional.ofNullable(mAllAppsContext.getSystemService(WindowManager.class))
.ifPresent(m -> m.addView(mAllAppsContext.getDragLayer(), mLayoutParams));
@@ -184,13 +185,25 @@
/** Destroys the controller and any All Apps window if present. */
public void onDestroy() {
TaskStackChangeListeners.getInstance().unregisterTaskStackListener(mTaskStackListener);
- mTaskbarContext.removeOnDeviceProfileChangeListener(this);
Optional.ofNullable(mAllAppsContext)
.map(c -> c.getSystemService(WindowManager.class))
.ifPresent(m -> m.removeView(mAllAppsContext.getDragLayer()));
mAllAppsContext = null;
}
+ /** Updates {@link DeviceProfile} instance for Taskbar's All Apps window. */
+ public void updateDeviceProfile(DeviceProfile dp) {
+ mDeviceProfile = dp;
+ Optional.ofNullable(mAllAppsContext).ifPresent(c -> {
+ AbstractFloatingView.closeAllOpenViewsExcept(c, false, TYPE_REBIND_SAFE);
+ c.dispatchDeviceProfileChanged();
+ });
+ }
+
+ DeviceProfile getDeviceProfile() {
+ return mDeviceProfile;
+ }
+
private LayoutParams createLayoutParams() {
LayoutParams layoutParams = new LayoutParams(
TYPE_APPLICATION_OVERLAY,
@@ -205,11 +218,6 @@
return layoutParams;
}
- @Override
- public void onDeviceProfileChanged(DeviceProfile dp) {
- Optional.ofNullable(mAllAppsContext).ifPresent(c -> c.updateDeviceProfile(dp));
- }
-
/**
* Proxy view connecting taskbar drag layer to the all apps window.
* <p>
diff --git a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
index 088e1cf..9667108 100644
--- a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
+++ b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
@@ -266,6 +266,13 @@
RectF cropRectF = new RectF(taskViewSimulator.getCurrentCropRect());
// Move the startRect to Launcher space as floatingIconView runs in Launcher
Matrix windowToHomePositionMap = new Matrix();
+
+ // If the start rect ends up overshooting too much to the left/right offscreen, bring it
+ // back to fullscreen. This can happen when the recentsScroll value isn't aligned with
+ // the pageScroll value for a given taskView, see b/228829958#comment12
+ mRemoteTargetHandles[0].getTaskViewSimulator().getOrientationState().getOrientationHandler()
+ .fixBoundsForHomeAnimStartRect(startRect, mDp);
+
homeToWindowPositionMap.invert(windowToHomePositionMap);
windowToHomePositionMap.mapRect(startRect);
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index d7ee3cb..76513a4 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -268,6 +268,16 @@
MAIN_EXECUTOR.execute(ProxyScreenStatusProvider.INSTANCE::onScreenTurnedOn);
}
+ /**
+ * Preloads the Overview activity.
+ *
+ * This method should only be used when the All Set page of the SUW is reached to safely
+ * preload the Launcher for the SUW first reveal.
+ */
+ public void preloadOverviewForSUWAllSet() {
+ preloadOverview(false, true);
+ }
+
@Override
public void onRotationProposal(int rotation, boolean isValid) {
executeForTaskbarManager(() -> mTaskbarManager.onRotationProposal(rotation, isValid));
@@ -883,6 +893,10 @@
}
private void preloadOverview(boolean fromInit) {
+ preloadOverview(fromInit, false);
+ }
+
+ private void preloadOverview(boolean fromInit, boolean forSUWAllSet) {
if (!mDeviceState.isUserUnlocked()) {
return;
}
@@ -892,7 +906,8 @@
return;
}
- if (RestoreDbTask.isPending(this) || !mDeviceState.isUserSetupComplete()) {
+ if ((RestoreDbTask.isPending(this) && !forSUWAllSet)
+ || !mDeviceState.isUserSetupComplete()) {
// Preloading while a restore is pending may cause launcher to start the restore
// too early.
return;
diff --git a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java
index 3dab616..66ed056 100644
--- a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java
+++ b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java
@@ -149,45 +149,50 @@
}
private void startBackgroundAnimation() {
- if (Utilities.ATLEAST_S && mVibrator != null && mVibrator.areAllPrimitivesSupported(
- VibrationEffect.Composition.PRIMITIVE_THUD)) {
- if (mBackgroundAnimatorListener == null) {
- mBackgroundAnimatorListener =
- new Animator.AnimatorListener() {
- @Override
- public void onAnimationStart(Animator animation) {
- runOnUiHelperThread(() -> mVibrator.vibrate(getVibrationEffect()));
- }
-
- @Override
- public void onAnimationRepeat(Animator animation) {
- runOnUiHelperThread(() -> mVibrator.vibrate(getVibrationEffect()));
- }
-
- @Override
- public void onAnimationEnd(Animator animation) {
- runOnUiHelperThread(mVibrator::cancel);
- }
-
- @Override
- public void onAnimationCancel(Animator animation) {
- runOnUiHelperThread(mVibrator::cancel);
- }
- };
- }
- mAnimatedBackground.addAnimatorListener(mBackgroundAnimatorListener);
+ if (!Utilities.ATLEAST_S || mVibrator == null) {
+ return;
}
- mAnimatedBackground.playAnimation();
- }
+ boolean supportsThud = mVibrator.areAllPrimitivesSupported(
+ VibrationEffect.Composition.PRIMITIVE_THUD);
- /**
- * Sets up the vibration effect for the next round of animation. The parameters vary between
- * different illustrations.
- */
- private VibrationEffect getVibrationEffect() {
- return VibrationEffect.startComposition()
- .addPrimitive(VibrationEffect.Composition.PRIMITIVE_THUD, 1.0f, 50)
- .compose();
+ if (!supportsThud && !mVibrator.areAllPrimitivesSupported(
+ VibrationEffect.Composition.PRIMITIVE_TICK)) {
+ return;
+ }
+ if (mBackgroundAnimatorListener == null) {
+ VibrationEffect vibrationEffect = VibrationEffect.startComposition()
+ .addPrimitive(supportsThud
+ ? VibrationEffect.Composition.PRIMITIVE_THUD
+ : VibrationEffect.Composition.PRIMITIVE_TICK,
+ /* scale= */ 1.0f,
+ /* delay= */ 50)
+ .compose();
+
+ mBackgroundAnimatorListener =
+ new Animator.AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ runOnUiHelperThread(() -> mVibrator.vibrate(vibrationEffect));
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+ runOnUiHelperThread(() -> mVibrator.vibrate(vibrationEffect));
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ runOnUiHelperThread(mVibrator::cancel);
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ runOnUiHelperThread(mVibrator::cancel);
+ }
+ };
+ }
+ mAnimatedBackground.addAnimatorListener(mBackgroundAnimatorListener);
+ mAnimatedBackground.playAnimation();
}
@Override
@@ -203,6 +208,7 @@
mBinder = binder;
mBinder.getTaskbarManager().setSetupUIVisible(isResumed());
mBinder.setSwipeUpProxy(isResumed() ? this::createSwipeUpProxy : null);
+ mBinder.preloadOverviewForSUWAllSet();
}
@Override
diff --git a/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java b/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java
index 4757d4b..1200208 100644
--- a/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java
+++ b/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java
@@ -75,6 +75,13 @@
if (view == null) {
return;
}
+ Transaction t = new Transaction();
+ for (int i = params.length - 1; i >= 0; i--) {
+ SurfaceParams surfaceParams = params[i];
+ if (surfaceParams.surface.isValid()) {
+ surfaceParams.applyTo(t);
+ }
+ }
mLastSequenceNumber++;
final int toApplySeqNo = mLastSequenceNumber;
@@ -85,13 +92,6 @@
.sendToTarget();
return;
}
- Transaction t = new Transaction();
- for (int i = params.length - 1; i >= 0; i--) {
- SurfaceParams surfaceParams = params[i];
- if (surfaceParams.surface.isValid()) {
- surfaceParams.applyTo(t);
- }
- }
mTargetViewRootImpl.mergeWithNextTransaction(t, frame);
Message.obtain(mApplyHandler, MSG_UPDATE_SEQUENCE_NUMBER, toApplySeqNo, 0)
.sendToTarget();
diff --git a/quickstep/src/com/android/quickstep/views/FloatingTaskView.java b/quickstep/src/com/android/quickstep/views/FloatingTaskView.java
index c980d1e..45fc3af 100644
--- a/quickstep/src/com/android/quickstep/views/FloatingTaskView.java
+++ b/quickstep/src/com/android/quickstep/views/FloatingTaskView.java
@@ -1,5 +1,6 @@
package com.android.quickstep.views;
+import static com.android.launcher3.AbstractFloatingView.TYPE_TASK_MENU;
import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
import static com.android.launcher3.anim.Interpolators.LINEAR;
@@ -19,6 +20,7 @@
import androidx.annotation.Nullable;
+import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BaseActivity;
import com.android.launcher3.InsettableFrameLayout;
import com.android.launcher3.LauncherAnimUtils;
@@ -110,13 +112,19 @@
*/
public static FloatingTaskView getFloatingTaskView(StatefulActivity launcher,
View originalView, @Nullable Bitmap thumbnail, Drawable icon, RectF positionOut) {
- final BaseDragLayer dragLayer = launcher.getDragLayer();
- ViewGroup parent = (ViewGroup) dragLayer.getParent();
+ final ViewGroup dragLayer = launcher.getDragLayer();
final FloatingTaskView floatingView = (FloatingTaskView) launcher.getLayoutInflater()
- .inflate(R.layout.floating_split_select_view, parent, false);
+ .inflate(R.layout.floating_split_select_view, dragLayer, false);
floatingView.init(launcher, originalView, thumbnail, icon, positionOut);
- parent.addView(floatingView);
+ // Add this animating view underneath the existing open task menu view (if there is one)
+ View openTaskView = AbstractFloatingView.getOpenView(launcher, TYPE_TASK_MENU);
+ int openTaskViewIndex = dragLayer.indexOfChild(openTaskView);
+ if (openTaskViewIndex == -1) {
+ // Add to top if not
+ openTaskViewIndex = dragLayer.getChildCount();
+ }
+ dragLayer.addView(floatingView, openTaskViewIndex - 1);
return floatingView;
}
@@ -125,7 +133,7 @@
Utilities.getBoundsForViewInDragLayer(mActivity.getDragLayer(), originalView, viewBounds,
false /* ignoreTransform */, null /* recycle */,
mStartingPosition);
- final InsettableFrameLayout.LayoutParams lp = new InsettableFrameLayout.LayoutParams(
+ final BaseDragLayer.LayoutParams lp = new BaseDragLayer.LayoutParams(
Math.round(mStartingPosition.width()),
Math.round(mStartingPosition.height()));
initPosition(mStartingPosition, lp);
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index a2f6792..364bd59 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -34,6 +34,7 @@
import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.ACCEL_0_75;
import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL;
+import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.FINAL_FRAME;
import static com.android.launcher3.anim.Interpolators.LINEAR;
@@ -4097,6 +4098,10 @@
mSecondSplitHiddenView.setVisibility(INVISIBLE);
InteractionJankMonitorWrapper.begin(this,
InteractionJankMonitorWrapper.CUJ_SPLIT_SCREEN_ENTER, "Second tile selected");
+
+ // Fade out all other views underneath placeholders
+ ObjectAnimator tvFade = ObjectAnimator.ofFloat(this, RecentsView.CONTENT_ALPHA,1, 0);
+ pendingAnimation.add(tvFade, DEACCEL_2, SpringProperty.DEFAULT);
pendingAnimation.buildAnim().start();
return true;
}
@@ -4110,11 +4115,11 @@
mSplitInstructionsView = null;
}
if (mFirstFloatingTaskView != null) {
- mActivity.getRootView().removeView(mFirstFloatingTaskView);
+ mActivity.getDragLayer().removeView(mFirstFloatingTaskView);
mFirstFloatingTaskView = null;
}
if (mSecondFloatingTaskView != null) {
- mActivity.getRootView().removeView(mSecondFloatingTaskView);
+ mActivity.getDragLayer().removeView(mSecondFloatingTaskView);
mSecondFloatingTaskView = null;
mSecondSplitHiddenView.setVisibility(VISIBLE);
mSecondSplitHiddenView = null;
diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java
index 3803f1b..bdf21b8 100644
--- a/quickstep/src/com/android/quickstep/views/TaskMenuView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java
@@ -16,7 +16,6 @@
package com.android.quickstep.views;
-import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_UNDEFINED;
import static com.android.quickstep.views.TaskThumbnailView.DIM_ALPHA;
@@ -245,17 +244,9 @@
LayoutParams lp = (LayoutParams) menuOptionView.getLayoutParams();
mTaskView.getPagedOrientationHandler().setLayoutParamsForTaskMenuOptionItem(lp,
menuOptionView, mActivity.getDeviceProfile());
- menuOptionView.setOnClickListener(view -> {
- if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
- RecentsView recentsView = mTaskView.getRecentsView();
- recentsView.switchToScreenshot(null,
- () -> recentsView.finishRecentsAnimation(true /* toRecents */,
- false /* shouldPip */,
- () -> menuOption.onClick(view)));
- } else {
- menuOption.onClick(view);
- }
- });
+ // Set an onClick listener on each menu option. The onClick method is responsible for
+ // ending LiveTile mode on the thumbnail if needed.
+ menuOptionView.setOnClickListener(menuOption::onClick);
mOptionLayout.addView(menuOptionView);
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index d58bb7c..f0ca46a 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -1537,7 +1537,6 @@
}
public void initiateSplitSelect(SplitPositionOption splitPositionOption) {
- AbstractFloatingView.closeOpenViews(mActivity, false, TYPE_TASK_MENU);
getRecentsView().initiateSplitSelect(this, splitPositionOption.stagePosition);
}
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java b/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java
index ba93975..1df9c02 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java
@@ -26,6 +26,7 @@
import com.android.launcher3.tapl.Taskbar;
import com.android.launcher3.ui.TaplTestsLauncher3;
+import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord;
import org.junit.After;
import org.junit.Assume;
@@ -85,6 +86,7 @@
}
@Test
+ @ScreenRecord // b/231615831
@PortraitLandscape
public void testLaunchAppInSplitscreen() throws Exception {
getTaskbar().getAppIcon(TEST_APP_NAME).dragToSplitscreen(
@@ -92,6 +94,7 @@
}
@Test
+ @ScreenRecord // b/231615831
@PortraitLandscape
public void testLaunchShortcutInSplitscreen() throws Exception {
getTaskbar().getAppIcon(TEST_APP_NAME)
@@ -120,6 +123,7 @@
}
@Test
+ @ScreenRecord // b/231615831
@PortraitLandscape
public void testLaunchAppInSplitscreen_FromTaskbarAllApps() throws Exception {
getTaskbar().openAllApps()
@@ -128,6 +132,7 @@
}
@Test
+ @ScreenRecord // b/231615831
@PortraitLandscape
public void testLaunchShortcutInSplitscreen_FromTaskbarAllApps() throws Exception {
getTaskbar().openAllApps()
diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml
index 2ac7e63..d0d82d4 100644
--- a/res/layout/all_apps.xml
+++ b/res/layout/all_apps.xml
@@ -30,6 +30,10 @@
android:visibility="gone" />
<include
+ layout="@layout/search_results_rv_layout"
+ android:visibility="gone" />
+
+ <include
layout="@layout/all_apps_rv_layout"
android:visibility="gone" />
diff --git a/res/layout/search_results_rv_layout.xml b/res/layout/search_results_rv_layout.xml
new file mode 100644
index 0000000..567cb5f
--- /dev/null
+++ b/res/layout/search_results_rv_layout.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2022 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.
+ -->
+<com.android.launcher3.allapps.SearchRecyclerView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/search_results_list_view"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:clipToPadding="false"
+ android:descendantFocusability="afterDescendants"
+ android:focusable="true" />
diff --git a/res/layout/secondary_launcher.xml b/res/layout/secondary_launcher.xml
index 0fe05ee..635db14 100644
--- a/res/layout/secondary_launcher.xml
+++ b/res/layout/secondary_launcher.xml
@@ -60,6 +60,10 @@
android:visibility="gone" />
<include
+ layout="@layout/search_results_rv_layout"
+ android:visibility="gone" />
+
+ <include
layout="@layout/all_apps_rv_layout"
android:visibility="gone" />
diff --git a/res/layout/work_apps_edu.xml b/res/layout/work_apps_edu.xml
index aa7c998..eeb7f4f 100644
--- a/res/layout/work_apps_edu.xml
+++ b/res/layout/work_apps_edu.xml
@@ -16,8 +16,8 @@
<com.android.launcher3.allapps.WorkEduCard xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/work_edu_card_margin"
- android:layout_marginBottom="@dimen/work_edu_card_bottom_margin"
+ android:paddingTop="@dimen/work_edu_card_margin"
+ android:paddingBottom="@dimen/work_edu_card_bottom_margin"
android:gravity="center">
<RelativeLayout
android:layout_width="match_parent"
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index c16792a..7b2ed8b 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -31,6 +31,7 @@
<dimen name="drop_target_button_drawable_horizontal_padding">24dp</dimen>
<dimen name="drop_target_button_drawable_vertical_padding">20dp</dimen>
<dimen name="drop_target_button_gap">32dp</dimen>
+ <dimen name="drop_target_button_workspace_edge_gap">32dp</dimen>
<dimen name="drop_target_top_margin">110dp</dimen>
<dimen name="drop_target_bottom_margin">48dp</dimen>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index e7b3375..39f0a2b 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -241,6 +241,7 @@
<dimen name="drop_target_button_drawable_horizontal_padding">16dp</dimen>
<dimen name="drop_target_button_drawable_vertical_padding">8dp</dimen>
<dimen name="drop_target_button_gap">28dp</dimen>
+ <dimen name="drop_target_button_workspace_edge_gap">0dp</dimen>
<!-- the distance an icon must be dragged before button drop targets accept it -->
<dimen name="drag_distanceThreshold">30dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 2109510..a10aa19 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -44,9 +44,9 @@
<item name="isMainColorDark">false</item>
<item name="isWorkspaceDarkText">false</item>
<item name="workspaceTextColor">@color/workspace_text_color_light</item>
- <item name="workspaceShadowColor">#B0000000</item>
- <item name="workspaceAmbientShadowColor">#40000000</item>
- <item name="workspaceKeyShadowColor">#89000000</item>
+ <item name="workspaceShadowColor">#ff000000</item>
+ <item name="workspaceAmbientShadowColor">#33000000</item>
+ <item name="workspaceKeyShadowColor">#ff000000</item>
<item name="workspaceStatusBarScrim">@drawable/workspace_bg</item>
<item name="widgetsTheme">@style/WidgetContainerTheme</item>
<item name="folderDotColor">@color/folder_dot_color</item>
@@ -82,9 +82,9 @@
<style name="LauncherTheme.DarkText" parent="@style/LauncherTheme">
<item name="workspaceTextColor">@color/workspace_text_color_dark</item>
- <item name="workspaceShadowColor">@android:color/transparent</item>
- <item name="workspaceAmbientShadowColor">@android:color/transparent</item>
- <item name="workspaceKeyShadowColor">@android:color/transparent</item>
+ <item name="workspaceShadowColor">#ffffffff</item>
+ <item name="workspaceAmbientShadowColor">#33ffffff</item>
+ <item name="workspaceKeyShadowColor">#ffffffff</item>
<item name="isWorkspaceDarkText">true</item>
<item name="workspaceStatusBarScrim">@null</item>
<item name="workspaceAccentColor">@color/workspace_accent_color_dark</item>
@@ -132,9 +132,9 @@
<style name="LauncherTheme.Dark.DarkText" parent="@style/LauncherTheme.Dark">
<item name="android:colorControlHighlight">#19212121</item>
<item name="workspaceTextColor">@color/workspace_text_color_dark</item>
- <item name="workspaceShadowColor">@android:color/transparent</item>
- <item name="workspaceAmbientShadowColor">@android:color/transparent</item>
- <item name="workspaceKeyShadowColor">@android:color/transparent</item>
+ <item name="workspaceShadowColor">#ffffffff</item>
+ <item name="workspaceAmbientShadowColor">#33ffffff</item>
+ <item name="workspaceKeyShadowColor">#ffffffff</item>
<item name="isWorkspaceDarkText">true</item>
<item name="workspaceStatusBarScrim">@null</item>
<item name="workspaceAccentColor">@color/workspace_accent_color_dark</item>
@@ -250,14 +250,14 @@
<!-- Icon displayed on the workspace -->
<style name="BaseIcon.Workspace.Shadows" parent="BaseIcon">
- <item name="android:shadowRadius">2.0</item>
+ <item name="android:shadowRadius">1.0</item>
<item name="android:shadowColor">?attr/workspaceShadowColor</item>
<item name="ambientShadowColor">?attr/workspaceAmbientShadowColor</item>
- <item name="ambientShadowBlur">1.5dp</item>
+ <item name="ambientShadowBlur">1.0dp</item>
<item name="keyShadowColor">?attr/workspaceKeyShadowColor</item>
- <item name="keyShadowBlur">.5dp</item>
- <item name="keyShadowOffsetX">.5dp</item>
- <item name="keyShadowOffsetY">.5dp</item>
+ <item name="keyShadowBlur">1.0dp</item>
+ <item name="keyShadowOffsetX">0dp</item>
+ <item name="keyShadowOffsetY">0dp</item>
</style>
<!-- Intentionally empty so we can override -->
diff --git a/src/com/android/launcher3/AbstractFloatingView.java b/src/com/android/launcher3/AbstractFloatingView.java
index 90869c2..21dbc5f 100644
--- a/src/com/android/launcher3/AbstractFloatingView.java
+++ b/src/com/android/launcher3/AbstractFloatingView.java
@@ -93,6 +93,7 @@
public static final int TYPE_WIDGETS_EDUCATION_DIALOG = 1 << 15;
public static final int TYPE_TASKBAR_EDUCATION_DIALOG = 1 << 16;
public static final int TYPE_TASKBAR_ALL_APPS = 1 << 17;
+ public static final int TYPE_ADD_TO_HOME_CONFIRMATION = 1 << 18;
public static final int TYPE_ALL = TYPE_FOLDER | TYPE_ACTION_POPUP
| TYPE_WIDGETS_BOTTOM_SHEET | TYPE_WIDGET_RESIZE_FRAME | TYPE_WIDGETS_FULL_SHEET
@@ -100,7 +101,7 @@
| TYPE_OPTIONS_POPUP | TYPE_SNACKBAR | TYPE_LISTENER | TYPE_ALL_APPS_EDU
| TYPE_ICON_SURFACE | TYPE_DRAG_DROP_POPUP | TYPE_PIN_WIDGET_FROM_EXTERNAL_POPUP
| TYPE_WIDGETS_EDUCATION_DIALOG | TYPE_TASKBAR_EDUCATION_DIALOG | TYPE_TASKBAR_ALL_APPS
- | TYPE_OPTIONS_POPUP_DIALOG;
+ | TYPE_OPTIONS_POPUP_DIALOG | TYPE_ADD_TO_HOME_CONFIRMATION;
// Type of popups which should be kept open during launcher rebind
public static final int TYPE_REBIND_SAFE = TYPE_WIDGETS_FULL_SHEET
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index 8da4f05..3b24df2 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -179,7 +179,12 @@
@Override
public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
- mActive = !options.isKeyboardDrag && supportsDrop(dragObject.dragInfo);
+ if (options.isKeyboardDrag) {
+ mActive = false;
+ } else {
+ setupItemInfo(dragObject.dragInfo);
+ mActive = supportsDrop(dragObject.dragInfo);
+ }
setVisibility(mActive ? View.VISIBLE : View.GONE);
mAccessibleDrag = options.isAccessibleDrag;
@@ -191,6 +196,11 @@
return supportsDrop(dragObject.dragInfo);
}
+ /**
+ * Setups button for the specified ItemInfo.
+ */
+ protected abstract void setupItemInfo(ItemInfo info);
+
protected abstract boolean supportsDrop(ItemInfo info);
public abstract boolean supportsAccessibilityDrop(ItemInfo info, View view);
diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java
index 371bb80..95d3ad9 100644
--- a/src/com/android/launcher3/DeleteDropTarget.java
+++ b/src/com/android/launcher3/DeleteDropTarget.java
@@ -85,6 +85,9 @@
}
@Override
+ protected void setupItemInfo(ItemInfo info) {}
+
+ @Override
protected boolean supportsDrop(ItemInfo info) {
return true;
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 1cffa2a..b276397 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -217,6 +217,7 @@
public int dropTargetHorizontalPaddingPx;
public int dropTargetVerticalPaddingPx;
public int dropTargetGapPx;
+ public int dropTargetButtonWorkspaceEdgeGapPx;
// Insets
private final Rect mInsets = new Rect();
@@ -348,6 +349,8 @@
dropTargetVerticalPaddingPx = res.getDimensionPixelSize(
R.dimen.drop_target_button_drawable_vertical_padding);
dropTargetGapPx = res.getDimensionPixelSize(R.dimen.drop_target_button_gap);
+ dropTargetButtonWorkspaceEdgeGapPx = res.getDimensionPixelSize(
+ R.dimen.drop_target_button_workspace_edge_gap);
workspaceSpringLoadedBottomSpace =
res.getDimensionPixelSize(R.dimen.dynamic_grid_min_spring_loaded_space);
@@ -789,7 +792,7 @@
/**
* Updates the iconSize for allApps* variants.
*/
- public void updateAllAppsIconSize(float scale, Resources res) {
+ private void updateAllAppsIconSize(float scale, Resources res) {
allAppsBorderSpacePx = new Point(
pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].x, mMetrics, scale),
pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].y, mMetrics, scale));
@@ -802,9 +805,9 @@
allAppsCellWidthPx = pxFromDp(inv.allAppsCellSize[mTypeIndex].x, mMetrics, scale);
if (isScalableGrid) {
allAppsIconSizePx =
- pxFromDp(inv.allAppsIconSize[mTypeIndex], mMetrics);
+ pxFromDp(inv.allAppsIconSize[mTypeIndex], mMetrics, scale);
allAppsIconTextSizePx =
- pxFromSp(inv.allAppsIconTextSize[mTypeIndex], mMetrics);
+ pxFromSp(inv.allAppsIconTextSize[mTypeIndex], mMetrics, scale);
allAppsIconDrawablePaddingPx = iconDrawablePaddingOriginalPx;
} else {
float invIconSizeDp = inv.allAppsIconSize[mTypeIndex];
diff --git a/src/com/android/launcher3/DropTargetBar.java b/src/com/android/launcher3/DropTargetBar.java
index dbddb26..d908440 100644
--- a/src/com/android/launcher3/DropTargetBar.java
+++ b/src/com/android/launcher3/DropTargetBar.java
@@ -186,14 +186,13 @@
availableWidth = scaledPanelWidth - halfButtonGap / 2;
} else {
// Both buttons plus the button gap do not display past the edge of the scaled
- // workspace.
- availableWidth = (scaledPanelWidth - dp.dropTargetGapPx) / 2;
+ // workspace, less a pre-defined gap from the edge of the workspace.
+ availableWidth = scaledPanelWidth - dp.dropTargetGapPx
+ - 2 * dp.dropTargetButtonWorkspaceEdgeGapPx;
}
int widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST);
firstButton.measure(widthSpec, heightSpec);
- secondButton.measure(widthSpec, heightSpec);
-
if (!mIsVertical) {
// Remove icons and put the button's text on two lines if text is truncated.
if (firstButton.isTextTruncated(availableWidth)) {
@@ -202,6 +201,14 @@
firstButton.setPadding(horizontalPadding, verticalPadding / 2,
horizontalPadding, verticalPadding / 2);
}
+ }
+
+ if (!dp.isTwoPanels) {
+ availableWidth -= firstButton.getMeasuredWidth() + dp.dropTargetGapPx;
+ widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST);
+ }
+ secondButton.measure(widthSpec, heightSpec);
+ if (!mIsVertical) {
if (secondButton.isTextTruncated(availableWidth)) {
secondButton.setIconVisible(false);
secondButton.setTextMultiLine(true);
@@ -243,13 +250,30 @@
int buttonGap = dp.dropTargetGapPx;
ButtonDropTarget leftButton = mTempTargets[0];
- leftButton.layout(barCenter - leftButton.getMeasuredWidth() - (buttonGap / 2), 0,
- barCenter - (buttonGap / 2), leftButton.getMeasuredHeight());
-
ButtonDropTarget rightButton = mTempTargets[1];
- rightButton.layout(barCenter + (buttonGap / 2), 0,
- barCenter + (buttonGap / 2) + rightButton.getMeasuredWidth(),
- rightButton.getMeasuredHeight());
+ if (dp.isTwoPanels) {
+ leftButton.layout(barCenter - leftButton.getMeasuredWidth() - (buttonGap / 2), 0,
+ barCenter - (buttonGap / 2), leftButton.getMeasuredHeight());
+ rightButton.layout(barCenter + (buttonGap / 2), 0,
+ barCenter + (buttonGap / 2) + rightButton.getMeasuredWidth(),
+ rightButton.getMeasuredHeight());
+ } else {
+ int scaledPanelWidth = (int) (dp.getCellLayoutWidth() * scale);
+
+ int leftButtonWidth = leftButton.getMeasuredWidth();
+ int rightButtonWidth = rightButton.getMeasuredWidth();
+ int extraSpace = scaledPanelWidth - leftButtonWidth - rightButtonWidth - buttonGap;
+
+ int leftButtonStart = barCenter - (scaledPanelWidth / 2) + extraSpace / 2;
+ int leftButtonEnd = leftButtonStart + leftButtonWidth;
+ int rightButtonStart = leftButtonEnd + buttonGap;
+ int rightButtonEnd = rightButtonStart + rightButtonWidth;
+
+ leftButton.layout(leftButtonStart, 0, leftButtonEnd,
+ leftButton.getMeasuredHeight());
+ rightButton.layout(rightButtonStart, 0, rightButtonEnd,
+ rightButton.getMeasuredHeight());
+ }
}
}
@@ -318,7 +342,7 @@
}
public ButtonDropTarget[] getDropTargets() {
- return mDropTargets;
+ return getVisibility() == View.VISIBLE ? mDropTargets : new ButtonDropTarget[0];
}
@Override
diff --git a/src/com/android/launcher3/BaseRecyclerView.java b/src/com/android/launcher3/FastScrollRecyclerView.java
similarity index 94%
rename from src/com/android/launcher3/BaseRecyclerView.java
rename to src/com/android/launcher3/FastScrollRecyclerView.java
index b6d3fc5..f117069 100644
--- a/src/com/android/launcher3/BaseRecyclerView.java
+++ b/src/com/android/launcher3/FastScrollRecyclerView.java
@@ -23,6 +23,7 @@
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityNodeInfo;
+import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.android.launcher3.compat.AccessibilityManagerCompat;
@@ -36,19 +37,19 @@
* <li> Enable fast scroller.
* </ul>
*/
-public abstract class BaseRecyclerView extends RecyclerView {
+public abstract class FastScrollRecyclerView extends RecyclerView {
protected RecyclerViewFastScroller mScrollbar;
- public BaseRecyclerView(Context context) {
+ public FastScrollRecyclerView(Context context) {
this(context, null);
}
- public BaseRecyclerView(Context context, AttributeSet attrs) {
+ public FastScrollRecyclerView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
- public BaseRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) {
+ public FastScrollRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@@ -65,6 +66,7 @@
onUpdateScrollbar(0);
}
+ @Nullable
public RecyclerViewFastScroller getScrollbar() {
return mScrollbar;
}
@@ -198,4 +200,4 @@
}
scrollToPosition(0);
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 4d33eae..73be5be 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -727,15 +727,16 @@
pageScrollChanged = true;
}
- if (childCount == 0) {
- return;
- }
-
if (DEBUG) Log.d(TAG, "PagedView.onLayout()");
pageScrollChanged |= getPageScrolls(pageScrolls, true, SIMPLE_SCROLL_LOGIC);
mPageScrolls = pageScrolls;
+ if (childCount == 0) {
+ onPageScrollsInitialized();
+ return;
+ }
+
final LayoutTransition transition = getLayoutTransition();
// If the transition is running defer updating max scroll, as some empty pages could
// still be present, and a max scroll change could cause sudden jumps in scroll.
diff --git a/src/com/android/launcher3/SecondaryDropTarget.java b/src/com/android/launcher3/SecondaryDropTarget.java
index 5b037e4..f8bc1f4 100644
--- a/src/com/android/launcher3/SecondaryDropTarget.java
+++ b/src/com/android/launcher3/SecondaryDropTarget.java
@@ -6,6 +6,7 @@
import static com.android.launcher3.Launcher.REQUEST_RECONFIGURE_APPWIDGET;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;
import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.DISMISS_PREDICTION;
+import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.INVALID;
import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.RECONFIGURE;
import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.UNINSTALL;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_DISMISS_PREDICTION_UNDO;
@@ -69,6 +70,7 @@
private boolean mHadPendingAlarm;
protected int mCurrentAccessibilityAction = -1;
+
public SecondaryDropTarget(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
@@ -134,24 +136,33 @@
}
@Override
+ protected void setupItemInfo(ItemInfo info) {
+ int buttonType = getButtonType(info, getViewUnderDrag(info));
+ if (buttonType != INVALID) {
+ setupUi(buttonType);
+ }
+ }
+
+ @Override
protected boolean supportsDrop(ItemInfo info) {
- return supportsAccessibilityDrop(info, getViewUnderDrag(info));
+ return getButtonType(info, getViewUnderDrag(info)) != INVALID;
}
@Override
public boolean supportsAccessibilityDrop(ItemInfo info, View view) {
+ return getButtonType(info, view) != INVALID;
+ }
+
+ private int getButtonType(ItemInfo info, View view) {
if (view instanceof AppWidgetHostView) {
if (getReconfigurableWidgetId(view) != INVALID_APPWIDGET_ID) {
- setupUi(RECONFIGURE);
- return true;
+ return RECONFIGURE;
}
- return false;
+ return INVALID;
} else if (FeatureFlags.ENABLE_PREDICTION_DISMISS.get() && info.isPredictedItem()) {
- setupUi(DISMISS_PREDICTION);
- return true;
+ return DISMISS_PREDICTION;
}
- setupUi(UNINSTALL);
Boolean uninstallDisabled = mUninstallDisabledCache.get(info.user);
if (uninstallDisabled == null) {
UserManager userManager =
@@ -165,16 +176,20 @@
mCacheExpireAlarm.setAlarm(CACHE_EXPIRE_TIMEOUT);
mCacheExpireAlarm.setOnAlarmListener(this);
if (uninstallDisabled) {
- return false;
+ return INVALID;
}
if (info instanceof ItemInfoWithIcon) {
ItemInfoWithIcon iconInfo = (ItemInfoWithIcon) info;
- if ((iconInfo.runtimeStatusFlags & FLAG_SYSTEM_MASK) != 0) {
- return (iconInfo.runtimeStatusFlags & FLAG_SYSTEM_NO) != 0;
+ if ((iconInfo.runtimeStatusFlags & FLAG_SYSTEM_MASK) != 0
+ && (iconInfo.runtimeStatusFlags & FLAG_SYSTEM_NO) == 0) {
+ return INVALID;
}
}
- return getUninstallTarget(info) != null;
+ if (getUninstallTarget(info) == null) {
+ return INVALID;
+ }
+ return UNINSTALL;
}
/**
diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
index 44d57d7..79214e8 100644
--- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
@@ -60,6 +60,7 @@
public static final int DISMISS_PREDICTION = R.id.action_dismiss_prediction;
public static final int PIN_PREDICTION = R.id.action_pin_prediction;
public static final int RECONFIGURE = R.id.action_reconfigure;
+ public static final int INVALID = -1;
protected static final int ADD_TO_WORKSPACE = R.id.action_add_to_workspace;
protected static final int MOVE = R.id.action_move;
protected static final int MOVE_TO_WORKSPACE = R.id.action_move_to_workspace;
diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
index 47f2dd5..2368cf7 100644
--- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
@@ -82,7 +82,7 @@
OnClickListener marketSearchClickListener = (v) -> mActivityContext.startActivitySafely(v,
marketSearchIntent, null);
for (int i = 0; i < mAH.size(); i++) {
- mAH.get(i).adapter.setLastSearchQuery(query, marketSearchClickListener);
+ mAH.get(i).mAdapter.setLastSearchQuery(query, marketSearchClickListener);
}
mIsSearching = true;
rebindAdapters();
@@ -101,7 +101,7 @@
* Sets results list for search
*/
public void setSearchResults(ArrayList<AdapterItem> results) {
- if (getApps().setSearchResults(results)) {
+ if (getSearchResultList().setSearchResults(results)) {
for (int i = 0; i < mAH.size(); i++) {
if (mAH.get(i).mRecyclerView != null) {
mAH.get(i).mRecyclerView.onSearchResultsChanged();
@@ -148,7 +148,7 @@
@Override
public String getDescription() {
- if (!mUsingTabs && mIsSearching) {
+ if (!mUsingTabs && isSearching()) {
return getContext().getString(R.string.all_apps_search_results);
} else {
return super.getDescription();
@@ -156,8 +156,13 @@
}
@Override
- protected boolean showTabs() {
- return super.showTabs() && !mIsSearching;
+ protected boolean shouldShowTabs() {
+ return super.shouldShowTabs() && !isSearching();
+ }
+
+ @Override
+ public boolean isSearching() {
+ return mIsSearching;
}
@Override
@@ -179,15 +184,19 @@
}
@Override
- protected View replaceRVContainer(boolean showTabs) {
- View rvContainer = super.replaceRVContainer(showTabs);
+ protected View replaceAppsRVContainer(boolean showTabs) {
+ View rvContainer = super.replaceAppsRVContainer(showTabs);
removeCustomRules(rvContainer);
+ removeCustomRules(getSearchRecyclerView());
if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
alignParentTop(rvContainer, showTabs);
+ alignParentTop(getSearchRecyclerView(), /* tabs= */ false);
layoutAboveSearchContainer(rvContainer);
+ layoutAboveSearchContainer(getSearchRecyclerView());
} else {
layoutBelowSearchContainer(rvContainer, showTabs);
+ layoutBelowSearchContainer(getSearchRecyclerView(), /* tabs= */ false);
}
return rvContainer;
@@ -214,7 +223,7 @@
float prog = Utilities.boundToRange((float) scrolledOffset / mHeaderThreshold, 0f, 1f);
boolean bgVisible = mSearchUiManager.getBackgroundVisibility();
- if (scrolledOffset == 0 && !mIsSearching) {
+ if (scrolledOffset == 0 && !isSearching()) {
bgVisible = true;
} else if (scrolledOffset > mHeaderThreshold) {
bgVisible = false;
@@ -248,7 +257,7 @@
int topMargin = getContext().getResources().getDimensionPixelSize(
R.dimen.all_apps_header_top_margin);
if (includeTabsMargin) {
- topMargin = topMargin + getContext().getResources().getDimensionPixelSize(
+ topMargin += getContext().getResources().getDimensionPixelSize(
R.dimen.all_apps_header_pill_height);
}
layoutParams.topMargin = topMargin;
@@ -289,9 +298,9 @@
}
@Override
- protected BaseAllAppsAdapter getAdapter(AlphabeticalAppsList<T> mAppsList,
+ protected BaseAllAppsAdapter<T> createAdapter(AlphabeticalAppsList<T> appsList,
BaseAdapterProvider[] adapterProviders) {
- return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), mAppsList,
+ return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), appsList,
adapterProviders);
}
}
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index 88e7fc0..af17cf7 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -35,8 +35,8 @@
import androidx.recyclerview.widget.RecyclerView;
-import com.android.launcher3.BaseRecyclerView;
import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.FastScrollRecyclerView;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
@@ -50,13 +50,13 @@
/**
* A RecyclerView with custom fast scroll support for the all apps view.
*/
-public class AllAppsRecyclerView extends BaseRecyclerView {
- private static final String TAG = "AllAppsContainerView";
+public class AllAppsRecyclerView extends FastScrollRecyclerView {
+ protected static final String TAG = "AllAppsRecyclerView";
private static final boolean DEBUG = false;
private static final boolean DEBUG_LATENCY = Utilities.isPropertyEnabled(SEARCH_LOGGING);
- private AlphabeticalAppsList<?> mApps;
- private final int mNumAppsPerRow;
+ protected AlphabeticalAppsList<?> mApps;
+ protected final int mNumAppsPerRow;
// The specific view heights that we use to calculate scroll
private final SparseIntArray mViewHeights = new SparseIntArray();
@@ -91,8 +91,8 @@
};
// The empty-search result background
- private AllAppsBackgroundDrawable mEmptySearchBackground;
- private int mEmptySearchBackgroundTopOffset;
+ protected AllAppsBackgroundDrawable mEmptySearchBackground;
+ protected int mEmptySearchBackgroundTopOffset;
public AllAppsRecyclerView(Context context) {
this(context, null);
@@ -127,7 +127,7 @@
return mApps;
}
- private void updatePoolSize() {
+ protected void updatePoolSize() {
DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile();
RecyclerView.RecycledViewPool pool = getRecycledViewPool();
int approxRows = (int) Math.ceil(grid.availableHeightPx / grid.allAppsIconSizePx);
@@ -152,8 +152,8 @@
Log.d(TAG, "onDraw at = " + System.currentTimeMillis());
}
if (DEBUG_LATENCY) {
- Log.d(SEARCH_LOGGING,
- "-- Recycle view onDraw, time stamp = " + System.currentTimeMillis());
+ Log.d(SEARCH_LOGGING, getClass().getSimpleName() + " onDraw; time stamp = "
+ + System.currentTimeMillis());
}
super.onDraw(c);
}
@@ -342,13 +342,6 @@
}
@Override
- public boolean supportsFastScrolling() {
- // Only allow fast scrolling when the user is not searching, since the results are not
- // grouped in a meaningful order
- return !mApps.hasFilter();
- }
-
- @Override
public int getCurrentScrollY() {
// Return early if there are no items or we haven't been measured
List<AllAppsGridAdapter.AdapterItem> items = mApps.getAdapterItems();
@@ -358,7 +351,7 @@
// Calculate the y and offset for the item
View child = getChildAt(0);
- int position = getChildPosition(child);
+ int position = getChildAdapterPosition(child);
if (position == NO_POSITION) {
return -1;
}
@@ -448,14 +441,4 @@
public boolean hasOverlappingRendering() {
return false;
}
-
- /**
- * Returns distance between left and right app icons
- */
- public int getTabWidth() {
- DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile();
- int totalWidth = getMeasuredWidth() - getPaddingLeft() - getPaddingRight();
- int iconPadding = totalWidth / grid.numShownAllAppsColumns - grid.allAppsIconSizePx;
- return totalWidth - iconPadding - grid.allAppsIconDrawablePaddingPx;
- }
}
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 3600bd2..a4a2085 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -84,7 +84,7 @@
@Override
public Float get(AllAppsTransitionController controller) {
if (controller.mIsTablet) {
- return controller.mAppsView.getRecyclerViewContainer().getTranslationY();
+ return controller.mAppsView.getActiveRecyclerView().getTranslationY();
} else {
return controller.getAppsViewPullbackTranslationY().get(
controller.mAppsView);
@@ -94,8 +94,7 @@
@Override
public void setValue(AllAppsTransitionController controller, float translation) {
if (controller.mIsTablet) {
- controller.mAppsView.getRecyclerViewContainer().setTranslationY(
- translation);
+ controller.mAppsView.getActiveRecyclerView().setTranslationY(translation);
} else {
controller.getAppsViewPullbackTranslationY().set(controller.mAppsView,
translation);
@@ -109,7 +108,7 @@
@Override
public Float get(AllAppsTransitionController controller) {
if (controller.mIsTablet) {
- return controller.mAppsView.getRecyclerViewContainer().getAlpha();
+ return controller.mAppsView.getActiveRecyclerView().getAlpha();
} else {
return controller.getAppsViewPullbackAlpha().getValue();
}
@@ -118,7 +117,7 @@
@Override
public void setValue(AllAppsTransitionController controller, float alpha) {
if (controller.mIsTablet) {
- controller.mAppsView.getRecyclerViewContainer().setAlpha(alpha);
+ controller.mAppsView.getActiveRecyclerView().setAlpha(alpha);
} else {
controller.getAppsViewPullbackAlpha().setValue(alpha);
}
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index 4ccfd39..45a567d 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -21,6 +21,7 @@
import android.content.Context;
+import androidx.annotation.Nullable;
import androidx.recyclerview.widget.DiffUtil;
import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem;
@@ -72,6 +73,7 @@
// The set of apps from the system
private final List<AppInfo> mApps = new ArrayList<>();
+ @Nullable
private final AllAppsStore mAllAppsStore;
// The number of results in current adapter
@@ -89,14 +91,16 @@
private int mNumAppRowsInAdapter;
private Predicate<ItemInfo> mItemFilter;
- public AlphabeticalAppsList(Context context, AllAppsStore appsStore,
+ public AlphabeticalAppsList(Context context, @Nullable AllAppsStore appsStore,
WorkAdapterProvider adapterProvider) {
mAllAppsStore = appsStore;
mActivityContext = ActivityContext.lookupContext(context);
mAppNameComparator = new AppInfoComparator(context);
mWorkAdapterProvider = adapterProvider;
mNumAppsPerRowAllApps = mActivityContext.getDeviceProfile().inv.numAllAppsColumns;
- mAllAppsStore.addUpdateListener(this);
+ if (mAllAppsStore != null) {
+ mAllAppsStore.addUpdateListener(this);
+ }
}
public void updateItemFilter(Predicate<ItemInfo> itemFilter) {
@@ -162,9 +166,9 @@
}
/**
- * Returns whether there are is a filter set.
+ * Returns whether there are search results which will hide the A-Z list.
*/
- public boolean hasFilter() {
+ public boolean hasSearchResults() {
return !mSearchResults.isEmpty();
}
@@ -172,7 +176,7 @@
* Returns whether there are no filtered results.
*/
public boolean hasNoFilteredResults() {
- return hasFilter() && mAccessibilityResultsCount == 0;
+ return hasSearchResults() && mAccessibilityResultsCount == 0;
}
/**
@@ -195,11 +199,14 @@
*/
@Override
public void onAppsUpdated() {
+ if (mAllAppsStore == null) {
+ return;
+ }
// Sort the list of apps
mApps.clear();
Stream<AppInfo> appSteam = Stream.of(mAllAppsStore.getApps());
- if (!hasFilter() && mItemFilter != null) {
+ if (!hasSearchResults() && mItemFilter != null) {
appSteam = appSteam.filter(mItemFilter);
}
appSteam = appSteam.sorted(mAppNameComparator);
@@ -240,7 +247,18 @@
// Recreate the filtered and sectioned apps (for convenience for the grid layout) from the
// ordered set of sections
- if (!hasFilter()) {
+ if (hasSearchResults()) {
+ mAdapterItems.addAll(mSearchResults);
+ if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
+ // Append the search market item
+ if (hasNoFilteredResults()) {
+ mAdapterItems.add(new AdapterItem(VIEW_TYPE_EMPTY_SEARCH));
+ } else {
+ mAdapterItems.add(new AdapterItem(VIEW_TYPE_ALL_APPS_DIVIDER));
+ }
+ mAdapterItems.add(new AdapterItem(VIEW_TYPE_SEARCH_MARKET));
+ }
+ } else {
int position = 0;
if (mWorkAdapterProvider != null) {
position += mWorkAdapterProvider.addWorkItems(mAdapterItems);
@@ -260,17 +278,6 @@
}
position++;
}
- } else {
- mAdapterItems.addAll(mSearchResults);
- if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
- // Append the search market item
- if (hasNoFilteredResults()) {
- mAdapterItems.add(new AdapterItem(VIEW_TYPE_EMPTY_SEARCH));
- } else {
- mAdapterItems.add(new AdapterItem(VIEW_TYPE_ALL_APPS_DIVIDER));
- }
- mAdapterItems.add(new AdapterItem(VIEW_TYPE_SEARCH_MARKET));
- }
}
mAccessibilityResultsCount = (int) mAdapterItems.stream()
.filter(AdapterItem::isCountedForAccessibility).count();
diff --git a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
index fc52797..74b9014 100644
--- a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
@@ -63,6 +63,7 @@
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ActivityContext;
+import com.android.launcher3.views.BaseDragLayer;
import com.android.launcher3.views.RecyclerViewFastScroller;
import com.android.launcher3.views.ScrimView;
import com.android.launcher3.views.SpringRelativeLayout;
@@ -83,7 +84,7 @@
OnDeviceProfileChangeListener, OnActivePageChangedListener,
ScrimView.ScrimDrawingController {
- private static final String BUNDLE_KEY_CURRENT_PAGE = "launcher.allapps.current_page";
+ protected static final String BUNDLE_KEY_CURRENT_PAGE = "launcher.allapps.current_page";
public static final float PULL_MULTIPLIER = .02f;
public static final float FLING_VELOCITY_MULTIPLIER = 1200f;
@@ -112,6 +113,7 @@
private int mNavBarScrimHeight = 0;
private AllAppsPagedView mViewPager;
+ private SearchRecyclerView mSearchRecyclerView;
protected FloatingHeaderView mHeader;
private View mBottomSheetBackground;
@@ -144,9 +146,10 @@
mActivityContext.getSystemService(UserManager.class),
this,
Utilities.getPrefs(mActivityContext), mActivityContext.getDeviceProfile());
- mAH = Arrays.asList(null, null);
- mAH.set(AdapterHolder.MAIN, new AdapterHolder(false /* isWork */));
- mAH.set(AdapterHolder.WORK, new AdapterHolder(true /* isWork */));
+ mAH = Arrays.asList(null, null, null);
+ mAH.set(AdapterHolder.MAIN, new AdapterHolder(AdapterHolder.MAIN));
+ mAH.set(AdapterHolder.WORK, new AdapterHolder(AdapterHolder.WORK));
+ mAH.set(AdapterHolder.SEARCH, new AdapterHolder(AdapterHolder.SEARCH));
mNavBarScrimPaint = new Paint();
mNavBarScrimPaint.setColor(Themes.getAttrColor(context, R.attr.allAppsNavBarScrimColor));
@@ -178,7 +181,7 @@
Bundle state = (Bundle) sparseArray.get(R.id.work_tab_state_id, null);
if (state != null) {
int currentPage = state.getInt(BUNDLE_KEY_CURRENT_PAGE, 0);
- if (currentPage != 0 && mViewPager != null) {
+ if (currentPage == AdapterHolder.WORK && mViewPager != null) {
mViewPager.setCurrentPage(currentPage);
rebindAdapters();
} else {
@@ -201,7 +204,7 @@
*/
public void setOnIconLongClickListener(OnLongClickListener listener) {
for (AdapterHolder holder : mAH) {
- holder.adapter.setOnIconLongClickListener(listener);
+ holder.mAdapter.setOnIconLongClickListener(listener);
}
}
@@ -216,7 +219,7 @@
@Override
public void onDeviceProfileChanged(DeviceProfile dp) {
for (AdapterHolder holder : mAH) {
- holder.adapter.setAppsPerRow(dp.numShownAllAppsColumns);
+ holder.mAdapter.setAppsPerRow(dp.numShownAllAppsColumns);
if (holder.mRecyclerView != null) {
// Remove all views and clear the pool, while keeping the data same. After this
// call, all the viewHolders will be recreated.
@@ -233,7 +236,7 @@
private void onAppsUpdated() {
mHasWorkApps = Stream.of(mAllAppsStore.getApps()).anyMatch(mWorkManager.getMatcher());
- if (!mAH.get(AdapterHolder.MAIN).mAppsList.hasFilter()) {
+ if (!isSearching()) {
rebindAdapters();
if (mHasWorkApps) {
mWorkManager.reset();
@@ -245,30 +248,32 @@
* Returns whether the view itself will handle the touch event or not.
*/
public boolean shouldContainerScroll(MotionEvent ev) {
+ BaseDragLayer dragLayer = mActivityContext.getDragLayer();
// Scroll if not within the container view (e.g. over large-screen scrim).
- if (!mActivityContext.getDragLayer().isEventOverView(this, ev)) {
+ if (!dragLayer.isEventOverView(getVisibleContainerView(), ev)) {
return true;
}
- if (mActivityContext.getDragLayer().isEventOverView(mBottomSheetHandleArea, ev)) {
+ if (dragLayer.isEventOverView(mBottomSheetHandleArea, ev)) {
return true;
}
AllAppsRecyclerView rv = getActiveRecyclerView();
if (rv == null) {
return true;
}
- if (rv.getScrollbar().getThumbOffsetY() >= 0
- && mActivityContext.getDragLayer().isEventOverView(rv.getScrollbar(), ev)) {
+ if (rv.getScrollbar() != null
+ && rv.getScrollbar().getThumbOffsetY() >= 0
+ && dragLayer.isEventOverView(rv.getScrollbar(), ev)) {
return false;
}
- return rv.shouldContainerScroll(ev, mActivityContext.getDragLayer());
+ return rv.shouldContainerScroll(ev, dragLayer);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
AllAppsRecyclerView rv = getActiveRecyclerView();
- if (rv != null && rv.getScrollbar().isHitInParent(ev.getX(), ev.getY(),
- mFastScrollerOffset)) {
+ if (rv != null && rv.getScrollbar() != null
+ && rv.getScrollbar().isHitInParent(ev.getX(), ev.getY(), mFastScrollerOffset)) {
mTouchHandler = rv.getScrollbar();
} else {
mTouchHandler = null;
@@ -284,8 +289,8 @@
public boolean onTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
AllAppsRecyclerView rv = getActiveRecyclerView();
- if (rv != null && rv.getScrollbar().isHitInParent(ev.getX(), ev.getY(),
- mFastScrollerOffset)) {
+ if (rv != null && rv.getScrollbar() != null
+ && rv.getScrollbar().isHitInParent(ev.getX(), ev.getY(), mFastScrollerOffset)) {
mTouchHandler = rv.getScrollbar();
} else {
mTouchHandler = null;
@@ -316,8 +321,16 @@
return getContext().getString(R.string.all_apps_button_label);
}
- /** The current recycler view visible in the container. */
+ /** The current active recycler view (A-Z list from one of the profiles, or search results). */
public AllAppsRecyclerView getActiveRecyclerView() {
+ if (isSearching()) {
+ return getSearchRecyclerView();
+ }
+ return getActiveAppsRecyclerView();
+ }
+
+ /** The current apps recycler view in the container. */
+ private AllAppsRecyclerView getActiveAppsRecyclerView() {
if (!mUsingTabs || isPersonalTab()) {
return mAH.get(AdapterHolder.MAIN).mRecyclerView;
} else {
@@ -325,6 +338,19 @@
}
}
+ /**
+ * The container for A-Z apps (the ViewPager for main+work tabs, or main RV). This is currently
+ * hidden while searching.
+ **/
+ private View getAppsRecyclerViewContainer() {
+ return mViewPager != null ? mViewPager : findViewById(R.id.apps_list_view);
+ }
+
+ /** The RV for search results, which is hidden while A-Z apps are visible. */
+ public SearchRecyclerView getSearchRecyclerView() {
+ return mSearchRecyclerView;
+ }
+
protected boolean isPersonalTab() {
return mViewPager == null || mViewPager.getNextPage() == 0;
}
@@ -372,6 +398,9 @@
});
mHeader = findViewById(R.id.all_apps_header);
+ mSearchRecyclerView = findViewById(R.id.search_results_list_view);
+ mAH.get(AdapterHolder.SEARCH).setup(mSearchRecyclerView,
+ /* Filter out A-Z apps */ itemInfo -> false);
rebindAdapters(true /* force */);
mBottomSheetBackground = findViewById(R.id.bottom_sheet_background);
@@ -388,7 +417,7 @@
mInsets.set(insets);
DeviceProfile grid = mActivityContext.getDeviceProfile();
- applyAdapterPaddings(grid);
+ applyAdapterSideAndBottomPaddings(grid);
MarginLayoutParams mlp = (MarginLayoutParams) getLayoutParams();
mlp.leftMargin = insets.left;
@@ -415,7 +444,7 @@
@Override
public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) {
mNavBarScrimHeight = getNavBarScrimHeight(insets);
- applyAdapterPaddings(mActivityContext.getDeviceProfile());
+ applyAdapterSideAndBottomPaddings(mActivityContext.getDeviceProfile());
return super.dispatchApplyWindowInsets(insets);
}
@@ -434,15 +463,23 @@
}
protected void rebindAdapters(boolean force) {
- boolean showTabs = showTabs();
+ updateSearchResultsVisibility();
+
+ boolean showTabs = shouldShowTabs();
if (showTabs == mUsingTabs && !force) {
return;
}
- // replaceRVcontainer() needs to use both mUsingTabs value to remove the old view AND
+ if (isSearching()) {
+ mUsingTabs = showTabs;
+ mWorkManager.detachWorkModeSwitch();
+ return;
+ }
+
+ // replaceAppsRVcontainer() needs to use both mUsingTabs value to remove the old view AND
// showTabs value to create new view. Hence the mUsingTabs new value assignment MUST happen
// after this call.
- replaceRVContainer(showTabs);
+ replaceAppsRVContainer(showTabs);
mUsingTabs = showTabs;
mAllAppsStore.unregisterIconContainer(mAH.get(AdapterHolder.MAIN).mRecyclerView);
@@ -483,13 +520,27 @@
mAllAppsStore.registerIconContainer(mAH.get(AdapterHolder.WORK).mRecyclerView);
}
- private void applyAdapterPaddings(DeviceProfile grid) {
- int bottomPadding = Math.max(mInsets.bottom, mNavBarScrimHeight);
- for (int i = 0; i < mAH.size(); i++) {
- mAH.get(i).mPadding.bottom = bottomPadding;
- mAH.get(i).mPadding.left = mAH.get(i).mPadding.right = grid.allAppsLeftRightPadding;
- mAH.get(i).applyPadding();
+ private void updateSearchResultsVisibility() {
+ if (isSearching()) {
+ getSearchRecyclerView().setVisibility(VISIBLE);
+ getAppsRecyclerViewContainer().setVisibility(GONE);
+ } else {
+ getSearchRecyclerView().setVisibility(GONE);
+ getAppsRecyclerViewContainer().setVisibility(VISIBLE);
}
+ if (mHeader.isSetUp()) {
+ mHeader.setActiveRV(getCurrentPage());
+ }
+ }
+
+ private void applyAdapterSideAndBottomPaddings(DeviceProfile grid) {
+ int bottomPadding = Math.max(mInsets.bottom, mNavBarScrimHeight);
+ mAH.forEach(adapterHolder -> {
+ adapterHolder.mPadding.bottom = bottomPadding;
+ adapterHolder.mPadding.left =
+ adapterHolder.mPadding.right = grid.allAppsLeftRightPadding;
+ adapterHolder.applyPadding();
+ });
}
private void setDeviceManagementResources() {
@@ -502,18 +553,23 @@
}
}
- protected boolean showTabs() {
+ protected boolean shouldShowTabs() {
return mHasWorkApps;
}
- protected View replaceRVContainer(boolean showTabs) {
- for (AdapterHolder adapterHolder : mAH) {
+ protected boolean isSearching() {
+ return false;
+ }
+
+ protected View replaceAppsRVContainer(boolean showTabs) {
+ for (int i = AdapterHolder.MAIN; i <= AdapterHolder.WORK; i++) {
+ AdapterHolder adapterHolder = mAH.get(i);
if (adapterHolder.mRecyclerView != null) {
adapterHolder.mRecyclerView.setLayoutManager(null);
adapterHolder.mRecyclerView.setAdapter(null);
}
}
- View oldView = getRecyclerViewContainer();
+ View oldView = getAppsRecyclerViewContainer();
int index = indexOfChild(oldView);
removeView(oldView);
int layout = showTabs ? R.layout.all_apps_tabs : R.layout.all_apps_rv_layout;
@@ -534,13 +590,8 @@
return newView;
}
- public View getRecyclerViewContainer() {
- return mViewPager != null ? mViewPager : findViewById(R.id.apps_list_view);
- }
-
@Override
public void onActivePageChanged(int currentActivePage) {
- mHeader.setMainActive(currentActivePage == AdapterHolder.MAIN);
if (mAH.get(currentActivePage).mRecyclerView != null) {
mAH.get(currentActivePage).mRecyclerView.bindFastScrollbar();
}
@@ -569,8 +620,8 @@
return isDescendantViewVisible(R.id.tab_work);
}
- public AlphabeticalAppsList<T> getApps() {
- return mAH.get(AdapterHolder.MAIN).mAppsList;
+ public AlphabeticalAppsList<T> getSearchResultList() {
+ return mAH.get(AdapterHolder.SEARCH).mAppsList;
}
public FloatingHeaderView getFloatingHeaderView() {
@@ -579,35 +630,40 @@
@VisibleForTesting
public View getContentView() {
- return mViewPager == null ? getActiveRecyclerView() : mViewPager;
+ return isSearching() ? getSearchRecyclerView() : getAppsRecyclerViewContainer();
}
/** The current page visible in all apps. */
public int getCurrentPage() {
- return mViewPager != null ? mViewPager.getCurrentPage() : AdapterHolder.MAIN;
+ return isSearching()
+ ? AdapterHolder.SEARCH
+ : mViewPager == null ? AdapterHolder.MAIN : mViewPager.getNextPage();
}
- /** The scroll bar for the active recycler view. */
+ /** The scroll bar for the active apps recycler view. */
public RecyclerViewFastScroller getScrollBar() {
- AllAppsRecyclerView rv = getActiveRecyclerView();
+ AllAppsRecyclerView rv = getActiveAppsRecyclerView();
return rv == null ? null : rv.getScrollbar();
}
void setupHeader() {
mHeader.setVisibility(View.VISIBLE);
+ boolean tabsHidden = !mUsingTabs;
mHeader.setup(
mAH.get(AdapterHolder.MAIN).mRecyclerView,
mAH.get(AdapterHolder.WORK).mRecyclerView,
- mAH.get(AdapterHolder.WORK).mRecyclerView == null);
+ (SearchRecyclerView) mAH.get(AdapterHolder.SEARCH).mRecyclerView,
+ getCurrentPage(),
+ tabsHidden);
int padding = mHeader.getMaxTranslation();
- for (int i = 0; i < mAH.size(); i++) {
- mAH.get(i).mPadding.top = padding;
- mAH.get(i).applyPadding();
- if (mAH.get(i).mRecyclerView != null) {
- mAH.get(i).mRecyclerView.scrollToTop();
+ mAH.forEach(adapterHolder -> {
+ adapterHolder.mPadding.top = padding;
+ adapterHolder.applyPadding();
+ if (adapterHolder.mRecyclerView != null) {
+ adapterHolder.mRecyclerView.scrollToTop();
}
- }
+ });
}
public boolean isHeaderVisible() {
@@ -623,7 +679,7 @@
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
- float distance = (float) ((1 - progress) * getHeight()); // px
+ float distance = (1 - progress) * getHeight(); // px
float settleVelocity = Math.min(0, distance
/ (AllAppsTransitionController.INTERP_COEFF * animator.getDuration())
+ velocity);
@@ -702,38 +758,47 @@
return ColorUtils.blendARGB(mScrimColor, mHeaderProtectionColor, blendRatio);
}
- protected abstract BaseAllAppsAdapter getAdapter(AlphabeticalAppsList<T> mAppsList,
+ protected abstract BaseAllAppsAdapter<T> createAdapter(AlphabeticalAppsList<T> mAppsList,
BaseAdapterProvider[] adapterProviders);
protected int getHeaderBottom() {
return (int) getTranslationY();
}
+ /**
+ * Returns a view that denotes the visible part of all apps container view.
+ */
+ public View getVisibleContainerView() {
+ return mActivityContext.getDeviceProfile().isTablet ? mBottomSheetBackground : this;
+ }
+
/** Holds a {@link BaseAllAppsAdapter} and related fields. */
public class AdapterHolder {
public static final int MAIN = 0;
public static final int WORK = 1;
+ public static final int SEARCH = 2;
- private final boolean mIsWork;
- public final BaseAllAppsAdapter<T> adapter;
+ private final int mType;
+ public final BaseAllAppsAdapter<T> mAdapter;
final RecyclerView.LayoutManager mLayoutManager;
final AlphabeticalAppsList<T> mAppsList;
final Rect mPadding = new Rect();
AllAppsRecyclerView mRecyclerView;
- AdapterHolder(boolean isWork) {
- mIsWork = isWork;
- mAppsList = new AlphabeticalAppsList<>(mActivityContext, mAllAppsStore,
- isWork ? mWorkManager.getAdapterProvider() : null);
+ AdapterHolder(int type) {
+ mType = type;
+ mAppsList = new AlphabeticalAppsList<>(mActivityContext,
+ isSearch() ? null : mAllAppsStore,
+ isWork() ? mWorkManager.getAdapterProvider() : null);
BaseAdapterProvider[] adapterProviders =
- isWork ? new BaseAdapterProvider[]{mMainAdapterProvider,
+ isWork() ? new BaseAdapterProvider[]{mMainAdapterProvider,
mWorkManager.getAdapterProvider()}
: new BaseAdapterProvider[]{mMainAdapterProvider};
- adapter = getAdapter(mAppsList, adapterProviders);
- mAppsList.setAdapter(adapter);
- mLayoutManager = adapter.getLayoutManager();
+ mAdapter = createAdapter(mAppsList, adapterProviders);
+ mAppsList.setAdapter(mAdapter);
+ mLayoutManager = mAdapter.getLayoutManager();
}
void setup(@NonNull View rv, @Nullable Predicate<ItemInfo> matcher) {
@@ -742,33 +807,34 @@
mRecyclerView.setEdgeEffectFactory(createEdgeEffectFactory());
mRecyclerView.setApps(mAppsList);
mRecyclerView.setLayoutManager(mLayoutManager);
- mRecyclerView.setAdapter(adapter);
+ mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setHasFixedSize(true);
// No animations will occur when changes occur to the items in this RecyclerView.
mRecyclerView.setItemAnimator(null);
mRecyclerView.addOnScrollListener(mScrollListener);
FocusedItemDecorator focusedItemDecorator = new FocusedItemDecorator(mRecyclerView);
mRecyclerView.addItemDecoration(focusedItemDecorator);
- adapter.setIconFocusListener(focusedItemDecorator.getFocusListener());
+ mAdapter.setIconFocusListener(focusedItemDecorator.getFocusListener());
applyPadding();
}
void applyPadding() {
if (mRecyclerView != null) {
int bottomOffset = 0;
- if (mIsWork && mWorkManager.getWorkModeSwitch() != null) {
+ if (isWork() && mWorkManager.getWorkModeSwitch() != null) {
bottomOffset = mInsets.bottom + mWorkManager.getWorkModeSwitch().getHeight();
}
mRecyclerView.setPadding(mPadding.left, mPadding.top, mPadding.right,
mPadding.bottom + bottomOffset);
}
}
- }
- /**
- * Returns a view that denotes the visible part of all apps container view.
- */
- public View getVisibleContainerView() {
- return mActivityContext.getDeviceProfile().isTablet ? mBottomSheetBackground : this;
+ private boolean isWork() {
+ return mType == WORK;
+ }
+
+ private boolean isSearch() {
+ return mType == SEARCH;
+ }
}
}
diff --git a/src/com/android/launcher3/allapps/FloatingHeaderView.java b/src/com/android/launcher3/allapps/FloatingHeaderView.java
index 72f14a8..515f80a 100644
--- a/src/com/android/launcher3/allapps/FloatingHeaderView.java
+++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java
@@ -33,6 +33,7 @@
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
import com.android.launcher3.R;
+import com.android.launcher3.allapps.BaseAllAppsContainerView.AdapterHolder;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
import com.android.launcher3.views.ActivityContext;
@@ -54,11 +55,10 @@
private final RecyclerView.OnScrollListener mOnScrollListener =
new RecyclerView.OnScrollListener() {
@Override
- public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
- }
+ public void onScrollStateChanged(@NonNull RecyclerView rv, int newState) {}
@Override
- public void onScrolled(RecyclerView rv, int dx, int dy) {
+ public void onScrolled(@NonNull RecyclerView rv, int dx, int dy) {
if (rv != mCurrentRV) {
return;
}
@@ -90,8 +90,8 @@
protected ViewGroup mTabLayout;
private AllAppsRecyclerView mMainRV;
private AllAppsRecyclerView mWorkRV;
+ private SearchRecyclerView mSearchRV;
private AllAppsRecyclerView mCurrentRV;
- private ViewGroup mParent;
public boolean mHeaderCollapsed;
protected int mSnappedScrolledY;
private int mTranslationY;
@@ -100,7 +100,6 @@
protected boolean mTabsHidden;
protected int mMaxTranslation;
- private boolean mMainRVActive = true;
private boolean mCollapsed = false;
@@ -164,12 +163,20 @@
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- if (mMainRV != null) {
- mTabLayout.getLayoutParams().width = mMainRV.getTabWidth();
- }
+ mTabLayout.getLayoutParams().width = getTabWidth();
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
+ /**
+ * Returns distance between left and right app icons
+ */
+ public int getTabWidth() {
+ DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile();
+ int totalWidth = getMeasuredWidth() - getPaddingLeft() - getPaddingRight();
+ int iconPadding = totalWidth / grid.numShownAllAppsColumns - grid.allAppsIconSizePx;
+ return totalWidth - iconPadding - grid.allAppsIconDrawablePaddingPx;
+ }
+
private void recreateAllRowsArray() {
int pluginCount = mPluginRows.size();
if (pluginCount == 0) {
@@ -232,7 +239,8 @@
return super.getFocusedChild();
}
- void setup(AllAppsRecyclerView mainRV, AllAppsRecyclerView workRV, boolean tabsHidden) {
+ void setup(AllAppsRecyclerView mainRV, AllAppsRecyclerView workRV, SearchRecyclerView searchRV,
+ int activeRV, boolean tabsHidden) {
for (FloatingHeaderRow row : mAllRows) {
row.setup(this, mAllRows, tabsHidden);
}
@@ -240,18 +248,27 @@
mTabsHidden = tabsHidden;
mTabLayout.setVisibility(tabsHidden ? View.GONE : View.VISIBLE);
- mMainRV = setupRV(mMainRV, mainRV);
- mWorkRV = setupRV(mWorkRV, workRV);
- mParent = (ViewGroup) mMainRV.getParent();
- setMainActive(mMainRVActive || mWorkRV == null);
+ mMainRV = mainRV;
+ mWorkRV = workRV;
+ mSearchRV = searchRV;
+ setActiveRV(activeRV);
reset(false);
}
- private AllAppsRecyclerView setupRV(AllAppsRecyclerView old, AllAppsRecyclerView updated) {
- if (old != updated && updated != null) {
- updated.addOnScrollListener(mOnScrollListener);
+ /** Whether this header has been set up previously. */
+ boolean isSetUp() {
+ return mMainRV != null;
+ }
+
+ /** Set the active AllApps RV which will adjust the alpha of the header when scrolled. */
+ void setActiveRV(int rvType) {
+ if (mCurrentRV != null) {
+ mCurrentRV.removeOnScrollListener(mOnScrollListener);
}
- return updated;
+ mCurrentRV =
+ rvType == AdapterHolder.MAIN ? mMainRV
+ : rvType == AdapterHolder.WORK ? mWorkRV : mSearchRV;
+ mCurrentRV.addOnScrollListener(mOnScrollListener);
}
private void updateExpectedHeight() {
@@ -267,11 +284,6 @@
}
}
- public void setMainActive(boolean active) {
- mCurrentRV = active ? mMainRV : mWorkRV;
- mMainRVActive = active;
- }
-
public int getMaxTranslation() {
if (mMaxTranslation == 0 && mTabsHidden) {
return getResources().getDimensionPixelSize(R.dimen.all_apps_search_bar_bottom_padding);
@@ -332,10 +344,15 @@
mHeaderClip.top = clipTop;
// clipping on a draw might cause additional redraw
setClipBounds(mHeaderClip);
- mMainRV.setClipBounds(mRVClip);
+ if (mMainRV != null) {
+ mMainRV.setClipBounds(mRVClip);
+ }
if (mWorkRV != null) {
mWorkRV.setClipBounds(mRVClip);
}
+ if (mSearchRV != null) {
+ mSearchRV.setClipBounds(mRVClip);
+ }
}
/**
@@ -402,8 +419,8 @@
}
private void calcOffset(Point p) {
- p.x = getLeft() - mCurrentRV.getLeft() - mParent.getLeft();
- p.y = getTop() - mCurrentRV.getTop() - mParent.getTop();
+ p.x = getLeft() - mCurrentRV.getLeft() - ((ViewGroup) mCurrentRV.getParent()).getLeft();
+ p.y = getTop() - mCurrentRV.getTop() - ((ViewGroup) mCurrentRV.getParent()).getTop();
}
public boolean hasVisibleContent() {
diff --git a/src/com/android/launcher3/allapps/SearchRecyclerView.java b/src/com/android/launcher3/allapps/SearchRecyclerView.java
new file mode 100644
index 0000000..482bd29
--- /dev/null
+++ b/src/com/android/launcher3/allapps/SearchRecyclerView.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2022 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.allapps;
+
+import android.content.Context;
+import android.util.AttributeSet;
+
+import com.android.launcher3.views.RecyclerViewFastScroller;
+
+/** A RecyclerView for AllApps Search results. */
+public class SearchRecyclerView extends AllAppsRecyclerView {
+ private static final String TAG = "SearchRecyclerView";
+
+ public SearchRecyclerView(Context context) {
+ this(context, null);
+ }
+
+ public SearchRecyclerView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public SearchRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) {
+ this(context, attrs, defStyleAttr, 0);
+ }
+
+ public SearchRecyclerView(Context context, AttributeSet attrs, int defStyleAttr,
+ int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ }
+
+ @Override
+ protected void updatePoolSize() {
+ RecycledViewPool pool = getRecycledViewPool();
+ pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_ICON, mNumAppsPerRow);
+ // TODO(b/206905515): Add maxes for other View types.
+ }
+
+ @Override
+ public boolean supportsFastScrolling() {
+ return false;
+ }
+
+ @Override
+ public RecyclerViewFastScroller getScrollbar() {
+ return null;
+ }
+}
diff --git a/src/com/android/launcher3/allapps/WorkEduCard.java b/src/com/android/launcher3/allapps/WorkEduCard.java
index c336496..836cd5a 100644
--- a/src/com/android/launcher3/allapps/WorkEduCard.java
+++ b/src/com/android/launcher3/allapps/WorkEduCard.java
@@ -71,7 +71,7 @@
super.onFinishInflate();
findViewById(R.id.action_btn).setOnClickListener(this);
MarginLayoutParams lp = ((MarginLayoutParams) findViewById(R.id.wrapper).getLayoutParams());
- lp.width = mActivityContext.getAppsView().getActiveRecyclerView().getTabWidth();
+ lp.width = mActivityContext.getAppsView().getFloatingHeaderView().getTabWidth();
}
@Override
diff --git a/src/com/android/launcher3/allapps/WorkProfileManager.java b/src/com/android/launcher3/allapps/WorkProfileManager.java
index dc9f18c..b70cb13 100644
--- a/src/com/android/launcher3/allapps/WorkProfileManager.java
+++ b/src/com/android/launcher3/allapps/WorkProfileManager.java
@@ -160,7 +160,7 @@
lp.bottomMargin = workFabMarginBottom;
int totalScreenWidth = mDeviceProfile.widthPx;
int personalWorkTabWidth =
- mAllApps.mActivityContext.getAppsView().getActiveRecyclerView().getTabWidth();
+ mAllApps.mActivityContext.getAppsView().getFloatingHeaderView().getTabWidth();
lp.rightMargin = lp.leftMargin = (totalScreenWidth - personalWorkTabWidth) / 2;
if (mWorkModeSwitch.getParent() != mAllApps) {
mAllApps.addView(mWorkModeSwitch);
diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
index 21372cf..c43a4d7 100644
--- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
+++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
@@ -104,6 +104,17 @@
}
@Override
+ public void fixBoundsForHomeAnimStartRect(RectF outStartRect, DeviceProfile deviceProfile) {
+ // We don't need to check the "top" value here because the startRect is in the orientation
+ // of the app, not of the fixed portrait launcher.
+ if (outStartRect.left > deviceProfile.heightPx) {
+ outStartRect.offsetTo(0, outStartRect.top);
+ } else if (outStartRect.left < -deviceProfile.heightPx) {
+ outStartRect.offsetTo(0, outStartRect.top);
+ }
+ }
+
+ @Override
public <T> void setPrimary(T target, Int2DAction<T> action, int param) {
action.call(target, 0, param);
}
diff --git a/src/com/android/launcher3/touch/PagedOrientationHandler.java b/src/com/android/launcher3/touch/PagedOrientationHandler.java
index 74e2020..2d9d95c 100644
--- a/src/com/android/launcher3/touch/PagedOrientationHandler.java
+++ b/src/com/android/launcher3/touch/PagedOrientationHandler.java
@@ -236,6 +236,12 @@
*/
void adjustFloatingIconStartVelocity(PointF velocity);
+ /**
+ * Ensures that outStartRect left bound is within the DeviceProfile's visual boundaries
+ * @param outStartRect The start rect that will directly be modified
+ */
+ void fixBoundsForHomeAnimStartRect(RectF outStartRect, DeviceProfile deviceProfile);
+
class ChildBounds {
public final int primaryDimension;
diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
index 816e396..942c191 100644
--- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
+++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
@@ -105,6 +105,15 @@
}
@Override
+ public void fixBoundsForHomeAnimStartRect(RectF outStartRect, DeviceProfile deviceProfile) {
+ if (outStartRect.left > deviceProfile.widthPx) {
+ outStartRect.offsetTo(0, outStartRect.top);
+ } else if (outStartRect.left < -deviceProfile.widthPx) {
+ outStartRect.offsetTo(0, outStartRect.top);
+ }
+ }
+
+ @Override
public <T> void setPrimary(T target, Int2DAction<T> action, int param) {
action.call(target, param, 0);
}
diff --git a/src/com/android/launcher3/views/DoubleShadowBubbleTextView.java b/src/com/android/launcher3/views/DoubleShadowBubbleTextView.java
index a309e6e..374555c 100644
--- a/src/com/android/launcher3/views/DoubleShadowBubbleTextView.java
+++ b/src/com/android/launcher3/views/DoubleShadowBubbleTextView.java
@@ -16,8 +16,6 @@
package com.android.launcher3.views;
-import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound;
-
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
@@ -56,11 +54,10 @@
super.onDraw(canvas);
return;
}
- int alpha = Color.alpha(getCurrentTextColor());
// We enhance the shadow by drawing the shadow twice
getPaint().setShadowLayer(mShadowInfo.ambientShadowBlur, 0, 0,
- getTextShadowColor(mShadowInfo.ambientShadowColor, alpha));
+ mShadowInfo.ambientShadowColor);
drawWithoutDot(canvas);
canvas.save();
@@ -72,7 +69,7 @@
mShadowInfo.keyShadowBlur,
mShadowInfo.keyShadowOffsetX,
mShadowInfo.keyShadowOffsetY,
- getTextShadowColor(mShadowInfo.keyShadowColor, alpha));
+ mShadowInfo.keyShadowColor);
drawWithoutDot(canvas);
canvas.restore();
@@ -113,24 +110,18 @@
return true;
} else if (ambientShadowAlpha > 0 && keyShadowAlpha == 0) {
textView.getPaint().setShadowLayer(ambientShadowBlur, 0, 0,
- getTextShadowColor(ambientShadowColor, textAlpha));
+ ambientShadowColor);
return true;
} else if (keyShadowAlpha > 0 && ambientShadowAlpha == 0) {
textView.getPaint().setShadowLayer(
keyShadowBlur,
keyShadowOffsetX,
keyShadowOffsetY,
- getTextShadowColor(keyShadowColor, textAlpha));
+ keyShadowColor);
return true;
} else {
return false;
}
}
}
-
- // Multiplies the alpha of shadowColor by textAlpha.
- private static int getTextShadowColor(int shadowColor, int textAlpha) {
- return setColorAlphaBound(shadowColor,
- Math.round(Color.alpha(shadowColor) * textAlpha / 255f));
- }
}
diff --git a/src/com/android/launcher3/views/RecyclerViewFastScroller.java b/src/com/android/launcher3/views/RecyclerViewFastScroller.java
index 2d6112f..cc2b440 100644
--- a/src/com/android/launcher3/views/RecyclerViewFastScroller.java
+++ b/src/com/android/launcher3/views/RecyclerViewFastScroller.java
@@ -45,7 +45,7 @@
import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.RecyclerView;
-import com.android.launcher3.BaseRecyclerView;
+import com.android.launcher3.FastScrollRecyclerView;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.graphics.FastScrollThumbDrawable;
@@ -129,7 +129,7 @@
private String mPopupSectionName;
private Insets mSystemGestureInsets;
- protected BaseRecyclerView mRv;
+ protected FastScrollRecyclerView mRv;
private RecyclerView.OnScrollListener mOnScrollListener;
private int mDownX;
@@ -174,7 +174,7 @@
ta.recycle();
}
- public void setRecyclerView(BaseRecyclerView rv, TextView popupView) {
+ public void setRecyclerView(FastScrollRecyclerView rv, TextView popupView) {
if (mRv != null && mOnScrollListener != null) {
mRv.removeOnScrollListener(mOnScrollListener);
}
diff --git a/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java b/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java
index 755e4a9..bdf646b 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java
@@ -27,8 +27,8 @@
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.OnItemTouchListener;
-import com.android.launcher3.BaseRecyclerView;
import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.FastScrollRecyclerView;
import com.android.launcher3.R;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.widget.model.WidgetListSpaceEntry;
@@ -41,7 +41,7 @@
/**
* The widgets recycler view.
*/
-public class WidgetsRecyclerView extends BaseRecyclerView implements OnItemTouchListener {
+public class WidgetsRecyclerView extends FastScrollRecyclerView implements OnItemTouchListener {
private WidgetsListAdapter mAdapter;
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index c93be8b..e00b569 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -375,6 +375,7 @@
@Test
@PortraitLandscape
+ @ScreenRecord
public void testDragToFolder() {
// TODO: add the use case to drag an icon to an existing folder. Currently it either fails
// on tablets or phones due to difference in resolution.
diff --git a/tests/src/com/android/launcher3/ui/WorkProfileTest.java b/tests/src/com/android/launcher3/ui/WorkProfileTest.java
index 7c1be1d..35b4ca6 100644
--- a/tests/src/com/android/launcher3/ui/WorkProfileTest.java
+++ b/tests/src/com/android/launcher3/ui/WorkProfileTest.java
@@ -140,8 +140,8 @@
executeOnLauncher(l -> {
ActivityAllAppsContainerView<?> allApps = l.getAppsView();
assertEquals("Work tab is not focused", allApps.getCurrentPage(), WORK_PAGE);
- View workPausedCard = allApps.getActiveRecyclerView().findViewHolderForAdapterPosition(
- 0).itemView;
+ View workPausedCard = allApps.getActiveRecyclerView()
+ .findViewHolderForAdapterPosition(0).itemView;
workPausedCard.findViewById(R.id.enable_work_apps).performClick();
});
waitForLauncherCondition("Work profile toggle ON failed", launcher -> {
diff --git a/tests/tapl/com/android/launcher3/tapl/Launchable.java b/tests/tapl/com/android/launcher3/tapl/Launchable.java
index 91ab1bd..33fea2d 100644
--- a/tests/tapl/com/android/launcher3/tapl/Launchable.java
+++ b/tests/tapl/com/android/launcher3/tapl/Launchable.java
@@ -66,20 +66,19 @@
"want to launch an app from " + launchableType())) {
LauncherInstrumentation.log("Launchable.launch before click "
+ mObject.getVisibleCenter() + " in " + mLauncher.getVisibleBounds(mObject));
- final String label = mObject.getText();
mLauncher.clickLauncherObject(mObject);
try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("clicked")) {
expectActivityStartEvents();
- return assertAppLaunched(label, selector);
+ return assertAppLaunched(selector);
}
}
}
- protected LaunchedAppState assertAppLaunched(String label, BySelector selector) {
+ protected LaunchedAppState assertAppLaunched(BySelector selector) {
mLauncher.assertTrue(
- "App didn't start: " + label + " (" + selector + ")",
+ "App didn't start: (" + selector + ")",
mLauncher.getDevice().wait(Until.hasObject(selector),
LauncherInstrumentation.WAIT_TIME_MS));
return new LaunchedAppState(mLauncher);
diff --git a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java
index face02a..046d36b 100644
--- a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java
+++ b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java
@@ -97,12 +97,16 @@
}
static void dragToSplitscreen(
- LauncherInstrumentation launcher, Launchable launchable, String expectedNewPackageName,
+ LauncherInstrumentation launcher,
+ Launchable launchable,
+ String expectedNewPackageName,
String expectedExistingPackageName) {
try (LauncherInstrumentation.Closable c1 = launcher.addContextLayer(
"want to drag taskbar item to splitscreen")) {
final Point displaySize = launcher.getRealDisplaySize();
- final Point endPoint = new Point(displaySize.x / 4, 3 * displaySize.y / 4);
+ // Drag to the center of the top-left quadrant of the screen, this point will work in
+ // both portrait and landscape.
+ final Point endPoint = new Point(displaySize.x / 4, displaySize.y / 4);
final long downTime = SystemClock.uptimeMillis();
// Use mObject before starting drag since the system drag and drop moves the original
// view.
@@ -142,9 +146,8 @@
try (LauncherInstrumentation.Closable c4 = launcher.addContextLayer(
"dropped item")) {
- launchable.assertAppLaunched(itemLabel, By.pkg(expectedNewPackageName));
- launchable.assertAppLaunched(
- itemLabel, By.pkg(expectedExistingPackageName));
+ launchable.assertAppLaunched(By.pkg(expectedNewPackageName));
+ launchable.assertAppLaunched(By.pkg(expectedExistingPackageName));
}
}
}