Merge "Add unit tests for TaskbarKeyguardController" into tm-qpr-dev
diff --git a/quickstep/src/com/android/launcher3/popup/QuickstepSystemShortcut.java b/quickstep/src/com/android/launcher3/popup/QuickstepSystemShortcut.java
index 9554bd3..45d1b11 100644
--- a/quickstep/src/com/android/launcher3/popup/QuickstepSystemShortcut.java
+++ b/quickstep/src/com/android/launcher3/popup/QuickstepSystemShortcut.java
@@ -101,7 +101,7 @@
RecentsView recentsView = mTarget.getOverviewPanel();
// Check if there is already an instance of this app running, if so, initiate the split
// using that.
- recentsView.findLastActiveTaskAndDoSplitOperation(
+ recentsView.findLastActiveTaskAndRunCallback(
intent.getComponent(),
(Consumer<Task>) foundTask -> {
SplitSelectSource source = new SplitSelectSource(mOriginalView,
diff --git a/quickstep/src/com/android/launcher3/taskbar/FallbackTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/FallbackTaskbarUIController.java
index df867cb..474dc3d 100644
--- a/quickstep/src/com/android/launcher3/taskbar/FallbackTaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/FallbackTaskbarUIController.java
@@ -73,12 +73,12 @@
boolean useStashedLauncherState = toState.hasOverviewActions();
boolean stashedLauncherState =
useStashedLauncherState && !FeatureFlags.ENABLE_TASKBAR_IN_OVERVIEW.get();
- TaskbarStashController controller = mControllers.taskbarStashController;
+ TaskbarStashController stashController = mControllers.taskbarStashController;
// Set both FLAG_IN_STASHED_LAUNCHER_STATE and FLAG_IN_APP to ensure the state is respected.
// For all other states, just use the current stashed-in-app setting (e.g. if long clicked).
- controller.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE, stashedLauncherState);
- controller.updateStateForFlag(FLAG_IN_APP, !useStashedLauncherState);
- return controller.applyStateWithoutStart(duration);
+ stashController.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE, stashedLauncherState);
+ stashController.updateStateForFlag(FLAG_IN_APP, !useStashedLauncherState);
+ return stashController.createApplyStateAnimator(duration);
}
private void animateToRecentsState(RecentsState toState) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
index a18aabe..237661e 100644
--- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
@@ -26,7 +26,6 @@
import android.annotation.ColorInt;
import android.os.RemoteException;
import android.util.Log;
-import android.util.SparseArray;
import android.view.TaskTransitionSpec;
import android.view.WindowManagerGlobal;
@@ -45,13 +44,13 @@
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.DisplayController;
+import com.android.launcher3.util.MultiPropertyFactory;
import com.android.launcher3.util.OnboardingPrefs;
import com.android.quickstep.RecentsAnimationCallbacks;
import com.android.quickstep.views.RecentsView;
import java.io.PrintWriter;
import java.util.Set;
-import java.util.stream.Stream;
/**
* A data source which integrates with a Launcher instance
@@ -65,7 +64,12 @@
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 static final int DISPLAY_PROGRESS_COUNT = 4;
+
+ private final AnimatedFloat mTaskbarInAppDisplayProgress = new AnimatedFloat();
+ private final MultiPropertyFactory<AnimatedFloat> mTaskbarInAppDisplayProgressMultiProp =
+ new MultiPropertyFactory<>(mTaskbarInAppDisplayProgress,
+ AnimatedFloat.VALUE, DISPLAY_PROGRESS_COUNT, Float::max);
private final QuickstepLauncher mLauncher;
@@ -305,11 +309,11 @@
* 1 => use in-app layout
*/
public void onTaskbarInAppDisplayProgressUpdate(float progress, int progressIndex) {
+ mTaskbarInAppDisplayProgressMultiProp.get(progressIndex).setValue(progress);
if (mControllers == null) {
// This method can be called before init() is called.
return;
}
- mTaskbarInAppDisplayProgress.put(progressIndex, progress);
if (mControllers.uiController.isIconAlignedWithHotseat()
&& !mTaskbarLauncherStateController.isAnimatingToLauncher()) {
// Only animate the nav buttons while home and not animating home, otherwise let
@@ -317,30 +321,13 @@
mControllers.navbarButtonsViewController
.getTaskbarNavButtonTranslationYForInAppDisplay()
.updateValue(mLauncher.getDeviceProfile().getTaskbarOffsetY()
- * getInAppDisplayProgress());
+ * mTaskbarInAppDisplayProgress.value);
}
}
/** 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();
+ return mTaskbarInAppDisplayProgress.value > 0;
}
@Override
@@ -358,7 +345,8 @@
@Override
public boolean isHotseatIconOnTopWhenAligned() {
return mTaskbarLauncherStateController.isInHotseatOnTopStates()
- && getInAppDisplayProgress(MINUS_ONE_PAGE_PROGRESS_INDEX) == 0;
+ && mTaskbarInAppDisplayProgressMultiProp.get(MINUS_ONE_PAGE_PROGRESS_INDEX)
+ .getValue() == 0;
}
@Override
@@ -369,28 +357,15 @@
"%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)));
- }
+ mTaskbarInAppDisplayProgressMultiProp.dump(
+ prefix + "\t",
+ pw,
+ "mTaskbarInAppDisplayProgressMultiProp",
+ "MINUS_ONE_PAGE_PROGRESS_INDEX",
+ "ALL_APPS_PAGE_PROGRESS_INDEX",
+ "WIDGETS_PAGE_PROGRESS_INDEX",
+ "SYSUI_SURFACE_PROGRESS_INDEX");
mTaskbarLauncherStateController.dumpLogs(prefix + "\t", pw);
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 4e795d9..5a81b2f 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -16,6 +16,7 @@
package com.android.launcher3.taskbar;
import static android.content.pm.PackageManager.FEATURE_PC;
+import static android.os.Trace.TRACE_TAG_APP;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
@@ -46,6 +47,7 @@
import android.graphics.Rect;
import android.os.Process;
import android.os.SystemProperties;
+import android.os.Trace;
import android.provider.Settings;
import android.util.Log;
import android.view.Display;
@@ -94,6 +96,7 @@
import com.android.launcher3.util.ViewCache;
import com.android.launcher3.views.ActivityContext;
import com.android.quickstep.views.RecentsView;
+import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.rotation.RotationButtonController;
import com.android.systemui.shared.system.ActivityManagerWrapper;
@@ -101,6 +104,7 @@
import com.android.systemui.unfold.util.ScopedUnfoldTransitionProgressProvider;
import java.io.PrintWriter;
+import java.util.function.Consumer;
/**
* The {@link ActivityContext} with which we inflate Taskbar-related Views. This allows UI elements
@@ -266,6 +270,13 @@
dispatchDeviceProfileChanged();
}
+ @Override
+ public void dispatchDeviceProfileChanged() {
+ super.dispatchDeviceProfileChanged();
+ Trace.instantForTrack(TRACE_TAG_APP, "TaskbarActivityContext#DeviceProfileChanged",
+ getDeviceProfile().toSmallString());
+ }
+
/**
* Copy the original DeviceProfile, match the number of hotseat icons and qsb width and update
* the icon size
@@ -778,12 +789,12 @@
});
});
} else if (tag instanceof WorkspaceItemInfo) {
+ // Tapping a launchable icon on Taskbar
WorkspaceItemInfo info = (WorkspaceItemInfo) tag;
if (!info.isDisabled() || !ItemClickHandler.handleDisabledItemClicked(info, this)) {
TaskbarUIController taskbarUIController = mControllers.uiController;
RecentsView recents = taskbarUIController.getRecentsView();
- if (recents != null
- && taskbarUIController.getRecentsView().isSplitSelectionActive()) {
+ if (recents != null && recents.isSplitSelectionActive()) {
// If we are selecting a second app for split, launch the split tasks
taskbarUIController.triggerSecondAppForSplit(info, info.intent, view);
} else {
@@ -810,7 +821,7 @@
getSystemService(LauncherApps.class)
.startShortcut(packageName, id, null, null, info.user);
} else {
- startItemInfoActivity(info);
+ launchFromTaskbarPreservingSplitIfVisible(recents, info);
}
mControllers.uiController.onTaskbarIconLaunched(info);
@@ -825,6 +836,7 @@
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
}
} else if (tag instanceof AppInfo) {
+ // Tapping an item in AllApps
AppInfo info = (AppInfo) tag;
TaskbarUIController taskbarUIController = mControllers.uiController;
RecentsView recents = taskbarUIController.getRecentsView();
@@ -833,9 +845,8 @@
// If we are selecting a second app for split, launch the split tasks
taskbarUIController.triggerSecondAppForSplit(info, info.intent, view);
} else {
- // Else launch the selected task
- startItemInfoActivity((AppInfo) tag);
- mControllers.uiController.onTaskbarIconLaunched((AppInfo) tag);
+ launchFromTaskbarPreservingSplitIfVisible(recents, info);
+ mControllers.uiController.onTaskbarIconLaunched(info);
}
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
} else if (tag instanceof ItemClickProxy) {
@@ -847,6 +858,31 @@
AbstractFloatingView.closeAllOpenViews(this);
}
+ /**
+ * Run when the user taps a Taskbar icon while in Overview. If the tapped app is currently
+ * visible to the user in Overview, or is part of a visible split pair, we expand the TaskView
+ * as if the user tapped on it (preserving the split pair). Otherwise, launch it normally
+ * (potentially breaking a split pair).
+ */
+ private void launchFromTaskbarPreservingSplitIfVisible(RecentsView recents, ItemInfo info) {
+ recents.findLastActiveTaskAndRunCallback(
+ info.getTargetComponent(),
+ (Consumer<Task>) foundTask -> {
+ if (foundTask != null) {
+ TaskView foundTaskView =
+ recents.getTaskViewByTaskId(foundTask.key.id);
+ if (foundTaskView != null
+ && foundTaskView.isVisibleToUser()) {
+ TestLogging.recordEvent(
+ TestProtocol.SEQUENCE_MAIN, "start: taskbarAppIcon");
+ foundTaskView.launchTasks();
+ return;
+ }
+ }
+ startItemInfoActivity(info);
+ });
+ }
+
private void startItemInfoActivity(ItemInfo info) {
Intent intent = new Intent(info.getIntent())
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index 4ad3858..d9773d4 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -183,7 +183,7 @@
stashController.updateStateForFlag(FLAG_IN_APP, false);
updateStateForFlag(FLAG_RECENTS_ANIMATION_RUNNING, true);
- animatorSet.play(stashController.applyStateWithoutStart(duration));
+ animatorSet.play(stashController.createApplyStateAnimator(duration));
animatorSet.play(applyState(duration, false));
if (mTaskBarRecentsAnimationListener != null) {
@@ -258,8 +258,9 @@
}
private Animator onStateChangeApplied(int changedFlags, long duration, boolean start) {
- boolean goingToLauncher = isInLauncher();
+ final boolean goingToLauncher = isInLauncher();
final float toAlignment = isIconAlignedWithHotseat() ? 1 : 0;
+ boolean handleOpenFloatingViews = false;
if (DEBUG) {
Log.d(TAG, "onStateChangeApplied - mState: " + getStateString(mState)
+ ", changedFlags: " + getStateString(changedFlags)
@@ -280,6 +281,10 @@
updateStateForFlag(FLAG_RESUMED, false);
applyState(0 /* duration */);
}
+ if (mLauncherState == LauncherState.NORMAL) {
+ // We're changing state to home, should close open popups e.g. Taskbar AllApps
+ handleOpenFloatingViews = true;
+ }
}
if (hasAnyFlag(changedFlags, FLAGS_LAUNCHER)) {
@@ -303,10 +308,11 @@
}
});
- if (goingToLauncher) {
- // Handle closing open popups when going home/overview
- AbstractFloatingView.closeAllOpenViews(mControllers.taskbarActivityContext);
- }
+ // Handle closing open popups when going home/overview
+ handleOpenFloatingViews = true;
+ }
+ if (handleOpenFloatingViews && goingToLauncher) {
+ AbstractFloatingView.closeAllOpenViews(mControllers.taskbarActivityContext);
}
float backgroundAlpha =
@@ -397,7 +403,7 @@
boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher);
TaskbarStashController stashController = mControllers.taskbarStashController;
stashController.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE, isInStashedState);
- Animator stashAnimator = stashController.applyStateWithoutStart(duration);
+ Animator stashAnimator = stashController.createApplyStateAnimator(duration);
if (stashAnimator != null) {
stashAnimator.addListener(new AnimatorListenerAdapter() {
@Override
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
index 6031b49..61d169f 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
@@ -35,6 +35,7 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
+import android.animation.ValueAnimator;
import android.annotation.Nullable;
import android.content.SharedPreferences;
import android.content.res.Resources;
@@ -69,8 +70,6 @@
*/
public class TaskbarStashController implements TaskbarControllers.LoggableTaskbarController {
- private static final String TAG = "TaskbarStashController";
-
public static final int FLAG_IN_APP = 1 << 0;
public static final int FLAG_STASHED_IN_APP_MANUAL = 1 << 1; // long press, persisted
public static final int FLAG_STASHED_IN_SYSUI_STATE = 1 << 2; // app pinning, keyguard, etc.
@@ -374,8 +373,8 @@
/**
* Returns the height that taskbar will inset when inside apps.
- * @see WindowInsets.Type#navigationBars()
- * @see WindowInsets.Type#systemBars()
+ * @see android.view.WindowInsets.Type#navigationBars()
+ * @see android.view.WindowInsets.Type#systemBars()
*/
public int getContentHeightToReportToApps() {
if ((isPhoneMode() && !mActivity.isThreeButtonNav())
@@ -408,7 +407,7 @@
/**
* Returns the height that taskbar will inset when inside apps.
- * @see WindowInsets.Type#tappableElement()
+ * @see android.view.WindowInsets.Type#tappableElement()
*/
public int getTappableHeightToReportToApps() {
int contentHeight = getContentHeightToReportToApps();
@@ -494,7 +493,6 @@
createAnimToIsStashed(
/* isStashed= */ false,
placeholderDuration,
- /* startDelay= */ 0,
/* animateBg= */ false,
/* changedFlags=*/ 0);
animation.play(mAnimator);
@@ -504,11 +502,10 @@
* Create a stash animation and save to {@link #mAnimator}.
* @param isStashed whether it's a stash animation or an unstash animation
* @param duration duration of the animation
- * @param startDelay how many milliseconds to delay the animation after starting it.
* @param animateBg whether the taskbar's background should be animated
*/
- private void createAnimToIsStashed(boolean isStashed, long duration, long startDelay,
- boolean animateBg, int changedFlags) {
+ private void createAnimToIsStashed(boolean isStashed, long duration, boolean animateBg,
+ int changedFlags) {
if (mAnimator != null) {
mAnimator.cancel();
}
@@ -528,13 +525,7 @@
.setDuration(duration));
mAnimator.play(mTaskbarImeBgAlpha.animateToValue(
hasAnyFlag(FLAG_STASHED_IN_APP_IME) ? 0 : 1).setDuration(duration));
- mAnimator.setStartDelay(startDelay);
- mAnimator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- mAnimator = null;
- }
- });
+ mAnimator.addListener(AnimatorListeners.forEndCallback(() -> mAnimator = null));
return;
}
@@ -615,7 +606,6 @@
mAnimator.playTogether(fullLengthAnimatorSet, firstHalfAnimatorSet,
secondHalfAnimatorSet);
- mAnimator.setStartDelay(startDelay);
mAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
@@ -701,19 +691,17 @@
}
public void applyState(long duration) {
- mStatePropertyHolder.setState(mState, duration, true);
+ createApplyStateAnimator(duration).start();
}
public void applyState(long duration, long startDelay) {
- mStatePropertyHolder.setState(mState, duration, startDelay, true);
+ Animator animator = createApplyStateAnimator(duration);
+ animator.setStartDelay(startDelay);
+ animator.start();
}
- public Animator applyStateWithoutStart() {
- return applyStateWithoutStart(TASKBAR_STASH_DURATION);
- }
-
- public Animator applyStateWithoutStart(long duration) {
- return mStatePropertyHolder.setState(mState, duration, false);
+ public Animator createApplyStateAnimator(long duration) {
+ return mStatePropertyHolder.createSetStateAnimator(mState, duration);
}
/**
@@ -948,22 +936,14 @@
}
/**
- * @see #setState(int, long, long, boolean) with a default startDelay = 0.
- */
- public Animator setState(int flags, long duration, boolean start) {
- return setState(flags, duration, 0 /* startDelay */, start);
- }
-
- /**
- * Applies the latest state, potentially calling onStateChangeApplied() and creating a new
- * animation (stored in mAnimator) which is started if {@param start} is true.
+ * Creates an animator (stored in mAnimator) which applies the latest state, potentially
+ * creating a new animation (stored in mAnimator).
* @param flags The latest flags to apply (see the top of this file).
* @param duration The length of the animation.
- * @param startDelay How long to delay the animation after calling start().
- * @param start Whether to start mAnimator immediately.
- * @return mAnimator if mIsStashed changed, else null.
+ * @return mAnimator if mIsStashed changed or an empty animator.
*/
- public Animator setState(int flags, long duration, long startDelay, boolean start) {
+ @NonNull
+ public Animator createSetStateAnimator(int flags, long duration) {
int changedFlags = mPrevFlags ^ flags;
if (mPrevFlags != flags) {
onStateChangeApplied(changedFlags);
@@ -979,24 +959,19 @@
&& mAnimator != null && mAnimator.isStarted())) {
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.TASKBAR_IN_APP_STATE, String.format(
- "setState: mIsStashed=%b, isStashed=%b, duration=%d, start=:%b",
+ "setState: mIsStashed=%b, isStashed=%b, duration=%d",
mIsStashed,
isStashed,
- duration,
- start));
+ duration));
}
mIsStashed = isStashed;
mIsHotseatIconOnTopWhenAligned = isHotseatIconOnTopWhenAligned;
// This sets mAnimator.
- createAnimToIsStashed(
- mIsStashed, duration, startDelay, /* animateBg= */ true, changedFlags);
- if (start) {
- mAnimator.start();
- }
+ createAnimToIsStashed(mIsStashed, duration, /* animateBg= */ true, changedFlags);
return mAnimator;
}
- return null;
+ return ValueAnimator.ofFloat(0, 1).setDuration(duration);
}
}
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
index 7b03746..ebb37a8 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
@@ -170,7 +170,7 @@
*/
public void triggerSecondAppForSplit(ItemInfoWithIcon info, Intent intent, View startingView) {
RecentsView recents = getRecentsView();
- recents.findLastActiveTaskAndDoSplitOperation(
+ recents.findLastActiveTaskAndRunCallback(
info.getTargetComponent(),
(Consumer<Task>) foundTask -> {
if (foundTask != null) {
diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
index a7651b6..078865f 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
@@ -15,6 +15,8 @@
*/
package com.android.launcher3.uioverrides;
+import static android.os.Trace.TRACE_TAG_APP;
+import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_OPTIMIZE_MEASURE;
import static android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT;
@@ -62,6 +64,7 @@
import android.os.CancellationSignal;
import android.os.IBinder;
import android.os.SystemProperties;
+import android.os.Trace;
import android.view.Display;
import android.view.HapticFeedbackConstants;
import android.view.RemoteAnimationTarget;
@@ -541,6 +544,7 @@
if (FeatureFlags.CONTINUOUS_VIEW_TREE_CAPTURE.get()) {
mViewCapture = ViewCapture.getInstance().startCapture(getWindow());
}
+ getWindow().addPrivateFlags(PRIVATE_FLAG_OPTIMIZE_MEASURE);
}
@Override
@@ -1036,6 +1040,13 @@
return false;
}
+ @Override
+ public void dispatchDeviceProfileChanged() {
+ super.dispatchDeviceProfileChanged();
+ Trace.instantForTrack(TRACE_TAG_APP, "QuickstepLauncher#DeviceProfileChanged",
+ getDeviceProfile().toSmallString());
+ }
+
private static final class LauncherTaskViewController extends
TaskViewTouchController<Launcher> {
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 45f6742..14b01fe 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -324,6 +324,7 @@
// May be set to false when mIsTransientTaskbar is true.
private boolean mCanSlowSwipeGoHome = true;
private boolean mHasReachedOverviewThreshold = false;
+ private boolean mDividerHiddenBeforeAnimation = false;
@Nullable
private RemoteAnimationTargets.ReleaseCheck mSwipePipToHomeReleaseCheck = null;
@@ -1677,7 +1678,8 @@
mRecentsAnimationController.enableInputConsumer();
// Start hiding the divider
- if (!mIsTransientTaskbar || mTaskbarAlreadyOpen || mIsTaskbarAllAppsOpen) {
+ if (!mIsTransientTaskbar || mTaskbarAlreadyOpen || mIsTaskbarAllAppsOpen
+ || mDividerHiddenBeforeAnimation) {
setDividerShown(false /* shown */, true /* immediate */);
}
}
@@ -2327,6 +2329,12 @@
}
private void setDividerShown(boolean shown, boolean immediate) {
+ if (mRecentsAnimationTargets == null) {
+ if (!shown) {
+ mDividerHiddenBeforeAnimation = true;
+ }
+ return;
+ }
if (mDividerAnimator != null) {
mDividerAnimator.cancel();
}
diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java
index 6f86bf5..f26189c 100644
--- a/quickstep/src/com/android/quickstep/RecentsActivity.java
+++ b/quickstep/src/com/android/quickstep/RecentsActivity.java
@@ -15,6 +15,7 @@
*/
package com.android.quickstep;
+import static android.os.Trace.TRACE_TAG_APP;
import static android.view.RemoteAnimationTarget.MODE_CLOSING;
import static android.view.RemoteAnimationTarget.MODE_OPENING;
@@ -36,6 +37,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
+import android.os.Trace;
import android.view.Display;
import android.view.RemoteAnimationAdapter;
import android.view.RemoteAnimationTarget;
@@ -448,6 +450,13 @@
return new RecentsAtomicAnimationFactory<>(this);
}
+ @Override
+ public void dispatchDeviceProfileChanged() {
+ super.dispatchDeviceProfileChanged();
+ Trace.instantForTrack(TRACE_TAG_APP, "RecentsActivity#DeviceProfileChanged",
+ getDeviceProfile().toSmallString());
+ }
+
private AnimatorListenerAdapter resetStateListener() {
return new AnimatorListenerAdapter() {
@Override
diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java
index bb97334..00fb7ec 100644
--- a/quickstep/src/com/android/quickstep/SystemUiProxy.java
+++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java
@@ -29,7 +29,6 @@
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ShortcutInfo;
-import android.graphics.Insets;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
@@ -51,10 +50,10 @@
import androidx.annotation.WorkerThread;
import com.android.internal.logging.InstanceId;
+import com.android.internal.util.ScreenshotRequest;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.systemui.shared.recents.ISystemUiProxy;
-import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.system.smartspace.ILauncherUnlockAnimationController;
import com.android.systemui.shared.system.smartspace.ISysuiUnlockAnimationController;
import com.android.systemui.shared.system.smartspace.SmartspaceState;
@@ -384,14 +383,12 @@
}
@Override
- public void handleImageBundleAsScreenshot(Bundle screenImageBundle, Rect locationInScreen,
- Insets visibleInsets, Task.TaskKey task) {
+ public void takeScreenshot(ScreenshotRequest request) {
if (mSystemUiProxy != null) {
try {
- mSystemUiProxy.handleImageBundleAsScreenshot(screenImageBundle, locationInScreen,
- visibleInsets, task);
+ mSystemUiProxy.takeScreenshot(request);
} catch (RemoteException e) {
- Log.w(TAG, "Failed call handleImageBundleAsScreenshot");
+ Log.w(TAG, "Failed call takeScreenshot");
}
}
}
diff --git a/quickstep/src/com/android/quickstep/util/ImageActionUtils.java b/quickstep/src/com/android/quickstep/util/ImageActionUtils.java
index 9fe24de..3a1c99b 100644
--- a/quickstep/src/com/android/quickstep/util/ImageActionUtils.java
+++ b/quickstep/src/com/android/quickstep/util/ImageActionUtils.java
@@ -18,6 +18,8 @@
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION;
+import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_OVERVIEW;
+import static android.view.WindowManager.TAKE_SCREENSHOT_PROVIDED_IMAGE;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.THREAD_POOL_EXECUTOR;
@@ -47,7 +49,7 @@
import androidx.core.content.FileProvider;
import com.android.internal.app.ChooserActivity;
-import com.android.internal.util.ScreenshotHelper;
+import com.android.internal.util.ScreenshotRequest;
import com.android.launcher3.BuildConfig;
import com.android.quickstep.SystemUiProxy;
import com.android.systemui.shared.recents.model.Task;
@@ -74,11 +76,17 @@
* Saves screenshot to location determine by SystemUiProxy
*/
public static void saveScreenshot(SystemUiProxy systemUiProxy, Bitmap screenshot,
- Rect screenshotBounds,
- Insets visibleInsets, Task.TaskKey task) {
- systemUiProxy.handleImageBundleAsScreenshot(
- ScreenshotHelper.HardwareBitmapBundler.hardwareBitmapToBundle(screenshot),
- screenshotBounds, visibleInsets, task);
+ Rect screenshotBounds, Insets visibleInsets, Task.TaskKey task) {
+ ScreenshotRequest request =
+ new ScreenshotRequest.Builder(TAKE_SCREENSHOT_PROVIDED_IMAGE, SCREENSHOT_OVERVIEW)
+ .setTopComponent(task.sourceComponent)
+ .setTaskId(task.id)
+ .setUserId(task.userId)
+ .setBitmap(screenshot)
+ .setBoundsOnScreen(screenshotBounds)
+ .setInsets(visibleInsets)
+ .build();
+ systemUiProxy.takeScreenshot(request);
}
/**
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index c11f7ed..5fa2a5c 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -1275,14 +1275,14 @@
}
/**
- * Pulls the list of active Tasks from RecentModel, and finds the most recently active Task
+ * Pulls the list of active Tasks from RecentsModel, and finds the most recently active Task
* matching a given ComponentName. Then uses that Task (which could be null) with the given
* callback.
*
- * Used in various splitscreen operations when we need to check if there is a currently running
- * Task of a certain type and use the most recent one.
+ * Used in various task-switching or splitscreen operations when we need to check if there is a
+ * currently running Task of a certain type and use the most recent one.
*/
- public void findLastActiveTaskAndDoSplitOperation(ComponentName componentName,
+ public void findLastActiveTaskAndRunCallback(ComponentName componentName,
Consumer<Task> callback) {
mModel.getTasks(taskGroups -> {
Task lastActiveTask = null;
diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml
index 98e8607..d97ba0f 100644
--- a/res/values-pt/strings.xml
+++ b/res/values-pt/strings.xml
@@ -32,7 +32,7 @@
<string name="split_screen_position_left" msgid="7537793098851830883">"Dividir para a esquerda"</string>
<string name="split_screen_position_right" msgid="1569377524925193369">"Dividir para a direita"</string>
<string name="split_app_info_accessibility" msgid="5475288491241414932">"Informações do app %1$s"</string>
- <string name="long_press_widget_to_add" msgid="3587712543577675817">"Toque e mantenha pressionado para mover um widget."</string>
+ <string name="long_press_widget_to_add" msgid="3587712543577675817">"Toque e pressione para mover um widget."</string>
<string name="long_accessible_way_to_add" msgid="2733588281439571974">"Toque duas vezes e mantenha a tela pressionada para mover um widget ou usar ações personalizadas."</string>
<string name="widget_dims_format" msgid="2370757736025621599">"%1$d × %2$d"</string>
<string name="widget_accessible_dims_format" msgid="3640149169885301790">"%1$d de largura por %2$d de altura"</string>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 4d2e1b7..d041dfe 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -252,6 +252,7 @@
<!-- Folders -->
<dimen name="page_indicator_dot_size">8dp</dimen>
+ <dimen name="page_indicator_dot_size_v2">6dp</dimen>
<dimen name="page_indicator_size">10dp</dimen>
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index f124940..8391b91 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -260,6 +260,7 @@
// Whether Taskbar will inset the bottom of apps by taskbarSize.
public boolean isTaskbarPresentInApps;
public int taskbarSize;
+ public int transientTaskbarSize;
public int stashedTaskbarSize;
public int transientTaskbarMargin;
@@ -324,12 +325,12 @@
}
if (isTaskbarPresent) {
+ transientTaskbarSize = res.getDimensionPixelSize(R.dimen.transient_taskbar_size);
+ transientTaskbarMargin = res.getDimensionPixelSize(R.dimen.transient_taskbar_margin);
if (DisplayController.isTransientTaskbar(context)) {
- taskbarSize = res.getDimensionPixelSize(R.dimen.transient_taskbar_size);
+ taskbarSize = transientTaskbarSize;
stashedTaskbarSize =
res.getDimensionPixelSize(R.dimen.transient_taskbar_stashed_size);
- transientTaskbarMargin =
- res.getDimensionPixelSize(R.dimen.transient_taskbar_margin);
} else {
taskbarSize = res.getDimensionPixelSize(R.dimen.taskbar_size);
stashedTaskbarSize = res.getDimensionPixelSize(R.dimen.taskbar_stashed_size);
@@ -1383,7 +1384,7 @@
public int getOverviewActionsClaimedSpaceBelow() {
if (isTaskbarPresent) {
if (FeatureFlags.ENABLE_TASKBAR_IN_OVERVIEW.get()) {
- return taskbarSize + transientTaskbarMargin * 2;
+ return transientTaskbarSize + transientTaskbarMargin * 2;
}
return isGestureMode
@@ -1679,6 +1680,16 @@
writer.println(prefix + pxToDpStr("getCellLayoutWidth()", getCellLayoutWidth()));
}
+ /** Returns a reduced representation of this DeviceProfile. */
+ public String toSmallString() {
+ return "isTablet:" + isTablet + ", "
+ + "isMultiDisplay:" + isMultiDisplay + ", "
+ + "widthPx:" + widthPx + ", "
+ + "heightPx:" + heightPx + ", "
+ + "insets:" + mInsets + ", "
+ + "rotationHint:" + rotationHint;
+ }
+
private static Context getContext(Context c, Info info, int orientation, WindowBounds bounds) {
Configuration config = new Configuration(c.getResources().getConfiguration());
config.orientation = orientation;
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index e9723a5..af6935f 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -87,6 +87,7 @@
import android.content.res.Configuration;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
+import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Build;
@@ -1276,11 +1277,19 @@
// Setup the drag controller (drop targets have to be added in reverse order in priority)
mDropTargetBar.setup(mDragController);
mAllAppsController.setupViews(mScrimView, mAppsView);
+
+ if (SHOW_DOT_PAGINATION.get()) {
+ mWorkspace.getPageIndicator().setShouldAutoHide(true);
+ mWorkspace.getPageIndicator().setPaintColor(
+ Themes.getAttrBoolean(this, R.attr.isWorkspaceDarkText)
+ ? Color.BLACK
+ : Color.WHITE);
+ }
}
@Override
public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
- if ((SHOW_DOT_PAGINATION.get()) && WorkspacePageIndicator.class.getName().equals(name)) {
+ if (SHOW_DOT_PAGINATION.get() && WorkspacePageIndicator.class.getName().equals(name)) {
return LayoutInflater.from(context).inflate(R.layout.page_indicator_dots,
(ViewGroup) parent, false);
}
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 6f6f86b..f7b0d96 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -25,6 +25,9 @@
import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_VERTICAL_PROGRESS;
+import static com.android.launcher3.util.SystemUiController.FLAG_DARK_NAV;
+import static com.android.launcher3.util.SystemUiController.FLAG_LIGHT_NAV;
+import static com.android.launcher3.util.SystemUiController.UI_STATE_ALL_APPS;
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
@@ -54,6 +57,7 @@
import com.android.launcher3.util.MultiPropertyFactory;
import com.android.launcher3.util.MultiPropertyFactory.MultiProperty;
import com.android.launcher3.util.MultiValueAlpha;
+import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ScrimView;
/**
@@ -73,6 +77,8 @@
public static final float SWIPE_ALL_APPS_TO_HOME_MIN_SCALE = 0.9f;
private static final int REVERT_SWIPE_ALL_APPS_TO_HOME_ANIMATION_DURATION_MS = 200;
+ private static final float NAV_BAR_COLOR_FORCE_UPDATE_THRESHOLD = 0.1f;
+
public static final FloatProperty<AllAppsTransitionController> ALL_APPS_PROGRESS =
new FloatProperty<AllAppsTransitionController>("allAppsProgress") {
@@ -151,6 +157,8 @@
private final Launcher mLauncher;
private final AnimatedFloat mAllAppScale = new AnimatedFloat(this::onScaleProgressChanged);
+ private final int mNavScrimFlag;
+
private boolean mIsVerticalLayout;
// Whether this class should take care of closing the keyboard.
@@ -177,10 +185,13 @@
public AllAppsTransitionController(Launcher l) {
mLauncher = l;
DeviceProfile dp = mLauncher.getDeviceProfile();
- setShiftRange(dp.allAppsShiftRange);
mProgress = 1f;
mIsVerticalLayout = dp.isVerticalBarLayout();
mIsTablet = dp.isTablet;
+ mNavScrimFlag = Themes.getAttrBoolean(l, R.attr.isMainColorDark)
+ ? FLAG_DARK_NAV : FLAG_LIGHT_NAV;
+
+ setShiftRange(dp.allAppsShiftRange);
mLauncher.addOnDeviceProfileChangeListener(this);
}
@@ -213,6 +224,11 @@
mProgress = progress;
getAppsViewProgressTranslationY().setValue(mProgress * mShiftRange);
mLauncher.onAllAppsTransition(1 - progress);
+
+ boolean hasScrim = progress < NAV_BAR_COLOR_FORCE_UPDATE_THRESHOLD
+ && mLauncher.getAppsView().getNavBarScrimHeight() > 0;
+ mLauncher.getSystemUiController().updateUiState(
+ UI_STATE_ALL_APPS, hasScrim ? mNavScrimFlag : 0);
}
public float getProgress() {
diff --git a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
index 1c67691..9bb8250 100644
--- a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
@@ -520,13 +520,20 @@
/**
* Returns a padding in case a scrim is shown on the bottom of the view and a padding is needed.
*/
- protected int getNavBarScrimHeight(WindowInsets insets) {
+ protected int computeNavBarScrimHeight(WindowInsets insets) {
return 0;
}
+ /**
+ * Returns the current height of nav bar scrim
+ */
+ public int getNavBarScrimHeight() {
+ return mNavBarScrimHeight;
+ }
+
@Override
public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) {
- mNavBarScrimHeight = getNavBarScrimHeight(insets);
+ mNavBarScrimHeight = computeNavBarScrimHeight(insets);
applyAdapterSideAndBottomPaddings(mActivityContext.getDeviceProfile());
return super.dispatchApplyWindowInsets(insets);
}
diff --git a/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java b/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java
index 5a5ba2b..aefedae 100644
--- a/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java
@@ -41,7 +41,7 @@
}
@Override
- protected int getNavBarScrimHeight(WindowInsets insets) {
+ protected int computeNavBarScrimHeight(WindowInsets insets) {
if (Utilities.ATLEAST_Q) {
return insets.getTappableElementInsets().bottom;
} else {
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index daf83d4..c328554 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -330,8 +330,8 @@
"HOME_GARDENING_WORKSPACE_BUTTONS", false,
"Change workspace edit buttons to reflect home gardening");
- public static final BooleanFlag ENABLE_DOWNLOAD_APP_UX_V2 = getDebugFlag(
- "ENABLE_DOWNLOAD_APP_UX_V2", false, "Updates the download app UX"
+ public static final BooleanFlag ENABLE_DOWNLOAD_APP_UX_V2 = new DeviceFlag(
+ "ENABLE_DOWNLOAD_APP_UX_V2", true, "Updates the download app UX"
+ " to have better visuals");
public static final BooleanFlag ENABLE_TASKBAR_REVISED_THRESHOLDS = getDebugFlag(
@@ -385,6 +385,11 @@
"ENABLE_MULTI_INSTANCE", false,
"Enables creation and filtering of multiple task instances in overview");
+ public static final BooleanFlag ENABLE_TASKBAR_PINNING = getDebugFlag(
+ "ENABLE_TASKBAR_PINNING", false,
+ "Enables taskbar pinning to allow user to switch between transient and persistent "
+ + "taskbar flavors");
+
public static void initialize(Context context) {
synchronized (sDebugFlags) {
for (DebugFlag flag : sDebugFlags) {
diff --git a/src/com/android/launcher3/folder/FolderPagedView.java b/src/com/android/launcher3/folder/FolderPagedView.java
index 1ada95c..10a2637 100644
--- a/src/com/android/launcher3/folder/FolderPagedView.java
+++ b/src/com/android/launcher3/folder/FolderPagedView.java
@@ -113,7 +113,6 @@
public void setFolder(Folder folder) {
mFolder = folder;
mPageIndicator = folder.findViewById(R.id.folder_page_indicator);
- mPageIndicator.setShouldAutoHide(false);
initParentViews(folder);
}
diff --git a/src/com/android/launcher3/graphics/PreloadIconDrawable.java b/src/com/android/launcher3/graphics/PreloadIconDrawable.java
index 9001a52..f2fde0e 100644
--- a/src/com/android/launcher3/graphics/PreloadIconDrawable.java
+++ b/src/com/android/launcher3/graphics/PreloadIconDrawable.java
@@ -82,7 +82,7 @@
// Duration = COMPLETE_ANIM_FRACTION * DURATION_SCALE
private static final float COMPLETE_ANIM_FRACTION = 1f;
- private static final float SMALL_SCALE = ENABLE_DOWNLOAD_APP_UX_V2.get() ? 0.867f : 0.7f;
+ private static final float SMALL_SCALE = 0.7f;
private static final float PROGRESS_STROKE_SCALE = ENABLE_DOWNLOAD_APP_UX_V2.get()
? 0.0655f
: 0.075f;
diff --git a/src/com/android/launcher3/pageindicators/PageIndicator.java b/src/com/android/launcher3/pageindicators/PageIndicator.java
index ec69193..570d6ff 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicator.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicator.java
@@ -46,4 +46,11 @@
default void skipAnimationsToEnd() {
// No-op by default
}
+
+ /**
+ * Sets the paint color.
+ */
+ default void setPaintColor(int color) {
+ // No-op by default
+ }
}
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
index c324ce3..b2c64b3 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
@@ -35,6 +35,7 @@
import android.os.Looper;
import android.util.AttributeSet;
import android.util.FloatProperty;
+import android.util.IntProperty;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewOutlineProvider;
@@ -58,7 +59,8 @@
private static final float SHIFT_THRESHOLD = 0.1f;
private static final long ANIMATION_DURATION = 150;
private static final int PAGINATION_FADE_DELAY = ViewConfiguration.getScrollDefaultDelay();
- private static final int ALPHA_ANIMATE_DURATION = ViewConfiguration.getScrollBarFadeDuration();
+ private static final int PAGINATION_FADE_IN_DURATION = 83;
+ private static final int PAGINATION_FADE_OUT_DURATION = 167;
private static final int ENTER_ANIMATION_START_DELAY = 300;
private static final int ENTER_ANIMATION_STAGGERED_DELAY = 150;
@@ -66,8 +68,9 @@
private static final int PAGE_INDICATOR_ALPHA = 255;
private static final int DOT_ALPHA = 128;
- private static final int DOT_GAP_FACTOR = 3;
- private static final int VISIBLE_ALPHA = 1;
+ private static final float DOT_ALPHA_FRACTION = 0.5f;
+ private static final int DOT_GAP_FACTOR = SHOW_DOT_PAGINATION.get() ? 4 : 3;
+ private static final int VISIBLE_ALPHA = 255;
private static final int INVISIBLE_ALPHA = 0;
private Paint mPaginationPaint;
@@ -89,21 +92,21 @@
obj.invalidate();
obj.invalidateOutline();
}
- };
+ };
- private static final FloatProperty<PageIndicatorDots> PAGINATION_ALPHA =
- new FloatProperty<PageIndicatorDots>("pagination_alpha") {
- @Override
- public Float get(PageIndicatorDots obj) {
- return obj.getAlpha();
- }
+ private static final IntProperty<PageIndicatorDots> PAGINATION_ALPHA =
+ new IntProperty<PageIndicatorDots>("pagination_alpha") {
+ @Override
+ public Integer get(PageIndicatorDots obj) {
+ return obj.mPaginationPaint.getAlpha();
+ }
- @Override
- public void setValue(PageIndicatorDots obj, float alpha) {
- obj.setAlpha(alpha);
- obj.invalidate();
- }
- };
+ @Override
+ public void setValue(PageIndicatorDots obj, int alpha) {
+ obj.mPaginationPaint.setAlpha(alpha);
+ obj.invalidate();
+ }
+ };
private final Handler mDelayedPaginationFadeHandler = new Handler(Looper.getMainLooper());
private final float mDotRadius;
@@ -112,9 +115,8 @@
private int mNumPages;
private int mActivePage;
- private int mCurrentScroll;
private int mTotalScroll;
- private boolean mShouldAutoHide = true;
+ private boolean mShouldAutoHide;
private int mToAlpha;
/**
@@ -133,7 +135,8 @@
private float[] mEntryAnimationRadiusFactors;
- private Runnable mHidePaginationRunnable = () -> animatePaginationToAlpha(INVISIBLE_ALPHA);
+ private final Runnable mHidePaginationRunnable =
+ () -> animatePaginationToAlpha(INVISIBLE_ALPHA);
public PageIndicatorDots(Context context) {
this(context, null);
@@ -149,7 +152,10 @@
mPaginationPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaginationPaint.setStyle(Style.FILL);
mPaginationPaint.setColor(Themes.getAttrColor(context, R.attr.folderPaginationColor));
- mDotRadius = getResources().getDimension(R.dimen.page_indicator_dot_size) / 2;
+ mDotRadius = (SHOW_DOT_PAGINATION.get()
+ ? getResources().getDimension(R.dimen.page_indicator_dot_size_v2)
+ : getResources().getDimension(R.dimen.page_indicator_dot_size))
+ / 2;
mCircleGap = DOT_GAP_FACTOR * mDotRadius;
setOutlineProvider(new MyOutlineProver());
mIsRtl = Utilities.isRtl(getResources());
@@ -157,15 +163,19 @@
@Override
public void setScroll(int currentScroll, int totalScroll) {
- if (SHOW_DOT_PAGINATION.get()) {
- animatePaginationToAlpha(VISIBLE_ALPHA);
+ if (SHOW_DOT_PAGINATION.get() && mActivePage != 0 && currentScroll == 0) {
+ CURRENT_POSITION.set(this, (float) mActivePage);
+ return;
}
if (mNumPages <= 1) {
- mCurrentScroll = 0;
return;
}
+ if (mShouldAutoHide) {
+ animatePaginationToAlpha(VISIBLE_ALPHA);
+ }
+
if (mIsRtl) {
currentScroll = totalScroll - currentScroll;
}
@@ -173,7 +183,7 @@
mTotalScroll = totalScroll;
int scrollPerPage = totalScroll / (mNumPages - 1);
- int pageToLeft = currentScroll / scrollPerPage;
+ int pageToLeft = scrollPerPage == 0 ? 0 : currentScroll / scrollPerPage;
int pageToLeftScroll = pageToLeft * scrollPerPage;
int pageToRightScroll = pageToLeftScroll + scrollPerPage;
@@ -181,31 +191,39 @@
if (currentScroll < pageToLeftScroll + scrollThreshold) {
// scroll is within the left page's threshold
animateToPosition(pageToLeft);
- if (SHOW_DOT_PAGINATION.get()) {
+ if (mShouldAutoHide) {
hideAfterDelay();
}
} else if (currentScroll > pageToRightScroll - scrollThreshold) {
// scroll is far enough from left page to go to the right page
animateToPosition(pageToLeft + 1);
- if (SHOW_DOT_PAGINATION.get()) {
+ if (mShouldAutoHide) {
hideAfterDelay();
}
} else {
// scroll is between left and right page
animateToPosition(pageToLeft + SHIFT_PER_ANIMATION);
+ if (mShouldAutoHide) {
+ mDelayedPaginationFadeHandler.removeCallbacksAndMessages(null);
+ }
}
}
@Override
public void setShouldAutoHide(boolean shouldAutoHide) {
- mShouldAutoHide = shouldAutoHide;
- if (shouldAutoHide && this.getAlpha() > INVISIBLE_ALPHA) {
+ mShouldAutoHide = shouldAutoHide && SHOW_DOT_PAGINATION.get();
+ if (shouldAutoHide && mPaginationPaint.getAlpha() > INVISIBLE_ALPHA) {
hideAfterDelay();
} else if (!shouldAutoHide) {
mDelayedPaginationFadeHandler.removeCallbacksAndMessages(null);
}
}
+ @Override
+ public void setPaintColor(int color) {
+ mPaginationPaint.setColor(color);
+ }
+
private void hideAfterDelay() {
mDelayedPaginationFadeHandler.removeCallbacksAndMessages(null);
mDelayedPaginationFadeHandler.postDelayed(mHidePaginationRunnable, PAGINATION_FADE_DELAY);
@@ -216,14 +234,17 @@
// Ignore the new animation if it is going to the same alpha as the current animation.
return;
}
- mToAlpha = alpha;
if (mAlphaAnimator != null) {
mAlphaAnimator.cancel();
}
- mAlphaAnimator = ObjectAnimator.ofFloat(this, PAGINATION_ALPHA,
+ mAlphaAnimator = ObjectAnimator.ofInt(this, PAGINATION_ALPHA,
alpha);
- mAlphaAnimator.setDuration(ALPHA_ANIMATE_DURATION);
+ // If we are animating to decrease the alpha, then it's a fade out animation
+ // whereas if we are animating to increase the alpha, it's a fade in animation.
+ mAlphaAnimator.setDuration(alpha < mToAlpha
+ ? PAGINATION_FADE_OUT_DURATION
+ : PAGINATION_FADE_IN_DURATION);
mAlphaAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
@@ -231,7 +252,7 @@
}
});
mAlphaAnimator.start();
-
+ mToAlpha = alpha;
}
/**
@@ -349,7 +370,12 @@
@Override
protected void onDraw(Canvas canvas) {
- if ((mShouldAutoHide && mTotalScroll == 0) || mNumPages < 2) {
+ if (mNumPages < 2) {
+ return;
+ }
+
+ if (mShouldAutoHide && mTotalScroll == 0) {
+ mPaginationPaint.setAlpha(INVISIBLE_ALPHA);
return;
}
@@ -373,15 +399,19 @@
x += circleGap;
}
} else {
+ int alpha = mPaginationPaint.getAlpha();
+
// Here we draw the dots
- mPaginationPaint.setAlpha(DOT_ALPHA);
+ mPaginationPaint.setAlpha(SHOW_DOT_PAGINATION.get()
+ ? ((int) (alpha * DOT_ALPHA_FRACTION))
+ : DOT_ALPHA);
for (int i = 0; i < mNumPages; i++) {
canvas.drawCircle(x, y, mDotRadius, mPaginationPaint);
x += circleGap;
}
// Here we draw the current page indicator
- mPaginationPaint.setAlpha(PAGE_INDICATOR_ALPHA);
+ mPaginationPaint.setAlpha(SHOW_DOT_PAGINATION.get() ? alpha : PAGE_INDICATOR_ALPHA);
canvas.drawRoundRect(getActiveRect(), mDotRadius, mDotRadius, mPaginationPaint);
}
}
@@ -450,6 +480,9 @@
@Override
public void onAnimationEnd(Animator animation) {
if (!mCancelled) {
+ if (mShouldAutoHide && SHOW_DOT_PAGINATION.get()) {
+ hideAfterDelay();
+ }
mAnimator = null;
animateToPosition(mFinalPosition);
}
diff --git a/src/com/android/launcher3/util/SystemUiController.java b/src/com/android/launcher3/util/SystemUiController.java
index 6945983..df54fd7 100644
--- a/src/com/android/launcher3/util/SystemUiController.java
+++ b/src/com/android/launcher3/util/SystemUiController.java
@@ -35,6 +35,7 @@
public static final int UI_STATE_SCRIM_VIEW = 1;
public static final int UI_STATE_WIDGET_BOTTOM_SHEET = 2;
public static final int UI_STATE_FULLSCREEN_TASK = 3;
+ public static final int UI_STATE_ALL_APPS = 4;
public static final int FLAG_LIGHT_NAV = 1 << 0;
public static final int FLAG_DARK_NAV = 1 << 1;
@@ -54,7 +55,7 @@
public @interface SystemUiControllerFlags {}
private final Window mWindow;
- private final int[] mStates = new int[4];
+ private final int[] mStates = new int[5];
public SystemUiController(Window window) {
mWindow = window;
diff --git a/tests/src/com/android/launcher3/celllayout/TestWorkspaceBuilder.java b/tests/src/com/android/launcher3/celllayout/TestWorkspaceBuilder.java
index 16448af..7e3588b 100644
--- a/tests/src/com/android/launcher3/celllayout/TestWorkspaceBuilder.java
+++ b/tests/src/com/android/launcher3/celllayout/TestWorkspaceBuilder.java
@@ -120,7 +120,7 @@
* be clean otherwise this doesn't overrides the existing icons.
*/
public FavoriteItemsTransaction fillHotseatIcons(FavoriteItemsTransaction transaction) {
- int hotseatCount = InvariantDeviceProfile.INSTANCE.get(mContext).numShownHotseatIcons;
+ int hotseatCount = InvariantDeviceProfile.INSTANCE.get(mContext).numDatabaseHotseatIcons;
for (int i = 0; i < hotseatCount; i++) {
transaction.addItem(getHotseatValues(i));
}
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index 70d122b..cf21dd7 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -299,7 +299,7 @@
/**
* Removes all icons from homescreen and hotseat.
*/
- public void clearHomescreen() throws Throwable {
+ public void clearHomescreen() {
LauncherSettings.Settings.call(mTargetContext.getContentResolver(),
LauncherSettings.Settings.METHOD_CREATE_EMPTY_DB);
LauncherSettings.Settings.call(mTargetContext.getContentResolver(),
diff --git a/tests/tapl/com/android/launcher3/tapl/AllAppsQsb.java b/tests/tapl/com/android/launcher3/tapl/AllAppsQsb.java
new file mode 100644
index 0000000..0931cd4
--- /dev/null
+++ b/tests/tapl/com/android/launcher3/tapl/AllAppsQsb.java
@@ -0,0 +1,37 @@
+/*
+ * 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.tapl;
+
+import androidx.test.uiautomator.UiObject2;
+
+/**
+ * Operations on AllApp screen qsb.
+ */
+class AllAppsQsb extends Qsb {
+
+ private final UiObject2 mAllAppsContainer;
+
+ AllAppsQsb(LauncherInstrumentation launcher, UiObject2 allAppsContainer) {
+ super(launcher);
+ mAllAppsContainer = allAppsContainer;
+ waitForQsbObject();
+ }
+
+ @Override
+ protected UiObject2 waitForQsbObject() {
+ return mLauncher.waitForObjectInContainer(mAllAppsContainer, "search_container_all_apps");
+ }
+}
diff --git a/tests/tapl/com/android/launcher3/tapl/HomeAllApps.java b/tests/tapl/com/android/launcher3/tapl/HomeAllApps.java
index 50b03aa..8ac1aef 100644
--- a/tests/tapl/com/android/launcher3/tapl/HomeAllApps.java
+++ b/tests/tapl/com/android/launcher3/tapl/HomeAllApps.java
@@ -115,4 +115,13 @@
}
}
}
+
+ /**
+ * Return the QSB UI object on the AllApps screen.
+ * @return the QSB UI object.
+ */
+ @NonNull
+ public Qsb getQsb() {
+ return new AllAppsQsb(mLauncher, verifyActiveContainer());
+ }
}
diff --git a/tests/tapl/com/android/launcher3/tapl/HomeQsb.java b/tests/tapl/com/android/launcher3/tapl/HomeQsb.java
index c365708..20d09a1 100644
--- a/tests/tapl/com/android/launcher3/tapl/HomeQsb.java
+++ b/tests/tapl/com/android/launcher3/tapl/HomeQsb.java
@@ -15,69 +15,23 @@
*/
package com.android.launcher3.tapl;
-import androidx.annotation.NonNull;
-import androidx.test.uiautomator.By;
-import androidx.test.uiautomator.BySelector;
import androidx.test.uiautomator.UiObject2;
-import androidx.test.uiautomator.Until;
/**
- * Operations on home screen qsb.
+ * Operations on Home screen qsb.
*/
-public class HomeQsb {
+class HomeQsb extends Qsb {
- private final LauncherInstrumentation mLauncher;
- private static final String ASSISTANT_APP_PACKAGE = "com.google.android.googlequicksearchbox";
- private static final String ASSISTANT_ICON_RES_ID = "mic_icon";
+ private final UiObject2 mHotSeat;
-
- HomeQsb(LauncherInstrumentation launcher) {
- mLauncher = launcher;
- mLauncher.waitForLauncherObject("search_container_hotseat");
+ HomeQsb(LauncherInstrumentation launcher, UiObject2 hotseat) {
+ super(launcher);
+ mHotSeat = hotseat;
+ waitForQsbObject();
}
- /**
- * Launch assistant app by tapping mic icon on qsb.
- */
- @NonNull
- public LaunchedAppState launchAssistant() {
- try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
- "want to click assistant mic icon button");
- LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
- UiObject2 assistantIcon = mLauncher.waitForLauncherObject(ASSISTANT_ICON_RES_ID);
-
- LauncherInstrumentation.log("HomeQsb.launchAssistant before click "
- + assistantIcon.getVisibleCenter() + " in "
- + mLauncher.getVisibleBounds(assistantIcon));
-
- mLauncher.clickLauncherObject(assistantIcon);
-
- try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("clicked")) {
- // assert Assistant App Launched
- BySelector selector = By.pkg(ASSISTANT_APP_PACKAGE);
- mLauncher.assertTrue(
- "assistant app didn't start: (" + selector + ")",
- mLauncher.getDevice().wait(Until.hasObject(selector),
- LauncherInstrumentation.WAIT_TIME_MS)
- );
- return new LaunchedAppState(mLauncher);
- }
- }
- }
-
- /**
- * Show search result page from tapping qsb.
- */
- public SearchResultFromQsb showSearchResult() {
- try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
- "want to open search result page");
- LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
- mLauncher.clickLauncherObject(
- mLauncher.waitForLauncherObject("search_container_hotseat"));
- try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer(
- "clicked qsb to open search result page")) {
- return new SearchResultFromQsb(mLauncher);
- }
- }
+ @Override
+ protected UiObject2 waitForQsbObject() {
+ return mLauncher.waitForObjectInContainer(mHotSeat, "search_container_hotseat");
}
}
diff --git a/tests/tapl/com/android/launcher3/tapl/Qsb.java b/tests/tapl/com/android/launcher3/tapl/Qsb.java
new file mode 100644
index 0000000..6bc4f21
--- /dev/null
+++ b/tests/tapl/com/android/launcher3/tapl/Qsb.java
@@ -0,0 +1,86 @@
+/*
+ * 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.tapl;
+
+import androidx.annotation.NonNull;
+import androidx.test.uiautomator.By;
+import androidx.test.uiautomator.BySelector;
+import androidx.test.uiautomator.UiObject2;
+import androidx.test.uiautomator.Until;
+
+/**
+ * Operations on qsb from either Home screen or AllApp screen.
+ */
+public abstract class Qsb {
+
+ private static final String ASSISTANT_APP_PACKAGE = "com.google.android.googlequicksearchbox";
+ private static final String ASSISTANT_ICON_RES_ID = "mic_icon";
+ protected final LauncherInstrumentation mLauncher;
+
+ protected Qsb(LauncherInstrumentation launcher) {
+ mLauncher = launcher;
+ }
+
+ // Waits for the quick search box.
+ protected abstract UiObject2 waitForQsbObject();
+ /**
+ * Launch assistant app by tapping mic icon on qsb.
+ */
+
+ @NonNull
+ public LaunchedAppState launchAssistant() {
+ try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
+ "want to click assistant mic icon button");
+ LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
+ UiObject2 assistantIcon = mLauncher.waitForLauncherObject(ASSISTANT_ICON_RES_ID);
+
+ LauncherInstrumentation.log("Qsb.launchAssistant before click "
+ + assistantIcon.getVisibleCenter() + " in "
+ + mLauncher.getVisibleBounds(assistantIcon));
+
+ mLauncher.clickLauncherObject(assistantIcon);
+
+ try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("clicked")) {
+ // assert Assistant App Launched
+ BySelector selector = By.pkg(ASSISTANT_APP_PACKAGE);
+ mLauncher.assertTrue(
+ "assistant app didn't start: (" + selector + ")",
+ mLauncher.getDevice().wait(Until.hasObject(selector),
+ LauncherInstrumentation.WAIT_TIME_MS)
+ );
+ return new LaunchedAppState(mLauncher);
+ }
+ }
+ }
+
+ /**
+ * Show search result page from tapping qsb.
+ */
+ public SearchResultFromQsb showSearchResult() {
+ try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
+ "want to open search result page");
+ LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
+ mLauncher.clickLauncherObject(waitForQsbObject());
+ // wait for the result rendering to complete
+ mLauncher.waitForIdle();
+ try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer(
+ "clicked qsb to open search result page")) {
+ return new SearchResultFromQsb(mLauncher);
+ }
+ }
+ }
+}
diff --git a/tests/tapl/com/android/launcher3/tapl/SearchResultFromQsb.java b/tests/tapl/com/android/launcher3/tapl/SearchResultFromQsb.java
index 80e4116..80176e9 100644
--- a/tests/tapl/com/android/launcher3/tapl/SearchResultFromQsb.java
+++ b/tests/tapl/com/android/launcher3/tapl/SearchResultFromQsb.java
@@ -23,7 +23,7 @@
import java.util.ArrayList;
/**
- * Operations on search result page opened from home screen qsb.
+ * Operations on search result page opened from qsb.
*/
public class SearchResultFromQsb {
// The input resource id in the search box.
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index 2c82c50..388955c 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -118,10 +118,11 @@
*
* The qsb must already be visible when calling this method.
*/
- public HomeQsb getQsb() {
+ @NonNull
+ public Qsb getQsb() {
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to get the home qsb")) {
- return new HomeQsb(mLauncher);
+ return new HomeQsb(mLauncher, mHotseat);
}
}