Merge "Originate split select animation from the original icon view instead of the split menu icon" into tm-dev
diff --git a/quickstep/res/layout/taskbar_all_apps.xml b/quickstep/res/layout/taskbar_all_apps.xml
index 34d4b23..d402469 100644
--- a/quickstep/res/layout/taskbar_all_apps.xml
+++ b/quickstep/res/layout/taskbar_all_apps.xml
@@ -34,10 +34,6 @@
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/res/values-sw600dp-land/dimens.xml b/quickstep/res/values-sw600dp-land/dimens.xml
index 4e3c02c..2cd48d5 100644
--- a/quickstep/res/values-sw600dp-land/dimens.xml
+++ b/quickstep/res/values-sw600dp-land/dimens.xml
@@ -15,8 +15,7 @@
*/
-->
<resources>
- <dimen name="overview_actions_top_margin_gesture">19.1dp</dimen>
- <dimen name="overview_actions_bottom_margin_gesture">10dp</dimen>
+ <dimen name="overview_actions_top_margin">12dp</dimen>
<dimen name="overview_grid_side_margin">52dp</dimen>
<dimen name="overview_page_spacing">38dp</dimen>
</resources>
diff --git a/quickstep/res/values-sw600dp/dimens.xml b/quickstep/res/values-sw600dp/dimens.xml
index 223a5e9..5153afa 100644
--- a/quickstep/res/values-sw600dp/dimens.xml
+++ b/quickstep/res/values-sw600dp/dimens.xml
@@ -20,8 +20,6 @@
<dimen name="overview_task_margin">12dp</dimen>
<dimen name="overview_task_margin_grid">4dp</dimen>
<dimen name="overview_actions_button_spacing">36dp</dimen>
- <dimen name="overview_actions_top_margin_gesture">19.37dp</dimen>
- <dimen name="overview_actions_bottom_margin_gesture">22dp</dimen>
<dimen name="overview_grid_side_margin">60dp</dimen>
<dimen name="overview_grid_row_spacing">36dp</dimen>
<dimen name="overview_page_spacing">36dp</dimen>
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index 3f08cf3..4210052 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -35,13 +35,12 @@
<dimen name="overview_task_margin">16dp</dimen>
<dimen name="overview_task_margin_grid">0dp</dimen>
<item name="overview_max_scale" format="float" type="dimen">0.7</item>
+ <item name="overview_modal_max_scale" format="float" type="dimen">1.1</item>
<!-- Overrideable in overlay that provides the Overview Actions. -->
<dimen name="overview_actions_height">48dp</dimen>
<dimen name="overview_actions_button_spacing">32dp</dimen>
- <dimen name="overview_actions_top_margin_gesture">28dp</dimen>
- <dimen name="overview_actions_bottom_margin_gesture">28dp</dimen>
- <dimen name="overview_actions_margin_three_button">8dp</dimen>
+ <dimen name="overview_actions_top_margin">24dp</dimen>
<dimen name="overview_actions_horizontal_margin">16dp</dimen>
<dimen name="overview_page_spacing">16dp</dimen>
diff --git a/quickstep/res/values/strings.xml b/quickstep/res/values/strings.xml
index f80deeb..81b0dd2 100644
--- a/quickstep/res/values/strings.xml
+++ b/quickstep/res/values/strings.xml
@@ -109,6 +109,8 @@
<string name="back_gesture_intro_title">Swipe to go back</string>
<!-- Introduction subtitle for the Back gesture tutorial. [CHAR LIMIT=200] -->
<string name="back_gesture_intro_subtitle">To go back to the last screen, swipe from the left or right edge to the middle of the screen.</string>
+ <!-- Introduction subtitle for the Back gesture tutorial that will be spoken by screen readers. [CHAR LIMIT=200] -->
+ <string name="back_gesture_spoken_intro_subtitle">To go back to the last screen, swipe with 2 fingers from the left or right edge to the middle of the screen.</string>
<string name="home_gesture_feedback_swipe_too_far_from_edge">Make sure you swipe up from the bottom edge of the screen.</string>
<!-- Feedback shown during interactive parts of Home gesture tutorial when the Overview gesture is detected. [CHAR LIMIT=100] -->
@@ -123,6 +125,8 @@
<string name="home_gesture_intro_title">Swipe to go home</string>
<!-- Introduction subtitle for the Home gesture tutorial. [CHAR LIMIT=100] -->
<string name="home_gesture_intro_subtitle">Swipe up from the bottom of your screen. This gesture always takes you to the Home screen.</string>
+ <!-- Introduction subtitle for the Home gesture tutorial that will be spoken by screen readers. [CHAR LIMIT=100] -->
+ <string name="home_gesture_spoken_intro_subtitle">Swipe up with 2 fingers from the bottom of the screen. This gesture always takes you to the Home screen.</string>
<!-- Feedback shown during interactive parts of Overview gesture tutorial when the gesture is started too far from the edge. [CHAR LIMIT=100] -->
<string name="overview_gesture_feedback_swipe_too_far_from_edge">Make sure you swipe up from the bottom edge of the screen.</string>
@@ -138,6 +142,8 @@
<string name="overview_gesture_intro_title">Swipe to switch apps</string>
<!-- Introduction subtitle for the Overview gesture tutorial. [CHAR LIMIT=100] -->
<string name="overview_gesture_intro_subtitle">To switch between apps, swipe up from the bottom of your screen, hold, then release.</string>
+ <!-- Introduction subtitle for the Overview gesture tutorial that will be spoken by screen readers. [CHAR LIMIT=100] -->
+ <string name="overview_gesture_spoken_intro_subtitle">To switch between apps, swipe up with 2 fingers from the bottom of your screen, hold, then release.</string>
<!-- Title shown during interactive part of Assistant gesture tutorial. [CHAR LIMIT=30] -->
<string name="assistant_gesture_tutorial_playground_title" translatable="false">Tutorial: Assistant</string>
diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java
index fe24c4b..2239102 100644
--- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java
+++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java
@@ -24,6 +24,9 @@
import static com.android.launcher3.config.FeatureFlags.ENABLE_SPLIT_FROM_WORKSPACE;
import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID;
import static com.android.launcher3.popup.QuickstepSystemShortcut.getSplitSelectShortcutByPosition;
+import static com.android.launcher3.taskbar.LauncherTaskbarUIController.ALL_APPS_PAGE_PROGRESS_INDEX;
+import static com.android.launcher3.taskbar.LauncherTaskbarUIController.MINUS_ONE_PAGE_PROGRESS_INDEX;
+import static com.android.launcher3.taskbar.LauncherTaskbarUIController.WIDGETS_PAGE_PROGRESS_INDEX;
import static com.android.launcher3.util.DisplayController.CHANGE_ACTIVE_SCREEN;
import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
import static com.android.launcher3.util.DisplayController.NavigationMode.TWO_BUTTONS;
@@ -229,6 +232,28 @@
public void onScrollChanged(float progress) {
super.onScrollChanged(progress);
mDepthController.onOverlayScrollChanged(progress);
+ onTaskbarInAppDisplayProgressUpdate(progress, MINUS_ONE_PAGE_PROGRESS_INDEX);
+ }
+
+ @Override
+ public void onAllAppsTransition(float progress) {
+ super.onAllAppsTransition(progress);
+ onTaskbarInAppDisplayProgressUpdate(progress, ALL_APPS_PAGE_PROGRESS_INDEX);
+ }
+
+ @Override
+ public void onWidgetsTransition(float progress) {
+ super.onWidgetsTransition(progress);
+ onTaskbarInAppDisplayProgressUpdate(progress, WIDGETS_PAGE_PROGRESS_INDEX);
+ }
+
+ private void onTaskbarInAppDisplayProgressUpdate(float progress, int flag) {
+ if (mTaskbarManager == null
+ || mTaskbarManager.getCurrentActivityContext() == null
+ || mTaskbarUIController == null) {
+ return;
+ }
+ mTaskbarUIController.onTaskbarInAppDisplayProgressUpdate(progress, flag);
}
@Override
@@ -296,7 +321,7 @@
new SplitSelectStateController(this, mHandler, getStateManager(),
getDepthController());
overviewPanel.init(mActionsView, controller);
- mActionsView.setDp(getDeviceProfile());
+ mActionsView.updateDimension(getDeviceProfile(), overviewPanel.getLastComputedTaskSize());
mActionsView.updateVerticalMargin(DisplayController.getNavigationMode(this));
mAppTransitionManager = new QuickstepTransitionManager(this);
diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
index 0f3474e..9f35401 100644
--- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
@@ -1354,7 +1354,7 @@
*/
private RectFSpringAnim getClosingWindowAnimators(AnimatorSet animation,
RemoteAnimationTargetCompat[] targets, View launcherView, PointF velocityPxPerS,
- RectF closingWindowStartRect) {
+ RectF closingWindowStartRect, float startWindowCornerRadius) {
FloatingIconView floatingIconView = null;
FloatingWidgetView floatingWidget = null;
RectF targetRect = new RectF();
@@ -1403,7 +1403,7 @@
final float windowAlphaThreshold = 1f - SHAPE_PROGRESS_DURATION;
RectFSpringAnim.OnUpdateListener runner = new SpringAnimRunner(targets, targetRect,
- windowTargetBounds) {
+ windowTargetBounds, startWindowCornerRadius) {
@Override
public void onUpdate(RectF currentRectF, float progress) {
finalFloatingIconView.update(1f, 255 /* fgAlpha */, currentRectF, progress,
@@ -1421,7 +1421,7 @@
final float floatingWidgetAlpha = isTransluscent ? 0 : 1;
FloatingWidgetView finalFloatingWidget = floatingWidget;
RectFSpringAnim.OnUpdateListener runner = new SpringAnimRunner(targets, targetRect,
- windowTargetBounds) {
+ windowTargetBounds, startWindowCornerRadius) {
@Override
public void onUpdate(RectF currentRectF, float progress) {
final float fallbackBackgroundAlpha =
@@ -1438,7 +1438,8 @@
} else {
// If no floating icon or widget is present, animate the to the default window
// target rect.
- anim.addOnUpdateListener(new SpringAnimRunner(targets, targetRect, windowTargetBounds));
+ anim.addOnUpdateListener(new SpringAnimRunner(
+ targets, targetRect, windowTargetBounds, startWindowCornerRadius));
}
// Use a fixed velocity to start the animation.
@@ -1580,7 +1581,8 @@
RemoteAnimationTargetCompat[] appTargets,
RemoteAnimationTargetCompat[] wallpaperTargets,
boolean fromUnlock,
- RectF startRect) {
+ RectF startRect,
+ float startWindowCornerRadius) {
AnimatorSet anim = null;
RectFSpringAnim rectFSpringAnim = null;
@@ -1612,7 +1614,8 @@
.getDimension(R.dimen.unlock_staggered_velocity_dp_per_s);
PointF velocity = new PointF(0, -velocityPxPerS);
rectFSpringAnim = getClosingWindowAnimators(
- anim, appTargets, launcherView, velocity, startRect);
+ anim, appTargets, launcherView, velocity, startRect,
+ startWindowCornerRadius);
if (!mLauncher.isInState(LauncherState.ALL_APPS)) {
anim.play(new StaggeredWorkspaceAnim(mLauncher, velocity.y,
true /* animateOverviewScrim */, launcherView).getAnimators());
@@ -1711,7 +1714,8 @@
Pair<RectFSpringAnim, AnimatorSet> pair = createWallpaperOpenAnimations(
appTargets, wallpaperTargets, mFromUnlock,
- new RectF(0, 0, mDeviceProfile.widthPx, mDeviceProfile.heightPx));
+ new RectF(0, 0, mDeviceProfile.widthPx, mDeviceProfile.heightPx),
+ QuickStepContract.getWindowCornerRadius(mLauncher));
mLauncher.clearForceInvisibleFlag(INVISIBLE_ALL);
result.setAnimation(pair.second, mLauncher);
@@ -1874,9 +1878,9 @@
private final Rect mTmpRect = new Rect();
SpringAnimRunner(RemoteAnimationTargetCompat[] appTargets, RectF targetRect,
- Rect windowTargetBounds) {
+ Rect windowTargetBounds, float startWindowCornerRadius) {
mAppTargets = appTargets;
- mStartRadius = QuickStepContract.getWindowCornerRadius(mLauncher);
+ mStartRadius = startWindowCornerRadius;
mEndRadius = Math.max(1, targetRect.width()) / 2f;
mSurfaceApplier = new SurfaceTransactionApplier(mDragLayer);
mWindowTargetBounds.set(windowTargetBounds);
diff --git a/quickstep/src/com/android/launcher3/search/SearchSessionManager.java b/quickstep/src/com/android/launcher3/search/SearchSessionManager.java
deleted file mode 100644
index da85793..0000000
--- a/quickstep/src/com/android/launcher3/search/SearchSessionManager.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.search;
-
-import android.app.search.SearchSession;
-import android.content.Context;
-
-import androidx.annotation.IntDef;
-import androidx.annotation.UiThread;
-
-import com.android.launcher3.R;
-import com.android.launcher3.model.data.ItemInfo;
-import com.android.launcher3.util.ResourceBasedOverride;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.util.List;
-
-/** Manages an all apps search session. */
-public class SearchSessionManager implements ResourceBasedOverride {
-
- /** Entry state for the search session (e.g. from all apps). */
- @Retention(RetentionPolicy.SOURCE)
- @IntDef(value = {ZERO_ALLAPPS, ZERO_QSB})
- public @interface ZeroEntryState {}
- public static final int ZERO_ALLAPPS = 1;
- public static final int ZERO_QSB = 2;
-
- /** Creates a {@link SearchSessionManager} instance. */
- public static SearchSessionManager newInstance(Context context) {
- return Overrides.getObject(
- SearchSessionManager.class, context, R.string.search_session_manager_class);
- }
-
- /** The current {@link SearchSession}. */
- @UiThread
- public void setSearchSession(SearchSession session) {}
-
- /** {@code true} if IME is shown. */
- public void setIsImeShown(boolean value) {}
-
- /** Returns {@code true} if IME is enabled. */
- public boolean getIsImeEnabled() {
- return false;
- }
-
- /** The current entry state for search. */
- public @ZeroEntryState int getEntryState() {
- return ZERO_ALLAPPS;
- }
-
- /**
- * When user enters all apps surface via tap on home widget, set the state to
- * {@code #ZERO_QSB}. When user exits, reset to {@code #ZERO_ALLAPPS}
- */
- public void setEntryState(@ZeroEntryState int state) {}
-
- /** This will be called before opening all apps, to prepare zero state suggestions. */
- public void prepareZeroState() {}
-
- /** Apply predicted items for the search zero state. */
- public void setZeroStatePredictedItems(List<ItemInfo> items) {}
-
- /** Returns {@code true} if the session is valid and should be enabled. */
- public boolean isValidSession() {
- return false;
- }
-
- /** Called when the search session is destroyed. */
- public void onDestroy() {}
-}
diff --git a/quickstep/src/com/android/launcher3/taskbar/DesktopTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/DesktopTaskbarUIController.java
index cf56248..e2359c0 100644
--- a/quickstep/src/com/android/launcher3/taskbar/DesktopTaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/DesktopTaskbarUIController.java
@@ -39,4 +39,10 @@
protected void onDestroy() {
mLauncher.getHotseat().setIconsAlpha(1f);
}
+
+ @Override
+ /** Disable taskbar stashing in desktop environment. */
+ public boolean supportsVisualStashing() {
+ return false;
+ }
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
index 793d987..a3e8b5c 100644
--- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
@@ -22,6 +22,7 @@
import android.annotation.ColorInt;
import android.os.RemoteException;
import android.util.Log;
+import android.util.SparseArray;
import android.view.MotionEvent;
import android.view.TaskTransitionSpec;
import android.view.WindowManagerGlobal;
@@ -43,6 +44,7 @@
import com.android.quickstep.AnimatedFloat;
import com.android.quickstep.RecentsAnimationCallbacks;
+import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Stream;
@@ -54,10 +56,22 @@
private static final String TAG = "TaskbarUIController";
+ public static final int MINUS_ONE_PAGE_PROGRESS_INDEX = 0;
+ public static final int ALL_APPS_PAGE_PROGRESS_INDEX = 1;
+ public static final int WIDGETS_PAGE_PROGRESS_INDEX = 2;
+ public static final int SYSUI_SURFACE_PROGRESS_INDEX = 3;
+
+ private final SparseArray<Float> mTaskbarInAppDisplayProgress = new SparseArray<>(4);
+
private final BaseQuickstepLauncher mLauncher;
private final DeviceProfile.OnDeviceProfileChangeListener mOnDeviceProfileChangeListener =
- this::onStashedInAppChanged;
+ dp -> {
+ onStashedInAppChanged(dp);
+ if (mControllers != null && mControllers.taskbarViewController != null) {
+ mControllers.taskbarViewController.onRotationChanged(dp);
+ }
+ };
// Initialized in init.
private AnimatedFloat mTaskbarOverrideBackgroundAlpha;
@@ -65,15 +79,6 @@
private final TaskbarLauncherStateController
mTaskbarLauncherStateController = new TaskbarLauncherStateController();
- private final DeviceProfile.OnDeviceProfileChangeListener mProfileChangeListener =
- new DeviceProfile.OnDeviceProfileChangeListener() {
- @Override
- public void onDeviceProfileChanged(DeviceProfile dp) {
- mControllers.taskbarViewController.onRotationChanged(
- mLauncher.getDeviceProfile());
- }
- };
-
public LauncherTaskbarUIController(BaseQuickstepLauncher launcher) {
mLauncher = launcher;
}
@@ -93,7 +98,6 @@
onStashedInAppChanged(mLauncher.getDeviceProfile());
mLauncher.addOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
- mLauncher.addOnDeviceProfileChangeListener(mProfileChangeListener);
}
@Override
@@ -102,9 +106,8 @@
onLauncherResumedOrPaused(false);
mTaskbarLauncherStateController.onDestroy();
- mLauncher.removeOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
mLauncher.setTaskbarUIController(null);
- mLauncher.removeOnDeviceProfileChangeListener(mProfileChangeListener);
+ mLauncher.removeOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
updateTaskTransitionSpec(true);
}
@@ -271,4 +274,85 @@
// gesture ends, start drawing taskbar's background again since launcher might stop drawing.
forceHideBackground(inProgress);
}
+
+ /**
+ * Animates Taskbar elements during a transition to a Launcher state that should use in-app
+ * layouts.
+ *
+ * @param progress [0, 1]
+ * 0 => use home layout
+ * 1 => use in-app layout
+ */
+ public void onTaskbarInAppDisplayProgressUpdate(float progress, int progressIndex) {
+ if (mControllers == null) {
+ // This method can be called before init() is called.
+ return;
+ }
+ mTaskbarInAppDisplayProgress.put(progressIndex, progress);
+ if (!mControllers.taskbarStashController.isInApp()
+ && !mTaskbarLauncherStateController.isAnimatingToLauncher()) {
+ // Only animate the nav buttons while home and not animating home, otherwise let
+ // the TaskbarViewController handle it.
+ mControllers.navbarButtonsViewController
+ .getTaskbarNavButtonTranslationYForInAppDisplay()
+ .updateValue(mLauncher.getDeviceProfile().getTaskbarOffsetY()
+ * getInAppDisplayProgress());
+ }
+ }
+
+ /** Returns true iff any in-app display progress > 0. */
+ public boolean shouldUseInAppLayout() {
+ return getInAppDisplayProgress() > 0;
+ }
+
+ private float getInAppDisplayProgress(int index) {
+ if (!mTaskbarInAppDisplayProgress.contains(index)) {
+ mTaskbarInAppDisplayProgress.put(index, 0f);
+ }
+ return mTaskbarInAppDisplayProgress.get(index);
+ }
+
+ private float getInAppDisplayProgress() {
+ return Stream.of(
+ getInAppDisplayProgress(MINUS_ONE_PAGE_PROGRESS_INDEX),
+ getInAppDisplayProgress(ALL_APPS_PAGE_PROGRESS_INDEX),
+ getInAppDisplayProgress(WIDGETS_PAGE_PROGRESS_INDEX),
+ getInAppDisplayProgress(SYSUI_SURFACE_PROGRESS_INDEX))
+ .max(Float::compareTo)
+ .get();
+ }
+
+ @Override
+ public void dumpLogs(String prefix, PrintWriter pw) {
+ super.dumpLogs(prefix, pw);
+
+ pw.println(String.format(
+ "%s\tmTaskbarOverrideBackgroundAlpha=%.2f",
+ prefix,
+ mTaskbarOverrideBackgroundAlpha.value));
+
+ pw.println(String.format("%s\tTaskbar in-app display progress:", prefix));
+ if (mControllers == null) {
+ pw.println(String.format("%s\t\tMissing mControllers", prefix));
+ } else {
+ pw.println(String.format(
+ "%s\t\tprogress at MINUS_ONE_PAGE_PROGRESS_INDEX=%.2f",
+ prefix,
+ getInAppDisplayProgress(MINUS_ONE_PAGE_PROGRESS_INDEX)));
+ pw.println(String.format(
+ "%s\t\tprogress at ALL_APPS_PAGE_PROGRESS_INDEX=%.2f",
+ prefix,
+ getInAppDisplayProgress(ALL_APPS_PAGE_PROGRESS_INDEX)));
+ pw.println(String.format(
+ "%s\t\tprogress at WIDGETS_PAGE_PROGRESS_INDEX=%.2f",
+ prefix,
+ getInAppDisplayProgress(WIDGETS_PAGE_PROGRESS_INDEX)));
+ pw.println(String.format(
+ "%s\t\tprogress at SYSUI_SURFACE_PROGRESS_INDEX=%.2f",
+ prefix,
+ getInAppDisplayProgress(SYSUI_SURFACE_PROGRESS_INDEX)));
+ }
+
+ mTaskbarLauncherStateController.dumpLogs(prefix + "\t", pw);
+ }
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
index f65b907..349dd0a 100644
--- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
@@ -16,6 +16,7 @@
package com.android.launcher3.taskbar;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
+import static com.android.launcher3.taskbar.LauncherTaskbarUIController.SYSUI_SURFACE_PROGRESS_INDEX;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_A11Y;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_BACK;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_HOME;
@@ -126,11 +127,13 @@
private final AnimatedFloat mTaskbarNavButtonTranslationY = new AnimatedFloat(
this::updateNavButtonTranslationY);
+ private final AnimatedFloat mTaskbarNavButtonTranslationYForInAppDisplay = new AnimatedFloat(
+ this::updateNavButtonTranslationY);
private final AnimatedFloat mTaskbarNavButtonTranslationYForIme = new AnimatedFloat(
this::updateNavButtonTranslationY);
- // Only applies to mTaskbarNavButtonTranslationY
- private final AnimatedFloat mNavButtonTranslationYMultiplier = new AnimatedFloat(
- this::updateNavButtonTranslationY);
+ // Used for System UI state updates that should translate the nav button for in-app display.
+ private final AnimatedFloat mNavButtonInAppDisplayProgressForSysui = new AnimatedFloat(
+ this::updateNavButtonInAppDisplayProgressForSysui);
private final AnimatedFloat mTaskbarNavButtonDarkIntensity = new AnimatedFloat(
this::updateNavButtonDarkIntensity);
private final AnimatedFloat mNavButtonDarkIntensityMultiplier = new AnimatedFloat(
@@ -173,7 +176,6 @@
public void init(TaskbarControllers controllers) {
mControllers = controllers;
mNavButtonsView.getLayoutParams().height = mContext.getDeviceProfile().taskbarSize;
- mNavButtonTranslationYMultiplier.value = 1;
boolean isThreeButtonNav = mContext.isThreeButtonNav();
mIsImeRenderingNavButtons =
@@ -205,9 +207,9 @@
// Make sure to remove nav bar buttons translation when notification shade is expanded or
// IME is showing (add separate translation for IME).
int flagsToRemoveTranslation = FLAG_NOTIFICATION_SHADE_EXPANDED | FLAG_IME_VISIBLE;
- mPropertyHolders.add(new StatePropertyHolder(mNavButtonTranslationYMultiplier,
+ mPropertyHolders.add(new StatePropertyHolder(mNavButtonInAppDisplayProgressForSysui,
flags -> (flags & flagsToRemoveTranslation) != 0, AnimatedFloat.VALUE,
- 0, 1));
+ 1, 0));
// Center nav buttons in new height for IME.
float transForIme = (mContext.getDeviceProfile().taskbarSize
- mControllers.taskbarInsetsController.getTaskbarHeightForIme()) / 2f;
@@ -526,6 +528,11 @@
return mTaskbarNavButtonTranslationY;
}
+ /** Use to set the translationY for the all nav+contextual buttons when in Launcher */
+ public AnimatedFloat getTaskbarNavButtonTranslationYForInAppDisplay() {
+ return mTaskbarNavButtonTranslationYForInAppDisplay;
+ }
+
/** Use to set the dark intensity for the all nav+contextual buttons */
public AnimatedFloat getTaskbarNavButtonDarkIntensity() {
return mTaskbarNavButtonDarkIntensity;
@@ -554,11 +561,26 @@
}
}
+ private void updateNavButtonInAppDisplayProgressForSysui() {
+ TaskbarUIController uiController = mControllers.uiController;
+ if (uiController instanceof LauncherTaskbarUIController) {
+ ((LauncherTaskbarUIController) uiController).onTaskbarInAppDisplayProgressUpdate(
+ mNavButtonInAppDisplayProgressForSysui.value, SYSUI_SURFACE_PROGRESS_INDEX);
+ }
+ }
+
private void updateNavButtonTranslationY() {
- float normalTranslationY = mTaskbarNavButtonTranslationY.value
- * mNavButtonTranslationYMultiplier.value;
- float otherTranslationY = mTaskbarNavButtonTranslationYForIme.value;
- mNavButtonsView.setTranslationY(normalTranslationY + otherTranslationY);
+ final float normalTranslationY = mTaskbarNavButtonTranslationY.value;
+ final float imeAdjustmentTranslationY = mTaskbarNavButtonTranslationYForIme.value;
+ TaskbarUIController uiController = mControllers.uiController;
+ final float inAppDisplayAdjustmentTranslationY =
+ (uiController instanceof LauncherTaskbarUIController
+ && ((LauncherTaskbarUIController) uiController).shouldUseInAppLayout())
+ ? mTaskbarNavButtonTranslationYForInAppDisplay.value : 0;
+
+ mNavButtonsView.setTranslationY(normalTranslationY
+ + imeAdjustmentTranslationY
+ + inAppDisplayAdjustmentTranslationY);
}
private void updateNavButtonDarkIntensity() {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index b349637..2f32219 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -199,7 +199,7 @@
new TaskbarInsetsController(this));
}
- public void init(TaskbarSharedState sharedState) {
+ public void init(@NonNull TaskbarSharedState sharedState) {
mLastRequestedNonFullscreenHeight = getDefaultTaskbarWindowHeight();
mWindowLayoutParams = createDefaultWindowLayoutParams();
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
index ff08e3d..449e0a7 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
@@ -61,6 +61,8 @@
private boolean mAreAllControllersInitialized;
private final List<Runnable> mPostInitCallbacks = new ArrayList<>();
+ @Nullable private TaskbarSharedState mSharedState = null;
+
public TaskbarControllers(TaskbarActivityContext taskbarActivityContext,
TaskbarDragController taskbarDragController,
TaskbarNavButtonController navButtonController,
@@ -104,8 +106,9 @@
* TaskbarControllers instance, but should be careful to only access things that were created
* in constructors for now, as some controllers may still be waiting for init().
*/
- public void init(TaskbarSharedState sharedState) {
+ public void init(@NonNull TaskbarSharedState sharedState) {
mAreAllControllersInitialized = false;
+ mSharedState = sharedState;
taskbarDragController.init(this);
navbarButtonsViewController.init(this);
@@ -116,11 +119,11 @@
taskbarUnfoldAnimationController.init(this);
taskbarKeyguardController.init(navbarButtonsViewController);
stashedHandleViewController.init(this);
- taskbarStashController.init(this, sharedState);
+ taskbarStashController.init(this, sharedState.setupUIVisible);
taskbarEduController.init(this);
taskbarPopupController.init(this);
taskbarForceVisibleImmersiveController.init(this);
- taskbarAllAppsController.init(this, sharedState);
+ taskbarAllAppsController.init(this, sharedState.allAppsVisible);
navButtonController.init(this);
taskbarInsetsController.init(this);
@@ -139,6 +142,12 @@
mPostInitCallbacks.clear();
}
+ @Nullable
+ public TaskbarSharedState getSharedState() {
+ // This should only be null if called before init() and after destroy().
+ return mSharedState;
+ }
+
public void onConfigurationChanged(@Config int configChanges) {
navbarButtonsViewController.onConfigurationChanged(configChanges);
}
@@ -147,6 +156,8 @@
* Cleans up all controllers.
*/
public void onDestroy() {
+ mSharedState = null;
+
navbarButtonsViewController.onDestroy();
uiController.onDestroy();
rotationButtonController.onDestroy();
@@ -187,9 +198,12 @@
return;
}
+ pw.println(String.format(
+ "%s\tmAreAllControllersInitialized=%b", prefix, mAreAllControllersInitialized));
for (LoggableTaskbarController controller : mControllersToLog) {
controller.dumpLogs(prefix + "\t", pw);
}
+ uiController.dumpLogs(prefix + "\t", pw);
rotationButtonController.dumpLogs(prefix + "\t", pw);
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index 36e6420..138fb99 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -42,7 +42,9 @@
import com.android.systemui.animation.ViewRootSync;
import com.android.systemui.shared.recents.model.ThumbnailData;
+import java.io.PrintWriter;
import java.util.HashMap;
+import java.util.StringJoiner;
import java.util.function.Consumer;
import java.util.function.Supplier;
@@ -476,4 +478,48 @@
controller.applyState();
}
}
+
+ private static String getStateString(int flags) {
+ StringJoiner str = new StringJoiner("|");
+ str.add((flags & FLAG_RESUMED) != 0 ? "FLAG_RESUMED" : "");
+ str.add((flags & FLAG_RECENTS_ANIMATION_RUNNING) != 0
+ ? "FLAG_RECENTS_ANIMATION_RUNNING" : "");
+ str.add((flags & FLAG_TRANSITION_STATE_RUNNING) != 0
+ ? "FLAG_TRANSITION_STATE_RUNNING" : "");
+ return str.toString();
+ }
+
+ protected void dumpLogs(String prefix, PrintWriter pw) {
+ pw.println(prefix + "TaskbarLauncherStateController:");
+
+ pw.println(String.format(
+ "%s\tmIconAlignmentForResumedState=%.2f",
+ prefix,
+ mIconAlignmentForResumedState.value));
+ pw.println(String.format(
+ "%s\tmIconAlignmentForGestureState=%.2f",
+ prefix,
+ mIconAlignmentForGestureState.value));
+ pw.println(String.format(
+ "%s\tmIconAlignmentForLauncherState=%.2f",
+ prefix,
+ mIconAlignmentForLauncherState.value));
+ pw.println(String.format(
+ "%s\tmTaskbarBackgroundAlpha=%.2f", prefix, mTaskbarBackgroundAlpha.value));
+ pw.println(String.format(
+ "%s\tmIconAlphaForHome=%.2f", prefix, mIconAlphaForHome.getValue()));
+ pw.println(String.format("%s\tmPrevState=%s", prefix, getStateString(mPrevState)));
+ pw.println(String.format("%s\tmState=%s", prefix, getStateString(mState)));
+ pw.println(String.format("%s\tmLauncherState=%s", prefix, mLauncherState));
+ pw.println(String.format(
+ "%s\tmIsAnimatingToLauncherViaGesture=%b",
+ prefix,
+ mIsAnimatingToLauncherViaGesture));
+ pw.println(String.format(
+ "%s\tmIsAnimatingToLauncherViaResume=%b",
+ prefix,
+ mIsAnimatingToLauncherViaResume));
+ pw.println(String.format(
+ "%s\tmShouldDelayLauncherStateAnim=%b", prefix, mShouldDelayLauncherStateAnim));
+ }
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
index e02a9d7..2e37170 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
@@ -194,6 +194,9 @@
* Sets a {@link StatefulActivity} to act as taskbar callback
*/
public void setActivity(@NonNull StatefulActivity activity) {
+ if (mActivity == activity) {
+ return;
+ }
mActivity = activity;
mUnfoldProgressProvider.setSourceProvider(getUnfoldTransitionProgressProviderForActivity(
activity));
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java
index a5c55b0..87b3789 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java
@@ -25,5 +25,4 @@
public boolean setupUIVisible = false;
public boolean allAppsVisible = false;
-
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
index f34759d..7d95743 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
@@ -17,6 +17,7 @@
import static android.view.HapticFeedbackConstants.LONG_PRESS;
+import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_HIDE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_SHOW;
import static com.android.launcher3.taskbar.Utilities.appendFlag;
@@ -34,7 +35,6 @@
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Utilities;
-import com.android.launcher3.taskbar.allapps.TaskbarAllAppsSlideInView;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.quickstep.AnimatedFloat;
@@ -167,7 +167,7 @@
mStashedHeight = mActivity.getDeviceProfile().stashedTaskbarSize;
}
- public void init(TaskbarControllers controllers, TaskbarSharedState sharedState) {
+ public void init(TaskbarControllers controllers, boolean setupUIVisible) {
mControllers = controllers;
TaskbarDragLayerController dragLayerController = controllers.taskbarDragLayerController;
@@ -188,7 +188,7 @@
boolean isManuallyStashedInApp = supportsManualStashing()
&& mPrefs.getBoolean(SHARED_PREFS_STASHED_KEY, DEFAULT_STASHED_PREF);
- boolean isInSetup = !mActivity.isUserSetupComplete() || sharedState.setupUIVisible;
+ boolean isInSetup = !mActivity.isUserSetupComplete() || setupUIVisible;
updateStateForFlag(FLAG_STASHED_IN_APP_MANUAL, isManuallyStashedInApp);
updateStateForFlag(FLAG_STASHED_IN_APP_SETUP, isInSetup);
updateStateForFlag(FLAG_IN_SETUP, isInSetup);
@@ -202,7 +202,7 @@
* state.
*/
public boolean supportsVisualStashing() {
- return !mActivity.isThreeButtonNav();
+ return mControllers.uiController.supportsVisualStashing();
}
/**
@@ -275,7 +275,7 @@
return !mIsStashed && isInApp();
}
- private boolean isInApp() {
+ public boolean isInApp() {
return hasAnyFlag(FLAGS_IN_APP);
}
@@ -564,7 +564,8 @@
updateStateForFlag(FLAG_STASHED_IN_APP_ALL_APPS, false);
if (applyState) {
- applyState(TaskbarAllAppsSlideInView.DEFAULT_CLOSE_DURATION);
+ applyState(ALL_APPS.getTransitionDuration(
+ mControllers.taskbarActivityContext, false /* isToState */));
}
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
index d5c399b..fcc34c6 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
@@ -22,6 +22,7 @@
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
+import java.io.PrintWriter;
import java.util.stream.Stream;
/**
@@ -48,6 +49,11 @@
return true;
}
+ public boolean supportsVisualStashing() {
+ if (mControllers == null) return false;
+ return !mControllers.taskbarActivityContext.isThreeButtonNav();
+ }
+
protected void onStashedInAppChanged() { }
public Stream<ItemInfoWithIcon> getAppIconsForEdu() {
@@ -86,4 +92,12 @@
stashController.applyState();
}
}
+
+ @CallSuper
+ protected void dumpLogs(String prefix, PrintWriter pw) {
+ pw.println(String.format(
+ "%sTaskbarUIController: using an instance of %s",
+ prefix,
+ getClass().getSimpleName()));
+ }
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
index 6416720..9b6cc66 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
@@ -73,6 +73,7 @@
private final AnimatedFloat mTaskbarIconTranslationYForStash = new AnimatedFloat(
this::updateTranslationY);
private AnimatedFloat mTaskbarNavButtonTranslationY;
+ private AnimatedFloat mTaskbarNavButtonTranslationYForInAppDisplay;
private final AnimatedFloat mThemeIconsBackground = new AnimatedFloat(
this::updateIconsBackground);
@@ -112,6 +113,8 @@
}
mTaskbarNavButtonTranslationY =
controllers.navbarButtonsViewController.getTaskbarNavButtonTranslationY();
+ mTaskbarNavButtonTranslationYForInAppDisplay = controllers.navbarButtonsViewController
+ .getTaskbarNavButtonTranslationYForInAppDisplay();
}
public void onDestroy() {
@@ -242,6 +245,7 @@
int offsetY = launcherDp.getTaskbarOffsetY();
setter.setFloat(mTaskbarIconTranslationYForHome, VALUE, -offsetY, LINEAR);
setter.setFloat(mTaskbarNavButtonTranslationY, VALUE, -offsetY, LINEAR);
+ setter.setFloat(mTaskbarNavButtonTranslationYForInAppDisplay, VALUE, offsetY, LINEAR);
if (Utilities.isDarkTheme(mTaskbarView.getContext())) {
setter.addFloat(mThemeIconsBackground, VALUE, 0f, 1f, LINEAR);
@@ -289,10 +293,12 @@
}
public void onRotationChanged(DeviceProfile deviceProfile) {
- if (areIconsVisible()) {
+ if (mControllers.taskbarStashController.isInApp()) {
// We only translate on rotation when on home
return;
}
+ mActivity.setTaskbarWindowHeight(
+ deviceProfile.taskbarSize + deviceProfile.getTaskbarOffsetY());
mTaskbarNavButtonTranslationY.updateValue(-deviceProfile.getTaskbarOffsetY());
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java
index 51fa4d9..0ea2aa0 100644
--- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java
@@ -44,10 +44,9 @@
}
@Override
- protected BaseAllAppsAdapter<TaskbarAllAppsContext> createAdapter(
- AlphabeticalAppsList<TaskbarAllAppsContext> appsList,
+ protected BaseAllAppsAdapter getAdapter(AlphabeticalAppsList<TaskbarAllAppsContext> mAppsList,
BaseAdapterProvider[] adapterProviders) {
- return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), appsList,
+ return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), mAppsList,
adapterProviders);
}
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java
index 9fca8eb..eaf9384 100644
--- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java
@@ -38,7 +38,6 @@
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.taskbar.TaskbarActivityContext;
import com.android.launcher3.taskbar.TaskbarControllers;
-import com.android.launcher3.taskbar.TaskbarSharedState;
import com.android.systemui.shared.system.TaskStackChangeListener;
import com.android.systemui.shared.system.TaskStackChangeListeners;
@@ -72,7 +71,6 @@
};
private TaskbarControllers mControllers;
- private TaskbarSharedState mSharedState;
/** Window context for all apps if it is open. */
private @Nullable TaskbarAllAppsContext mAllAppsContext;
@@ -88,18 +86,17 @@
}
/** Initialize the controller. */
- public void init(TaskbarControllers controllers, TaskbarSharedState sharedState) {
+ public void init(TaskbarControllers controllers, boolean allAppsVisible) {
if (!FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) {
return;
}
mControllers = controllers;
- mSharedState = sharedState;
/*
* Recreate All Apps if it was open in the previous Taskbar instance (e.g. the configuration
* changed).
*/
- if (mSharedState.allAppsVisible) {
+ if (allAppsVisible) {
show(false);
}
}
@@ -141,7 +138,9 @@
return;
}
mProxyView.show();
- mSharedState.allAppsVisible = true;
+ // mControllers and getSharedState should never be null here. Do not handle null-pointer
+ // to catch invalid states.
+ mControllers.getSharedState().allAppsVisible = true;
mAllAppsContext = new TaskbarAllAppsContext(mTaskbarContext,
this,
@@ -176,7 +175,9 @@
return;
}
mProxyView.close(false);
- mSharedState.allAppsVisible = false;
+ // mControllers and getSharedState should never be null here. Do not handle null-pointer
+ // to catch invalid states.
+ mControllers.getSharedState().allAppsVisible = false;
onDestroy();
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java
index a37ebac..2d7ce32 100644
--- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java
@@ -15,13 +15,16 @@
*/
package com.android.launcher3.taskbar.allapps;
+import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE;
+import static com.android.systemui.animation.Interpolators.EMPHASIZED_ACCELERATE;
import android.animation.PropertyValuesHolder;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
+import android.view.animation.Interpolator;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
@@ -33,9 +36,6 @@
/** Wrapper for taskbar all apps with slide-in behavior. */
public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarAllAppsContext>
implements Insettable, DeviceProfile.OnDeviceProfileChangeListener {
- static final int DEFAULT_OPEN_DURATION = 500;
- public static final int DEFAULT_CLOSE_DURATION = 200;
-
private TaskbarAllAppsContainerView mAppsView;
private OnCloseListener mOnCloseBeginListener;
private float mShiftRange;
@@ -61,7 +61,8 @@
mOpenCloseAnimator.setValues(
PropertyValuesHolder.ofFloat(TRANSLATION_SHIFT, TRANSLATION_SHIFT_OPENED));
mOpenCloseAnimator.setInterpolator(AGGRESSIVE_EASE);
- mOpenCloseAnimator.setDuration(DEFAULT_OPEN_DURATION).start();
+ mOpenCloseAnimator.setDuration(
+ ALL_APPS.getTransitionDuration(mContext, true /* isToState */)).start();
} else {
mTranslationShift = TRANSLATION_SHIFT_OPENED;
}
@@ -80,7 +81,12 @@
@Override
protected void handleClose(boolean animate) {
Optional.ofNullable(mOnCloseBeginListener).ifPresent(OnCloseListener::onSlideInViewClosed);
- handleClose(animate, DEFAULT_CLOSE_DURATION);
+ handleClose(animate, ALL_APPS.getTransitionDuration(mContext, false /* isToState */));
+ }
+
+ @Override
+ protected Interpolator getIdleInterpolator() {
+ return EMPHASIZED_ACCELERATE;
}
@Override
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java
index f19b7de..a39e872 100644
--- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java
@@ -15,8 +15,8 @@
*/
package com.android.launcher3.taskbar.allapps;
+import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_STASHED_IN_APP_ALL_APPS;
-import static com.android.launcher3.taskbar.allapps.TaskbarAllAppsSlideInView.DEFAULT_OPEN_DURATION;
import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT;
import com.android.launcher3.AbstractFloatingView;
@@ -81,7 +81,8 @@
private void setUpTaskbarStashing() {
mTaskbarStashController.updateStateForFlag(FLAG_STASHED_IN_APP_ALL_APPS, true);
- mTaskbarStashController.applyState(DEFAULT_OPEN_DURATION);
+ mTaskbarStashController.applyState(
+ ALL_APPS.getTransitionDuration(mContext, true /* isToState */));
mSlideInView.setOnCloseBeginListener(() -> {
AbstractFloatingView.closeOpenContainer(
mContext, AbstractFloatingView.TYPE_ACTION_POPUP);
diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
index f32b315..7c52e80 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
@@ -220,8 +220,7 @@
(getActivityFlags() & ACTIVITY_STATE_USER_WILL_BE_ACTIVE) != 0;
boolean visible = (state == NORMAL || state == OVERVIEW)
&& (willUserBeActive || isUserActive())
- && !profile.isVerticalBarLayout()
- && profile.isPhone && !profile.isLandscape;
+ && !profile.isVerticalBarLayout();
UiThreadHelper.runAsyncCommand(this, SET_SHELF_HEIGHT, visible ? 1 : 0,
profile.hotseatBarSizePx);
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
index 86f26c3..00a98c0 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
@@ -118,7 +118,7 @@
if (toState == OVERVIEW_SPLIT_SELECT) {
// Animation to "dismiss" selected taskView
PendingAnimation splitSelectInitAnimation = mRecentsView.createSplitSelectInitAnimation(
- toState.getTransitionDuration(mLauncher));
+ toState.getTransitionDuration(mLauncher, true /* isToState */));
// Add properties to shift remaining taskViews to get out of placeholder view
splitSelectInitAnimation.setFloat(mRecentsView, taskViewsFloat.first,
toState.getSplitSelectTranslation(mLauncher), LINEAR);
diff --git a/quickstep/src/com/android/launcher3/uioverrides/plugins/PluginManagerWrapper.java b/quickstep/src/com/android/launcher3/uioverrides/plugins/PluginManagerWrapper.java
index df0ac7c..fe0bca6 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/plugins/PluginManagerWrapper.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/plugins/PluginManagerWrapper.java
@@ -33,12 +33,12 @@
import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.shared.plugins.PluginManagerImpl;
import com.android.systemui.shared.plugins.PluginPrefs;
+import com.android.systemui.shared.system.UncaughtExceptionPreHandlerManager;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.Optional;
import java.util.Set;
public class PluginManagerWrapper {
@@ -48,6 +48,9 @@
public static final String PLUGIN_CHANGED = PluginManager.PLUGIN_CHANGED;
+ private static final UncaughtExceptionPreHandlerManager UNCAUGHT_EXCEPTION_PRE_HANDLER_MANAGER =
+ new UncaughtExceptionPreHandlerManager();
+
private final Context mContext;
private final PluginManager mPluginManager;
private final PluginEnablerImpl mPluginEnabler;
@@ -67,7 +70,7 @@
mPluginManager = new PluginManagerImpl(c, instanceManagerFactory,
Utilities.IS_DEBUG_DEVICE,
- Optional.ofNullable(Thread.getDefaultUncaughtExceptionHandler()), mPluginEnabler,
+ UNCAUGHT_EXCEPTION_PRE_HANDLER_MANAGER, mPluginEnabler,
new PluginPrefs(c), privilegedPlugins);
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
index cd14b3f..c25a815 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
@@ -30,15 +30,16 @@
*/
public class AllAppsState extends LauncherState {
- private static final int STATE_FLAGS = FLAG_WORKSPACE_INACCESSIBLE | FLAG_CLOSE_POPUPS;
+ private static final int STATE_FLAGS =
+ FLAG_WORKSPACE_INACCESSIBLE | FLAG_CLOSE_POPUPS | FLAG_HOTSEAT_INACCESSIBLE;
public AllAppsState(int id) {
super(id, LAUNCHER_STATE_ALLAPPS, STATE_FLAGS);
}
@Override
- public int getTransitionDuration(Context context) {
- return 150;
+ public int getTransitionDuration(Context context, boolean isToState) {
+ return isToState ? 500 : 300;
}
@Override
@@ -88,7 +89,9 @@
@Override
public int getVisibleElements(Launcher launcher) {
- return ALL_APPS_CONTENT | HOTSEAT_ICONS;
+ // Don't add HOTSEAT_ICONS for phones in ALL_APPS state.
+ return launcher.getDeviceProfile().isPhone ? ALL_APPS_CONTENT
+ : ALL_APPS_CONTENT | HOTSEAT_ICONS;
}
@Override
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewModalTaskState.java b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewModalTaskState.java
index 6f084a1..0c49e5f 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewModalTaskState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewModalTaskState.java
@@ -40,7 +40,7 @@
}
@Override
- public int getTransitionDuration(Context launcher) {
+ public int getTransitionDuration(Context launcher, boolean isToState) {
return 300;
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
index 236454e..699ce97 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
@@ -22,10 +22,12 @@
import android.graphics.Rect;
import android.os.SystemProperties;
+import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
+import com.android.launcher3.taskbar.LauncherTaskbarUIController;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.Themes;
import com.android.quickstep.util.LayoutUtils;
@@ -56,7 +58,7 @@
}
@Override
- public int getTransitionDuration(Context context) {
+ public int getTransitionDuration(Context context, boolean isToState) {
// In gesture modes, overview comes in all the way from the side, so give it more time.
return DisplayController.getNavigationMode(context).hasGestures ? 380 : 250;
}
@@ -93,7 +95,13 @@
@Override
public boolean isTaskbarStashed(Launcher launcher) {
- return true;
+ if (launcher instanceof BaseQuickstepLauncher) {
+ LauncherTaskbarUIController uiController =
+ ((BaseQuickstepLauncher) launcher).getTaskbarUIController();
+
+ return uiController != null && uiController.supportsVisualStashing();
+ }
+ return super.isTaskbarStashed(launcher);
}
@Override
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java b/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java
index b1d83e7..b5b03a1 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java
@@ -42,6 +42,7 @@
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_X;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_Y;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_SCRIM_FADE;
+import static com.android.launcher3.states.StateAnimationConfig.ANIM_VERTICAL_PROGRESS;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCALE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_TRANSLATE;
@@ -50,6 +51,8 @@
import static com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController.ALL_APPS_SCRIM_OPAQUE_THRESHOLD;
import static com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController.ALL_APPS_SCRIM_VISIBLE_THRESHOLD;
import static com.android.quickstep.views.RecentsView.RECENTS_SCALE_PROPERTY;
+import static com.android.systemui.animation.Interpolators.EMPHASIZED_ACCELERATE;
+import static com.android.systemui.animation.Interpolators.EMPHASIZED_DECELERATE;
import android.animation.ValueAnimator;
@@ -179,12 +182,17 @@
}
config.duration = Math.max(config.duration, mHintToNormalDuration);
} else if (fromState == ALL_APPS && toState == NORMAL) {
- config.setInterpolator(ANIM_ALL_APPS_FADE, Interpolators.clampToProgress(DEACCEL,
- 1 - ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD,
- 1 - ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD));
- config.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(DEACCEL,
+ boolean isTablet = mActivity.getDeviceProfile().isTablet;
+ config.setInterpolator(ANIM_ALL_APPS_FADE,
+ isTablet ? FINAL_FRAME : Interpolators.clampToProgress(LINEAR,
+ 1 - ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD,
+ 1 - ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD));
+ config.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(LINEAR,
1 - ALL_APPS_SCRIM_OPAQUE_THRESHOLD,
1 - ALL_APPS_SCRIM_VISIBLE_THRESHOLD));
+ config.setInterpolator(ANIM_VERTICAL_PROGRESS, EMPHASIZED_ACCELERATE);
+ } else if (fromState == NORMAL && toState == ALL_APPS) {
+ config.setInterpolator(ANIM_VERTICAL_PROGRESS, EMPHASIZED_DECELERATE);
}
}
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java
index 7ec1243..4da1d41 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java
@@ -180,7 +180,7 @@
// Normally we compute the duration based on the velocity and distance to the given
// state, but since the hint state tracks the entire screen without a clear endpoint, we
// need to manually set the duration to a reasonable value.
- animator.setDuration(HINT_STATE.getTransitionDuration(mLauncher));
+ animator.setDuration(HINT_STATE.getTransitionDuration(mLauncher, true /* isToState */));
}
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java
index 27a55c3..1504c12 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java
@@ -21,10 +21,9 @@
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
-import static com.android.launcher3.anim.Interpolators.ACCEL;
-import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.FINAL_FRAME;
import static com.android.launcher3.anim.Interpolators.INSTANT;
+import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_SCRIM_FADE;
@@ -131,10 +130,10 @@
boolean isTablet = mLauncher.getDeviceProfile().isTablet;
builder.setInterpolator(ANIM_ALL_APPS_FADE, isTablet
? INSTANT
- : Interpolators.clampToProgress(ACCEL,
+ : Interpolators.clampToProgress(LINEAR,
ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD,
ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD));
- builder.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(ACCEL,
+ builder.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(LINEAR,
ALL_APPS_SCRIM_VISIBLE_THRESHOLD,
ALL_APPS_SCRIM_OPAQUE_THRESHOLD));
return builder;
@@ -145,10 +144,10 @@
boolean isTablet = mLauncher.getDeviceProfile().isTablet;
builder.setInterpolator(ANIM_ALL_APPS_FADE, isTablet
? FINAL_FRAME
- : Interpolators.clampToProgress(DEACCEL,
+ : Interpolators.clampToProgress(LINEAR,
1 - ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD,
1 - ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD));
- builder.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(DEACCEL,
+ builder.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(LINEAR,
1 - ALL_APPS_SCRIM_OPAQUE_THRESHOLD,
1 - ALL_APPS_SCRIM_VISIBLE_THRESHOLD));
return builder;
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index b90e820..5acce89 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -163,7 +163,11 @@
if (mActivity != activity) {
return;
}
+ if (mTaskAnimationManager != null) {
+ mTaskAnimationManager.finishRunningRecentsAnimation(true);
+ }
mRecentsView = null;
+ mActivity.unregisterActivityLifecycleCallbacks(mLifecycleCallbacks);
mActivity = null;
}
};
@@ -1571,9 +1575,6 @@
private void reset() {
mStateCallback.setStateOnUiThread(STATE_HANDLER_INVALIDATED);
- if (mActivity != null) {
- mActivity.unregisterActivityLifecycleCallbacks(mLifecycleCallbacks);
- }
}
/**
diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
index 9686510..48127c0 100644
--- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
@@ -19,7 +19,6 @@
import static com.android.launcher3.anim.Interpolators.ACCEL_2;
import static com.android.launcher3.anim.Interpolators.INSTANT;
import static com.android.launcher3.anim.Interpolators.LINEAR;
-import static com.android.launcher3.util.DisplayController.getNavigationMode;
import static com.android.quickstep.AbsSwipeUpHandler.RECENTS_ATTACH_DURATION;
import static com.android.quickstep.GestureState.GestureEndTarget.RECENTS;
import static com.android.quickstep.util.RecentsAtomicAnimationFactory.INDEX_RECENTS_FADE_ANIM;
@@ -62,7 +61,6 @@
import com.android.quickstep.util.ActivityInitListener;
import com.android.quickstep.util.AnimatorControllerWithResistance;
import com.android.quickstep.util.SplitScreenBounds;
-import com.android.quickstep.views.OverviewActionsView;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.recents.model.ThumbnailData;
@@ -224,7 +222,7 @@
Resources res = context.getResources();
if (dp.isTablet) {
Rect gridRect = new Rect();
- calculateGridSize(context, dp, gridRect);
+ calculateGridSize(dp, gridRect);
PointF taskDimension = getTaskDimension(context, dp);
float scale = gridRect.height() / taskDimension.y;
@@ -238,15 +236,15 @@
int taskMargin = dp.overviewTaskMarginPx;
calculateTaskSizeInternal(context, dp,
dp.overviewTaskThumbnailTopMarginPx,
- getOverviewActionsHeight(context, dp),
+ dp.getOverviewActionsClaimedSpace(),
res.getDimensionPixelSize(R.dimen.overview_minimum_next_prev_size) + taskMargin,
+ Gravity.CENTER,
outRect);
}
}
- private void calculateTaskSizeInternal(Context context, DeviceProfile dp,
- int claimedSpaceAbove, int claimedSpaceBelow, int minimumHorizontalPadding,
- Rect outRect) {
+ private void calculateTaskSizeInternal(Context context, DeviceProfile dp, int claimedSpaceAbove,
+ int claimedSpaceBelow, int minimumHorizontalPadding, int gravity, Rect outRect) {
PointF taskDimension = getTaskDimension(context, dp);
Rect insets = dp.getInsets();
@@ -264,7 +262,7 @@
int outWidth = Math.round(scale * taskDimension.x);
int outHeight = Math.round(scale * taskDimension.y);
- Gravity.apply(Gravity.CENTER, outWidth, outHeight, potentialTaskRect, outRect);
+ Gravity.apply(gravity, outWidth, outHeight, potentialTaskRect, outRect);
}
private static PointF getTaskDimension(Context context, DeviceProfile dp) {
@@ -314,10 +312,10 @@
/**
* Calculates the overview grid size for the provided device configuration.
*/
- public final void calculateGridSize(Context context, DeviceProfile dp, Rect outRect) {
+ public final void calculateGridSize(DeviceProfile dp, Rect outRect) {
Rect insets = dp.getInsets();
int topMargin = dp.overviewTaskThumbnailTopMarginPx;
- int bottomMargin = getOverviewActionsHeight(context, dp);
+ int bottomMargin = dp.getOverviewActionsClaimedSpace();
int sideMargin = dp.overviewGridSideMargin;
outRect.set(0, 0, dp.widthPx, dp.heightPx);
@@ -352,21 +350,17 @@
* Calculates the modal taskView size for the provided device configuration
*/
public final void calculateModalTaskSize(Context context, DeviceProfile dp, Rect outRect) {
+ calculateTaskSize(context, dp, outRect);
+ float maxScale = context.getResources().getFloat(R.dimen.overview_modal_max_scale);
calculateTaskSizeInternal(
context, dp,
dp.overviewTaskMarginPx,
- getOverviewActionsHeight(context, dp),
- dp.overviewTaskMarginPx,
+ dp.heightPx - outRect.bottom - dp.getInsets().bottom,
+ Math.round((dp.availableWidthPx - outRect.width() * maxScale) / 2),
+ Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM,
outRect);
}
- /** Gets the space that the overview actions will take, including bottom margin. */
- private int getOverviewActionsHeight(Context context, DeviceProfile dp) {
- return OverviewActionsView.getOverviewActionsBottomMarginPx(getNavigationMode(context), dp)
- + OverviewActionsView.getOverviewActionsTopMarginPx(getNavigationMode(context), dp)
- + dp.overviewActionsHeight;
- }
-
/**
* Called when the gesture ends and the animation starts towards the given target. Used to add
* an optional additional animation with the same duration.
diff --git a/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java b/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java
index 921674a..dc65b50 100644
--- a/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java
+++ b/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java
@@ -29,7 +29,6 @@
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Handler;
-import android.util.MathUtils;
import android.util.Pair;
import android.view.RemoteAnimationTarget;
import android.view.SurfaceControl;
@@ -46,6 +45,7 @@
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat;
+
/**
* Controls the animation of swiping back and returning to launcher.
*
@@ -88,6 +88,7 @@
private boolean mAnimatorSetInProgress = false;
private float mBackProgress = 0;
private boolean mBackInProgress = false;
+ private IOnBackInvokedCallback mBackCallback;
public LauncherBackAnimationController(
BaseQuickstepLauncher launcher,
@@ -113,34 +114,35 @@
* @param handler Handler to the thread to run the animations on.
*/
public void registerBackCallbacks(Handler handler) {
- SystemUiProxy.INSTANCE.get(mLauncher).setBackToLauncherCallback(
- new IOnBackInvokedCallback.Stub() {
- @Override
- public void onBackCancelled() {
- handler.post(() -> resetPositionAnimated());
- }
+ mBackCallback = new IOnBackInvokedCallback.Stub() {
+ @Override
+ public void onBackCancelled() {
+ handler.post(() -> resetPositionAnimated());
+ }
- @Override
- public void onBackInvoked() {
- handler.post(() -> startTransition());
- }
+ @Override
+ public void onBackInvoked() {
+ handler.post(() -> startTransition());
+ }
- @Override
- public void onBackProgressed(BackEvent backEvent) {
- mBackProgress = backEvent.getProgress();
- // TODO: Update once the interpolation curve spec is finalized.
- mBackProgress =
- 1 - (1 - mBackProgress) * (1 - mBackProgress) * (1
- - mBackProgress);
- if (!mBackInProgress) {
- startBack(backEvent);
- } else {
- updateBackProgress(mBackProgress, backEvent);
- }
- }
+ @Override
+ public void onBackProgressed(BackEvent backEvent) {
+ mBackProgress = backEvent.getProgress();
+ // TODO: Update once the interpolation curve spec is finalized.
+ mBackProgress =
+ 1 - (1 - mBackProgress) * (1 - mBackProgress) * (1
+ - mBackProgress);
+ if (!mBackInProgress) {
+ startBack(backEvent);
+ } else {
+ updateBackProgress(mBackProgress, backEvent);
+ }
+ }
- public void onBackStarted() { }
- });
+ @Override
+ public void onBackStarted() { }
+ };
+ SystemUiProxy.INSTANCE.get(mLauncher).setBackToLauncherCallback(mBackCallback);
}
private void resetPositionAnimated() {
@@ -163,7 +165,10 @@
/** Unregisters the back to launcher callback in shell. */
public void unregisterBackCallbacks() {
- SystemUiProxy.INSTANCE.get(mLauncher).clearBackToLauncherCallback();
+ if (mBackCallback != null) {
+ SystemUiProxy.INSTANCE.get(mLauncher).clearBackToLauncherCallback(mBackCallback);
+ }
+ mBackCallback = null;
}
private void startBack(BackEvent backEvent) {
@@ -195,10 +200,10 @@
float followWidth = screenWidth - dX;
// The 'progress width' is the width of the window if it strictly linearly interpolates
// to minimum scale base on progress.
- float progressWidth = MathUtils.lerp(1, MIN_WINDOW_SCALE, progress) * screenWidth;
+ float progressWidth = Utilities.mapRange(progress, 1, MIN_WINDOW_SCALE) * screenWidth;
// The final width is derived from interpolating between the follow with and progress width
// using gesture progress.
- float width = MathUtils.lerp(followWidth, progressWidth, progress);
+ float width = Utilities.mapRange(progress, followWidth, progressWidth);
float height = screenHeight / screenWidth * width;
float deltaYRatio = (event.getTouchY() - mInitialTouchPos.y) / screenHeight;
// Base the window movement in the Y axis on the touch movement in the Y axis.
@@ -221,13 +226,15 @@
return;
}
mCurrentRect.set(
- MathUtils.lerp(mCancelRect.left, mStartRect.left, progress),
- MathUtils.lerp(mCancelRect.top, mStartRect.top, progress),
- MathUtils.lerp(mCancelRect.right, mStartRect.right, progress),
- MathUtils.lerp(mCancelRect.bottom, mStartRect.bottom, progress));
+ Utilities.mapRange(progress, mCancelRect.left, mStartRect.left),
+ Utilities.mapRange(progress, mCancelRect.top, mStartRect.top),
+ Utilities.mapRange(progress, mCancelRect.right, mStartRect.right),
+ Utilities.mapRange(progress, mCancelRect.bottom, mStartRect.bottom));
+ float endCornerRadius = Utilities.mapRange(
+ mBackProgress, mWindowScaleStartCornerRadius, mWindowScaleEndCornerRadius);
float cornerRadius = Utilities.mapRange(
- progress, mWindowScaleEndCornerRadius, mWindowScaleStartCornerRadius);
+ progress, endCornerRadius, mWindowScaleStartCornerRadius);
applyTransform(mCurrentRect, cornerRadius);
}
@@ -267,12 +274,15 @@
mLauncher.getStateManager().moveToRestState();
}
+ float cornerRadius = Utilities.mapRange(
+ mBackProgress, mWindowScaleStartCornerRadius, mWindowScaleEndCornerRadius);
Pair<RectFSpringAnim, AnimatorSet> pair =
mQuickstepTransitionManager.createWallpaperOpenAnimations(
new RemoteAnimationTargetCompat[]{mBackTarget},
new RemoteAnimationTargetCompat[]{},
false /* fromUnlock */,
- mCurrentRect);
+ mCurrentRect,
+ cornerRadius);
startTransitionAnimations(pair.first, pair.second);
mLauncher.clearForceInvisibleFlag(INVISIBLE_ALL);
}
diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java
index 5ef89d3..fc4c23f 100644
--- a/quickstep/src/com/android/quickstep/SystemUiProxy.java
+++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java
@@ -847,8 +847,14 @@
}
}
- /** Clears the previously registered {@link IOnBackInvokedCallback}. */
- public void clearBackToLauncherCallback() {
+ /** Clears the previously registered {@link IOnBackInvokedCallback}.
+ *
+ * @param callback The previously registered callback instance.
+ */
+ public void clearBackToLauncherCallback(IOnBackInvokedCallback callback) {
+ if (mBackToLauncherCallback != callback) {
+ return;
+ }
mBackToLauncherCallback = null;
if (mBackAnimation == null) {
return;
diff --git a/quickstep/src/com/android/quickstep/TaskIconCache.java b/quickstep/src/com/android/quickstep/TaskIconCache.java
index 300f085..3803f03 100644
--- a/quickstep/src/com/android/quickstep/TaskIconCache.java
+++ b/quickstep/src/com/android/quickstep/TaskIconCache.java
@@ -256,7 +256,7 @@
private BaseIconFactory getIconFactory() {
if (mIconFactory == null) {
mIconFactory = new BaseIconFactory(mContext,
- DisplayController.INSTANCE.get(mContext).getInfo().densityDpi,
+ DisplayController.INSTANCE.get(mContext).getInfo().getDensityDpi(),
mContext.getResources().getDimensionPixelSize(R.dimen.taskbar_icon_size));
}
return mIconFactory;
diff --git a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
index d94e5f1..f53491b 100644
--- a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
+++ b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
@@ -320,6 +320,10 @@
Toast.LENGTH_LONG).show();
}
+ /** Called when the snapshot has updated its full screen drawing parameters. */
+ public void setFullscreenParams(TaskView.FullscreenDrawParams fullscreenParams) {
+ }
+
private class ScreenshotSystemShortcut extends SystemShortcut {
private final BaseDraggingActivity mActivity;
diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java
index 29f2123..6179b81 100644
--- a/quickstep/src/com/android/quickstep/TaskViewUtils.java
+++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java
@@ -38,7 +38,6 @@
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.launcher3.statehandlers.DepthController.DEPTH;
import static com.android.launcher3.testing.TestProtocol.BAD_STATE;
-import static com.android.quickstep.TaskAnimationManager.ENABLE_SHELL_TRANSITIONS;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING;
@@ -501,7 +500,7 @@
}
for (int i = 0; i < nonAppTargets.length; ++i) {
- final SurfaceControl leash = appTargets[i].leash;
+ final SurfaceControl leash = nonAppTargets[i].leash;
if (nonAppTargets[i].windowType == TYPE_DOCK_DIVIDER && leash != null) {
openingTargets.add(leash);
}
diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java
index 5094d49..f68bbbc 100644
--- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java
+++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java
@@ -112,7 +112,7 @@
RecentsState currentState = mActivity.getStateManager().getState();
if (isSplitSelectionState(state) && !isSplitSelectionState(currentState)) {
setter.add(mRecentsView.createSplitSelectInitAnimation(
- state.getTransitionDuration(mActivity)).buildAnim());
+ state.getTransitionDuration(mActivity, true /* isToState */)).buildAnim());
}
Pair<FloatProperty, FloatProperty> taskViewsFloat =
diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
index c9ee2db..3e68c7f 100644
--- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
+++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
@@ -221,6 +221,9 @@
setOverviewStateEnabled(true);
setOverviewGridEnabled(toState.displayOverviewTasksAsGrid(mActivity.getDeviceProfile()));
setOverviewFullscreenEnabled(toState.isFullScreen());
+ if (toState == MODAL_TASK) {
+ setOverviewSelectEnabled(true);
+ }
Log.d(BAD_STATE, "FRV onStateTransitionStart setFreezeVisibility=true, toState=" + toState);
setFreezeViewVisibility(true);
}
@@ -236,6 +239,9 @@
Log.d(BAD_STATE, "FRV onStateTransitionComplete setFreezeVisibility=false, finalState="
+ finalState);
setFreezeViewVisibility(false);
+ if (finalState != MODAL_TASK) {
+ setOverviewSelectEnabled(false);
+ }
if (isOverlayEnabled) {
runActionOnRemoteHandles(remoteTargetHandle ->
diff --git a/quickstep/src/com/android/quickstep/fallback/RecentsState.java b/quickstep/src/com/android/quickstep/fallback/RecentsState.java
index 9705bb6..77db6b7 100644
--- a/quickstep/src/com/android/quickstep/fallback/RecentsState.java
+++ b/quickstep/src/com/android/quickstep/fallback/RecentsState.java
@@ -77,7 +77,7 @@
}
@Override
- public int getTransitionDuration(Context context) {
+ public int getTransitionDuration(Context context, boolean isToState) {
return 250;
}
diff --git a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialController.java b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialController.java
index 9ba5577..35d9f22 100644
--- a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialController.java
+++ b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialController.java
@@ -33,17 +33,22 @@
}
@Override
- public Integer getIntroductionTitle() {
+ public int getIntroductionTitle() {
return R.string.back_gesture_intro_title;
}
@Override
- public Integer getIntroductionSubtitle() {
+ public int getIntroductionSubtitle() {
return R.string.back_gesture_intro_subtitle;
}
@Override
- public Integer getSuccessFeedbackSubtitle() {
+ public int getSpokenIntroductionSubtitle() {
+ return R.string.back_gesture_spoken_intro_subtitle;
+ }
+
+ @Override
+ public int getSuccessFeedbackSubtitle() {
return mTutorialFragment.isAtFinalStep()
? R.string.back_gesture_feedback_complete_without_follow_up
: R.string.back_gesture_feedback_complete_with_overview_follow_up;
diff --git a/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialController.java b/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialController.java
index 6254313..f519d50 100644
--- a/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialController.java
+++ b/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialController.java
@@ -32,17 +32,22 @@
}
@Override
- public Integer getIntroductionTitle() {
+ public int getIntroductionTitle() {
return R.string.home_gesture_intro_title;
}
@Override
- public Integer getIntroductionSubtitle() {
+ public int getIntroductionSubtitle() {
return R.string.home_gesture_intro_subtitle;
}
@Override
- public Integer getSuccessFeedbackSubtitle() {
+ public int getSpokenIntroductionSubtitle() {
+ return R.string.home_gesture_spoken_intro_subtitle;
+ }
+
+ @Override
+ public int getSuccessFeedbackSubtitle() {
return mTutorialFragment.isAtFinalStep()
? R.string.home_gesture_feedback_complete_without_follow_up
: R.string.home_gesture_feedback_complete_with_follow_up;
diff --git a/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java b/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java
index 09640c6..6b016ce 100644
--- a/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java
+++ b/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java
@@ -42,17 +42,22 @@
}
@Override
- public Integer getIntroductionTitle() {
+ public int getIntroductionTitle() {
return R.string.overview_gesture_intro_title;
}
@Override
- public Integer getIntroductionSubtitle() {
+ public int getIntroductionSubtitle() {
return R.string.overview_gesture_intro_subtitle;
}
@Override
- public Integer getSuccessFeedbackSubtitle() {
+ public int getSpokenIntroductionSubtitle() {
+ return R.string.overview_gesture_spoken_intro_subtitle;
+ }
+
+ @Override
+ public int getSuccessFeedbackSubtitle() {
return mTutorialFragment.getNumSteps() > 1 && mTutorialFragment.isAtFinalStep()
? R.string.overview_gesture_feedback_complete_with_follow_up
: R.string.overview_gesture_feedback_complete_without_follow_up;
diff --git a/quickstep/src/com/android/quickstep/interaction/TutorialController.java b/quickstep/src/com/android/quickstep/interaction/TutorialController.java
index 6a8894e..fa7d848 100644
--- a/quickstep/src/com/android/quickstep/interaction/TutorialController.java
+++ b/quickstep/src/com/android/quickstep/interaction/TutorialController.java
@@ -62,7 +62,7 @@
abstract class TutorialController implements BackGestureAttemptCallback,
NavBarGestureAttemptCallback {
- private static final String TAG = "TutorialController";
+ private static final String LOG_TAG = "TutorialController";
private static final float FINGER_DOT_VISIBLE_ALPHA = 0.7f;
private static final float FINGER_DOT_SMALL_SCALE = 0.7f;
@@ -217,18 +217,23 @@
}
@StringRes
- public Integer getIntroductionTitle() {
- return null;
+ public int getIntroductionTitle() {
+ return NO_ID;
}
@StringRes
- public Integer getIntroductionSubtitle() {
- return null;
+ public int getIntroductionSubtitle() {
+ return NO_ID;
}
@StringRes
- public Integer getSuccessFeedbackSubtitle() {
- return null;
+ public int getSpokenIntroductionSubtitle() {
+ return NO_ID;
+ }
+
+ @StringRes
+ public int getSuccessFeedbackSubtitle() {
+ return NO_ID;
}
void showFeedback() {
@@ -247,7 +252,16 @@
* Show feedback reflecting a successful gesture attempt.
**/
void showSuccessFeedback() {
- showFeedback(getSuccessFeedbackSubtitle(), true);
+ int successSubtitleResId = getSuccessFeedbackSubtitle();
+ if (successSubtitleResId == NO_ID) {
+ // Allow crash since this should never be reached with a tutorial controller used in
+ // production.
+ Log.e(LOG_TAG,
+ "Cannot show success feedback for tutorial step: " + mTutorialType
+ + ", no success feedback subtitle",
+ new IllegalStateException());
+ }
+ showFeedback(successSubtitleResId, true);
}
/**
@@ -269,6 +283,7 @@
isGestureSuccessful
? R.string.gesture_tutorial_nice : R.string.gesture_tutorial_try_again,
subtitleResId,
+ NO_ID,
isGestureSuccessful,
false);
}
@@ -276,6 +291,7 @@
void showFeedback(
int titleResId,
int subtitleResId,
+ int spokenSubtitleResId,
boolean isGestureSuccessful,
boolean useGestureAnimationDelay) {
mFeedbackTitleView.removeCallbacks(mTitleViewCallback);
@@ -287,7 +303,10 @@
mFeedbackTitleView.setText(titleResId);
TextView subtitle =
mFeedbackView.findViewById(R.id.gesture_tutorial_fragment_feedback_subtitle);
- subtitle.setText(subtitleResId);
+ subtitle.setText(spokenSubtitleResId == NO_ID
+ ? mContext.getText(subtitleResId)
+ : Utilities.wrapForTts(
+ mContext.getText(subtitleResId), mContext.getString(spokenSubtitleResId)));
if (isGestureSuccessful) {
if (mTutorialFragment.isAtFinalStep()) {
showActionButton();
@@ -580,7 +599,7 @@
packageManager.getApplicationInfo(
PIXEL_TIPS_APP_PACKAGE_NAME, PackageManager.GET_META_DATA));
} catch (PackageManager.NameNotFoundException e) {
- Log.e(TAG,
+ Log.e(LOG_TAG,
"Could not find app label for package name: "
+ PIXEL_TIPS_APP_PACKAGE_NAME
+ ". Defaulting to 'Pixel Tips.'",
@@ -593,7 +612,7 @@
subtitleTextView.setText(
mContext.getString(R.string.skip_tutorial_dialog_subtitle, tipsAppName));
} else {
- Log.w(TAG, "No subtitle view in the skip tutorial dialog to update.");
+ Log.w(LOG_TAG, "No subtitle view in the skip tutorial dialog to update.");
}
Button cancelButton = (Button) contentView.findViewById(
@@ -602,7 +621,7 @@
cancelButton.setOnClickListener(
v -> tutorialDialog.dismiss());
} else {
- Log.w(TAG, "No cancel button in the skip tutorial dialog to update.");
+ Log.w(LOG_TAG, "No cancel button in the skip tutorial dialog to update.");
}
Button confirmButton = contentView.findViewById(
@@ -613,7 +632,7 @@
tutorialDialog.dismiss();
});
} else {
- Log.w(TAG, "No confirm button in the skip tutorial dialog to update.");
+ Log.w(LOG_TAG, "No confirm button in the skip tutorial dialog to update.");
}
tutorialDialog.getWindow().setBackgroundDrawable(
diff --git a/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java b/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
index 33e800d..1599c8c 100644
--- a/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
+++ b/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
@@ -15,6 +15,8 @@
*/
package com.android.quickstep.interaction;
+import static android.view.View.NO_ID;
+
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.app.Activity;
@@ -211,13 +213,31 @@
if (isGestureComplete()) {
mTutorialController.showSuccessFeedback();
} else if (!mIntroductionShown) {
- Integer introTileStringResId = mTutorialController.getIntroductionTitle();
- Integer introSubtitleResId = mTutorialController.getIntroductionSubtitle();
- if (introTileStringResId != null && introSubtitleResId != null) {
- mTutorialController.showFeedback(
- introTileStringResId, introSubtitleResId, false, true);
- mIntroductionShown = true;
+ int introTitleResId = mTutorialController.getIntroductionTitle();
+ int introSubtitleResId = mTutorialController.getIntroductionSubtitle();
+ if (introTitleResId == NO_ID) {
+ // Allow crash since this should never be reached with a tutorial controller used in
+ // production.
+ Log.e(LOG_TAG,
+ "Cannot show introduction feedback for tutorial step: " + mTutorialType
+ + ", no introduction feedback title",
+ new IllegalStateException());
}
+ if (introTitleResId == NO_ID) {
+ // Allow crash since this should never be reached with a tutorial controller used in
+ // production.
+ Log.e(LOG_TAG,
+ "Cannot show introduction feedback for tutorial step: " + mTutorialType
+ + ", no introduction feedback subtitle",
+ new IllegalStateException());
+ }
+ mTutorialController.showFeedback(
+ introTitleResId,
+ introSubtitleResId,
+ mTutorialController.getSpokenIntroductionSubtitle(),
+ false,
+ true);
+ mIntroductionShown = true;
}
}
diff --git a/quickstep/src/com/android/quickstep/util/OverviewToHomeAnim.java b/quickstep/src/com/android/quickstep/util/OverviewToHomeAnim.java
index 5cf4f0b..3cec1a4 100644
--- a/quickstep/src/com/android/quickstep/util/OverviewToHomeAnim.java
+++ b/quickstep/src/com/android/quickstep/util/OverviewToHomeAnim.java
@@ -82,7 +82,7 @@
// WorkspaceRevealAnim handles the depth, so don't interfere.
config.animFlags |= StateAnimationConfig.SKIP_DEPTH_CONTROLLER;
}
- config.duration = startState.getTransitionDuration(mLauncher);
+ config.duration = startState.getTransitionDuration(mLauncher, false /* isToState */);
AnimatorSet stateAnim = stateManager.createAtomicAnimation(
startState, NORMAL, config);
stateAnim.addListener(new AnimationSuccessListener() {
diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
index 45aaf35..306ebd7 100644
--- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
@@ -100,6 +100,9 @@
setOverviewStateEnabled(toState.overviewUi);
setOverviewGridEnabled(toState.displayOverviewTasksAsGrid(mActivity.getDeviceProfile()));
setOverviewFullscreenEnabled(toState.getOverviewFullscreenProgress() == 1);
+ if (toState == OVERVIEW_MODAL_TASK) {
+ setOverviewSelectEnabled(true);
+ }
Log.d(BAD_STATE, "LRV onStateTransitionStart setFreezeVisibility=true, toState=" + toState);
setFreezeViewVisibility(true);
}
@@ -115,6 +118,9 @@
Log.d(BAD_STATE, "LRV onStateTransitionComplete setFreezeVisibility=false, finalState="
+ finalState);
setFreezeViewVisibility(false);
+ if (finalState != OVERVIEW_MODAL_TASK) {
+ setOverviewSelectEnabled(false);
+ }
if (isOverlayEnabled) {
runActionOnRemoteHandles(remoteTargetHandle ->
diff --git a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java
index 99a2d6f..1c4e497 100644
--- a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java
+++ b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java
@@ -16,8 +16,6 @@
package com.android.quickstep.views;
-import static com.android.launcher3.util.DisplayController.NavigationMode.THREE_BUTTONS;
-
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
@@ -58,7 +56,6 @@
HIDDEN_NON_ZERO_ROTATION,
HIDDEN_NO_TASKS,
HIDDEN_NO_RECENTS,
- HIDDEN_FOCUSED_SCROLL,
HIDDEN_SPLIT_SCREEN})
@Retention(RetentionPolicy.SOURCE)
public @interface ActionsHiddenFlags { }
@@ -66,8 +63,7 @@
public static final int HIDDEN_NON_ZERO_ROTATION = 1 << 0;
public static final int HIDDEN_NO_TASKS = 1 << 1;
public static final int HIDDEN_NO_RECENTS = 1 << 2;
- public static final int HIDDEN_FOCUSED_SCROLL = 1 << 3;
- public static final int HIDDEN_SPLIT_SCREEN = 1 << 4;
+ public static final int HIDDEN_SPLIT_SCREEN = 1 << 3;
@IntDef(flag = true, value = {
DISABLED_SCROLLING,
@@ -99,6 +95,7 @@
@Nullable
protected DeviceProfile mDp;
+ private final Rect mTaskSize = new Rect();
public OverviewActionsView(Context context) {
this(context, null);
@@ -202,8 +199,10 @@
* Offsets OverviewActionsView horizontal position based on 3 button nav container in taskbar.
*/
private void updatePadding() {
- boolean alignFor3ButtonTaskbar = mDp.isTaskbarPresent &&
- DisplayController.getNavigationMode(getContext()) == THREE_BUTTONS;
+ if (mDp == null) {
+ return;
+ }
+ boolean alignFor3ButtonTaskbar = mDp.isTaskbarPresent && !mDp.isGestureMode;
if (alignFor3ButtonTaskbar) {
// Add extra horizontal spacing
int additionalPadding = ApiWrapper.getHotseatEndOffset(getContext());
@@ -225,15 +224,34 @@
LayoutParams actionParams = (LayoutParams) findViewById(
R.id.action_buttons).getLayoutParams();
actionParams.setMargins(
- actionParams.leftMargin, getOverviewActionsTopMarginPx(mode, mDp),
- actionParams.rightMargin, getOverviewActionsBottomMarginPx(mode, mDp));
+ actionParams.leftMargin, mDp.overviewActionsTopMarginPx,
+ actionParams.rightMargin, getBottomMargin());
+ }
+
+ private int getBottomMargin() {
+ if (mDp == null) {
+ return 0;
+ }
+
+ if (mDp.isVerticalBarLayout()) {
+ return mDp.getInsets().bottom;
+ }
+
+ if (!mDp.isGestureMode && mDp.isTaskbarPresent) {
+ return mDp.getOverviewActionsClaimedSpaceBelow();
+ }
+
+ // Align to bottom of task Rect.
+ return mDp.heightPx - mTaskSize.bottom - mDp.overviewActionsTopMarginPx
+ - mDp.overviewActionsHeight;
}
/**
- * Set the device profile for this view to draw with.
+ * Updates device profile and task size for this view to draw with.
*/
- public void setDp(DeviceProfile dp) {
+ public void updateDimension(DeviceProfile dp, Rect taskSize) {
mDp = dp;
+ mTaskSize.set(taskSize);
updateVerticalMargin(DisplayController.getNavigationMode(getContext()));
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
@@ -257,45 +275,4 @@
mSplitButton.setVisibility(visible ? VISIBLE : GONE);
findViewById(R.id.action_split_space).setVisibility(visible ? VISIBLE : GONE);
}
-
- /** Get the top margin associated with the action buttons in Overview. */
- public static int getOverviewActionsTopMarginPx(NavigationMode mode, DeviceProfile dp) {
- // In vertical bar, use the smaller task margin for the top regardless of mode
- if (dp.isVerticalBarLayout()) {
- return dp.overviewTaskMarginPx;
- }
-
- if (mode == NavigationMode.THREE_BUTTONS) {
- return dp.overviewActionsMarginThreeButtonPx;
- }
-
- return dp.overviewActionsTopMarginGesturePx;
- }
-
- /** Get the bottom margin associated with the action buttons in Overview. */
- public static int getOverviewActionsBottomMarginPx(NavigationMode mode, DeviceProfile dp) {
- int bottomInset = dp.getInsets().bottom;
-
- if (dp.isVerticalBarLayout()) {
- return bottomInset;
- }
-
- if (mode == NavigationMode.THREE_BUTTONS) {
- int bottomMargin = dp.overviewActionsMarginThreeButtonPx + bottomInset;
- if (dp.isTaskbarPresent) {
- // Align vertically, using taskbar height + mDp.taskbarOffsetY() to estimate where
- // the button nav top is.
- int actionsTop = (dp.heightPx - bottomMargin - bottomInset)
- - dp.overviewActionsHeight;
- int navTop = dp.heightPx - (dp.taskbarSize + dp.getTaskbarOffsetY());
- bottomMargin -=
- navTop - actionsTop + ((dp.taskbarSize - dp.overviewActionsHeight) / 2);
- }
- return bottomMargin;
- }
-
- // There is no bottom inset when taskbar is present, use stashed taskbar as padding instead.
- return dp.overviewActionsBottomMarginGesturePx
- + (dp.isTaskbarPresent ? dp.stashedTaskbarSize : bottomInset);
- }
}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 01b06cb..224c1f6 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -378,6 +378,8 @@
// OverScroll constants
private static final int OVERSCROLL_PAGE_SNAP_ANIMATION_DURATION = 270;
+ private static final int DEFAULT_ACTIONS_VIEW_ALPHA_ANIMATION_DURATION = 300;
+
private static final int DISMISS_TASK_DURATION = 300;
private static final int ADDITION_TASK_DURATION = 200;
private static final float INITIAL_DISMISS_TRANSLATION_INTERPOLATION_OFFSET = 0.55f;
@@ -455,6 +457,7 @@
protected boolean mFreezeViewVisibility;
private boolean mOverviewGridEnabled;
private boolean mOverviewFullscreenEnabled;
+ private boolean mOverviewSelectEnabled;
private float mAdjacentPageHorizontalOffset = 0;
protected float mTaskViewsSecondaryTranslation = 0;
@@ -651,6 +654,8 @@
private TaskView mMovingTaskView;
private OverviewActionsView mActionsView;
+ private ObjectAnimator mActionsViewAlphaAnimator;
+ private float mActionsViewAlphaAnimatorFinalValue;
private MultiWindowModeChangedListener mMultiWindowModeChangedListener =
new MultiWindowModeChangedListener() {
@@ -1144,6 +1149,11 @@
return getScrollForPage(taskIndex) == getPagedOrientationHandler().getPrimaryScroll(this);
}
+ private boolean isFocusedTaskInExpectedScrollPosition() {
+ TaskView focusedTask = getFocusedTaskView();
+ return focusedTask != null && isTaskInExpectedScrollPosition(indexOfChild(focusedTask));
+ }
+
/**
* Returns a {@link TaskView} that has taskId matching {@code taskId} or null if no match.
*/
@@ -1190,13 +1200,15 @@
@Override
protected void onPageBeginTransition() {
super.onPageBeginTransition();
- mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING, true);
+ if (!mActivity.getDeviceProfile().isTablet) {
+ mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING, true);
+ }
}
@Override
protected void onPageEndTransition() {
super.onPageEndTransition();
- if (isClearAllHidden()) {
+ if (isClearAllHidden() && !mActivity.getDeviceProfile().isTablet) {
mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING, false);
}
if (getNextPage() > 0) {
@@ -1637,11 +1649,11 @@
// Propagate DeviceProfile change event.
runActionOnRemoteHandles(
remoteTargetHandle -> remoteTargetHandle.getTaskViewSimulator().setDp(dp));
- mActionsView.setDp(dp);
mOrientationState.setDeviceProfile(dp);
// Update RecentsView and TaskView's DeviceProfile dependent layout.
updateOrientationHandler();
+ mActionsView.updateDimension(dp, mLastComputedTaskSize);
}
private void updateOrientationHandler() {
@@ -1706,7 +1718,7 @@
dp.widthPx - mInsets.right - mTempRect.right,
dp.heightPx - mInsets.bottom - mTempRect.bottom);
- mSizeStrategy.calculateGridSize(mActivity, mActivity.getDeviceProfile(),
+ mSizeStrategy.calculateGridSize(mActivity.getDeviceProfile(),
mLastComputedGridSize);
mSizeStrategy.calculateGridTaskSize(mActivity, mActivity.getDeviceProfile(),
mLastComputedGridTaskSize, mOrientationHandler);
@@ -1764,7 +1776,8 @@
* Returns the size of task selected to enter modal state.
*/
public Point getSelectedTaskSize() {
- mSizeStrategy.calculateTaskSize(mActivity, mActivity.getDeviceProfile(), mTempRect);
+ mSizeStrategy.calculateTaskSize(mActivity, mActivity.getDeviceProfile(),
+ mTempRect);
return new Point(mTempRect.width(), mTempRect.height());
}
@@ -1806,16 +1819,24 @@
}
private void updateActionsViewFocusedScroll() {
- boolean hiddenFocusedScroll;
if (showAsGrid()) {
- TaskView focusedTaskView = getFocusedTaskView();
- hiddenFocusedScroll = focusedTaskView == null
- || !isTaskInExpectedScrollPosition(indexOfChild(focusedTaskView));
- } else {
- hiddenFocusedScroll = false;
+ float actionsViewAlphaValue = isFocusedTaskInExpectedScrollPosition() ? 1 : 0;
+ // If animation is already in progress towards the same end value, do not restart.
+ if (mActionsViewAlphaAnimator == null || !mActionsViewAlphaAnimator.isStarted()
+ || (mActionsViewAlphaAnimator.isStarted()
+ && mActionsViewAlphaAnimatorFinalValue != actionsViewAlphaValue)) {
+ animateActionsViewAlpha(actionsViewAlphaValue,
+ DEFAULT_ACTIONS_VIEW_ALPHA_ANIMATION_DURATION);
+ }
}
- mActionsView.updateHiddenFlags(OverviewActionsView.HIDDEN_FOCUSED_SCROLL,
- hiddenFocusedScroll);
+ }
+
+ private void animateActionsViewAlpha(float alphaValue, long duration) {
+ mActionsViewAlphaAnimator = ObjectAnimator.ofFloat(
+ mActionsView.getVisibilityAlpha(), MultiValueAlpha.VALUE, alphaValue);
+ mActionsViewAlphaAnimatorFinalValue = alphaValue;
+ mActionsViewAlphaAnimator.setDuration(duration);
+ mActionsViewAlphaAnimator.start();
}
/**
@@ -2344,10 +2365,9 @@
}
private void animateActionsViewIn() {
- ObjectAnimator anim = ObjectAnimator.ofFloat(
- mActionsView.getVisibilityAlpha(), MultiValueAlpha.VALUE, 0, 1);
- anim.setDuration(TaskView.SCALE_ICON_DURATION);
- anim.start();
+ if (!showAsGrid() || isFocusedTaskInExpectedScrollPosition()) {
+ animateActionsViewAlpha(1, TaskView.SCALE_ICON_DURATION);
+ }
}
public void animateUpTaskIconScale() {
@@ -3289,7 +3309,7 @@
// Update various scroll-dependent UI.
dispatchScrollChanged();
updateActionsViewFocusedScroll();
- if (isClearAllHidden()) {
+ if (isClearAllHidden() && !mActivity.getDeviceProfile().isTablet) {
mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING,
false);
}
@@ -3688,10 +3708,7 @@
// Update the pivots such that when the task is scaled, it fills the full page
getTaskSize(mTempRect);
- getPagedViewOrientedState().getFullScreenScaleAndPivot(mTempRect,
- mActivity.getDeviceProfile(), mTempPointF);
- setPivotX(mTempPointF.x);
- setPivotY(mTempPointF.y);
+ updatePivots();
setTaskModalness(mTaskModalness);
mLastComputedTaskStartPushOutDistance = null;
mLastComputedTaskEndPushOutDistance = null;
@@ -3703,6 +3720,18 @@
: IMPORTANT_FOR_ACCESSIBILITY_AUTO);
}
+ private void updatePivots() {
+ if (mOverviewSelectEnabled) {
+ setPivotX(mLastComputedTaskSize.centerX());
+ setPivotY(mLastComputedTaskSize.bottom);
+ } else {
+ getPagedViewOrientedState().getFullScreenScaleAndPivot(mTempRect,
+ mActivity.getDeviceProfile(), mTempPointF);
+ setPivotX(mTempPointF.x);
+ setPivotY(mTempPointF.y);
+ }
+ }
+
private void updatePageOffsets() {
float offset = mAdjacentPageHorizontalOffset;
float modalOffset = ACCEL_0_75.getInterpolation(mTaskModalness);
@@ -4029,7 +4058,8 @@
// TODO(194414938) starting bounds seem slightly off, investigate
Rect firstTaskStartingBounds = new Rect();
Rect firstTaskEndingBounds = mTempRect;
- int duration = mActivity.getStateManager().getState().getTransitionDuration(getContext());
+ int duration = mActivity.getStateManager().getState().getTransitionDuration(getContext(),
+ false /* isToState */);
PendingAnimation pendingAnimation = new PendingAnimation(duration);
int halfDividerSize = getResources()
@@ -4865,6 +4895,17 @@
}
/**
+ * Update whether RecentsView is in select mode. Should be enabled before transitioning to
+ * select mode, and only disabled after transitioning from select mode.
+ */
+ public void setOverviewSelectEnabled(boolean overviewSelectEnabled) {
+ if (mOverviewSelectEnabled != overviewSelectEnabled) {
+ mOverviewSelectEnabled = overviewSelectEnabled;
+ updatePivots();
+ }
+ }
+
+ /**
* Switch the current running task view to static snapshot mode,
* capturing the snapshot at the same time.
*/
diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
index bff8651..d8120ff 100644
--- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -283,6 +283,7 @@
public void setFullscreenParams(TaskView.FullscreenDrawParams fullscreenParams) {
mFullscreenParams = fullscreenParams;
+ getTaskOverlay().setFullscreenParams(fullscreenParams);
invalidate();
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 8869ff1..b5971f2 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -1022,7 +1022,7 @@
}
public float getTaskCornerRadius() {
- return TaskCornerRadius.get(mActivity);
+ return mCurrentFullscreenParams.mCornerRadius;
}
@Override
diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml
index d0d82d4..2ac7e63 100644
--- a/res/layout/all_apps.xml
+++ b/res/layout/all_apps.xml
@@ -30,10 +30,6 @@
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
deleted file mode 100644
index 567cb5f..0000000
--- a/res/layout/search_results_rv_layout.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?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 635db14..0fe05ee 100644
--- a/res/layout/secondary_launcher.xml
+++ b/res/layout/secondary_launcher.xml
@@ -60,10 +60,6 @@
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/values/attrs.xml b/res/values/attrs.xml
index dd3e08b..e85969b 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -306,6 +306,17 @@
if not specified -->
<attr name="allAppsBorderSpaceTwoPanelLandscapeVertical" format="float" />
+ <!-- alignment of hotseat to the grid.
+ Not applicable for 3 button mode when taskbar is enabled -->
+ <!-- defaults to numColumns, if not specified -->
+ <attr name="hotseatColumnSpan" format="integer" />
+ <!-- defaults to numColumns, if not specified -->
+ <attr name="hotseatColumnSpanLandscape" format="integer" />
+ <!-- defaults to numColumns, if not specified -->
+ <attr name="hotseatColumnSpanTwoPanelLandscape" format="integer" />
+ <!-- defaults to numColumns, if not specified -->
+ <attr name="hotseatColumnSpanTwoPanelPortrait" format="integer" />
+
<!-- defaults to borderSpaceDps, if not specified -->
<attr name="hotseatBorderSpace" format="float" />
<!-- defaults to hotseatBorderSpace, if not specified -->
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 52ff3f0..2c3f5ed 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -368,9 +368,7 @@
<dimen name="overview_actions_height">0dp</dimen>
<dimen name="overview_actions_button_spacing">0dp</dimen>
<dimen name="overview_actions_margin_gesture">0dp</dimen>
- <dimen name="overview_actions_top_margin_gesture">0dp</dimen>
- <dimen name="overview_actions_bottom_margin_gesture">0dp</dimen>
- <dimen name="overview_actions_margin_three_button">0dp</dimen>
+ <dimen name="overview_actions_top_margin">0dp</dimen>
<dimen name="overview_grid_side_margin">0dp</dimen>
<dimen name="overview_grid_row_spacing">0dp</dimen>
<dimen name="overview_page_spacing">0dp</dimen>
diff --git a/res/xml/device_profiles.xml b/res/xml/device_profiles.xml
index 07ce598..258da80 100644
--- a/res/xml/device_profiles.xml
+++ b/res/xml/device_profiles.xml
@@ -176,6 +176,7 @@
launcher:allAppsBorderSpaceHorizontal="8"
launcher:allAppsBorderSpaceVertical="16"
launcher:allAppsBorderSpaceLandscape="16"
+ launcher:hotseatColumnSpanLandscape="4"
launcher:hotseatBorderSpace="58"
launcher:hotseatBorderSpaceLandscape="50.4"
launcher:canBeDefault="true" />
diff --git a/res/xml/paddings_6x5.xml b/res/xml/paddings_6x5.xml
index a958ec7..a72f554 100644
--- a/res/xml/paddings_6x5.xml
+++ b/res/xml/paddings_6x5.xml
@@ -32,7 +32,7 @@
</device-padding>
<device-padding
- launcher:maxEmptySpace="80dp">
+ launcher:maxEmptySpace="170dp">
<workspaceTopPadding
launcher:a="0"
launcher:b="20dp"/>
@@ -47,7 +47,7 @@
</device-padding>
<device-padding
- launcher:maxEmptySpace="280dp">
+ launcher:maxEmptySpace="410dp">
<workspaceTopPadding
launcher:a="0"
launcher:b="112dp"/>
diff --git a/src/com/android/launcher3/FastScrollRecyclerView.java b/src/com/android/launcher3/BaseRecyclerView.java
similarity index 95%
rename from src/com/android/launcher3/FastScrollRecyclerView.java
rename to src/com/android/launcher3/BaseRecyclerView.java
index a60d143..9369bdc 100644
--- a/src/com/android/launcher3/FastScrollRecyclerView.java
+++ b/src/com/android/launcher3/BaseRecyclerView.java
@@ -37,19 +37,19 @@
* <li> Enable fast scroller.
* </ul>
*/
-public abstract class FastScrollRecyclerView extends RecyclerView {
+public abstract class BaseRecyclerView extends RecyclerView {
protected RecyclerViewFastScroller mScrollbar;
- public FastScrollRecyclerView(Context context) {
+ public BaseRecyclerView(Context context) {
this(context, null);
}
- public FastScrollRecyclerView(Context context, AttributeSet attrs) {
+ public BaseRecyclerView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
- public FastScrollRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) {
+ public BaseRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@@ -206,4 +206,4 @@
}
scrollToPosition(0);
}
-}
+}
\ No newline at end of file
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 74ec7ee..6302739 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -96,7 +96,6 @@
private static final int MAX_SEARCH_LOOP_COUNT = 20;
private static final int[] STATE_PRESSED = new int[]{android.R.attr.state_pressed};
- private static final float HIGHLIGHT_SCALE = 1.16f;
private final PointF mTranslationForReorderBounce = new PointF(0, 0);
private final PointF mTranslationForReorderPreview = new PointF(0, 0);
@@ -259,6 +258,12 @@
mDotParams.scale = 0f;
mForceHideDot = false;
setBackground(null);
+
+ setTag(null);
+ if (mIconLoadRequest != null) {
+ mIconLoadRequest.cancel();
+ mIconLoadRequest = null;
+ }
}
private void cancelDotScaleAnim() {
@@ -363,8 +368,7 @@
}
}
- public void setBubbleTextHolder(
- BubbleTextHolder bubbleTextHolder) {
+ public void setBubbleTextHolder(BubbleTextHolder bubbleTextHolder) {
mBubbleTextHolder = bubbleTextHolder;
}
@@ -1020,19 +1024,6 @@
getIconBounds(mIconSize, bounds);
}
- private int getIconSizeForDisplay(int display) {
- DeviceProfile grid = mActivity.getDeviceProfile();
- switch (display) {
- case DISPLAY_ALL_APPS:
- return grid.allAppsIconSizePx;
- case DISPLAY_FOLDER:
- return grid.folderChildIconSizePx;
- case DISPLAY_WORKSPACE:
- default:
- return grid.iconSizePx;
- }
- }
-
public void getSourceVisualDragBounds(Rect bounds) {
getIconBounds(mIconSize, bounds);
}
@@ -1045,8 +1036,8 @@
}
private void resetIconScale() {
- if (mIcon instanceof FastBitmapDrawable) {
- ((FastBitmapDrawable) mIcon).resetScale();
+ if (mIcon != null) {
+ mIcon.resetScale();
}
}
diff --git a/src/com/android/launcher3/DefaultLayoutParser.java b/src/com/android/launcher3/DefaultLayoutParser.java
index af85594..4daca8b 100644
--- a/src/com/android/launcher3/DefaultLayoutParser.java
+++ b/src/com/android/launcher3/DefaultLayoutParser.java
@@ -7,15 +7,19 @@
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
+import android.content.pm.LauncherApps;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.os.Bundle;
+import android.os.Process;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
import com.android.launcher3.LauncherSettings.Favorites;
+import com.android.launcher3.model.data.WorkspaceItemInfo;
+import com.android.launcher3.shortcuts.ShortcutKey;
import com.android.launcher3.util.Thunk;
import org.xmlpull.v1.XmlPullParser;
@@ -23,6 +27,7 @@
import java.io.IOException;
import java.net.URISyntaxException;
+import java.util.Collections;
import java.util.List;
/**
@@ -43,6 +48,8 @@
private static final String ATTR_CONTAINER = "container";
private static final String ATTR_SCREEN = "screen";
private static final String ATTR_FOLDER_ITEMS = "folderItems";
+ private static final String ATTR_SHORTCUT_ID = "shortcutId";
+ private static final String ATTR_PACKAGE_NAME = "packageName";
// TODO: Remove support for this broadcast, instead use widget options to send bind time options
private static final String ACTION_APPWIDGET_DEFAULT_WORKSPACE_CONFIGURE =
@@ -178,7 +185,6 @@
}
}
-
/**
* Shortcut parser which allows any uri and not just web urls.
*/
@@ -189,6 +195,35 @@
}
@Override
+ public int parseAndAdd(XmlPullParser parser) {
+ final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME);
+ final String shortcutId = getAttributeValue(parser, ATTR_SHORTCUT_ID);
+ if (!TextUtils.isEmpty(packageName) && !TextUtils.isEmpty(shortcutId)) {
+ return parseAndAddDeepShortcut(shortcutId, packageName);
+ }
+ return super.parseAndAdd(parser);
+ }
+
+ /**
+ * This method parses and adds a deep shortcut.
+ * @return item id if the shortcut is successfully added else -1
+ */
+ private int parseAndAddDeepShortcut(String shortcutId, String packageName) {
+ try {
+ LauncherApps launcherApps = mContext.getSystemService(LauncherApps.class);
+ launcherApps.pinShortcuts(packageName, Collections.singletonList(shortcutId),
+ Process.myUserHandle());
+ Intent intent = ShortcutKey.makeIntent(shortcutId, packageName);
+ mValues.put(Favorites.RESTORED, WorkspaceItemInfo.FLAG_RESTORED_ICON);
+ return addShortcut(null, intent, Favorites.ITEM_TYPE_DEEP_SHORTCUT);
+ } catch (Exception e) {
+ Log.e(TAG, "Unable to pin the shortcut for shortcut id = " + shortcutId
+ + " and package name = " + packageName);
+ }
+ return -1;
+ }
+
+ @Override
protected Intent parseIntent(XmlPullParser parser) {
String uri = null;
try {
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 33bb0a5..88030ae 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -158,6 +158,7 @@
public final int numShownHotseatIcons;
public int hotseatCellHeightPx;
private final int hotseatExtraVerticalSize;
+ private final boolean areNavButtonsInline;
// In portrait: size = height, in landscape: size = width
public int hotseatBarSizePx;
public int hotseatBarTopPaddingPx;
@@ -195,9 +196,7 @@
public int overviewTaskIconDrawableSizeGridPx;
public int overviewTaskThumbnailTopMarginPx;
public final int overviewActionsHeight;
- public final int overviewActionsMarginThreeButtonPx;
- public final int overviewActionsTopMarginGesturePx;
- public final int overviewActionsBottomMarginGesturePx;
+ public final int overviewActionsTopMarginPx;
public final int overviewActionsButtonSpacing;
public int overviewPageSpacing;
public int overviewRowSpacing;
@@ -360,7 +359,7 @@
// We shrink hotseat sizes regardless of orientation, if nav buttons are inline and QSB
// might be inline in either orientations, to keep hotseat size consistent across rotation.
- boolean areNavButtonsInline = isTaskbarPresent && !isGestureMode;
+ areNavButtonsInline = isTaskbarPresent && !isGestureMode;
if (areNavButtonsInline && canQsbInline) {
numShownHotseatIcons = inv.numShrunkenHotseatIcons;
} else {
@@ -375,15 +374,14 @@
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_top_padding);
if (isQsbInline) {
hotseatBarBottomPaddingPx = res.getDimensionPixelSize(R.dimen.inline_qsb_bottom_margin);
- qsbWidth = calculateQsbWidth();
} else {
hotseatBarBottomPaddingPx = (isTallDevice ? res.getDimensionPixelSize(
R.dimen.dynamic_grid_hotseat_bottom_tall_padding)
: res.getDimensionPixelSize(
R.dimen.dynamic_grid_hotseat_bottom_non_tall_padding))
+ res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_padding);
- qsbWidth = 0;
}
+
springLoadedHotseatBarTopMarginPx = res.getDimensionPixelSize(
R.dimen.spring_loaded_hotseat_top_margin);
hotseatBarSidePaddingEndPx =
@@ -392,9 +390,7 @@
hotseatBarSidePaddingStartPx = isVerticalBarLayout() ? workspacePageIndicatorHeight : 0;
hotseatExtraVerticalSize =
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_extra_vertical_size);
- hotseatBorderSpace = pxFromDp(inv.hotseatBorderSpaces[mTypeIndex], mMetrics);
- updateHotseatIconSize(
- pxFromDp(inv.iconSize[INDEX_DEFAULT], mMetrics));
+ updateHotseatIconSize(pxFromDp(inv.iconSize[INDEX_DEFAULT], mMetrics));
qsbBottomMarginOriginalPx = isScalableGrid
? res.getDimensionPixelSize(R.dimen.scalable_grid_qsb_bottom_margin)
@@ -408,16 +404,14 @@
overviewTaskIconDrawableSizeGridPx =
res.getDimensionPixelSize(R.dimen.task_thumbnail_icon_drawable_size_grid);
overviewTaskThumbnailTopMarginPx = overviewTaskIconSizePx + overviewTaskMarginPx * 2;
- overviewActionsTopMarginGesturePx = res.getDimensionPixelSize(
- R.dimen.overview_actions_top_margin_gesture);
- overviewActionsBottomMarginGesturePx = res.getDimensionPixelSize(
- R.dimen.overview_actions_bottom_margin_gesture);
+ // In vertical bar, use the smaller task margin for the top regardless of mode.
+ overviewActionsTopMarginPx = isVerticalBarLayout()
+ ? overviewTaskMarginPx
+ : res.getDimensionPixelSize(R.dimen.overview_actions_top_margin);
overviewPageSpacing = res.getDimensionPixelSize(R.dimen.overview_page_spacing);
overviewActionsButtonSpacing = res.getDimensionPixelSize(
R.dimen.overview_actions_button_spacing);
overviewActionsHeight = res.getDimensionPixelSize(R.dimen.overview_actions_height);
- overviewActionsMarginThreeButtonPx = res.getDimensionPixelSize(
- R.dimen.overview_actions_margin_three_button);
// Grid task's top margin is only overviewTaskIconSizePx + overviewTaskMarginGridPx, but
// overviewTaskThumbnailTopMarginPx is applied to all TaskThumbnailView, so exclude the
// extra margin when calculating row spacing.
@@ -487,6 +481,10 @@
cellLayoutPadding);
updateWorkspacePadding();
+ // Hotseat and QSB width depends on updated cellSize and workspace padding
+ hotseatBorderSpace = calculateHotseatBorderSpace();
+ qsbWidth = calculateQsbWidth();
+
flingToDeleteThresholdVelocity = res.getDimensionPixelSize(
R.dimen.drag_flingToDeleteMinVelocity);
@@ -497,14 +495,26 @@
new DotRenderer(allAppsIconSizePx, dotPath, DEFAULT_DOT_SIZE);
}
+ /**
+ * QSB width is always calculated because when in 3 button nav the width doesn't follow the
+ * width of the hotseat.
+ */
private int calculateQsbWidth() {
- int columns = isTwoPanels ? inv.numColumns * 2 : inv.numColumns;
+ if (isQsbInline) {
+ int columns = isTwoPanels ? inv.numColumns * 2 : inv.numColumns;
+ return getIconToIconWidthForColumns(columns)
+ - iconSizePx * numShownHotseatIcons
+ - hotseatBorderSpace * numShownHotseatIcons;
+ } else {
+ int columns = inv.hotseatColumnSpan[mTypeIndex];
+ return getIconToIconWidthForColumns(columns);
+ }
+ }
- return cellWidthPx * columns
- + cellLayoutBorderSpacePx.x * (columns - 1)
- - (cellWidthPx - iconSizePx) // left and right cell space
- - iconSizePx * numShownHotseatIcons
- - hotseatBorderSpace * numShownHotseatIcons;
+ private int getIconToIconWidthForColumns(int columns) {
+ return columns * getCellSize().x
+ + (columns - 1) * cellLayoutBorderSpacePx.x
+ - (getCellSize().x - iconSizePx); // left and right cell space
}
private int getHorizontalMarginPx(InvariantDeviceProfile idp, Resources res) {
@@ -658,7 +668,7 @@
Point workspacePadding = getTotalWorkspacePadding();
// Check to see if the icons fit within the available height.
- float usedHeight = getCellLayoutHeight();
+ float usedHeight = getCellLayoutHeightSpecification();
final int maxHeight = getWorkspaceHeight(workspacePadding);
float extraHeight = Math.max(0, maxHeight - usedHeight);
float scaleY = maxHeight / usedHeight;
@@ -669,7 +679,8 @@
// We scale to fit the cellWidth and cellHeight in the available space.
// The benefit of scalable grids is that we can get consistent aspect ratios between
// devices.
- float usedWidth = getCellLayoutWidth() + (desiredWorkspaceHorizontalMarginPx * 2);
+ float usedWidth =
+ getCellLayoutWidthSpecification() + (desiredWorkspaceHorizontalMarginPx * 2);
// We do not subtract padding here, as we also scale the workspace padding if needed.
scaleX = availableWidthPx / usedWidth;
shouldScale = true;
@@ -678,19 +689,19 @@
if (shouldScale) {
float scale = Math.min(scaleX, scaleY);
updateIconSize(scale, res);
- extraHeight = Math.max(0, maxHeight - getCellLayoutHeight());
+ extraHeight = Math.max(0, maxHeight - getCellLayoutHeightSpecification());
}
updateAvailableFolderCellDimensions(res);
return Math.round(extraHeight);
}
- private int getCellLayoutHeight() {
+ private int getCellLayoutHeightSpecification() {
return (cellHeightPx * inv.numRows) + (cellLayoutBorderSpacePx.y * (inv.numRows - 1))
+ cellLayoutPaddingPx.top + cellLayoutPaddingPx.bottom;
}
- private int getCellLayoutWidth() {
+ private int getCellLayoutWidthSpecification() {
int numColumns = isTwoPanels ? inv.numColumns * 2 : inv.numColumns;
return (cellWidthPx * numColumns) + (cellLayoutBorderSpacePx.x * (numColumns - 1))
+ cellLayoutPaddingPx.left + cellLayoutPaddingPx.right;
@@ -744,13 +755,6 @@
// All apps
updateAllAppsIconSize(scale, res);
- // Hotseat
- hotseatBorderSpace = pxFromDp(inv.hotseatBorderSpaces[mTypeIndex], mMetrics, scale);
- if (isQsbInline) {
- qsbWidth = calculateQsbWidth();
- } else {
- qsbWidth = 0;
- }
updateHotseatIconSize(iconSizePx);
// Folder icon
@@ -758,6 +762,23 @@
folderIconOffsetYPx = (iconSizePx - folderIconSizePx) / 2;
}
+ /**
+ * Hotseat width spans a certain number of columns on scalable grids.
+ * This method calculates the space between the icons to achieve that width.
+ */
+ private int calculateHotseatBorderSpace() {
+ if (!isScalableGrid) return 0;
+ //TODO(http://b/228998082) remove this when 3 button spaces are fixed
+ if (areNavButtonsInline) {
+ return pxFromDp(inv.hotseatBorderSpaces[mTypeIndex], mMetrics);
+ } else {
+ int columns = inv.hotseatColumnSpan[mTypeIndex];
+ float hotseatWidthPx = getIconToIconWidthForColumns(columns);
+ float hotseatIconsTotalPx = iconSizePx * numShownHotseatIcons;
+ return (int) (hotseatWidthPx - hotseatIconsTotalPx) / (numShownHotseatIcons - 1);
+ }
+ }
+
/**
* Updates the iconSize for allApps* variants.
@@ -920,7 +941,7 @@
/**
* Gets the scaled bottom of the workspace in px for the spring-loaded edit state.
*/
- public float getWorkspaceSpringLoadShrunkBottom() {
+ private float getWorkspaceSpringLoadShrunkBottom() {
int topOfHotseat = hotseatBarSizePx + springLoadedHotseatBarTopMarginPx;
workspaceSpringLoadShrunkBottom =
heightPx - (isVerticalBarLayout() ? getVerticalHotseatLastItemBottomOffset()
@@ -931,10 +952,30 @@
/**
* Gets the minimum visible amount of the next workspace page when in the spring-loaded state.
*/
- public float getWorkspaceSpringLoadedMinimumNextPageVisible() {
+ private float getWorkspaceSpringLoadedMinimumNextPageVisible() {
return getCellSize().x / 2f;
}
+ /**
+ * Gets the scale of the workspace for the spring-loaded edit state.
+ */
+ public float getWorkspaceSpringLoadScale() {
+ float cellLayoutHeight = availableHeightPx - workspacePadding.top - workspacePadding.bottom;
+ float scale = (getWorkspaceSpringLoadShrunkBottom() - getWorkspaceSpringLoadShrunkTop())
+ / cellLayoutHeight;
+ scale = Math.min(scale, 1f);
+
+ // Reduce scale if next pages would not be visible after scaling the workspace
+ int workspaceWidth = getWorkspaceWidth();
+ float scaledWorkspaceWidth = workspaceWidth * scale;
+ float maxAvailableWidth =
+ workspaceWidth - (2 * getWorkspaceSpringLoadedMinimumNextPageVisible());
+ if (scaledWorkspaceWidth > maxAvailableWidth) {
+ scale *= maxAvailableWidth / scaledWorkspaceWidth;
+ }
+ return scale;
+ }
+
public int getWorkspaceWidth() {
return getWorkspaceWidth(getTotalWorkspacePadding());
}
@@ -1053,6 +1094,13 @@
mHotseatPadding.left -= diff;
mHotseatPadding.right += diff;
}
+ } else if (isScalableGrid) {
+ int sideSpacing = (availableWidthPx - qsbWidth) / 2;
+ mHotseatPadding.set(sideSpacing,
+ hotseatBarTopPaddingPx,
+ sideSpacing,
+ hotseatBarSizePx - hotseatCellHeightPx - hotseatBarTopPaddingPx
+ + mInsets.bottom);
} else {
// We want the edges of the hotseat to line up with the edges of the workspace, but the
// icons in the hotseat are a different size, and so don't line up perfectly. To account
@@ -1104,6 +1152,24 @@
}
/**
+ * Returns the number of pixels required below OverviewActions excluding insets.
+ */
+ public int getOverviewActionsClaimedSpaceBelow() {
+ if (isTaskbarPresent && !isGestureMode) {
+ // Align vertically to where nav buttons are.
+ return ((taskbarSize - overviewActionsHeight) / 2) + getTaskbarOffsetY();
+ }
+
+ return 0;
+ }
+
+ /** Gets the space that the overview actions will take, including bottom margin. */
+ public int getOverviewActionsClaimedSpace() {
+ return overviewActionsTopMarginPx + overviewActionsHeight
+ + getOverviewActionsClaimedSpaceBelow();
+ }
+
+ /**
* @return the bounds for which the open folders should be contained within
*/
public Rect getAbsoluteOpenFolderBounds() {
@@ -1271,6 +1337,7 @@
writer.println(prefix + pxToDpStr("allAppsLeftRightMargin", allAppsLeftRightMargin));
writer.println(prefix + pxToDpStr("hotseatBarSizePx", hotseatBarSizePx));
+ writer.println(prefix + "\tinv.hotseatColumnSpan: " + inv.hotseatColumnSpan[mTypeIndex]);
writer.println(prefix + pxToDpStr("hotseatCellHeightPx", hotseatCellHeightPx));
writer.println(prefix + pxToDpStr("hotseatBarTopPaddingPx", hotseatBarTopPaddingPx));
writer.println(prefix + pxToDpStr("hotseatBarBottomPaddingPx", hotseatBarBottomPaddingPx));
@@ -1323,12 +1390,10 @@
overviewTaskIconDrawableSizeGridPx));
writer.println(prefix + pxToDpStr("overviewTaskThumbnailTopMarginPx",
overviewTaskThumbnailTopMarginPx));
- writer.println(prefix + pxToDpStr("overviewActionsMarginThreeButtonPx",
- overviewActionsMarginThreeButtonPx));
- writer.println(prefix + pxToDpStr("overviewActionsTopMarginGesturePx",
- overviewActionsTopMarginGesturePx));
- writer.println(prefix + pxToDpStr("overviewActionsBottomMarginGesturePx",
- overviewActionsBottomMarginGesturePx));
+ writer.println(prefix + pxToDpStr("overviewActionsTopMarginPx",
+ overviewActionsTopMarginPx));
+ writer.println(prefix + pxToDpStr("overviewActionsHeight",
+ overviewActionsHeight));
writer.println(prefix + pxToDpStr("overviewActionsButtonSpacing",
overviewActionsButtonSpacing));
writer.println(prefix + pxToDpStr("overviewPageSpacing", overviewPageSpacing));
@@ -1344,12 +1409,14 @@
prefix + pxToDpStr("workspaceSpringLoadShrunkTop", workspaceSpringLoadShrunkTop));
writer.println(prefix + pxToDpStr("workspaceSpringLoadShrunkBottom",
workspaceSpringLoadShrunkBottom));
+ writer.println(
+ prefix + pxToDpStr("getWorkspaceSpringLoadScale()", getWorkspaceSpringLoadScale()));
}
private static Context getContext(Context c, Info info, int orientation, WindowBounds bounds) {
Configuration config = new Configuration(c.getResources().getConfiguration());
config.orientation = orientation;
- config.densityDpi = info.densityDpi;
+ config.densityDpi = info.getDensityDpi();
config.smallestScreenWidthDp = (int) info.smallestSizeDp(bounds);
return c.createConfigurationContext(config);
}
diff --git a/src/com/android/launcher3/DropTargetBar.java b/src/com/android/launcher3/DropTargetBar.java
index ec3629d..2e3f26c 100644
--- a/src/com/android/launcher3/DropTargetBar.java
+++ b/src/com/android/launcher3/DropTargetBar.java
@@ -237,10 +237,8 @@
rightButton.getMeasuredHeight());
} else if (dp.isPhone) {
// Buttons aligned to outer edges of scaled workspace.
- float shrunkTop = dp.getWorkspaceSpringLoadShrunkTop();
- float shrunkBottom = dp.getWorkspaceSpringLoadShrunkBottom();
- float scale =
- (shrunkBottom - shrunkTop) / launcher.getWorkspace().getNormalChildHeight();
+ float scale = dp.getWorkspaceSpringLoadScale();
+
int workspaceWidth = (int) (launcher.getWorkspace().getNormalChildWidth() * scale);
int start = barCenter - (workspaceWidth / 2);
int end = barCenter + (workspaceWidth / 2);
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index a9db5ce..76106fc 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -173,17 +173,9 @@
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- int width;
- if (mActivity.getDeviceProfile().isQsbInline) {
- width = mActivity.getDeviceProfile().qsbWidth;
- } else {
- MarginLayoutParams qsbParams = (MarginLayoutParams) mQsb.getLayoutParams();
- width = getShortcutsAndWidgets().getMeasuredWidth()
- - qsbParams.getMarginStart()
- - qsbParams.getMarginEnd();
- }
+ int qsbWidth = mActivity.getDeviceProfile().qsbWidth;
- mQsb.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
+ mQsb.measure(MeasureSpec.makeMeasureSpec(qsbWidth, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(mQsbHeight, MeasureSpec.EXACTLY));
}
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 36c1797..89b1771 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -125,6 +125,7 @@
public PointF[] borderSpaces;
public float folderBorderSpace;
public float[] hotseatBorderSpaces;
+ public int[] hotseatColumnSpan;
public float[] horizontalMargin;
@@ -356,6 +357,7 @@
numDatabaseHotseatIcons = deviceType == TYPE_MULTI_DISPLAY
? closestProfile.numDatabaseHotseatIcons : closestProfile.numHotseatIcons;
hotseatBorderSpaces = displayOption.hotseatBorderSpaces;
+ hotseatColumnSpan = displayOption.hotseatColumnSpan;
numAllAppsColumns = closestProfile.numAllAppsColumns;
numDatabaseAllAppsColumns = deviceType == TYPE_MULTI_DISPLAY
@@ -396,7 +398,8 @@
// We need to ensure that there is enough extra space in the wallpaper
// for the intended parallax effects
float parallaxFactor =
- dpiFromPx(Math.min(displayWidth, displayHeight), displayInfo.densityDpi) < 720
+ dpiFromPx(Math.min(displayWidth, displayHeight), displayInfo.getDensityDpi())
+ < 720
? 2
: wallpaperTravelToScreenWidthRatio(displayWidth, displayHeight);
defaultWallpaperSize.x =
@@ -585,8 +588,8 @@
}
}
- float width = dpiFromPx(minWidthPx, displayInfo.densityDpi);
- float height = dpiFromPx(minHeightPx, displayInfo.densityDpi);
+ float width = dpiFromPx(minWidthPx, displayInfo.getDensityDpi());
+ float height = dpiFromPx(minHeightPx, displayInfo.getDensityDpi());
// Sort the profiles based on the closeness to the device size
Collections.sort(points, (a, b) ->
@@ -806,7 +809,9 @@
private float folderBorderSpace;
private final PointF[] borderSpaces = new PointF[COUNT_SIZES];
private final float[] horizontalMargin = new float[COUNT_SIZES];
+ //TODO(http://b/228998082) remove this when 3 button spaces are fixed
private final float[] hotseatBorderSpaces = new float[COUNT_SIZES];
+ private final int[] hotseatColumnSpan = new int[COUNT_SIZES];
private final float[] iconSizes = new float[COUNT_SIZES];
private final float[] textSizes = new float[COUNT_SIZES];
@@ -1032,6 +1037,17 @@
R.styleable.ProfileDisplayOption_hotseatBorderSpaceTwoPanelPortrait,
hotseatBorderSpaces[INDEX_DEFAULT]);
+ hotseatColumnSpan[INDEX_DEFAULT] = a.getInt(
+ R.styleable.ProfileDisplayOption_hotseatColumnSpan, grid.numColumns);
+ hotseatColumnSpan[INDEX_LANDSCAPE] = a.getInt(
+ R.styleable.ProfileDisplayOption_hotseatColumnSpanLandscape, grid.numColumns);
+ hotseatColumnSpan[INDEX_TWO_PANEL_LANDSCAPE] = a.getInt(
+ R.styleable.ProfileDisplayOption_hotseatColumnSpanTwoPanelLandscape,
+ grid.numColumns);
+ hotseatColumnSpan[INDEX_TWO_PANEL_PORTRAIT] = a.getInt(
+ R.styleable.ProfileDisplayOption_hotseatColumnSpanTwoPanelPortrait,
+ grid.numColumns);
+
a.recycle();
}
@@ -1090,6 +1106,7 @@
minCellSize[i].y += p.minCellSize[i].y;
horizontalMargin[i] += p.horizontalMargin[i];
hotseatBorderSpaces[i] += p.hotseatBorderSpaces[i];
+ hotseatColumnSpan[i] = p.hotseatColumnSpan[i];
allAppsCellSize[i].x += p.allAppsCellSize[i].x;
allAppsCellSize[i].y += p.allAppsCellSize[i].y;
allAppsIconSizes[i] += p.allAppsIconSizes[i];
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 463280b..1c62ded 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2750,7 +2750,7 @@
packageName);
if (supportsAllAppsState && isInState(LauncherState.ALL_APPS)) {
- return getFirstMatch(Collections.singletonList(mAppsView.getActiveAppsRecyclerView()),
+ return getFirstMatch(Collections.singletonList(mAppsView.getActiveRecyclerView()),
preferredItem, packageAndUserAndApp);
} else {
List<ViewGroup> containers = new ArrayList<>(mWorkspace.getPanelCount() + 1);
@@ -3168,6 +3168,24 @@
return new DragOptions();
}
+ /**
+ * Animates Launcher elements during a transition to the All Apps page.
+ *
+ * @param progress Transition progress from 0 to 1; where 0 => home and 1 => all apps.
+ */
+ public void onAllAppsTransition(float progress) {
+ // No-Op
+ }
+
+ /**
+ * Animates Launcher elements during a transition to the Widgets pages.
+ *
+ * @param progress Transition progress from 0 to 1; where 0 => home and 1 => widgets.
+ */
+ public void onWidgetsTransition(float progress) {
+ // No-Op
+ }
+
private static class NonConfigInstance {
public Configuration config;
public Bitmap snapshot;
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index baee49f..ea6a919 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -80,6 +80,9 @@
public static final int FLAG_CLOSE_POPUPS = BaseState.getFlag(6);
public static final int FLAG_OVERVIEW_UI = BaseState.getFlag(7);
+ // Flag indicating that hotseat and its contents are not accessible.
+ public static final int FLAG_HOTSEAT_INACCESSIBLE = BaseState.getFlag(8);
+
public static final float NO_OFFSET = 0;
public static final float NO_SCALE = 1;
@@ -110,7 +113,7 @@
FLAG_DISABLE_RESTORE | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED | FLAG_HIDE_BACK_BUTTON |
FLAG_HAS_SYS_UI_SCRIM) {
@Override
- public int getTransitionDuration(Context context) {
+ public int getTransitionDuration(Context context, boolean isToState) {
// Arbitrary duration, when going to NORMAL we use the state we're coming from instead.
return 0;
}
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 8358f2a..7b96838 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -273,6 +273,16 @@
}
/**
+ * Similar to {@link #mapCoordInSelfToDescendant(View descendant, View root, float[] coord)}
+ * but accepts a Rect instead of float[].
+ */
+ public static void mapRectInSelfToDescendant(View descendant, View root, Rect rect) {
+ float[] coords = new float[]{rect.left, rect.top, rect.right, rect.bottom};
+ mapCoordInSelfToDescendant(descendant, root, coords);
+ rect.set((int) coords[0], (int) coords[1], (int) coords[2], (int) coords[3]);
+ }
+
+ /**
* Inverse of {@link #getDescendantCoordRelativeToAncestor(View, View, float[], boolean)}.
*/
public static void mapCoordInSelfToDescendant(View descendant, View root, float[] coord) {
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index ed01660..836d4b8 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -200,6 +200,7 @@
private final int[] mTempXY = new int[2];
private final float[] mTempFXY = new float[2];
+ private final Rect mTempRect = new Rect();
@Thunk float[] mDragViewVisualCenter = new float[2];
private SpringLoadedDragController mSpringLoadedDragController;
@@ -906,7 +907,11 @@
* two panel UI is enabled.
*/
public int getScreenPair(int screenId) {
- if (screenId % 2 == 0) {
+ if (screenId == EXTRA_EMPTY_SCREEN_ID) {
+ return EXTRA_EMPTY_SCREEN_SECOND_ID;
+ } else if (screenId == EXTRA_EMPTY_SCREEN_SECOND_ID) {
+ return EXTRA_EMPTY_SCREEN_ID;
+ } else if (screenId % 2 == 0) {
return screenId + 1;
} else {
return screenId - 1;
@@ -1730,7 +1735,7 @@
// If it's an external drop (e.g. from All Apps), check if it should be accepted
CellLayout dropTargetLayout = mDropToLayout;
if (d.dragSource != this) {
- // Don't accept the drop if we're not over a screen at time of drop
+ // Don't accept the drop if we're not over a valid drop target at time of drop
if (dropTargetLayout == null) {
return false;
}
@@ -2113,7 +2118,7 @@
final Runnable onCompleteCallback = onCompleteRunnable;
mLauncher.getDragController().animateDragViewToOriginalPosition(
/* onComplete= */ callbackList::executeAllAndDestroy, cell,
- SPRING_LOADED.getTransitionDuration(mLauncher));
+ SPRING_LOADED.getTransitionDuration(mLauncher, true /* isToState */));
mLauncher.getStateManager().goToState(NORMAL, /* delay= */ 0,
onCompleteCallback == null
? null
@@ -2331,17 +2336,6 @@
xy[1] = xy[1] - v.getTop();
}
- boolean isPointInSelfOverHotseat(int x, int y) {
- mTempFXY[0] = x;
- mTempFXY[1] = y;
- mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempFXY, true);
- View hotseat = mLauncher.getHotseat();
- return mTempFXY[0] >= hotseat.getLeft()
- && mTempFXY[0] <= hotseat.getRight()
- && mTempFXY[1] >= hotseat.getTop()
- && mTempFXY[1] <= hotseat.getBottom();
- }
-
/**
* Updates the point in {@param xy} to point to the co-ordinate space of {@param layout}
* @param layout either hotseat of a page in workspace
@@ -2379,7 +2373,7 @@
final View child = (mDragInfo == null) ? null : mDragInfo.cell;
if (setDropLayoutForDragObject(d, mDragViewVisualCenter[0], mDragViewVisualCenter[1])) {
- if (mLauncher.isHotseatLayout(mDragTargetLayout)) {
+ if (mDragTargetLayout == null || mLauncher.isHotseatLayout(mDragTargetLayout)) {
mSpringLoadedDragController.cancel();
} else {
mSpringLoadedDragController.setAlarm(mDragTargetLayout);
@@ -2458,52 +2452,25 @@
*/
private boolean setDropLayoutForDragObject(DragObject d, float centerX, float centerY) {
CellLayout layout = null;
- // Test to see if we are over the hotseat first
- if (mLauncher.getHotseat() != null && !isDragWidget(d)) {
- if (isPointInSelfOverHotseat(d.x, d.y)) {
- layout = mLauncher.getHotseat();
+ if (shouldUseHotseatAsDropLayout(d)) {
+ layout = mLauncher.getHotseat();
+ } else if (!isDragObjectOverSmartSpace(d)) {
+ // If the object is over qsb/smartspace, we don't want to highlight anything.
+
+ // Check neighbour pages
+ layout = checkDragObjectIsOverNeighbourPages(d, centerX);
+
+ if (layout == null) {
+ // Check visible pages
+ IntSet visiblePageIndices = getVisiblePageIndices();
+ for (int visiblePageIndex : visiblePageIndices) {
+ layout = verifyInsidePage(visiblePageIndex, d.x, d.y);
+ if (layout != null) break;
+ }
}
}
- // Note, centerX represents the center of the object that is being dragged, visually. d.x
- // represents the location of the finger within the dragged item.
- float touchX;
- float touchY = d.y;
-
- // Go through the pages and check if the dragged item is inside one of them. This block
- // is responsible for determining whether we need to snap to a different screen.
- int nextPage = getNextPage();
- IntSet pageIndexesToVerify = IntSet.wrap(nextPage - 1, nextPage
- + (isTwoPanelEnabled() ? 2 : 1));
- for (int pageIndex : pageIndexesToVerify) {
- if (layout != null || isPageInTransition()) {
- break;
- }
-
- // When deciding whether to perform a page switch, we need to consider the most extreme
- // X coordinate between the finger location and the center of the object being dragged.
- // This is either the max or the min of the two depending on whether dragging to the
- // left / right, respectively.
- touchX = ((((pageIndex < nextPage) && !mIsRtl) || pageIndex > nextPage && mIsRtl)
- ? Math.min(d.x, centerX) : Math.max(d.x, centerX));
- layout = verifyInsidePage(pageIndex, touchX, touchY);
- }
-
- // If the dragged item isn't located in one of the pages above, the icon will stay on the
- // current screen. For two panel pick the closest panel on the current screen,
- // on one panel just choose the current page.
- if (layout == null && nextPage >= 0 && nextPage < getPageCount()) {
- if (isTwoPanelEnabled()) {
- // When determining which panel to use within a single screen, we always use
- // the centroid of the object rather than the finger.
- touchX = centerX;
- nextPage = getScreenCenter(getScrollX()) > touchX
- ? (mIsRtl ? nextPage + 1 : nextPage) // left side
- : (mIsRtl ? nextPage : nextPage + 1); // right side
- }
- layout = (CellLayout) getChildAt(nextPage);
- }
-
+ // Update the current drop layout if the target changed
if (layout != mDragTargetLayout) {
setCurrentDropLayout(layout);
setCurrentDragOverlappingLayout(layout);
@@ -2512,6 +2479,69 @@
return false;
}
+ private boolean shouldUseHotseatAsDropLayout(DragObject dragObject) {
+ if (mLauncher.getHotseat() == null
+ || mLauncher.getHotseat().getShortcutsAndWidgets() == null
+ || isDragWidget(dragObject)) {
+ return false;
+ }
+ View hotseatShortcuts = mLauncher.getHotseat().getShortcutsAndWidgets();
+ getViewBoundsRelativeToWorkspace(hotseatShortcuts, mTempRect);
+ return mTempRect.contains(dragObject.x, dragObject.y);
+ }
+
+ private boolean isDragObjectOverSmartSpace(DragObject dragObject) {
+ if (mQsb == null) {
+ return false;
+ }
+ getViewBoundsRelativeToWorkspace(mQsb, mTempRect);
+ return mTempRect.contains(dragObject.x, dragObject.y);
+ }
+
+ private CellLayout checkDragObjectIsOverNeighbourPages(DragObject d, float centerX) {
+ if (isPageInTransition()) {
+ return null;
+ }
+
+ // Check the workspace pages whether the object is over any of them
+
+ // Note, centerX represents the center of the object that is being dragged, visually.
+ // d.x represents the location of the finger within the dragged item.
+ float touchX;
+ float touchY = d.y;
+
+ // Go through the pages and check if the dragged item is inside one of them. This block
+ // is responsible for determining whether we need to snap to a different screen.
+ int nextPage = getNextPage();
+ IntSet pageIndexesToVerify = IntSet.wrap(nextPage - 1,
+ nextPage + (isTwoPanelEnabled() ? 2 : 1));
+
+ for (int pageIndex : pageIndexesToVerify) {
+ // When deciding whether to perform a page switch, we need to consider the most
+ // extreme X coordinate between the finger location and the center of the object
+ // being dragged. This is either the max or the min of the two depending on whether
+ // dragging to the left / right, respectively.
+ touchX = (((pageIndex < nextPage) && !mIsRtl) || (pageIndex > nextPage && mIsRtl))
+ ? Math.min(d.x, centerX) : Math.max(d.x, centerX);
+ CellLayout layout = verifyInsidePage(pageIndex, touchX, touchY);
+ if (layout != null) {
+ return layout;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Gets the given view's bounds relative to Workspace
+ */
+ private void getViewBoundsRelativeToWorkspace(View view, Rect outRect) {
+ mLauncher.getDragLayer()
+ .getDescendantRectRelativeToSelf(view, mTempRect);
+ // map draglayer relative bounds to workspace
+ mLauncher.getDragLayer().mapRectInSelfToDescendant(this, mTempRect);
+ outRect.set(mTempRect);
+ }
+
/**
* Returns the child CellLayout if the point is inside the page coordinates, null otherwise.
*/
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index 84b95ec..bf56ac0 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -25,6 +25,7 @@
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
import static com.android.launcher3.LauncherAnimUtils.WORKSPACE_SCALE_PROPERTY_FACTORY;
import static com.android.launcher3.LauncherState.FLAG_HAS_SYS_UI_SCRIM;
+import static com.android.launcher3.LauncherState.FLAG_HOTSEAT_INACCESSIBLE;
import static com.android.launcher3.LauncherState.HINT_STATE;
import static com.android.launcher3.LauncherState.HOTSEAT_ICONS;
import static com.android.launcher3.LauncherState.NORMAL;
@@ -151,6 +152,12 @@
propertySetter.setViewAlpha(mLauncher.getWorkspace().getPageIndicator(),
workspacePageIndicatorAlpha, fadeInterpolator);
+ // Update the accessibility flags for hotseat based on launcher state.
+ hotseat.setImportantForAccessibility(
+ state.hasFlag(FLAG_HOTSEAT_INACCESSIBLE)
+ ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
+ : View.IMPORTANT_FOR_ACCESSIBILITY_AUTO);
+
Interpolator translationInterpolator =
config.getInterpolator(ANIM_WORKSPACE_TRANSLATE, ZOOM_OUT);
propertySetter.setFloat(mWorkspace, VIEW_TRANSLATE_X,
diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
index 16a2823..e279f59 100644
--- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
@@ -80,7 +80,7 @@
OnClickListener marketSearchClickListener = (v) -> mActivityContext.startActivitySafely(v,
marketSearchIntent, null);
for (int i = 0; i < mAH.size(); i++) {
- mAH.get(i).mAdapter.setLastSearchQuery(query, marketSearchClickListener);
+ mAH.get(i).adapter.setLastSearchQuery(query, marketSearchClickListener);
}
mIsSearching = true;
rebindAdapters();
@@ -142,7 +142,7 @@
@Override
public String getDescription() {
- if (!mUsingTabs && isSearching()) {
+ if (!mUsingTabs && mIsSearching) {
return getContext().getString(R.string.all_apps_search_results);
} else {
return super.getDescription();
@@ -150,13 +150,8 @@
}
@Override
- protected boolean shouldShowTabs() {
- return super.shouldShowTabs() && !isSearching();
- }
-
- @Override
- public boolean isSearching() {
- return mIsSearching;
+ protected boolean showTabs() {
+ return super.showTabs() && !mIsSearching;
}
@Override
@@ -178,19 +173,15 @@
}
@Override
- protected View replaceAppsRVContainer(boolean showTabs) {
- View rvContainer = super.replaceAppsRVContainer(showTabs);
+ protected View replaceRVContainer(boolean showTabs) {
+ View rvContainer = super.replaceRVContainer(showTabs);
removeCustomRules(rvContainer);
- removeCustomRules(getSearchRecyclerView());
if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
alignParentTop(rvContainer, showTabs);
- alignParentTop(getSearchRecyclerView(), showTabs);
layoutAboveSearchContainer(rvContainer);
- layoutAboveSearchContainer(getSearchRecyclerView());
} else {
layoutBelowSearchContainer(rvContainer, showTabs);
- layoutBelowSearchContainer(getSearchRecyclerView(), showTabs);
}
return rvContainer;
@@ -217,7 +208,7 @@
float prog = Utilities.boundToRange((float) scrolledOffset / mHeaderThreshold, 0f, 1f);
boolean bgVisible = mSearchUiManager.getBackgroundVisibility();
- if (scrolledOffset == 0 && !isSearching()) {
+ if (scrolledOffset == 0 && !mIsSearching) {
bgVisible = true;
} else if (scrolledOffset > mHeaderThreshold) {
bgVisible = false;
@@ -251,7 +242,7 @@
int topMargin = getContext().getResources().getDimensionPixelSize(
R.dimen.all_apps_header_top_margin);
if (includeTabsMargin) {
- topMargin += getContext().getResources().getDimensionPixelSize(
+ topMargin = topMargin + getContext().getResources().getDimensionPixelSize(
R.dimen.all_apps_header_pill_height);
}
layoutParams.topMargin = topMargin;
@@ -292,9 +283,9 @@
}
@Override
- protected BaseAllAppsAdapter<T> createAdapter(AlphabeticalAppsList<T> appsList,
+ protected BaseAllAppsAdapter getAdapter(AlphabeticalAppsList<T> mAppsList,
BaseAdapterProvider[] adapterProviders) {
- return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), appsList,
+ return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), mAppsList,
adapterProviders);
}
}
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index 18c6788..7dbe711 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -37,8 +37,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;
@@ -53,13 +53,13 @@
/**
* A RecyclerView with custom fast scroll support for the all apps view.
*/
-public class AllAppsRecyclerView extends FastScrollRecyclerView {
- protected static final String TAG = "AllAppsRecyclerView";
+public class AllAppsRecyclerView extends BaseRecyclerView {
+ private static final String TAG = "AllAppsContainerView";
private static final boolean DEBUG = false;
private static final boolean DEBUG_LATENCY = Utilities.isPropertyEnabled(SEARCH_LOGGING);
- protected AlphabeticalAppsList<?> mApps;
- protected final int mNumAppsPerRow;
+ private AlphabeticalAppsList<?> mApps;
+ private final int mNumAppsPerRow;
// The specific view heights that we use to calculate scroll
private final SparseIntArray mViewHeights = new SparseIntArray();
@@ -74,8 +74,8 @@
};
// The empty-search result background
- protected AllAppsBackgroundDrawable mEmptySearchBackground;
- protected int mEmptySearchBackgroundTopOffset;
+ private AllAppsBackgroundDrawable mEmptySearchBackground;
+ private int mEmptySearchBackgroundTopOffset;
private ArrayList<View> mAutoSizedOverlays = new ArrayList<>();
@@ -112,7 +112,7 @@
return mApps;
}
- protected void updatePoolSize() {
+ private void updatePoolSize() {
DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile();
RecyclerView.RecycledViewPool pool = getRecycledViewPool();
int approxRows = (int) Math.ceil(grid.availableHeightPx / grid.allAppsIconSizePx);
@@ -137,8 +137,8 @@
Log.d(TAG, "onDraw at = " + System.currentTimeMillis());
}
if (DEBUG_LATENCY) {
- Log.d(SEARCH_LOGGING, getClass().getSimpleName() + " onDraw; time stamp = "
- + System.currentTimeMillis());
+ Log.d(SEARCH_LOGGING,
+ "-- Recycle view onDraw, time stamp = " + System.currentTimeMillis());
}
super.onDraw(c);
}
@@ -223,7 +223,8 @@
&& mEmptySearchBackground != null && mEmptySearchBackground.getAlpha() > 0) {
mEmptySearchBackground.setHotspot(e.getX(), e.getY());
}
- hideKeyboardAsync(ActivityContext.lookupContext(getContext()), getApplicationWindowToken());
+ hideKeyboardAsync(ActivityContext.lookupContext(getContext()),
+ getApplicationWindowToken());
return result;
}
@@ -359,6 +360,13 @@
}
@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();
@@ -368,7 +376,7 @@
// Calculate the y and offset for the item
View child = getChildAt(0);
- int position = getChildAdapterPosition(child);
+ int position = getChildPosition(child);
if (position == NO_POSITION) {
return -1;
}
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 723bc65..3600bd2 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -84,8 +84,7 @@
@Override
public Float get(AllAppsTransitionController controller) {
if (controller.mIsTablet) {
- return controller.mAppsView.getAppsRecyclerViewContainer()
- .getTranslationY();
+ return controller.mAppsView.getRecyclerViewContainer().getTranslationY();
} else {
return controller.getAppsViewPullbackTranslationY().get(
controller.mAppsView);
@@ -95,7 +94,7 @@
@Override
public void setValue(AllAppsTransitionController controller, float translation) {
if (controller.mIsTablet) {
- controller.mAppsView.getAppsRecyclerViewContainer().setTranslationY(
+ controller.mAppsView.getRecyclerViewContainer().setTranslationY(
translation);
} else {
controller.getAppsViewPullbackTranslationY().set(controller.mAppsView,
@@ -110,7 +109,7 @@
@Override
public Float get(AllAppsTransitionController controller) {
if (controller.mIsTablet) {
- return controller.mAppsView.getAppsRecyclerViewContainer().getAlpha();
+ return controller.mAppsView.getRecyclerViewContainer().getAlpha();
} else {
return controller.getAppsViewPullbackAlpha().getValue();
}
@@ -119,7 +118,7 @@
@Override
public void setValue(AllAppsTransitionController controller, float alpha) {
if (controller.mIsTablet) {
- controller.mAppsView.getAppsRecyclerViewContainer().setAlpha(alpha);
+ controller.mAppsView.getRecyclerViewContainer().setAlpha(alpha);
} else {
controller.getAppsViewPullbackAlpha().setValue(alpha);
}
@@ -191,6 +190,7 @@
public void setProgress(float progress) {
mProgress = progress;
getAppsViewProgressTranslationY().set(mAppsView, mProgress * mShiftRange);
+ mLauncher.onAllAppsTransition(1 - progress);
}
public float getProgress() {
@@ -255,8 +255,6 @@
anim.setInterpolator(verticalProgressInterpolator);
anim.addListener(getProgressAnimatorListener());
builder.add(anim);
- // Use ANIM_VERTICAL_PROGRESS's interpolator to determine state transition threshold.
- builder.setInterpolator(verticalProgressInterpolator);
setAlphas(toState, config, builder);
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index 42374b8..2a16210 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -18,8 +18,6 @@
import android.content.Context;
-import androidx.annotation.Nullable;
-
import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.data.AppInfo;
@@ -45,10 +43,6 @@
public static final String TAG = "AlphabeticalAppsList";
- private static final int FAST_SCROLL_FRACTION_DISTRIBUTE_BY_ROWS_FRACTION = 0;
- private static final int FAST_SCROLL_FRACTION_DISTRIBUTE_BY_NUM_SECTIONS = 1;
-
- private final int mFastScrollDistributionMode = FAST_SCROLL_FRACTION_DISTRIBUTE_BY_NUM_SECTIONS;
private final WorkAdapterProvider mWorkAdapterProvider;
/**
@@ -73,7 +67,6 @@
// 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
@@ -91,16 +84,14 @@
private int mNumAppRowsInAdapter;
private ItemInfoMatcher mItemFilter;
- public AlphabeticalAppsList(Context context, @Nullable AllAppsStore appsStore,
+ public AlphabeticalAppsList(Context context, AllAppsStore appsStore,
WorkAdapterProvider adapterProvider) {
mAllAppsStore = appsStore;
mActivityContext = ActivityContext.lookupContext(context);
mAppNameComparator = new AppInfoComparator(context);
mWorkAdapterProvider = adapterProvider;
mNumAppsPerRowAllApps = mActivityContext.getDeviceProfile().inv.numAllAppsColumns;
- if (mAllAppsStore != null) {
- mAllAppsStore.addUpdateListener(this);
- }
+ mAllAppsStore.addUpdateListener(this);
}
public void updateItemFilter(ItemInfoMatcher itemFilter) {
@@ -173,9 +164,9 @@
}
/**
- * Returns whether there are search results which will hide the A-Z list.
+ * Returns whether there are is a filter set.
*/
- public boolean hasSearchResults() {
+ public boolean hasFilter() {
return !mSearchResults.isEmpty();
}
@@ -183,7 +174,7 @@
* Returns whether there are no filtered results.
*/
public boolean hasNoFilteredResults() {
- return hasSearchResults() && mAccessibilityResultsCount == 0;
+ return hasFilter() && mAccessibilityResultsCount == 0;
}
/**
@@ -201,40 +192,16 @@
return true;
}
- /** Appends results to search. */
- public void appendSearchResults(ArrayList<AdapterItem> results) {
- if (hasSearchResults() && results != null && results.size() > 0) {
- updateSearchAdapterItems(results, mSearchResults.size());
- mSearchResults.addAll(results);
- refreshRecyclerView();
- }
- }
-
- void updateSearchAdapterItems(ArrayList<AdapterItem> list, int offset) {
- for (int i = 0; i < list.size(); i++) {
- AdapterItem adapterItem = list.get(i);
- adapterItem.position = offset + i;
- mAdapterItems.add(adapterItem);
-
- if (adapterItem.isCountedForAccessibility()) {
- mAccessibilityResultsCount++;
- }
- }
- }
-
/**
* Updates internals when the set of apps are updated.
*/
@Override
public void onAppsUpdated() {
- if (mAllAppsStore == null) {
- return;
- }
// Sort the list of apps
mApps.clear();
for (AppInfo app : mAllAppsStore.getApps()) {
- if (mItemFilter == null || mItemFilter.matches(app, null) || hasSearchResults()) {
+ if (mItemFilter == null || mItemFilter.matches(app, null) || hasFilter()) {
mApps.add(app);
}
}
@@ -294,7 +261,6 @@
String lastSectionName = null;
FastScrollSectionInfo lastFastScrollerSectionInfo = null;
int position = 0;
- int appIndex = 0;
// Prepare to update the list of sections, filtered apps, etc.
mAccessibilityResultsCount = 0;
@@ -304,18 +270,7 @@
// Recreate the filtered and sectioned apps (for convenience for the grid layout) from the
// ordered set of sections
- if (hasSearchResults()) {
- if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
- // Append the search market item
- if (hasNoFilteredResults()) {
- mSearchResults.add(AdapterItem.asEmptySearch(position++));
- } else {
- mSearchResults.add(AdapterItem.asAllAppsDivider(position++));
- }
- mSearchResults.add(AdapterItem.asMarketSearch(position++));
- }
- updateSearchAdapterItems(mSearchResults, 0);
- } else {
+ if (!hasFilter()) {
mAccessibilityResultsCount = mApps.size();
if (mWorkAdapterProvider != null) {
position += mWorkAdapterProvider.addWorkItems(mAdapterItems);
@@ -334,14 +289,34 @@
}
// Create an app item
- AdapterItem appItem = AdapterItem.asApp(position++, sectionName, info,
- appIndex++);
+ AdapterItem appItem = AdapterItem.asApp(position++, info);
if (lastFastScrollerSectionInfo.fastScrollToItem == null) {
lastFastScrollerSectionInfo.fastScrollToItem = appItem;
}
mAdapterItems.add(appItem);
}
+ } else {
+ int count = mSearchResults.size();
+ for (int i = 0; i < count; i++) {
+ AdapterItem adapterItem = mSearchResults.get(i);
+ adapterItem.position = i;
+ mAdapterItems.add(adapterItem);
+
+ if (adapterItem.isCountedForAccessibility()) {
+ mAccessibilityResultsCount++;
+ }
+ }
+ if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
+ // Append the search market item
+ if (hasNoFilteredResults()) {
+ mAdapterItems.add(AdapterItem.asEmptySearch(position++));
+ } else {
+ mAdapterItems.add(AdapterItem.asAllAppsDivider(position++));
+ }
+ mAdapterItems.add(AdapterItem.asMarketSearch(position++));
+
+ }
}
if (mNumAppsPerRowAllApps != 0) {
// Update the number of rows in the adapter after we do all the merging (otherwise, we
@@ -367,34 +342,16 @@
mNumAppRowsInAdapter = rowIndex + 1;
// Pre-calculate all the fast scroller fractions
- switch (mFastScrollDistributionMode) {
- case FAST_SCROLL_FRACTION_DISTRIBUTE_BY_ROWS_FRACTION:
- float rowFraction = 1f / mNumAppRowsInAdapter;
- for (FastScrollSectionInfo info : mFastScrollerSections) {
- AdapterItem item = info.fastScrollToItem;
- if (!BaseAllAppsAdapter.isIconViewType(item.viewType)) {
- info.touchFraction = 0f;
- continue;
- }
-
- float subRowFraction =
- item.rowAppIndex * (rowFraction / mNumAppsPerRowAllApps);
- info.touchFraction = item.rowIndex * rowFraction + subRowFraction;
- }
- break;
- case FAST_SCROLL_FRACTION_DISTRIBUTE_BY_NUM_SECTIONS:
- float perSectionTouchFraction = 1f / mFastScrollerSections.size();
- float cumulativeTouchFraction = 0f;
- for (FastScrollSectionInfo info : mFastScrollerSections) {
- AdapterItem item = info.fastScrollToItem;
- if (!BaseAllAppsAdapter.isIconViewType(item.viewType)) {
- info.touchFraction = 0f;
- continue;
- }
- info.touchFraction = cumulativeTouchFraction;
- cumulativeTouchFraction += perSectionTouchFraction;
- }
- break;
+ float perSectionTouchFraction = 1f / mFastScrollerSections.size();
+ float cumulativeTouchFraction = 0f;
+ for (FastScrollSectionInfo info : mFastScrollerSections) {
+ AdapterItem item = info.fastScrollToItem;
+ if (!BaseAllAppsAdapter.isIconViewType(item.viewType)) {
+ info.touchFraction = 0f;
+ continue;
+ }
+ info.touchFraction = cumulativeTouchFraction;
+ cumulativeTouchFraction += perSectionTouchFraction;
}
}
}
diff --git a/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java b/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java
index 976284d..8ac2536 100644
--- a/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java
+++ b/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java
@@ -36,7 +36,6 @@
import com.android.launcher3.R;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.data.AppInfo;
-import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.views.ActivityContext;
import java.util.Arrays;
@@ -94,31 +93,21 @@
// The type of this item
public int viewType;
- // The section name of this item. Note that there can be multiple items with different
- // sectionNames in the same section
- public String sectionName = null;
// The row that this item shows up on
public int rowIndex;
// The index of this app in the row
public int rowAppIndex;
// The associated ItemInfoWithIcon for the item
- public ItemInfoWithIcon itemInfo = null;
- // The index of this app not including sections
- public int appIndex = -1;
- // Search section associated to result
- public DecorationInfo decorationInfo = null;
+ public AppInfo itemInfo = null;
/**
* Factory method for AppIcon AdapterItem
*/
- public static AdapterItem asApp(int pos, String sectionName, AppInfo appInfo,
- int appIndex) {
+ public static AdapterItem asApp(int pos, AppInfo appInfo) {
AdapterItem item = new AdapterItem();
item.viewType = VIEW_TYPE_ICON;
item.position = pos;
- item.sectionName = sectionName;
item.itemInfo = appInfo;
- item.appIndex = appIndex;
return item;
}
@@ -267,11 +256,7 @@
AdapterItem adapterItem = mApps.getAdapterItems().get(position);
BubbleTextView icon = (BubbleTextView) holder.itemView;
icon.reset();
- if (adapterItem.itemInfo instanceof AppInfo) {
- icon.applyFromApplicationInfo((AppInfo) adapterItem.itemInfo);
- } else {
- icon.applyFromItemInfoWithIcon(adapterItem.itemInfo);
- }
+ icon.applyFromApplicationInfo(adapterItem.itemInfo);
break;
case VIEW_TYPE_EMPTY_SEARCH:
TextView emptyViewText = (TextView) holder.itemView;
diff --git a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
index 6a44989..f913aa9 100644
--- a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
@@ -80,7 +80,7 @@
OnDeviceProfileChangeListener, OnActivePageChangedListener,
ScrimView.ScrimDrawingController {
- protected static final String BUNDLE_KEY_CURRENT_PAGE = "launcher.allapps.current_page";
+ private 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;
@@ -109,7 +109,6 @@
private int mNavBarScrimHeight = 0;
private AllAppsPagedView mViewPager;
- private SearchRecyclerView mSearchRecyclerView;
protected FloatingHeaderView mHeader;
private View mBottomSheetBackground;
@@ -142,10 +141,9 @@
mActivityContext.getSystemService(UserManager.class),
this,
Utilities.getPrefs(mActivityContext));
- 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));
+ mAH = Arrays.asList(null, null);
+ mAH.set(AdapterHolder.MAIN, new AdapterHolder(false /* isWork */));
+ mAH.set(AdapterHolder.WORK, new AdapterHolder(true /* isWork */));
mNavBarScrimPaint = new Paint();
mNavBarScrimPaint.setColor(Themes.getAttrColor(context, R.attr.allAppsNavBarScrimColor));
@@ -177,7 +175,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 == AdapterHolder.WORK && mViewPager != null) {
+ if (currentPage != 0 && mViewPager != null) {
mViewPager.setCurrentPage(currentPage);
rebindAdapters();
} else {
@@ -200,7 +198,7 @@
*/
public void setOnIconLongClickListener(OnLongClickListener listener) {
for (AdapterHolder holder : mAH) {
- holder.mAdapter.setOnIconLongClickListener(listener);
+ holder.adapter.setOnIconLongClickListener(listener);
}
}
@@ -215,7 +213,7 @@
@Override
public void onDeviceProfileChanged(DeviceProfile dp) {
for (AdapterHolder holder : mAH) {
- holder.mAdapter.setAppsPerRow(dp.numShownAllAppsColumns);
+ holder.adapter.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.
@@ -239,7 +237,7 @@
}
}
mHasWorkApps = hasWorkApps;
- if (!mAH.get(AdapterHolder.MAIN).mAppsList.hasSearchResults()) {
+ if (!mAH.get(AdapterHolder.MAIN).mAppsList.hasFilter()) {
rebindAdapters();
if (hasWorkApps) {
mWorkManager.reset();
@@ -258,11 +256,7 @@
if (mActivityContext.getDragLayer().isEventOverView(mBottomSheetHandleArea, ev)) {
return true;
}
- if (isSearching()) {
- return mAH.get(AdapterHolder.SEARCH).mRecyclerView
- .shouldContainerScroll(ev, mActivityContext.getDragLayer());
- }
- AllAppsRecyclerView rv = getActiveAppsRecyclerView();
+ AllAppsRecyclerView rv = getActiveRecyclerView();
if (rv == null) {
return true;
}
@@ -276,7 +270,7 @@
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
- AllAppsRecyclerView rv = getActiveAppsRecyclerView();
+ AllAppsRecyclerView rv = getActiveRecyclerView();
if (rv != null && rv.getScrollbar().isHitInParent(ev.getX(), ev.getY(),
mFastScrollerOffset)) {
mTouchHandler = rv.getScrollbar();
@@ -293,7 +287,7 @@
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
- AllAppsRecyclerView rv = getActiveAppsRecyclerView();
+ AllAppsRecyclerView rv = getActiveRecyclerView();
if (rv != null && rv.getScrollbar().isHitInParent(ev.getX(), ev.getY(),
mFastScrollerOffset)) {
mTouchHandler = rv.getScrollbar();
@@ -326,8 +320,8 @@
return getContext().getString(R.string.all_apps_button_label);
}
- /** The current apps recycler view in the container (may be hidden for search results). */
- public AllAppsRecyclerView getActiveAppsRecyclerView() {
+ /** The current recycler view visible in the container. */
+ public AllAppsRecyclerView getActiveRecyclerView() {
if (!mUsingTabs || isPersonalTab()) {
return mAH.get(AdapterHolder.MAIN).mRecyclerView;
} else {
@@ -376,15 +370,12 @@
// This is a focus listener that proxies focus from a view into the list view. This is to
// work around the search box from getting first focus and showing the cursor.
setOnFocusChangeListener((v, hasFocus) -> {
- if (hasFocus && getActiveAppsRecyclerView() != null) {
- getActiveAppsRecyclerView().requestFocus();
+ if (hasFocus && getActiveRecyclerView() != null) {
+ getActiveRecyclerView().requestFocus();
}
});
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, componentName) -> false);
rebindAdapters(true /* force */);
mBottomSheetBackground = findViewById(R.id.bottom_sheet_background);
@@ -447,19 +438,13 @@
}
protected void rebindAdapters(boolean force) {
- updateSearchResultsVisibility();
-
- boolean showTabs = shouldShowTabs();
+ boolean showTabs = showTabs();
if (showTabs == mUsingTabs && !force) {
return;
}
mUsingTabs = showTabs;
+ replaceRVContainer(mUsingTabs);
- if (isSearching()) {
- return;
- }
-
- replaceAppsRVContainer(mUsingTabs);
mAllAppsStore.unregisterIconContainer(mAH.get(AdapterHolder.MAIN).mRecyclerView);
mAllAppsStore.unregisterIconContainer(mAH.get(AdapterHolder.WORK).mRecyclerView);
@@ -494,17 +479,6 @@
mAllAppsStore.registerIconContainer(mAH.get(AdapterHolder.WORK).mRecyclerView);
}
- private void updateSearchResultsVisibility() {
- if (isSearching()) {
- getSearchRecyclerView().setVisibility(VISIBLE);
- getAppsRecyclerViewContainer().setVisibility(GONE);
- } else {
- getSearchRecyclerView().setVisibility(GONE);
- getAppsRecyclerViewContainer().setVisibility(VISIBLE);
- }
- mHeader.setActiveRV(getCurrentPage());
- }
-
private void setDeviceManagementResources() {
if (mActivityContext.getStringCache() != null) {
Button personalTab = findViewById(R.id.tab_personal);
@@ -515,23 +489,18 @@
}
}
- protected boolean shouldShowTabs() {
+ protected boolean showTabs() {
return mHasWorkApps;
}
- protected boolean isSearching() {
- return false;
- }
-
- protected View replaceAppsRVContainer(boolean showTabs) {
- for (int i = AdapterHolder.MAIN; i <= AdapterHolder.WORK; i++) {
- AdapterHolder adapterHolder = mAH.get(i);
+ protected View replaceRVContainer(boolean showTabs) {
+ for (AdapterHolder adapterHolder : mAH) {
if (adapterHolder.mRecyclerView != null) {
adapterHolder.mRecyclerView.setLayoutManager(null);
adapterHolder.mRecyclerView.setAdapter(null);
}
}
- View oldView = getAppsRecyclerViewContainer();
+ View oldView = getRecyclerViewContainer();
int index = indexOfChild(oldView);
removeView(oldView);
int layout = showTabs ? R.layout.all_apps_tabs : R.layout.all_apps_rv_layout;
@@ -552,17 +521,13 @@
return newView;
}
- public View getAppsRecyclerViewContainer() {
+ public View getRecyclerViewContainer() {
return mViewPager != null ? mViewPager : findViewById(R.id.apps_list_view);
}
- public SearchRecyclerView getSearchRecyclerView() {
- return mSearchRecyclerView;
- }
-
@Override
public void onActivePageChanged(int currentActivePage) {
- mHeader.setActiveRV(currentActivePage);
+ mHeader.setMainActive(currentActivePage == AdapterHolder.MAIN);
if (mAH.get(currentActivePage).mRecyclerView != null) {
mAH.get(currentActivePage).mRecyclerView.bindFastScrollbar();
}
@@ -591,8 +556,8 @@
return isDescendantViewVisible(R.id.tab_work);
}
- public AlphabeticalAppsList<T> getSearchResultList() {
- return mAH.get(AdapterHolder.SEARCH).mAppsList;
+ public AlphabeticalAppsList<T> getApps() {
+ return mAH.get(AdapterHolder.MAIN).mAppsList;
}
public FloatingHeaderView getFloatingHeaderView() {
@@ -601,19 +566,17 @@
@VisibleForTesting
public View getContentView() {
- return mViewPager == null ? getActiveAppsRecyclerView() : mViewPager;
+ return mViewPager == null ? getActiveRecyclerView() : mViewPager;
}
/** The current page visible in all apps. */
public int getCurrentPage() {
- return isSearching()
- ? AdapterHolder.SEARCH
- : mViewPager == null ? AdapterHolder.MAIN : mViewPager.getCurrentPage();
+ return mViewPager != null ? mViewPager.getCurrentPage() : AdapterHolder.MAIN;
}
/** The scroll bar for the active recycler view. */
public RecyclerViewFastScroller getScrollBar() {
- AllAppsRecyclerView rv = getActiveAppsRecyclerView();
+ AllAppsRecyclerView rv = getActiveRecyclerView();
return rv == null ? null : rv.getScrollbar();
}
@@ -622,9 +585,7 @@
mHeader.setup(
mAH.get(AdapterHolder.MAIN).mRecyclerView,
mAH.get(AdapterHolder.WORK).mRecyclerView,
- (SearchRecyclerView) mAH.get(AdapterHolder.SEARCH).mRecyclerView,
- getCurrentPage(),
- /* tabsHidden= */ mAH.get(AdapterHolder.WORK).mRecyclerView == null);
+ mAH.get(AdapterHolder.WORK).mRecyclerView == null);
int padding = mHeader.getMaxTranslation();
for (int i = 0; i < mAH.size(); i++) {
@@ -735,48 +696,39 @@
return ColorUtils.blendARGB(mScrimColor, mHeaderProtectionColor, blendRatio);
}
- protected abstract BaseAllAppsAdapter<T> createAdapter(AlphabeticalAppsList<T> mAppsList,
+ protected abstract BaseAllAppsAdapter getAdapter(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 int mType;
- public final BaseAllAppsAdapter<T> mAdapter;
+ private final boolean mIsWork;
+ public final BaseAllAppsAdapter<T> adapter;
final RecyclerView.LayoutManager mLayoutManager;
final AlphabeticalAppsList<T> mAppsList;
final Rect mPadding = new Rect();
AllAppsRecyclerView mRecyclerView;
boolean mVerticalFadingEdge;
- AdapterHolder(int type) {
- mType = type;
- mAppsList = new AlphabeticalAppsList<>(mActivityContext,
- isSearch() ? null : mAllAppsStore,
- isWork() ? mWorkManager.getAdapterProvider() : null);
+ AdapterHolder(boolean isWork) {
+ mIsWork = isWork;
+ mAppsList = new AlphabeticalAppsList<>(mActivityContext, mAllAppsStore,
+ isWork ? mWorkManager.getAdapterProvider() : null);
BaseAdapterProvider[] adapterProviders =
- isWork() ? new BaseAdapterProvider[]{mMainAdapterProvider,
+ isWork ? new BaseAdapterProvider[]{mMainAdapterProvider,
mWorkManager.getAdapterProvider()}
: new BaseAdapterProvider[]{mMainAdapterProvider};
- mAdapter = createAdapter(mAppsList, adapterProviders);
- mAppsList.setAdapter(mAdapter);
- mLayoutManager = mAdapter.getLayoutManager();
+ adapter = getAdapter(mAppsList, adapterProviders);
+ mAppsList.setAdapter(adapter);
+ mLayoutManager = adapter.getLayoutManager();
}
void setup(@NonNull View rv, @Nullable ItemInfoMatcher matcher) {
@@ -785,14 +737,14 @@
mRecyclerView.setEdgeEffectFactory(createEdgeEffectFactory());
mRecyclerView.setApps(mAppsList);
mRecyclerView.setLayoutManager(mLayoutManager);
- mRecyclerView.setAdapter(mAdapter);
+ mRecyclerView.setAdapter(adapter);
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);
- mAdapter.setIconFocusListener(focusedItemDecorator.getFocusListener());
+ adapter.setIconFocusListener(focusedItemDecorator.getFocusListener());
applyVerticalFadingEdgeEnabled(mVerticalFadingEdge);
applyPadding();
}
@@ -800,7 +752,7 @@
void applyPadding() {
if (mRecyclerView != null) {
int bottomOffset = 0;
- if (isWork() && mWorkManager.getWorkModeSwitch() != null) {
+ if (mIsWork && mWorkManager.getWorkModeSwitch() != null) {
bottomOffset = mInsets.bottom + mWorkManager.getWorkModeSwitch().getHeight();
}
mRecyclerView.setPadding(mPadding.left, mPadding.top, mPadding.right,
@@ -810,15 +762,15 @@
private void applyVerticalFadingEdgeEnabled(boolean enabled) {
mVerticalFadingEdge = enabled;
- mRecyclerView.setVerticalFadingEdgeEnabled(!mUsingTabs && mVerticalFadingEdge);
+ mAH.get(AdapterHolder.MAIN).mRecyclerView.setVerticalFadingEdgeEnabled(!mUsingTabs
+ && mVerticalFadingEdge);
}
+ }
- private boolean isWork() {
- return mType == WORK;
- }
-
- private boolean isSearch() {
- return mType == SEARCH;
- }
+ /**
+ * Returns a view that denotes the visible part of all apps container view.
+ */
+ public View getVisibleContainerView() {
+ return mActivityContext.getDeviceProfile().isTablet ? mBottomSheetBackground : this;
}
}
diff --git a/src/com/android/launcher3/allapps/DecorationInfo.java b/src/com/android/launcher3/allapps/DecorationInfo.java
deleted file mode 100644
index 50b250c..0000000
--- a/src/com/android/launcher3/allapps/DecorationInfo.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.launcher3.allapps;
-
-public class DecorationInfo {
-}
diff --git a/src/com/android/launcher3/allapps/FloatingHeaderView.java b/src/com/android/launcher3/allapps/FloatingHeaderView.java
index 3e717bd..72f14a8 100644
--- a/src/com/android/launcher3/allapps/FloatingHeaderView.java
+++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java
@@ -33,7 +33,6 @@
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;
@@ -91,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;
@@ -101,6 +100,7 @@
protected boolean mTabsHidden;
protected int mMaxTranslation;
+ private boolean mMainRVActive = true;
private boolean mCollapsed = false;
@@ -232,8 +232,7 @@
return super.getFocusedChild();
}
- void setup(AllAppsRecyclerView mainRV, AllAppsRecyclerView workRV, SearchRecyclerView searchRV,
- int activeRV, boolean tabsHidden) {
+ void setup(AllAppsRecyclerView mainRV, AllAppsRecyclerView workRV, boolean tabsHidden) {
for (FloatingHeaderRow row : mAllRows) {
row.setup(this, mAllRows, tabsHidden);
}
@@ -243,8 +242,8 @@
mTabLayout.setVisibility(tabsHidden ? View.GONE : View.VISIBLE);
mMainRV = setupRV(mMainRV, mainRV);
mWorkRV = setupRV(mWorkRV, workRV);
- mSearchRV = (SearchRecyclerView) setupRV(mSearchRV, searchRV);
- setActiveRV(activeRV);
+ mParent = (ViewGroup) mMainRV.getParent();
+ setMainActive(mMainRVActive || mWorkRV == null);
reset(false);
}
@@ -268,10 +267,9 @@
}
}
- public void setActiveRV(int rvType) {
- mCurrentRV =
- rvType == AdapterHolder.MAIN ? mMainRV
- : rvType == AdapterHolder.WORK ? mWorkRV : mSearchRV;
+ public void setMainActive(boolean active) {
+ mCurrentRV = active ? mMainRV : mWorkRV;
+ mMainRVActive = active;
}
public int getMaxTranslation() {
@@ -334,15 +332,10 @@
mHeaderClip.top = clipTop;
// clipping on a draw might cause additional redraw
setClipBounds(mHeaderClip);
- if (mMainRV != null) {
- mMainRV.setClipBounds(mRVClip);
- }
+ mMainRV.setClipBounds(mRVClip);
if (mWorkRV != null) {
mWorkRV.setClipBounds(mRVClip);
}
- if (mSearchRV != null) {
- mSearchRV.setClipBounds(mRVClip);
- }
}
/**
@@ -409,8 +402,8 @@
}
private void calcOffset(Point p) {
- p.x = getLeft() - mCurrentRV.getLeft() - ((ViewGroup) mCurrentRV.getParent()).getLeft();
- p.y = getTop() - mCurrentRV.getTop() - ((ViewGroup) mCurrentRV.getParent()).getTop();
+ p.x = getLeft() - mCurrentRV.getLeft() - mParent.getLeft();
+ p.y = getTop() - mCurrentRV.getTop() - mParent.getTop();
}
public boolean hasVisibleContent() {
diff --git a/src/com/android/launcher3/allapps/SearchRecyclerView.java b/src/com/android/launcher3/allapps/SearchRecyclerView.java
deleted file mode 100644
index 435668a..0000000
--- a/src/com/android/launcher3/allapps/SearchRecyclerView.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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;
-
-/** 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;
- }
-}
diff --git a/src/com/android/launcher3/allapps/WorkEduCard.java b/src/com/android/launcher3/allapps/WorkEduCard.java
index fa9a8f6..c336496 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().getActiveAppsRecyclerView().getTabWidth();
+ lp.width = mActivityContext.getAppsView().getActiveRecyclerView().getTabWidth();
}
@Override
diff --git a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
index 4bd106f..bc2c318 100644
--- a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
+++ b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
@@ -57,7 +57,7 @@
private final AllAppsSearchBarController mSearchBarController;
private final SpannableStringBuilder mSearchQueryBuilder;
- private AlphabeticalAppsList<?> mSearchResultsList;
+ private AlphabeticalAppsList<?> mApps;
private ActivityAllAppsContainerView<?> mAppsView;
// The amount of pixels to shift down and overlap with the rest of the content.
@@ -102,8 +102,8 @@
// Update the width to match the grid padding
DeviceProfile dp = mLauncher.getDeviceProfile();
int myRequestedWidth = getSize(widthMeasureSpec);
- int rowWidth = myRequestedWidth - mAppsView.getActiveAppsRecyclerView().getPaddingLeft()
- - mAppsView.getActiveAppsRecyclerView().getPaddingRight();
+ int rowWidth = myRequestedWidth - mAppsView.getActiveRecyclerView().getPaddingLeft()
+ - mAppsView.getActiveRecyclerView().getPaddingRight();
int cellWidth = DeviceProfile.calculateCellWidth(rowWidth,
dp.cellLayoutBorderSpacePx.x, dp.numShownHotseatIcons);
@@ -131,7 +131,7 @@
@Override
public void initializeSearch(ActivityAllAppsContainerView<?> appsView) {
- mSearchResultsList = appsView.getSearchResultList();
+ mApps = appsView.getApps();
mAppsView = appsView;
mSearchBarController.initialize(
new DefaultAppSearchAlgorithm(getContext()),
@@ -170,23 +170,15 @@
@Override
public void onSearchResult(String query, ArrayList<AdapterItem> items) {
if (items != null) {
- mSearchResultsList.setSearchResults(items);
+ mApps.setSearchResults(items);
notifyResultChanged();
mAppsView.setLastSearchQuery(query);
}
}
@Override
- public void onAppendSearchResult(String query, ArrayList<AdapterItem> items) {
- if (items != null) {
- mSearchResultsList.appendSearchResults(items);
- notifyResultChanged();
- }
- }
-
- @Override
public void clearSearchResult() {
- if (mSearchResultsList.setSearchResults(null)) {
+ if (mApps.setSearchResults(null)) {
notifyResultChanged();
}
diff --git a/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithm.java b/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithm.java
index 222c8fe..33d0082 100644
--- a/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithm.java
+++ b/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithm.java
@@ -85,7 +85,7 @@
for (int i = 0; i < total && resultCount < MAX_RESULTS_COUNT; i++) {
AppInfo info = apps.get(i);
if (StringMatcherUtility.matches(queryTextLower, info.title.toString(), matcher)) {
- AdapterItem appItem = AdapterItem.asApp(resultCount, "", info, resultCount);
+ AdapterItem appItem = AdapterItem.asApp(resultCount, info);
result.add(appItem);
resultCount++;
}
diff --git a/src/com/android/launcher3/anim/Interpolators.java b/src/com/android/launcher3/anim/Interpolators.java
index 5a46ce1..4ff5d5e 100644
--- a/src/com/android/launcher3/anim/Interpolators.java
+++ b/src/com/android/launcher3/anim/Interpolators.java
@@ -47,13 +47,6 @@
public static final Interpolator DEACCEL_2_5 = new DecelerateInterpolator(2.5f);
public static final Interpolator DEACCEL_3 = new DecelerateInterpolator(3f);
- /**
- * The decelerating emphasized interpolator. Used for hero / emphasized movement of content that
- * is appearing e.g. when coming from off screen
- */
- public static final Interpolator EMPHASIZED_DECELERATE = new PathInterpolator(
- 0.05f, 0.7f, 0.1f, 1f);
-
public static final Interpolator ACCEL_DEACCEL = new AccelerateDecelerateInterpolator();
public static final Interpolator FAST_OUT_SLOW_IN = new PathInterpolator(0.4f, 0f, 0.2f, 1f);
diff --git a/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java b/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java
index 29e7c18..f9916d0 100644
--- a/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java
+++ b/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java
@@ -87,7 +87,8 @@
// Total duration for the drop animation to complete.
long duration = mContext.getResources().getInteger(R.integer.config_dropAnimMaxDuration) +
LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY +
- LauncherState.SPRING_LOADED.getTransitionDuration(Launcher.getLauncher(mContext));
+ LauncherState.SPRING_LOADED.getTransitionDuration(Launcher.getLauncher(mContext),
+ true /* isToState */);
// Delay the actual accept() call until the drop animation is complete.
return PinRequestHelper.createWorkspaceItemFromPinItemRequest(
mContext, mRequest, duration);
diff --git a/src/com/android/launcher3/search/SearchCallback.java b/src/com/android/launcher3/search/SearchCallback.java
index 5796116..495a303 100644
--- a/src/com/android/launcher3/search/SearchCallback.java
+++ b/src/com/android/launcher3/search/SearchCallback.java
@@ -32,13 +32,6 @@
void onSearchResult(String query, ArrayList<T> items);
/**
- * Called when the search from secondary source is complete.
- *
- * @param items list of search results
- */
- void onAppendSearchResult(String query, ArrayList<T> items);
-
- /**
* Called when the search results should be cleared.
*/
void clearSearchResult();
diff --git a/src/com/android/launcher3/shortcuts/ShortcutKey.java b/src/com/android/launcher3/shortcuts/ShortcutKey.java
index 0c6d675..9af68c0 100644
--- a/src/com/android/launcher3/shortcuts/ShortcutKey.java
+++ b/src/com/android/launcher3/shortcuts/ShortcutKey.java
@@ -57,11 +57,17 @@
}
public static Intent makeIntent(ShortcutInfo si) {
+ return makeIntent(si.getId(), si.getPackage()).setComponent(si.getActivity());
+ }
+
+ /**
+ * Creates an intent for shortcut id and package name.
+ */
+ public static Intent makeIntent(String shortcutId, String packageName) {
return new Intent(Intent.ACTION_MAIN)
.addCategory(INTENT_CATEGORY)
- .setComponent(si.getActivity())
- .setPackage(si.getPackage())
+ .setPackage(packageName)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)
- .putExtra(EXTRA_SHORTCUT_ID, si.getId());
+ .putExtra(EXTRA_SHORTCUT_ID, shortcutId);
}
}
diff --git a/src/com/android/launcher3/statemanager/BaseState.java b/src/com/android/launcher3/statemanager/BaseState.java
index 122573c..4a68dda 100644
--- a/src/com/android/launcher3/statemanager/BaseState.java
+++ b/src/com/android/launcher3/statemanager/BaseState.java
@@ -36,7 +36,7 @@
/**
* @return How long the animation to this state should take (or from this state to NORMAL).
*/
- int getTransitionDuration(Context context);
+ int getTransitionDuration(Context context, boolean isToState);
/**
* Returns the state to go back to from this state
diff --git a/src/com/android/launcher3/statemanager/StateManager.java b/src/com/android/launcher3/statemanager/StateManager.java
index 1767939..2aa9dde 100644
--- a/src/com/android/launcher3/statemanager/StateManager.java
+++ b/src/com/android/launcher3/statemanager/StateManager.java
@@ -253,8 +253,8 @@
// Since state mBaseState can be reached from multiple states, just assume that the
// transition plays in reverse and use the same duration as previous state.
mConfig.duration = state == mBaseState
- ? fromState.getTransitionDuration(mActivity)
- : state.getTransitionDuration(mActivity);
+ ? fromState.getTransitionDuration(mActivity, false /* isToState */)
+ : state.getTransitionDuration(mActivity, true /* isToState */);
prepareForAtomicAnimation(fromState, state, mConfig);
AnimatorSet animation = createAnimationToNewWorkspaceInternal(state).buildAnim();
if (listener != null) {
diff --git a/src/com/android/launcher3/states/HintState.java b/src/com/android/launcher3/states/HintState.java
index 8b52016..4cfced8 100644
--- a/src/com/android/launcher3/states/HintState.java
+++ b/src/com/android/launcher3/states/HintState.java
@@ -43,7 +43,7 @@
}
@Override
- public int getTransitionDuration(Context context) {
+ public int getTransitionDuration(Context context, boolean isToState) {
return 80;
}
diff --git a/src/com/android/launcher3/states/SpringLoadedState.java b/src/com/android/launcher3/states/SpringLoadedState.java
index 7e9d56d..15cdc20 100644
--- a/src/com/android/launcher3/states/SpringLoadedState.java
+++ b/src/com/android/launcher3/states/SpringLoadedState.java
@@ -39,7 +39,7 @@
}
@Override
- public int getTransitionDuration(Context context) {
+ public int getTransitionDuration(Context context, boolean isToState) {
return 150;
}
@@ -52,16 +52,7 @@
}
float shrunkTop = grid.getWorkspaceSpringLoadShrunkTop();
- float shrunkBottom = grid.getWorkspaceSpringLoadShrunkBottom();
- float scale = Math.min((shrunkBottom - shrunkTop) / ws.getNormalChildHeight(), 1f);
-
- // Reduce scale if next pages would not be visible after scaling the workspace
- float scaledWorkspaceWidth = ws.getWidth() * scale;
- float maxAvailableWidth =
- ws.getWidth() - (2 * grid.getWorkspaceSpringLoadedMinimumNextPageVisible());
- if (scaledWorkspaceWidth > maxAvailableWidth) {
- scale *= maxAvailableWidth / scaledWorkspaceWidth;
- }
+ float scale = grid.getWorkspaceSpringLoadScale();
float halfHeight = ws.getHeight() / 2;
float myCenter = ws.getTop() + halfHeight;
diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java
index ee8f85d..a6b481a 100644
--- a/src/com/android/launcher3/testing/TestInformationHandler.java
+++ b/src/com/android/launcher3/testing/TestInformationHandler.java
@@ -108,7 +108,7 @@
case TestProtocol.REQUEST_APPS_LIST_SCROLL_Y: {
return getLauncherUIProperty(Bundle::putInt,
- l -> l.getAppsView().getActiveAppsRecyclerView().getCurrentScrollY());
+ l -> l.getAppsView().getActiveRecyclerView().getCurrentScrollY());
}
case TestProtocol.REQUEST_WIDGETS_SCROLL_Y: {
diff --git a/src/com/android/launcher3/util/DisplayController.java b/src/com/android/launcher3/util/DisplayController.java
index 8005181..7c73be5 100644
--- a/src/com/android/launcher3/util/DisplayController.java
+++ b/src/com/android/launcher3/util/DisplayController.java
@@ -242,7 +242,9 @@
change |= CHANGE_SUPPORTED_BOUNDS;
Point currentS = newInfo.currentSize;
- Point expectedS = oldInfo.mPerDisplayBounds.get(newInfo.displayId).first.size;
+ Pair<CachedDisplayInfo, WindowBounds[]> cachedBounds =
+ oldInfo.mPerDisplayBounds.get(newInfo.displayId);
+ Point expectedS = cachedBounds == null ? null : cachedBounds.first.size;
if (newInfo.supportedBounds.size() != oldInfo.supportedBounds.size()) {
Log.e("b/198965093",
"Inconsistent number of displays"
@@ -250,10 +252,12 @@
+ "\noldInfo.supportedBounds: " + oldInfo.supportedBounds
+ "\nnewInfo.supportedBounds: " + newInfo.supportedBounds);
}
- if ((Math.min(currentS.x, currentS.y) != Math.min(expectedS.x, expectedS.y)
+ if (expectedS != null
+ && (Math.min(currentS.x, currentS.y) != Math.min(expectedS.x, expectedS.y)
|| Math.max(currentS.x, currentS.y) != Math.max(expectedS.x, expectedS.y))
&& display.getState() == Display.STATE_OFF) {
- Log.e("b/198965093", "Display size changed while display is off, ignoring change");
+ Log.e("b/198965093",
+ "Display size changed while display is off, ignoring change");
return;
}
}
@@ -286,7 +290,7 @@
// Configuration property
public final float fontScale;
- public final int densityDpi;
+ private final int densityDpi;
public final NavigationMode navigationMode;
private final PortraitSize mScreenSizeDp;
@@ -353,6 +357,10 @@
public float smallestSizeDp(WindowBounds bounds) {
return dpiFromPx(Math.min(bounds.bounds.width(), bounds.bounds.height()), densityDpi);
}
+
+ public int getDensityDpi() {
+ return densityDpi;
+ }
}
/**
diff --git a/src/com/android/launcher3/util/Executors.java b/src/com/android/launcher3/util/Executors.java
index 8485371..6978e0c 100644
--- a/src/com/android/launcher3/util/Executors.java
+++ b/src/com/android/launcher3/util/Executors.java
@@ -15,17 +15,12 @@
*/
package com.android.launcher3.util;
-import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
-
-import static java.util.concurrent.Executors.newSingleThreadExecutor;
-
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Process;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
@@ -42,7 +37,7 @@
private static final int KEEP_ALIVE = 1;
/** Dedicated executor instances for work depending on other packages. */
- private static final Map<String, ExecutorService> PACKAGE_EXECUTORS = new ConcurrentHashMap<>();
+ private static final Map<String, LooperExecutor> PACKAGE_EXECUTORS = new ConcurrentHashMap<>();
/**
* An {@link ThreadPoolExecutor} to be used with async task with no limit on the queue size.
@@ -90,11 +85,10 @@
*
* @param packageName Package associated with the executor.
*/
- public static ExecutorService getPackageExecutor(String packageName) {
+ public static LooperExecutor getPackageExecutor(String packageName) {
return PACKAGE_EXECUTORS.computeIfAbsent(
- packageName,
- p -> newSingleThreadExecutor(
- new SimpleThreadFactory(p, THREAD_PRIORITY_BACKGROUND)));
+ packageName, p -> new LooperExecutor(
+ createAndStartNewLooper(p, Process.THREAD_PRIORITY_DEFAULT)));
}
/**
diff --git a/src/com/android/launcher3/util/window/WindowManagerProxy.java b/src/com/android/launcher3/util/window/WindowManagerProxy.java
index 5aaa275..61b7fa1 100644
--- a/src/com/android/launcher3/util/window/WindowManagerProxy.java
+++ b/src/com/android/launcher3/util/window/WindowManagerProxy.java
@@ -22,7 +22,6 @@
import static com.android.launcher3.ResourceUtils.NAVBAR_HEIGHT;
import static com.android.launcher3.ResourceUtils.NAVBAR_HEIGHT_LANDSCAPE;
import static com.android.launcher3.ResourceUtils.NAVBAR_LANDSCAPE_LEFT_RIGHT_SIZE;
-import static com.android.launcher3.ResourceUtils.getDimenByName;
import static com.android.launcher3.Utilities.dpiFromPx;
import static com.android.launcher3.util.MainThreadInitializedObject.forOverride;
import static com.android.launcher3.util.RotationUtils.deltaRotation;
@@ -157,16 +156,16 @@
int bottomNav = isTablet
? 0
: (config.screenHeightDp > config.screenWidthDp
- ? getDimenByName(NAVBAR_HEIGHT, systemRes, 0)
+ ? getDimenByName(NAVBAR_HEIGHT, systemRes)
: (isGesture
- ? getDimenByName(NAVBAR_HEIGHT_LANDSCAPE, systemRes, 0)
+ ? getDimenByName(NAVBAR_HEIGHT_LANDSCAPE, systemRes)
: 0));
Insets newNavInsets = Insets.of(navInsets.left, navInsets.top, navInsets.right, bottomNav);
insetsBuilder.setInsets(WindowInsets.Type.navigationBars(), newNavInsets);
insetsBuilder.setInsetsIgnoringVisibility(WindowInsets.Type.navigationBars(), newNavInsets);
Insets statusBarInsets = oldInsets.getInsets(WindowInsets.Type.statusBars());
- int statusBarHeight = getDimenByName("status_bar_height", systemRes, 0);
+ int statusBarHeight = getDimenByName("status_bar_height", systemRes);
Insets newStatusBarInsets = Insets.of(
statusBarInsets.left,
Math.max(statusBarInsets.top, statusBarHeight),
@@ -222,23 +221,23 @@
boolean isTabletOrGesture = isTablet
|| (Utilities.ATLEAST_R && isGestureNav(context));
- int statusBarHeight = getDimenByName("status_bar_height", systemRes, 0);
+ int statusBarHeight = getDimenByName("status_bar_height", systemRes);
int navBarHeightPortrait, navBarHeightLandscape, navbarWidthLandscape;
navBarHeightPortrait = isTablet
? (mTaskbarDrawnInProcess
? 0 : systemRes.getDimensionPixelSize(R.dimen.taskbar_size))
- : getDimenByName(NAVBAR_HEIGHT, systemRes, 0);
+ : getDimenByName(NAVBAR_HEIGHT, systemRes);
navBarHeightLandscape = isTablet
? (mTaskbarDrawnInProcess
? 0 : systemRes.getDimensionPixelSize(R.dimen.taskbar_size))
: (isTabletOrGesture
- ? getDimenByName(NAVBAR_HEIGHT_LANDSCAPE, systemRes, 0) : 0);
+ ? getDimenByName(NAVBAR_HEIGHT_LANDSCAPE, systemRes) : 0);
navbarWidthLandscape = isTabletOrGesture
? 0
- : getDimenByName(NAVBAR_LANDSCAPE_LEFT_RIGHT_SIZE, systemRes, 0);
+ : getDimenByName(NAVBAR_LANDSCAPE_LEFT_RIGHT_SIZE, systemRes);
WindowBounds[] result = new WindowBounds[4];
Point tempSize = new Point();
@@ -274,6 +273,13 @@
return result;
}
+ /**
+ * Wrapper around the utility method for easier emulation
+ */
+ protected int getDimenByName(String resName, Resources res) {
+ return ResourceUtils.getDimenByName(resName, res, 0);
+ }
+
protected boolean isGestureNav(Context context) {
return ResourceUtils.getIntegerByName("config_navBarInteractionMode",
context.getResources(), INVALID_RESOURCE_HANDLE) == 2;
diff --git a/src/com/android/launcher3/views/AbstractSlideInView.java b/src/com/android/launcher3/views/AbstractSlideInView.java
index ed31e8d..47503b1 100644
--- a/src/com/android/launcher3/views/AbstractSlideInView.java
+++ b/src/com/android/launcher3/views/AbstractSlideInView.java
@@ -231,13 +231,17 @@
if (mSwipeDetector.isIdleState()) {
mOpenCloseAnimator
.setDuration(defaultDuration)
- .setInterpolator(Interpolators.ACCEL);
+ .setInterpolator(getIdleInterpolator());
} else {
mOpenCloseAnimator.setInterpolator(mScrollInterpolator);
}
mOpenCloseAnimator.start();
}
+ protected Interpolator getIdleInterpolator() {
+ return Interpolators.ACCEL;
+ }
+
protected void onCloseComplete() {
mIsOpen = false;
getPopupContainer().removeView(this);
diff --git a/src/com/android/launcher3/views/BaseDragLayer.java b/src/com/android/launcher3/views/BaseDragLayer.java
index f71aa13..4c001fd 100644
--- a/src/com/android/launcher3/views/BaseDragLayer.java
+++ b/src/com/android/launcher3/views/BaseDragLayer.java
@@ -413,6 +413,14 @@
}
/**
+ * Similar to {@link #mapCoordInSelfToDescendant(View descendant, float[] coord)}
+ * but accepts a Rect instead of float[].
+ */
+ public void mapRectInSelfToDescendant(View descendant, Rect rect) {
+ Utilities.mapRectInSelfToDescendant(descendant, this, rect);
+ }
+
+ /**
* Inverse of {@link #getDescendantCoordRelativeToSelf(View, float[])}.
*/
public void mapCoordInSelfToDescendant(View descendant, float[] coord) {
diff --git a/src/com/android/launcher3/views/RecyclerViewFastScroller.java b/src/com/android/launcher3/views/RecyclerViewFastScroller.java
index 5f6e453..a982786 100644
--- a/src/com/android/launcher3/views/RecyclerViewFastScroller.java
+++ b/src/com/android/launcher3/views/RecyclerViewFastScroller.java
@@ -43,7 +43,7 @@
import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.RecyclerView;
-import com.android.launcher3.FastScrollRecyclerView;
+import com.android.launcher3.BaseRecyclerView;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.graphics.FastScrollThumbDrawable;
@@ -127,7 +127,7 @@
private String mPopupSectionName;
private Insets mSystemGestureInsets;
- protected FastScrollRecyclerView mRv;
+ protected BaseRecyclerView mRv;
private RecyclerView.OnScrollListener mOnScrollListener;
private int mDownX;
@@ -172,7 +172,7 @@
ta.recycle();
}
- public void setRecyclerView(FastScrollRecyclerView rv, TextView popupView) {
+ public void setRecyclerView(BaseRecyclerView rv, TextView popupView) {
if (mRv != null && mOnScrollListener != null) {
mRv.removeOnScrollListener(mOnScrollListener);
}
diff --git a/src/com/android/launcher3/widget/BaseWidgetSheet.java b/src/com/android/launcher3/widget/BaseWidgetSheet.java
index b12574f..c7bb612 100644
--- a/src/com/android/launcher3/widget/BaseWidgetSheet.java
+++ b/src/com/android/launcher3/widget/BaseWidgetSheet.java
@@ -44,6 +44,7 @@
import com.android.launcher3.util.SystemUiController;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.AbstractSlideInView;
+import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.ArrowTipView;
/**
@@ -306,4 +307,11 @@
return mActivityContext.getSharedPrefs().getBoolean(KEY_WIDGETS_EDUCATION_TIP_SEEN, false)
|| Utilities.IS_RUNNING_IN_TEST_HARNESS;
}
+
+ @Override
+ protected void setTranslationShift(float translationShift) {
+ super.setTranslationShift(translationShift);
+ Launcher launcher = ActivityContext.lookupContext(getContext());
+ launcher.onWidgetsTransition(1 - translationShift);
+ }
}
diff --git a/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java b/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java
index ea62c17..f780f03 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 FastScrollRecyclerView implements OnItemTouchListener {
+public class WidgetsRecyclerView extends BaseRecyclerView implements OnItemTouchListener {
private WidgetsListAdapter mAdapter;
diff --git a/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java b/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java
index 2751a52..a15508a 100644
--- a/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java
+++ b/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java
@@ -95,11 +95,6 @@
}
@Override
- public void onAppendSearchResult(String query, ArrayList<WidgetsListBaseEntry> items) {
- // Not needed.
- }
-
- @Override
public void clearSearchResult() {
// Any existing search session will be cancelled by setting text to empty.
mInput.setText("");
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java b/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java
index 8a435c9..2f8e680 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java
@@ -39,8 +39,8 @@
}
@Override
- public int getTransitionDuration(Context context) {
- return 320;
+ public int getTransitionDuration(Context context, boolean isToState) {
+ return isToState ? 500 : 300;
}
@Override
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/states/OverviewState.java b/src_ui_overrides/com/android/launcher3/uioverrides/states/OverviewState.java
index d154317..7a228c4 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/states/OverviewState.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/states/OverviewState.java
@@ -34,7 +34,7 @@
}
@Override
- public int getTransitionDuration(Context context) {
+ public int getTransitionDuration(Context context, boolean isToState) {
return 250;
}
diff --git a/tests/res/raw/devices.json b/tests/res/raw/devices.json
new file mode 100644
index 0000000..a78dd86
--- /dev/null
+++ b/tests/res/raw/devices.json
@@ -0,0 +1,45 @@
+{
+ "pixel6pro": {
+ "width": 1440,
+ "height": 3120,
+ "density": 560,
+ "name": "pixel6pro",
+ "cutout": "0, 130, 0, 0",
+ "grids": [
+ "normal",
+ "reasonable",
+ "practical",
+ "big",
+ "crazy_big"
+ ],
+ "resourceOverrides": {
+ "status_bar_height": 98,
+ "navigation_bar_height_landscape": 56,
+ "navigation_bar_height": 56,
+ "navigation_bar_width": 56
+ }
+ },
+ "test": {
+ "data needs updating": 0
+ },
+ "pixel5": {
+ "width": 1080,
+ "height": 2340,
+ "density": 440,
+ "name": "pixel5",
+ "cutout": "0, 136, 0, 0",
+ "grids": [
+ "normal",
+ "reasonable",
+ "practical",
+ "big",
+ "crazy_big"
+ ],
+ "resourceOverrides": {
+ "status_bar_height": 66,
+ "navigation_bar_height_landscape": 44,
+ "navigation_bar_height": 44,
+ "navigation_bar_width": 44
+ }
+ }
+}
diff --git a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
index f91f1c4..6d0fcb6 100644
--- a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
+++ b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
@@ -64,6 +64,7 @@
windowBounds = WindowBounds(x, y, x, y - 100, 0)
whenever(info.isTablet(any())).thenReturn(false)
+ whenever(info.getDensityDpi()).thenReturn(560)
inv = newScalableInvariantDeviceProfile()
}
@@ -77,6 +78,7 @@
windowBounds = WindowBounds(x, y, x, y - 100, 0)
whenever(info.isTablet(any())).thenReturn(true)
+ whenever(info.getDensityDpi()).thenReturn(320)
inv = newScalableInvariantDeviceProfile()
}
@@ -107,6 +109,7 @@
PointF(16f, 16f)
).toTypedArray()
hotseatBorderSpaces = FloatArray(4) { 16f }
+ hotseatColumnSpan = IntArray(4) { 4 }
iconSize = FloatArray(4) { 56f }
allAppsIconSize = FloatArray(4) { 56f }
iconTextSize = FloatArray(4) { 14f }
diff --git a/tests/src/com/android/launcher3/HotseatSizeTest.kt b/tests/src/com/android/launcher3/HotseatShownIconsTest.kt
similarity index 97%
rename from tests/src/com/android/launcher3/HotseatSizeTest.kt
rename to tests/src/com/android/launcher3/HotseatShownIconsTest.kt
index a44939f..593239d 100644
--- a/tests/src/com/android/launcher3/HotseatSizeTest.kt
+++ b/tests/src/com/android/launcher3/HotseatShownIconsTest.kt
@@ -23,15 +23,13 @@
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
-import org.mockito.ArgumentMatchers
-import org.mockito.Mockito.`when` as whenever
/**
* Test for [DeviceProfile]
*/
@SmallTest
@RunWith(AndroidJUnit4::class)
-class HotseatSizeTest : DeviceProfileBaseTest() {
+class HotseatShownIconsTest : DeviceProfileBaseTest() {
@Test
fun hotseat_size_is_normal_for_handhelds() {
diff --git a/tests/src/com/android/launcher3/InlineQsbTest.kt b/tests/src/com/android/launcher3/InlineQsbTest.kt
index e00dca8..905c1e1 100644
--- a/tests/src/com/android/launcher3/InlineQsbTest.kt
+++ b/tests/src/com/android/launcher3/InlineQsbTest.kt
@@ -29,17 +29,16 @@
class InlineQsbTest : DeviceProfileBaseTest() {
@Test
- fun qsbWidth_is_match_parent_for_phones() {
+ fun qsb_is_not_inline_for_phones() {
initializeVarsForPhone()
val dp = newDP()
assertThat(dp.isQsbInline).isFalse()
- assertThat(dp.qsbWidth).isEqualTo(0)
}
@Test
- fun qsbWidth_is_match_parent_for_tablet_portrait() {
+ fun qsb_is_inline_for_tablet_portrait() {
initializeVarsForTablet()
inv = newScalableInvariantDeviceProfile().apply {
inlineQsb = booleanArrayOf(
@@ -62,11 +61,10 @@
)
assertThat(dp.isQsbInline).isFalse()
- assertThat(dp.qsbWidth).isEqualTo(0)
}
@Test
- fun qsbWidth_has_size_for_tablet_landscape() {
+ fun qsb_is_inline_for_tablet_landscape() {
initializeVarsForTablet(isLandscape = true)
inv = newScalableInvariantDeviceProfile().apply {
inlineQsb = booleanArrayOf(
@@ -75,16 +73,17 @@
false,
false
)
+ numColumns = 6
+ numRows = 5
+ numShownHotseatIcons = 6
}
val dp = newDP()
if (dp.hotseatQsbHeight > 0) {
assertThat(dp.isQsbInline).isTrue()
- assertThat(dp.qsbWidth).isGreaterThan(0)
} else { // Launcher3 doesn't have QSB height
assertThat(dp.isQsbInline).isFalse()
- assertThat(dp.qsbWidth).isEqualTo(0)
}
}
@@ -92,14 +91,13 @@
* This test is to make sure that a tablet doesn't inline the QSB if the layout doesn't support
*/
@Test
- fun qsbWidth_is_match_parent_for_tablet_landscape_without_inline() {
+ fun qsb_is_not_inline_for_tablet_landscape_without_inline() {
initializeVarsForTablet(isLandscape = true)
useTwoPanels = true
val dp = newDP()
assertThat(dp.isQsbInline).isFalse()
- assertThat(dp.qsbWidth).isEqualTo(0)
}
}
\ No newline at end of file
diff --git a/tests/src/com/android/launcher3/deviceemulator/DisplayEmulator.java b/tests/src/com/android/launcher3/deviceemulator/DisplayEmulator.java
new file mode 100644
index 0000000..31468c5
--- /dev/null
+++ b/tests/src/com/android/launcher3/deviceemulator/DisplayEmulator.java
@@ -0,0 +1,95 @@
+/*
+ * 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.deviceemulator;
+
+import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
+
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.net.Uri;
+import android.os.UserHandle;
+import android.view.Display;
+import android.view.IWindowManager;
+import android.view.WindowManagerGlobal;
+
+import androidx.test.uiautomator.UiDevice;
+
+import com.android.launcher3.deviceemulator.models.DeviceEmulationData;
+import com.android.launcher3.tapl.LauncherInstrumentation;
+import com.android.launcher3.util.window.WindowManagerProxy;
+
+import java.util.concurrent.Callable;
+
+
+public class DisplayEmulator {
+ Context mContext;
+ LauncherInstrumentation mLauncher;
+ DisplayEmulator(Context context, LauncherInstrumentation launcher) {
+ mContext = context;
+ mLauncher = launcher;
+ }
+
+ /**
+ * By changing the WindowManagerProxy we can override the window insets information
+ **/
+ private IWindowManager changeWindowManagerInstance(DeviceEmulationData deviceData) {
+ WindowManagerProxy.INSTANCE.initializeForTesting(
+ new TestWindowManagerProxy(mContext, deviceData));
+ return WindowManagerGlobal.getWindowManagerService();
+ }
+
+ public <T> T emulate(DeviceEmulationData device, String grid, Callable<T> runInEmulation)
+ throws Exception {
+ WindowManagerProxy original = WindowManagerProxy.INSTANCE.get(mContext);
+ // Set up emulation
+ final int userId = UserHandle.myUserId();
+ WindowManagerProxy.INSTANCE.initializeForTesting(
+ new TestWindowManagerProxy(mContext, device));
+ IWindowManager wm = changeWindowManagerInstance(device);
+ // Change density twice to force display controller to reset its state
+ wm.setForcedDisplayDensityForUser(Display.DEFAULT_DISPLAY, device.density / 2, userId);
+ wm.setForcedDisplayDensityForUser(Display.DEFAULT_DISPLAY, device.density, userId);
+ wm.setForcedDisplaySize(Display.DEFAULT_DISPLAY, device.width, device.height);
+ wm.setForcedDisplayScalingMode(Display.DEFAULT_DISPLAY, 1);
+
+ // Set up grid
+ setGrid(grid);
+ try {
+ return runInEmulation.call();
+ } finally {
+ // Clear emulation
+ WindowManagerProxy.INSTANCE.initializeForTesting(original);
+ UiDevice.getInstance(getInstrumentation()).executeShellCommand("cmd window reset");
+ }
+ }
+
+ private void setGrid(String gridType) {
+ // When the grid changes, the desktop arrangement get stored in SQL and we need to wait to
+ // make sure there is no SQL operations running and get SQL_BUSY error, that's why we need
+ // to call mLauncher.waitForLauncherInitialized();
+ mLauncher.waitForLauncherInitialized();
+ String testProviderAuthority = mContext.getPackageName() + ".grid_control";
+ Uri gridUri = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(testProviderAuthority)
+ .appendPath("default_grid")
+ .build();
+ ContentValues values = new ContentValues();
+ values.put("name", gridType);
+ mContext.getContentResolver().update(gridUri, values, null, null);
+ }
+}
diff --git a/tests/src/com/android/launcher3/deviceemulator/TestWindowManagerProxy.java b/tests/src/com/android/launcher3/deviceemulator/TestWindowManagerProxy.java
new file mode 100644
index 0000000..ca2f81e
--- /dev/null
+++ b/tests/src/com/android/launcher3/deviceemulator/TestWindowManagerProxy.java
@@ -0,0 +1,75 @@
+/*
+ * 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.deviceemulator;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Point;
+import android.graphics.Rect;
+import android.view.Display;
+import android.view.WindowInsets;
+
+import com.android.launcher3.deviceemulator.models.DeviceEmulationData;
+import com.android.launcher3.util.RotationUtils;
+import com.android.launcher3.util.WindowBounds;
+import com.android.launcher3.util.window.CachedDisplayInfo;
+import com.android.launcher3.util.window.WindowManagerProxy;
+
+public class TestWindowManagerProxy extends WindowManagerProxy {
+
+ private final DeviceEmulationData mDevice;
+
+ public TestWindowManagerProxy(Context context, DeviceEmulationData device) {
+ super(true);
+ mDevice = device;
+ }
+
+ @Override
+ public boolean isInternalDisplay(Display display) {
+ return display.getDisplayId() == Display.DEFAULT_DISPLAY;
+ }
+
+ @Override
+ protected int getDimenByName(String resName, Resources res) {
+ Integer mock = mDevice.resourceOverrides.get(resName);
+ return mock != null ? mock : super.getDimenByName(resName, res);
+ }
+
+ @Override
+ public CachedDisplayInfo getDisplayInfo(Context context, Display display) {
+ int rotation = display.getRotation();
+ Point size = new Point(mDevice.width, mDevice.height);
+ RotationUtils.rotateSize(size, rotation);
+ Rect cutout = new Rect(mDevice.cutout);
+ RotationUtils.rotateRect(cutout, rotation);
+ return new CachedDisplayInfo(getDisplayId(display), size, rotation, cutout);
+ }
+
+ @Override
+ public WindowBounds getRealBounds(Context windowContext, Display display,
+ CachedDisplayInfo info) {
+ return estimateInternalDisplayBounds(windowContext)
+ .get(getDisplayId(display)).second[display.getRotation()];
+ }
+
+ @Override
+ public WindowInsets normalizeWindowInsets(Context context, WindowInsets oldInsets,
+ Rect outInsets) {
+ outInsets.set(getRealBounds(context, context.getDisplay(),
+ getDisplayInfo(context, context.getDisplay())).insets);
+ return oldInsets;
+ }
+}
diff --git a/tests/src/com/android/launcher3/deviceemulator/models/DeviceEmulationData.java b/tests/src/com/android/launcher3/deviceemulator/models/DeviceEmulationData.java
new file mode 100644
index 0000000..8d275cc
--- /dev/null
+++ b/tests/src/com/android/launcher3/deviceemulator/models/DeviceEmulationData.java
@@ -0,0 +1,154 @@
+/*
+ * 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.deviceemulator.models;
+
+import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
+
+import static com.android.launcher3.ResourceUtils.NAVBAR_HEIGHT;
+import static com.android.launcher3.ResourceUtils.NAVBAR_HEIGHT_LANDSCAPE;
+import static com.android.launcher3.ResourceUtils.NAVBAR_LANDSCAPE_LEFT_RIGHT_SIZE;
+import static com.android.launcher3.ResourceUtils.getDimenByName;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Rect;
+import android.os.Build;
+import android.util.ArrayMap;
+
+import com.android.launcher3.InvariantDeviceProfile;
+import com.android.launcher3.util.DisplayController;
+import com.android.launcher3.util.IOUtils;
+import com.android.launcher3.util.IntArray;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Map;
+
+public class DeviceEmulationData {
+
+ public final int width;
+ public final int height;
+ public final int density;
+ public final String name;
+ public final String[] grids;
+ public final Rect cutout;
+ public final Map<String, Integer> resourceOverrides;
+
+ private static final String[] EMULATED_SYSTEM_RESOURCES = new String[]{
+ NAVBAR_HEIGHT,
+ NAVBAR_HEIGHT_LANDSCAPE,
+ NAVBAR_LANDSCAPE_LEFT_RIGHT_SIZE,
+ "status_bar_height",
+ };
+
+ public DeviceEmulationData(int width, int height, int density, Rect cutout, String name,
+ String[] grid,
+ Map<String, Integer> resourceOverrides) {
+ this.width = width;
+ this.height = height;
+ this.density = density;
+ this.name = name;
+ this.grids = grid;
+ this.cutout = cutout;
+ this.resourceOverrides = resourceOverrides;
+ }
+
+ public static DeviceEmulationData deviceFromJSON(JSONObject json) throws JSONException {
+ int width = json.getInt("width");
+ int height = json.getInt("height");
+ int density = json.getInt("density");
+ String name = json.getString("name");
+
+ JSONArray gridArray = json.getJSONArray("grids");
+ String[] grids = new String[gridArray.length()];
+ for (int i = 0, count = grids.length; i < count; i++) {
+ grids[i] = gridArray.getString(i);
+ }
+
+ IntArray deviceCutout = IntArray.fromConcatString(json.getString("cutout"));
+ Rect cutout = new Rect(deviceCutout.get(0), deviceCutout.get(1), deviceCutout.get(2),
+ deviceCutout.get(3));
+
+
+ JSONObject resourceOverridesJson = json.getJSONObject("resourceOverrides");
+ Map<String, Integer> resourceOverrides = new ArrayMap<>();
+ for (String key : resourceOverridesJson.keySet()) {
+ resourceOverrides.put(key, resourceOverridesJson.getInt(key));
+ }
+ return new DeviceEmulationData(width, height, density, cutout, name, grids,
+ resourceOverrides);
+ }
+
+ @Override
+ public String toString() {
+ JSONObject json = new JSONObject();
+ try {
+ json.put("width", width);
+ json.put("height", height);
+ json.put("density", density);
+ json.put("name", name);
+ json.put("cutout", IntArray.wrap(
+ cutout.left, cutout.top, cutout.right, cutout.bottom).toConcatString());
+
+ JSONArray gridArray = new JSONArray();
+ Arrays.stream(grids).forEach(gridArray::put);
+ json.put("grids", gridArray);
+
+
+ JSONObject resourceOverrides = new JSONObject();
+ for (Map.Entry<String, Integer> e : this.resourceOverrides.entrySet()) {
+ resourceOverrides.put(e.getKey(), e.getValue());
+ }
+ json.put("resourceOverrides", resourceOverrides);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return json.toString();
+ }
+
+ public static DeviceEmulationData getCurrentDeviceData(Context context) {
+ DisplayController.Info info = DisplayController.INSTANCE.get(context).getInfo();
+ String[] grids = InvariantDeviceProfile.INSTANCE.get(context)
+ .parseAllGridOptions(context).stream()
+ .map(go -> go.name).toArray(String[]::new);
+ String code = Build.MODEL.replaceAll("\\s", "").toLowerCase();
+
+ Map<String, Integer> resourceOverrides = new ArrayMap<>();
+ for (String s : EMULATED_SYSTEM_RESOURCES) {
+ resourceOverrides.put(s, getDimenByName(s, context.getResources(), 0));
+ }
+ return new DeviceEmulationData(info.currentSize.x, info.currentSize.y,
+ info.getDensityDpi(), info.cutout, code, grids, resourceOverrides);
+ }
+
+ public static DeviceEmulationData getDevice(String deviceCode) throws Exception {
+ return DeviceEmulationData.deviceFromJSON(readJSON().getJSONObject(deviceCode));
+ }
+
+ private static JSONObject readJSON() throws Exception {
+ Context context = getInstrumentation().getContext();
+ Resources myRes = context.getResources();
+ int resId = myRes.getIdentifier("devices", "raw", context.getPackageName());
+ try (InputStream is = myRes.openRawResource(resId)) {
+ return new JSONObject(new String(IOUtils.toByteArray(is)));
+ }
+ }
+
+}
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index 9b37741..7080c85 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -525,7 +525,7 @@
}
protected int getAllAppsScroll(Launcher launcher) {
- return launcher.getAppsView().getActiveAppsRecyclerView().getCurrentScrollY();
+ return launcher.getAppsView().getActiveRecyclerView().getCurrentScrollY();
}
private void checkLauncherIntegrity(
diff --git a/tests/src/com/android/launcher3/ui/WorkProfileTest.java b/tests/src/com/android/launcher3/ui/WorkProfileTest.java
index 13b93d1..f31e4f3 100644
--- a/tests/src/com/android/launcher3/ui/WorkProfileTest.java
+++ b/tests/src/com/android/launcher3/ui/WorkProfileTest.java
@@ -134,8 +134,8 @@
executeOnLauncher(l -> {
ActivityAllAppsContainerView<?> allApps = l.getAppsView();
assertEquals("Work tab is not focused", allApps.getCurrentPage(), WORK_PAGE);
- View workPausedCard = allApps.getActiveAppsRecyclerView()
- .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 -> {
@@ -155,7 +155,7 @@
});
waitForLauncherCondition("Work profile education not shown",
- l -> l.getAppsView().getActiveAppsRecyclerView()
+ l -> l.getAppsView().getActiveRecyclerView()
.findViewHolderForAdapterPosition(0).itemView instanceof WorkEduCard,
LauncherInstrumentation.WAIT_TIME_MS);
}
diff --git a/tests/src/com/android/launcher3/util/rule/FailureWatcher.java b/tests/src/com/android/launcher3/util/rule/FailureWatcher.java
index 657f213..4c41d7e 100644
--- a/tests/src/com/android/launcher3/util/rule/FailureWatcher.java
+++ b/tests/src/com/android/launcher3/util/rule/FailureWatcher.java
@@ -132,7 +132,9 @@
dumpCommand("logcat -d -s TestRunner", diagFile(description, "FilteredLogcat", "txt"));
// Dump bugreport
- if (launcher.getSystemAnomalyMessage(false, false) != null) {
+ final String systemAnomalyMessage = launcher.getSystemAnomalyMessage(false, false);
+ if (systemAnomalyMessage != null) {
+ Log.d(TAG, "Saving bugreport, system anomaly message: " + systemAnomalyMessage, e);
dumpCommand("bugreportz -s", diagFile(description, "Bugreport", "zip"));
}
}
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index fee4490..ae0f6a6 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -389,8 +389,7 @@
// Since the destination can be on another page, we need to drag to the edge first
// until we reach the target page
while (targetDest.x > displayX || targetDest.x < 0) {
- // TODO: b/219919285
- int edgeX = targetDest.x > 0 ? displayX - 1 : 1;
+ int edgeX = targetDest.x > 0 ? displayX : 0;
Point screenEdge = new Point(edgeX, targetDest.y);
Point finalDragStart = dragStart;
executeAndWaitForPageScroll(launcher,