Merge "Fixing transaction applier holding on to the release check if no frame update was scheduled" into tm-dev
diff --git a/quickstep/AndroidManifest-launcher.xml b/quickstep/AndroidManifest-launcher.xml
index a24a588..7d7054f 100644
--- a/quickstep/AndroidManifest-launcher.xml
+++ b/quickstep/AndroidManifest-launcher.xml
@@ -57,6 +57,7 @@
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
+ <action android:name="android.intent.action.SHOW_WORK_APPS" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.MONKEY"/>
diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
index a3e8b5c..ca30e72 100644
--- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
@@ -19,6 +19,7 @@
import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTRA_NAVIGATION_BAR;
import android.animation.Animator;
+import android.animation.AnimatorSet;
import android.annotation.ColorInt;
import android.os.RemoteException;
import android.util.Log;
@@ -28,6 +29,7 @@
import android.view.WindowManagerGlobal;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.android.launcher3.BaseQuickstepLauncher;
@@ -140,6 +142,24 @@
}
/**
+ * Adds the Launcher resume animator to the given animator set.
+ *
+ * This should be used to run a Launcher resume animation whose progress matches a
+ * swipe progress.
+ *
+ * @param placeholderDuration a placeholder duration to be used to ensure all full-length
+ * sub-animations are properly coordinated. This duration should not
+ * actually be used since this animation tracks a swipe progress.
+ */
+ protected void addLauncherResumeAnimation(AnimatorSet animation, int placeholderDuration) {
+ animation.play(onLauncherResumedOrPaused(
+ /* isResumed= */ true,
+ /* fromInit= */ false,
+ /* startAnimation= */ false,
+ placeholderDuration));
+ }
+
+ /**
* Should be called from onResume() and onPause(), and animates the Taskbar accordingly.
*/
public void onLauncherResumedOrPaused(boolean isResumed) {
@@ -147,9 +167,19 @@
}
private void onLauncherResumedOrPaused(boolean isResumed, boolean fromInit) {
+ onLauncherResumedOrPaused(
+ isResumed,
+ fromInit,
+ /* startAnimation= */ true,
+ QuickstepTransitionManager.CONTENT_ALPHA_DURATION);
+ }
+
+ @Nullable
+ private Animator onLauncherResumedOrPaused(
+ boolean isResumed, boolean fromInit, boolean startAnimation, int duration) {
if (mKeyguardController.isScreenOff()) {
if (!isResumed) {
- return;
+ return null;
} else {
// Resuming implicitly means device unlocked
mKeyguardController.setScreenOn();
@@ -157,8 +187,7 @@
}
mTaskbarLauncherStateController.updateStateForFlag(FLAG_RESUMED, isResumed);
- mTaskbarLauncherStateController.applyState(
- fromInit ? 0 : QuickstepTransitionManager.CONTENT_ALPHA_DURATION);
+ return mTaskbarLauncherStateController.applyState(fromInit ? 0 : duration, startAnimation);
}
/**
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 2f32219..ed1001c 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -29,6 +29,7 @@
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
import android.animation.AnimatorSet;
+import android.animation.ValueAnimator;
import android.app.ActivityOptions;
import android.content.ActivityNotFoundException;
import android.content.Context;
@@ -60,6 +61,8 @@
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.R;
+import com.android.launcher3.anim.AnimatorPlaybackController;
+import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dot.DotInfo;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIcon;
@@ -735,6 +738,45 @@
}
/**
+ * Displays a single frame of the Launcher start from SUW animation.
+ *
+ * This animation is a combination of the Launcher resume animation, which animates the hotseat
+ * icons into position, the Taskbar unstash to hotseat animation, which animates the Taskbar
+ * stash bar into the hotseat icons, and an override to prevent showing the Taskbar all apps
+ * button.
+ *
+ * This should be used to run a Taskbar unstash to hotseat animation whose progress matches a
+ * swipe progress.
+ *
+ * @param duration a placeholder duration to be used to ensure all full-length
+ * sub-animations are properly coordinated. This duration should not actually
+ * be used since this animation tracks a swipe progress.
+ */
+ protected AnimatorPlaybackController createLauncherStartFromSuwAnim(int duration) {
+ AnimatorSet fullAnimation = new AnimatorSet();
+ fullAnimation.setDuration(duration);
+
+ TaskbarUIController uiController = mControllers.uiController;
+ if (uiController instanceof LauncherTaskbarUIController) {
+ ((LauncherTaskbarUIController) uiController).addLauncherResumeAnimation(
+ fullAnimation, duration);
+ }
+ mControllers.taskbarStashController.addUnstashToHotseatAnimation(fullAnimation, duration);
+
+ if (!FeatureFlags.ENABLE_ALL_APPS_BUTTON_IN_HOTSEAT.get()) {
+ ValueAnimator alphaOverride = ValueAnimator.ofFloat(0, 1);
+ alphaOverride.setDuration(duration);
+ alphaOverride.addUpdateListener(a -> {
+ // Override the alpha updates in the icon alignment animation.
+ mControllers.taskbarViewController.getAllAppsButtonView().setAlpha(0);
+ });
+ fullAnimation.play(alphaOverride);
+ }
+
+ return AnimatorPlaybackController.wrap(fullAnimation, duration);
+ }
+
+ /**
* Called when we determine the touchable region.
*
* @param exclude {@code true} then the magnification region computation will omit the window.
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
index 2e37170..ef7bab9 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
@@ -39,6 +39,7 @@
import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.LauncherAppState;
+import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.statemanager.StatefulActivity;
import com.android.launcher3.taskbar.unfold.NonDestroyableScopedUnfoldTransitionProgressProvider;
import com.android.launcher3.util.DisplayController;
@@ -183,6 +184,17 @@
}
/**
+ * Displays a frame of the first Launcher reveal animation.
+ *
+ * This should be used to run a first Launcher reveal animation whose progress matches a swipe
+ * progress.
+ */
+ public AnimatorPlaybackController createLauncherStartFromSuwAnim(int duration) {
+ return mTaskbarActivityContext == null
+ ? null : mTaskbarActivityContext.createLauncherStartFromSuwAnim(duration);
+ }
+
+ /**
* Called when the user is unlocked
*/
public void onUserUnlocked() {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
index 7d95743..fc9f9d0 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
@@ -35,6 +35,8 @@
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Utilities;
+import com.android.launcher3.anim.AnimatorListeners;
+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;
@@ -368,12 +370,33 @@
}
/**
+ * Adds the Taskbar unstash to Hotseat animator to the animator set.
+ *
+ * This should be used to run a Taskbar unstash to Hotseat animation whose progress matches a
+ * swipe progress.
+ *
+ * @param placeholderDuration a placeholder duration to be used to ensure all full-length
+ * sub-animations are properly coordinated. This duration should not
+ * actually be used since this animation tracks a swipe progress.
+ */
+ protected void addUnstashToHotseatAnimation(AnimatorSet animation, int placeholderDuration) {
+ createAnimToIsStashed(
+ /* isStashed= */ false,
+ placeholderDuration,
+ /* startDelay= */ 0,
+ /* animateBg= */ false);
+ animation.play(mAnimator);
+ }
+
+ /**
* 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) {
+ private void createAnimToIsStashed(
+ boolean isStashed, long duration, long startDelay, boolean animateBg) {
if (mAnimator != null) {
mAnimator.cancel();
}
@@ -408,10 +431,14 @@
secondHalfDurationScale = 0.5f;
final float stashTranslation = (mUnstashedHeight - mStashedHeight) / 2f;
- fullLengthAnimatorSet.playTogether(
- mTaskbarBackgroundOffset.animateToValue(1),
- mIconTranslationYForStash.animateToValue(stashTranslation)
- );
+ fullLengthAnimatorSet.play(mIconTranslationYForStash.animateToValue(stashTranslation));
+ if (animateBg) {
+ fullLengthAnimatorSet.play(mTaskbarBackgroundOffset.animateToValue(1));
+ } else {
+ fullLengthAnimatorSet.addListener(AnimatorListeners.forEndCallback(
+ () -> mTaskbarBackgroundOffset.updateValue(1)));
+ }
+
firstHalfAnimatorSet.playTogether(
mIconAlphaForStash.animateToValue(0),
mIconScaleForStash.animateToValue(STASHED_TASKBAR_SCALE)
@@ -424,10 +451,15 @@
secondHalfDurationScale = 0.75f;
fullLengthAnimatorSet.playTogether(
- mTaskbarBackgroundOffset.animateToValue(0),
mIconScaleForStash.animateToValue(1),
- mIconTranslationYForStash.animateToValue(0)
- );
+ mIconTranslationYForStash.animateToValue(0));
+ if (animateBg) {
+ fullLengthAnimatorSet.play(mTaskbarBackgroundOffset.animateToValue(0));
+ } else {
+ fullLengthAnimatorSet.addListener(AnimatorListeners.forEndCallback(
+ () -> mTaskbarBackgroundOffset.updateValue(0)));
+ }
+
firstHalfAnimatorSet.playTogether(
mTaskbarStashedHandleAlpha.animateToValue(0)
);
@@ -728,7 +760,7 @@
mIsStashed = isStashed;
// This sets mAnimator.
- createAnimToIsStashed(mIsStashed, duration, startDelay);
+ createAnimToIsStashed(mIsStashed, duration, startDelay, /* animateBg= */ true);
if (start) {
mAnimator.start();
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
index 5db495d..3dd7932 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
@@ -258,21 +258,21 @@
setter.addOnFrameListener(anim -> mActivity.setTaskbarWindowHeight(
anim.getAnimatedFraction() > 0 ? expandedHeight : collapsedHeight));
- int count = mTaskbarView.getChildCount();
- for (int i = 0; i < count; i++) {
+ for (int i = 0; i < mTaskbarView.getChildCount(); i++) {
View child = mTaskbarView.getChildAt(i);
- int positionInHotseat = -1;
- boolean isRtl = Utilities.isRtl(child.getResources());
+ int positionInHotseat;
if (FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()
- && ((isRtl && i == 0) || (!isRtl && i == count - 1))) {
+ && child == mTaskbarView.getAllAppsButtonView()) {
// Note that there is no All Apps button in the hotseat, this position is only used
// as its convenient for animation purposes.
- positionInHotseat = isRtl
+ positionInHotseat = Utilities.isRtl(child.getResources())
? -1
: mActivity.getDeviceProfile().numShownHotseatIcons;
- setter.setViewAlpha(child, 0, LINEAR);
+ if (!FeatureFlags.ENABLE_ALL_APPS_BUTTON_IN_HOTSEAT.get()) {
+ setter.setViewAlpha(child, 0, LINEAR);
+ }
} else if (child.getTag() instanceof ItemInfo) {
positionInHotseat = ((ItemInfo) child.getTag()).screenId;
} else {
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index dc2b61b..1b1cb85 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -151,6 +151,7 @@
// Null if the recents animation hasn't started yet or has been canceled or finished.
protected @Nullable RecentsAnimationController mRecentsAnimationController;
+ protected @Nullable RecentsAnimationController mDeferredCleanupRecentsAnimationController;
protected RecentsAnimationTargets mRecentsAnimationTargets;
protected T mActivity;
protected Q mRecentsView;
@@ -435,6 +436,9 @@
mRecentsView.switchToScreenshot(snapshots, () -> {
if (mRecentsAnimationController != null) {
mRecentsAnimationController.cleanupScreenshot();
+ } else if (mDeferredCleanupRecentsAnimationController != null) {
+ mDeferredCleanupRecentsAnimationController.cleanupScreenshot();
+ mDeferredCleanupRecentsAnimationController = null;
}
});
mRecentsView.onRecentsAnimationComplete();
@@ -839,6 +843,9 @@
public void onRecentsAnimationCanceled(HashMap<Integer, ThumbnailData> thumbnailDatas) {
ActiveGestureLog.INSTANCE.addLog("cancelRecentsAnimation");
mActivityInitListener.unregister();
+ // Cache the recents animation controller so we can defer its cleanup to after having
+ // properly cleaned up the screenshot without accidentally using it.
+ mDeferredCleanupRecentsAnimationController = mRecentsAnimationController;
mStateCallback.setStateOnUiThread(STATE_GESTURE_CANCELLED | STATE_HANDLER_INVALIDATED);
if (mRecentsAnimationTargets != null) {
@@ -1065,11 +1072,10 @@
: LAST_TASK;
}
} else {
- // If swiping at a diagonal on the current task, base end target on the faster velocity.
+ // If swiping at a diagonal, base end target on the faster velocity.
boolean isSwipeUp = endVelocity < 0;
- boolean willGoToNewTask = canGoToNewTask && (
- mRecentsView.getDestinationPage() != mRecentsView.getCurrentPage()
- || Math.abs(velocity.x) > Math.abs(endVelocity));
+ boolean willGoToNewTask =
+ canGoToNewTask && Math.abs(velocity.x) > Math.abs(endVelocity);
if (mDeviceState.isFullyGesturalNavMode() && isSwipeUp) {
endTarget = willGoToNewTask ? NEW_TASK : HOME;
diff --git a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java
index db19c45..a379aad 100644
--- a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java
+++ b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java
@@ -17,6 +17,7 @@
import static com.android.launcher3.Utilities.mapBoundToRange;
import static com.android.launcher3.Utilities.mapRange;
+import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import android.animation.Animator;
@@ -54,6 +55,8 @@
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
+import com.android.launcher3.anim.AnimatorPlaybackController;
+import com.android.launcher3.util.Executors;
import com.android.quickstep.AnimatedFloat;
import com.android.quickstep.GestureState;
import com.android.quickstep.TouchInteractionService.TISBinder;
@@ -77,6 +80,8 @@
private static final float HINT_BOTTOM_FACTOR = 1 - .94f;
+ private static final int MAX_SWIPE_DURATION = 350;
+
private TISBindHelper mTISBindHelper;
private TISBinder mBinder;
@@ -89,6 +94,8 @@
private LottieAnimationView mAnimatedBackground;
private Animator.AnimatorListener mBackgroundAnimatorListener;
+ private AnimatorPlaybackController mLauncherStartAnim = null;
+
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -136,6 +143,10 @@
startBackgroundAnimation();
}
+ private void runOnUiHelperThread(Runnable runnable) {
+ Executors.UI_HELPER_EXECUTOR.execute(runnable);
+ }
+
private void startBackgroundAnimation() {
if (Utilities.ATLEAST_S && mVibrator != null && mVibrator.areAllPrimitivesSupported(
VibrationEffect.Composition.PRIMITIVE_THUD)) {
@@ -144,22 +155,22 @@
new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
- mVibrator.vibrate(getVibrationEffect());
+ runOnUiHelperThread(() -> mVibrator.vibrate(getVibrationEffect()));
}
@Override
public void onAnimationRepeat(Animator animation) {
- mVibrator.vibrate(getVibrationEffect());
+ runOnUiHelperThread(() -> mVibrator.vibrate(getVibrationEffect()));
}
@Override
public void onAnimationEnd(Animator animation) {
- mVibrator.cancel();
+ runOnUiHelperThread(mVibrator::cancel);
}
@Override
public void onAnimationCancel(Animator animation) {
- mVibrator.cancel();
+ runOnUiHelperThread(mVibrator::cancel);
}
};
}
@@ -232,11 +243,20 @@
private void onSwipeProgressUpdate() {
mBackground.setProgress(mSwipeProgress.value);
- float alpha = Utilities.mapBoundToRange(mSwipeProgress.value, 0, HINT_BOTTOM_FACTOR,
- 1, 0, LINEAR);
+ float alpha = Utilities.mapBoundToRange(
+ mSwipeProgress.value, 0, HINT_BOTTOM_FACTOR, 1, 0, LINEAR);
mContentView.setAlpha(alpha);
mContentView.setTranslationY((alpha - 1) * mSwipeUpShift);
+ if (mLauncherStartAnim == null) {
+ mLauncherStartAnim = mBinder.getTaskbarManager().createLauncherStartFromSuwAnim(
+ MAX_SWIPE_DURATION);
+ }
+ if (mLauncherStartAnim != null) {
+ mLauncherStartAnim.setPlayFraction(Utilities.mapBoundToRange(
+ mSwipeProgress.value, 0, 1, 0, 1, FAST_OUT_SLOW_IN));
+ }
+
if (alpha == 0f) {
mAnimatedBackground.pauseAnimation();
} else if (!mAnimatedBackground.isAnimating()) {
diff --git a/res/values-sw600dp-land/dimens.xml b/res/values-sw600dp-land/dimens.xml
index dce09e3..63970cd 100644
--- a/res/values-sw600dp-land/dimens.xml
+++ b/res/values-sw600dp-land/dimens.xml
@@ -16,6 +16,9 @@
-->
<resources>
+<!-- PagedView -->
+ <dimen name="min_page_snap_velocity">3600dp</dimen>
+
<!-- Hotseat -->
<dimen name="spring_loaded_hotseat_top_margin">44dp</dimen>
diff --git a/res/values-sw600dp/config.xml b/res/values-sw600dp/config.xml
new file mode 100644
index 0000000..072b92d
--- /dev/null
+++ b/res/values-sw600dp/config.xml
@@ -0,0 +1,21 @@
+<?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.
+-->
+<resources>
+
+ <!-- The duration of the PagedView page snap animation -->
+ <integer name="config_pageSnapAnimationDuration">550</integer>
+
+</resources>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index eb347f2..d69e777 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -15,6 +15,9 @@
-->
<resources>
+<!-- PagedView-->
+ <dimen name="min_page_snap_velocity">3000dp</dimen>
+
<!-- DragController -->
<dimen name="drag_flingToDeleteMinVelocity">-1000dp</dimen>
diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml
index 439ea93..235631d 100644
--- a/res/values-sw720dp-land/dimens.xml
+++ b/res/values-sw720dp-land/dimens.xml
@@ -15,6 +15,9 @@
-->
<resources>
+<!-- PagedView -->
+ <dimen name="min_page_snap_velocity">5300dp</dimen>
+
<!-- Dynamic grid -->
<dimen name="dynamic_grid_edge_margin">21.93dp</dimen>
<dimen name="cell_layout_padding">29.33dp</dimen>
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index 8e985bd..7b2ed8b 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -15,6 +15,9 @@
-->
<resources>
+<!-- PagedView -->
+ <dimen name="min_page_snap_velocity">3400dp</dimen>
+
<!-- AllApps -->
<dimen name="all_apps_bottom_sheet_horizontal_padding">28dp</dimen>
diff --git a/res/values/config.xml b/res/values/config.xml
index 5ecd929..9aa1f03 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -1,3 +1,18 @@
+<?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.
+-->
<resources>
<!-- Miscellaneous -->
<bool name="config_largeHeap">false</bool>
@@ -25,6 +40,9 @@
<!-- The duration of the animation from search hint to text entry -->
<integer name="config_searchHintAnimationDuration">50</integer>
+ <!-- The duration of the PagedView page snap animation -->
+ <integer name="config_pageSnapAnimationDuration">750</integer>
+
<!-- View tag key used to store SpringAnimation data. -->
<item type="id" name="spring_animation_tag" />
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index e02ee8a..2612a7d 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -57,13 +57,18 @@
<dimen name="workspace_page_indicator_line_height">1dp</dimen>
<dimen name="workspace_page_indicator_overlap_workspace">0dp</dimen>
-<!-- Drop target bar -->
+ <!-- Drop target bar -->
<dimen name="dynamic_grid_drop_target_size">56dp</dimen>
<dimen name="drop_target_vertical_gap">20dp</dimen>
<dimen name="drop_target_top_margin">32dp</dimen>
<dimen name="drop_target_bottom_margin">16dp</dimen>
-<!-- App Widget resize frame -->
+ <!-- App Widget resize frame -->
+ <!-- Button drop target bar -->
+ <dimen name="button_drop_target_min_text_size">10sp</dimen>
+ <dimen name="button_drop_target_resize_text_increment">1sp</dimen>
+
+ <!-- App Widget resize frame -->
<dimen name="widget_handle_margin">13dp</dimen>
<dimen name="resize_frame_background_padding">24dp</dimen>
<dimen name="resize_frame_margin">22dp</dimen>
@@ -76,7 +81,7 @@
<dimen name="widget_reconfigure_button_size">36dp</dimen>
<dimen name="widget_reconfigure_tip_top_margin">16dp</dimen>
-<!-- Fast scroll -->
+ <!-- Fast scroll -->
<dimen name="fastscroll_track_min_width">6dp</dimen>
<dimen name="fastscroll_track_max_width">8dp</dimen>
<dimen name="fastscroll_thumb_padding">1dp</dimen>
@@ -97,6 +102,13 @@
<dimen name="fastscroll_width">58dp</dimen>
<dimen name="fastscroll_end_margin">-26dp</dimen>
+ <!-- PagedView -->
+ <dimen name="fling_threshold_velocity">500dp</dimen>
+ <dimen name="easy_fling_threshold_velocity">400dp</dimen>
+ <dimen name="min_fling_velocity">250dp</dimen>
+ <!-- The minimum velocity of a page snap after a fling gesture -->
+ <dimen name="min_page_snap_velocity">1500dp</dimen>
+
<!-- All Apps -->
<dimen name="all_apps_starting_vertical_translate">300dp</dimen>
<dimen name="all_apps_search_bar_field_height">48dp</dimen>
@@ -129,19 +141,20 @@
<dimen name="all_apps_paged_view_top_padding">40dp</dimen>
<dimen name="all_apps_personal_work_tabs_vertical_margin">16dp</dimen>
+ <dimen name="all_apps_icon_drawable_padding">8dp</dimen>
<!-- The size of corner radius of the arrow in the arrow toast. -->
<dimen name="arrow_toast_corner_radius">2dp</dimen>
<dimen name="arrow_toast_elevation">2dp</dimen>
<dimen name="arrow_toast_arrow_width">10dp</dimen>
-<!-- Search bar in All Apps -->
+ <!-- Search bar in All Apps -->
<dimen name="all_apps_header_max_elevation">3dp</dimen>
<dimen name="all_apps_header_scroll_to_elevation">16dp</dimen>
<dimen name="all_apps_header_shadow_height">6dp</dimen>
<dimen name="all_apps_divider_margin_vertical">8dp</dimen>
-<!-- Floating action button inside work tab to toggle work profile -->
+ <!-- Floating action button inside work tab to toggle work profile -->
<dimen name="work_fab_height">56dp</dimen>
<dimen name="work_fab_radius">16dp</dimen>
<dimen name="work_card_padding_horizontal">10dp</dimen>
@@ -212,13 +225,13 @@
<dimen name="shortcut_preview_padding_right">0dp</dimen>
<dimen name="shortcut_preview_padding_top">0dp</dimen>
-<!-- Pin widget dialog -->
+ <!-- Pin widget dialog -->
<dimen name="pin_widget_button_padding_horizontal">8dp</dimen>
<dimen name="pin_widget_button_padding_vertical">4dp</dimen>
<dimen name="pin_widget_button_inset_horizontal">4dp</dimen>
<dimen name="pin_widget_button_inset_vertical">6dp</dimen>
-<!-- Dragging -->
+ <!-- Dragging -->
<!-- Drag padding to add to the bottom of drop targets -->
<dimen name="drop_target_drag_padding">14dp</dimen>
<dimen name="drop_target_text_size">16sp</dimen>
@@ -243,7 +256,7 @@
<dimen name="spring_loaded_panel_border">2dp</dimen>
<dimen name="keyboard_drag_stroke_width">4dp</dimen>
-<!-- Folders -->
+ <!-- Folders -->
<dimen name="page_indicator_dot_size">8dp</dimen>
<dimen name="folder_cell_x_padding">9dp</dimen>
@@ -255,22 +268,22 @@
<dimen name="folder_content_padding_left_right">8dp</dimen>
<dimen name="folder_content_padding_top">16dp</dimen>
-<!-- Sizes for managed profile badges -->
+ <!-- Sizes for managed profile badges -->
<dimen name="profile_badge_size">24dp</dimen>
<dimen name="profile_badge_margin">5dp</dimen>
<dimen name="profile_badge_minimum_top">2dp</dimen>
-<!-- Shadows and outlines -->
+ <!-- Shadows and outlines -->
<dimen name="blur_size_thin_outline">1dp</dimen>
<dimen name="blur_size_medium_outline">2dp</dimen>
<dimen name="blur_size_click_shadow">4dp</dimen>
<dimen name="click_shadow_high_shift">2dp</dimen>
-<!-- Pending widget -->
+ <!-- Pending widget -->
<dimen name="pending_widget_min_padding">8dp</dimen>
<dimen name="pending_widget_elevation">2dp</dimen>
-<!-- Deep shortcuts -->
+ <!-- Deep shortcuts -->
<dimen name="deep_shortcuts_elevation">2dp</dimen>
<dimen name="bg_popup_padding">2dp</dimen>
<dimen name="bg_popup_item_width">216dp</dimen>
@@ -304,7 +317,7 @@
<!-- (system_shortcut_header_icon_touch_size - system_shortcut_icon_size) / 2 -->
<dimen name="system_shortcut_header_icon_padding">14dp</dimen>
-<!-- Notifications -->
+ <!-- Notifications -->
<dimen name="bg_round_rect_radius">8dp</dimen>
<dimen name="notification_max_trans">8dp</dimen>
<dimen name="notification_space">8dp</dimen>
@@ -322,11 +335,11 @@
<dimen name="notification_main_text_padding_start">56dp</dimen>
<dimen name="horizontal_ellipsis_size">18dp</dimen>
-<!-- Overview -->
+ <!-- Overview -->
<dimen name="options_menu_icon_size">24dp</dimen>
<dimen name="options_menu_thumb_size">32dp</dimen>
-<!-- Snackbar -->
+ <!-- Snackbar -->
<dimen name="snackbar_height">48dp</dimen>
<dimen name="snackbar_content_height">32dp</dimen>
<dimen name="snackbar_padding">8dp</dimen>
@@ -338,17 +351,17 @@
<dimen name="snackbar_max_text_size">14sp</dimen>
<dimen name="snackbar_max_width">504dp</dimen>
-<!-- Developer Options -->
+ <!-- Developer Options -->
<dimen name="developer_options_filter_margins">10dp</dimen>
-<!-- Theming related -->
+ <!-- Theming related -->
<dimen name="default_dialog_corner_radius">8dp</dimen>
<dimen name="dialogCornerRadius">@dimen/default_dialog_corner_radius</dimen>
<!-- Onboarding bottomsheet related -->
<dimen name="bottom_sheet_edu_padding">24dp</dimen>
-<!-- Taskbar related (placeholders to compile in Launcher3 without Quickstep) -->
+ <!-- Taskbar related (placeholders to compile in Launcher3 without Quickstep) -->
<dimen name="taskbar_size">0dp</dimen>
<dimen name="taskbar_stashed_size">0dp</dimen>
<dimen name="qsb_widget_height">0dp</dimen>
@@ -359,10 +372,10 @@
<!-- Size of the maximum radius for the enforced rounded rectangles. -->
<dimen name="enforced_rounded_corner_max_radius">16dp</dimen>
-<!-- Base Swipe Detector, speed in dp/s -->
+ <!-- Base Swipe Detector, speed in dp/s -->
<dimen name="base_swift_detector_fling_release_velocity">1dp</dimen>
-<!-- Overview placeholder to compile in Launcher3 without Quickstep -->
+ <!-- Overview placeholder to compile in Launcher3 without Quickstep -->
<dimen name="task_thumbnail_icon_size">0dp</dimen>
<dimen name="task_thumbnail_icon_drawable_size">0dp</dimen>
<dimen name="task_thumbnail_icon_drawable_size_grid">0dp</dimen>
@@ -381,17 +394,17 @@
<dimen name="task_menu_width_grid">216dp</dimen>
-<!-- Workspace grid visualization parameters -->
+ <!-- Workspace grid visualization parameters -->
<dimen name="grid_visualization_rounding_radius">28dp</dimen>
<dimen name="grid_visualization_horizontal_cell_spacing">6dp</dimen>
<dimen name="grid_visualization_vertical_cell_spacing">6dp</dimen>
-<!-- Search results related parameters -->
+ <!-- Search results related parameters -->
<dimen name="search_row_icon_size">48dp</dimen>
<dimen name="search_row_small_icon_size">32dp</dimen>
<dimen name="padded_rounded_button_padding">8dp</dimen>
-<!-- Bottom sheet related parameters -->
+ <!-- Bottom sheet related parameters -->
<dimen name="bottom_sheet_extra_top_padding">0dp</dimen>
<dimen name="bottom_sheet_handle_width">32dp</dimen>
<dimen name="bottom_sheet_handle_height">4dp</dimen>
diff --git a/res/xml/device_profiles.xml b/res/xml/device_profiles.xml
index 290bc8c..0802552 100644
--- a/res/xml/device_profiles.xml
+++ b/res/xml/device_profiles.xml
@@ -34,6 +34,8 @@
launcher:minHeightDps="300"
launcher:iconImageSize="48"
launcher:iconTextSize="13.0"
+ launcher:allAppsBorderSpace="16"
+ launcher:allAppsCellHeight="104"
launcher:canBeDefault="true" />
<display-option
@@ -42,6 +44,8 @@
launcher:minHeightDps="400"
launcher:iconImageSize="48"
launcher:iconTextSize="13.0"
+ launcher:allAppsBorderSpace="16"
+ launcher:allAppsCellHeight="104"
launcher:canBeDefault="true" />
</grid-option>
@@ -63,6 +67,8 @@
launcher:minHeightDps="420"
launcher:iconImageSize="48"
launcher:iconTextSize="13.0"
+ launcher:allAppsBorderSpace="16"
+ launcher:allAppsCellHeight="104"
launcher:canBeDefault="true" />
<display-option
@@ -71,6 +77,8 @@
launcher:minHeightDps="450"
launcher:iconImageSize="48"
launcher:iconTextSize="13.0"
+ launcher:allAppsBorderSpace="16"
+ launcher:allAppsCellHeight="104"
launcher:canBeDefault="true" />
<display-option
@@ -79,6 +87,8 @@
launcher:minHeightDps="491.33"
launcher:iconImageSize="48"
launcher:iconTextSize="13.0"
+ launcher:allAppsBorderSpace="16"
+ launcher:allAppsCellHeight="104"
launcher:canBeDefault="true" />
<display-option
@@ -87,6 +97,8 @@
launcher:minHeightDps="567"
launcher:iconImageSize="54"
launcher:iconTextSize="13.0"
+ launcher:allAppsBorderSpace="16"
+ launcher:allAppsCellHeight="104"
launcher:canBeDefault="true" />
<display-option
@@ -95,6 +107,8 @@
launcher:minHeightDps="567"
launcher:iconImageSize="54"
launcher:iconTextSize="13.0"
+ launcher:allAppsBorderSpace="16"
+ launcher:allAppsCellHeight="104"
launcher:canBeDefault="true" />
</grid-option>
@@ -116,6 +130,8 @@
launcher:minHeightDps="694"
launcher:iconImageSize="56"
launcher:iconTextSize="14.4"
+ launcher:allAppsBorderSpace="16"
+ launcher:allAppsCellHeight="104"
launcher:canBeDefault="true" />
<display-option
@@ -124,6 +140,8 @@
launcher:minHeightDps="694"
launcher:iconImageSize="56"
launcher:iconTextSize="14.4"
+ launcher:allAppsBorderSpace="16"
+ launcher:allAppsCellHeight="104"
launcher:canBeDefault="true" />
<display-option
@@ -132,6 +150,8 @@
launcher:minHeightDps="400"
launcher:iconImageSize="48"
launcher:iconTextSize="13.0"
+ launcher:allAppsBorderSpace="16"
+ launcher:allAppsCellHeight="104"
launcher:canBeDefault="true" />
</grid-option>
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index f028d3c..5152217 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -255,7 +255,6 @@
mInsets.set(windowBounds.insets);
isScalableGrid = inv.isScalable && !isVerticalBarLayout() && !isMultiWindowMode;
-
// Determine device posture.
mInfo = info;
isTablet = info.isTablet(windowBounds);
@@ -265,8 +264,8 @@
// Some more constants.
context = getContext(context, info, isVerticalBarLayout() || (isTablet && isLandscape)
- ? Configuration.ORIENTATION_LANDSCAPE
- : Configuration.ORIENTATION_PORTRAIT,
+ ? Configuration.ORIENTATION_LANDSCAPE
+ : Configuration.ORIENTATION_PORTRAIT,
windowBounds);
final Resources res = context.getResources();
mMetrics = res.getDisplayMetrics();
@@ -313,7 +312,6 @@
allAppsShiftRange = isTablet
? heightPx - allAppsTopPadding
: res.getDimensionPixelSize(R.dimen.all_apps_starting_vertical_translate);
-
folderLabelTextScale = res.getFloat(R.dimen.folder_label_text_scale);
folderContentPaddingLeftRight =
res.getDimensionPixelSize(R.dimen.folder_content_padding_left_right);
@@ -795,27 +793,26 @@
allAppsBorderSpacePx = new Point(
pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].x, mMetrics, scale),
pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].y, mMetrics, scale));
+ // AllApps cells don't have real space between cells,
+ // so we add the border space to the cell height
+ allAppsCellHeightPx = pxFromDp(inv.allAppsCellSize[mTypeIndex].y, mMetrics, scale)
+ + allAppsBorderSpacePx.y;
+ // but width is just the cell,
+ // the border is added in #updateAllAppsContainerWidth
+ allAppsCellWidthPx = pxFromDp(inv.allAppsCellSize[mTypeIndex].x, mMetrics, scale);
if (isScalableGrid) {
allAppsIconSizePx =
pxFromDp(inv.allAppsIconSize[mTypeIndex], mMetrics);
allAppsIconTextSizePx =
pxFromSp(inv.allAppsIconTextSize[mTypeIndex], mMetrics);
allAppsIconDrawablePaddingPx = iconDrawablePaddingOriginalPx;
- // AllApps cells don't have real space between cells,
- // so we add the border space to the cell height
- allAppsCellHeightPx = pxFromDp(inv.allAppsCellSize[mTypeIndex].y, mMetrics, scale)
- + allAppsBorderSpacePx.y;
- // but width is just the cell,
- // the border is added in #updateAllAppsContainerWidth
- allAppsCellWidthPx = pxFromDp(inv.allAppsCellSize[mTypeIndex].x, mMetrics, scale);
} else {
- float invIconSizeDp = inv.iconSize[mTypeIndex];
- float invIconTextSizeSp = inv.iconTextSize[mTypeIndex];
+ float invIconSizeDp = inv.allAppsIconSize[mTypeIndex];
+ float invIconTextSizeSp = inv.allAppsIconTextSize[mTypeIndex];
allAppsIconSizePx = Math.max(1, pxFromDp(invIconSizeDp, mMetrics, scale));
allAppsIconTextSizePx = (int) (pxFromSp(invIconTextSizeSp, mMetrics) * scale);
- allAppsIconDrawablePaddingPx = (int) (iconDrawablePaddingOriginalPx * scale);
- allAppsCellWidthPx = allAppsIconSizePx + (2 * allAppsIconDrawablePaddingPx);
- allAppsCellHeightPx = getCellSize().y;
+ allAppsIconDrawablePaddingPx =
+ res.getDimensionPixelSize(R.dimen.all_apps_icon_drawable_padding);
}
updateAllAppsContainerWidth(res);
@@ -1145,7 +1142,7 @@
return Math.min(qsbBottomMarginPx + taskbarSize, freeSpace);
} else {
return (int) (freeSpace * mQsbCenterFactor)
- + (isTaskbarPresent ? taskbarSize : mInsets.bottom);
+ + (isTaskbarPresent ? taskbarSize : mInsets.bottom);
}
}
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 95a8a2a..4d33eae 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -28,6 +28,8 @@
import android.animation.LayoutTransition;
import android.annotation.SuppressLint;
import android.content.Context;
+import android.content.res.Configuration;
+import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
@@ -78,27 +80,19 @@
public static final int INVALID_PAGE = -1;
protected static final ComputePageScrollsLogic SIMPLE_SCROLL_LOGIC = (v) -> v.getVisibility() != GONE;
- public static final int PAGE_SNAP_ANIMATION_DURATION = 750;
-
private static final float RETURN_TO_ORIGINAL_PAGE_THRESHOLD = 0.33f;
// The page is moved more than halfway, automatically move to the next page on touch up.
private static final float SIGNIFICANT_MOVE_THRESHOLD = 0.4f;
private static final float MAX_SCROLL_PROGRESS = 1.0f;
- // The following constants need to be scaled based on density. The scaled versions will be
- // assigned to the corresponding member variables below.
- private static final int FLING_THRESHOLD_VELOCITY = 500;
- private static final int EASY_FLING_THRESHOLD_VELOCITY = 400;
- private static final int MIN_SNAP_VELOCITY = 1500;
- private static final int MIN_FLING_VELOCITY = 250;
-
private boolean mFreeScroll = false;
- protected final int mFlingThresholdVelocity;
- protected final int mEasyFlingThresholdVelocity;
- protected final int mMinFlingVelocity;
- protected final int mMinSnapVelocity;
+ private int mFlingThresholdVelocity;
+ private int mEasyFlingThresholdVelocity;
+ private int mMinFlingVelocity;
+ private int mMinSnapVelocity;
+ private int mPageSnapAnimationDuration;
protected boolean mFirstLayout = true;
@@ -192,11 +186,7 @@
mPageSlop = configuration.getScaledPagingTouchSlop();
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
- float density = getResources().getDisplayMetrics().density;
- mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * density);
- mEasyFlingThresholdVelocity = (int) (EASY_FLING_THRESHOLD_VELOCITY * density);
- mMinFlingVelocity = (int) (MIN_FLING_VELOCITY * density);
- mMinSnapVelocity = (int) (MIN_SNAP_VELOCITY * density);
+ updateVelocityValues();
initEdgeEffect();
setDefaultFocusHighlightEnabled(false);
@@ -628,6 +618,22 @@
- mInsets.left - mInsets.right;
}
+ private void updateVelocityValues() {
+ Resources res = getResources();
+ mFlingThresholdVelocity = res.getDimensionPixelSize(R.dimen.fling_threshold_velocity);
+ mEasyFlingThresholdVelocity =
+ res.getDimensionPixelSize(R.dimen.easy_fling_threshold_velocity);
+ mMinFlingVelocity = res.getDimensionPixelSize(R.dimen.min_fling_velocity);
+ mMinSnapVelocity = res.getDimensionPixelSize(R.dimen.min_page_snap_velocity);
+ mPageSnapAnimationDuration = res.getInteger(R.integer.config_pageSnapAnimationDuration);
+ }
+
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ updateVelocityValues();
+ }
+
@Override
public void requestLayout() {
mIsLayoutValid = false;
@@ -1616,7 +1622,7 @@
}
protected void snapToDestination() {
- snapToPage(getDestinationPage(), PAGE_SNAP_ANIMATION_DURATION);
+ snapToPage(getDestinationPage(), mPageSnapAnimationDuration);
}
// We want the duration of the page snap animation to be influenced by the distance that
@@ -1640,7 +1646,7 @@
if (Math.abs(velocity) < mMinFlingVelocity) {
// If the velocity is low enough, then treat this more as an automatic page advance
// as opposed to an apparent physical response to flinging
- return snapToPage(whichPage, PAGE_SNAP_ANIMATION_DURATION);
+ return snapToPage(whichPage, mPageSnapAnimationDuration);
}
// Here we compute a "distance" that will be used in the computation of the overall
@@ -1663,11 +1669,11 @@
}
public boolean snapToPage(int whichPage) {
- return snapToPage(whichPage, PAGE_SNAP_ANIMATION_DURATION);
+ return snapToPage(whichPage, mPageSnapAnimationDuration);
}
public boolean snapToPageImmediately(int whichPage) {
- return snapToPage(whichPage, PAGE_SNAP_ANIMATION_DURATION, true);
+ return snapToPage(whichPage, mPageSnapAnimationDuration, true);
}
public boolean snapToPage(int whichPage, int duration) {
diff --git a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
index 95c67dd..fc52797 100644
--- a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
@@ -326,7 +326,7 @@
}
protected boolean isPersonalTab() {
- return mViewPager.getNextPage() == 0;
+ return mViewPager == null || mViewPager.getNextPage() == 0;
}
/**
@@ -388,34 +388,34 @@
mInsets.set(insets);
DeviceProfile grid = mActivityContext.getDeviceProfile();
- for (int i = 0; i < mAH.size(); i++) {
- mAH.get(i).mPadding.bottom = insets.bottom;
- mAH.get(i).mPadding.left = mAH.get(i).mPadding.right = grid.allAppsLeftRightPadding;
- mAH.get(i).applyPadding();
- }
+ applyAdapterPaddings(grid);
MarginLayoutParams mlp = (MarginLayoutParams) getLayoutParams();
- int leftRightMargin = grid.allAppsLeftRightMargin;
- mlp.leftMargin = insets.left + leftRightMargin;
- mlp.rightMargin = insets.right + leftRightMargin;
+ mlp.leftMargin = insets.left;
+ mlp.rightMargin = insets.right;
setLayoutParams(mlp);
if (grid.isVerticalBarLayout()) {
setPadding(grid.workspacePadding.left, 0, grid.workspacePadding.right, 0);
} else {
- setPadding(0, grid.allAppsTopPadding, 0, 0);
+ setPadding(grid.allAppsLeftRightMargin, grid.allAppsTopPadding,
+ grid.allAppsLeftRightMargin, 0);
}
InsettableFrameLayout.dispatchInsets(this, insets);
}
+ /**
+ * 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) {
+ return 0;
+ }
+
@Override
public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) {
- if (Utilities.ATLEAST_Q) {
- mNavBarScrimHeight = insets.getTappableElementInsets().bottom;
- } else {
- mNavBarScrimHeight = insets.getStableInsetBottom();
- }
+ mNavBarScrimHeight = getNavBarScrimHeight(insets);
+ applyAdapterPaddings(mActivityContext.getDeviceProfile());
return super.dispatchApplyWindowInsets(insets);
}
@@ -483,6 +483,15 @@
mAllAppsStore.registerIconContainer(mAH.get(AdapterHolder.WORK).mRecyclerView);
}
+ private void applyAdapterPaddings(DeviceProfile grid) {
+ int bottomPadding = Math.max(mInsets.bottom, mNavBarScrimHeight);
+ for (int i = 0; i < mAH.size(); i++) {
+ mAH.get(i).mPadding.bottom = bottomPadding;
+ mAH.get(i).mPadding.left = mAH.get(i).mPadding.right = grid.allAppsLeftRightPadding;
+ mAH.get(i).applyPadding();
+ }
+ }
+
private void setDeviceManagementResources() {
if (mActivityContext.getStringCache() != null) {
Button personalTab = findViewById(R.id.tab_personal);
diff --git a/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java b/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java
index 8601819..20f5e74 100644
--- a/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java
@@ -18,9 +18,11 @@
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
+import android.view.WindowInsets;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
+import com.android.launcher3.Utilities;
/**
* AllAppsContainerView with launcher specific callbacks
@@ -58,4 +60,13 @@
}
return super.onTouchEvent(ev);
}
+
+ @Override
+ protected int getNavBarScrimHeight(WindowInsets insets) {
+ if (Utilities.ATLEAST_Q) {
+ return insets.getTappableElementInsets().bottom;
+ } else {
+ return insets.getStableInsetBottom();
+ }
+ }
}
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index 54edb33..9775b87 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -246,6 +246,10 @@
"ENABLE_ALL_APPS_IN_TASKBAR", true,
"Enables accessing All Apps from the system Taskbar.");
+ public static final BooleanFlag ENABLE_ALL_APPS_BUTTON_IN_HOTSEAT = getDebugFlag(
+ "ENABLE_ALL_APPS_BUTTON_IN_HOTSEAT", false,
+ "Enables displaying the all apps button in the hotseat.");
+
public static final BooleanFlag ENABLE_ALL_APPS_ONE_SEARCH_IN_TASKBAR = getDebugFlag(
"ENABLE_ALL_APPS_ONE_SEARCH_IN_TASKBAR", false,
"Enables One Search box in Taskbar All Apps.");
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index 512fa1c..e68ebdb 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -72,7 +72,6 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.OnAlarmListener;
-import com.android.launcher3.PagedView;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutAndWidgetContainer;
import com.android.launcher3.Utilities;
@@ -145,7 +144,7 @@
* Time for which the scroll hint is shown before automatically changing page.
*/
public static final int SCROLL_HINT_DURATION = 500;
- public static final int RESCROLL_DELAY = PagedView.PAGE_SNAP_ANIMATION_DURATION + 150;
+ private static final int RESCROLL_EXTRA_DELAY = 150;
public static final int SCROLL_NONE = -1;
public static final int SCROLL_LEFT = 0;
@@ -1523,7 +1522,9 @@
// Pause drag event until the scrolling is finished
mScrollPauseAlarm.setOnAlarmListener(new OnScrollFinishedListener(mDragObject));
- mScrollPauseAlarm.setAlarm(RESCROLL_DELAY);
+ int rescrollDelay = getResources().getInteger(
+ R.integer.config_pageSnapAnimationDuration) + RESCROLL_EXTRA_DELAY;
+ mScrollPauseAlarm.setAlarm(rescrollDelay);
}
}
diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java
index 2b6e426..f4f270c 100644
--- a/src/com/android/launcher3/logging/StatsLogManager.java
+++ b/src/com/android/launcher3/logging/StatsLogManager.java
@@ -731,7 +731,8 @@
enum LatencyType {
UNKNOWN(0),
COLD(1),
- HOT(2);
+ HOT(2),
+ TIMEOUT(3);
private final int mId;
diff --git a/src/com/android/launcher3/model/BaseLoaderResults.java b/src/com/android/launcher3/model/BaseLoaderResults.java
index 6c4cfb9..b50ab58 100644
--- a/src/com/android/launcher3/model/BaseLoaderResults.java
+++ b/src/com/android/launcher3/model/BaseLoaderResults.java
@@ -43,6 +43,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
import java.util.concurrent.Executor;
/**
@@ -203,7 +204,9 @@
}
private void bind() {
- IntSet currentScreenIds = mCallbacks.getPagesToBindSynchronously(mOrderedScreenIds);
+ final IntSet currentScreenIds =
+ mCallbacks.getPagesToBindSynchronously(mOrderedScreenIds);
+ Objects.requireNonNull(currentScreenIds, "Null screen ids provided by " + mCallbacks);
// Separate the items that are on the current screen, and all the other remaining items
ArrayList<ItemInfo> currentWorkspaceItems = new ArrayList<>();
diff --git a/src/com/android/launcher3/model/BgDataModel.java b/src/com/android/launcher3/model/BgDataModel.java
index d52537e..de23c4b 100644
--- a/src/com/android/launcher3/model/BgDataModel.java
+++ b/src/com/android/launcher3/model/BgDataModel.java
@@ -31,6 +31,7 @@
import android.util.ArraySet;
import android.util.Log;
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.android.launcher3.LauncherSettings;
@@ -469,6 +470,7 @@
* or an empty IntSet
* @param orderedScreenIds All the page ids to be bound
*/
+ @NonNull
default IntSet getPagesToBindSynchronously(IntArray orderedScreenIds) {
return new IntSet();
}
diff --git a/src/com/android/launcher3/model/ModelUtils.java b/src/com/android/launcher3/model/ModelUtils.java
index df6768d..422af43 100644
--- a/src/com/android/launcher3/model/ModelUtils.java
+++ b/src/com/android/launcher3/model/ModelUtils.java
@@ -51,7 +51,7 @@
* specified screen.
*/
public static <T extends ItemInfo> void filterCurrentWorkspaceItems(
- IntSet currentScreenIds,
+ final IntSet currentScreenIds,
ArrayList<T> allWorkspaceItems,
ArrayList<T> currentScreenItems,
ArrayList<T> otherScreenItems) {
diff --git a/src/com/android/launcher3/secondarydisplay/SecondaryDragLayer.java b/src/com/android/launcher3/secondarydisplay/SecondaryDragLayer.java
index e906c95..c79d70d 100644
--- a/src/com/android/launcher3/secondarydisplay/SecondaryDragLayer.java
+++ b/src/com/android/launcher3/secondarydisplay/SecondaryDragLayer.java
@@ -120,23 +120,20 @@
int maxWidth =
grid.allAppsCellWidthPx * grid.numShownAllAppsColumns + horizontalPadding;
- int appsWidth = Math.min(width, maxWidth);
+ int appsWidth = Math.min(width - getPaddingLeft() - getPaddingRight(), maxWidth);
int maxHeight =
grid.allAppsCellHeightPx * grid.numShownAllAppsColumns + verticalPadding;
- int appsHeight = Math.min(height, maxHeight);
+ int appsHeight = Math.min(height - getPaddingTop() - getPaddingBottom(), maxHeight);
mAppsView.measure(
makeMeasureSpec(appsWidth, EXACTLY), makeMeasureSpec(appsHeight, EXACTLY));
-
} else if (child == mAllAppsButton) {
int appsButtonSpec = makeMeasureSpec(grid.iconSizePx, EXACTLY);
mAllAppsButton.measure(appsButtonSpec, appsButtonSpec);
-
} else if (child == mWorkspace) {
measureChildWithMargins(mWorkspace, widthMeasureSpec, 0, heightMeasureSpec,
grid.iconSizePx + grid.edgeMarginPx);
-
} else {
measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
}
diff --git a/src/com/android/launcher3/states/RotationHelper.java b/src/com/android/launcher3/states/RotationHelper.java
index 8b425da..38b62d4 100644
--- a/src/com/android/launcher3/states/RotationHelper.java
+++ b/src/com/android/launcher3/states/RotationHelper.java
@@ -109,7 +109,7 @@
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
- if (mDestroyed) return;
+ if (mDestroyed || mIgnoreAutoRotateSettings) return;
boolean wasRotationEnabled = mHomeRotationEnabled;
mHomeRotationEnabled = mSharedPrefs.getBoolean(ALLOW_ROTATION_PREFERENCE_KEY,
getAllowRotationDefaultValue(mActivity.getDeviceProfile()));
diff --git a/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java b/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java
index d2d569f..9442734 100644
--- a/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java
+++ b/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java
@@ -18,7 +18,6 @@
import static com.android.launcher3.Utilities.ATLEAST_R;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
-import static com.android.launcher3.widget.BaseWidgetSheet.MAX_WIDTH_SCALE_FOR_LARGER_SCREEN;
import android.animation.PropertyValuesHolder;
import android.annotation.SuppressLint;
@@ -106,7 +105,10 @@
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
DeviceProfile deviceProfile = mActivityContext.getDeviceProfile();
int widthUsed;
- if (mInsets.bottom > 0) {
+ if (deviceProfile.isTablet) {
+ int margin = deviceProfile.allAppsLeftRightMargin;
+ widthUsed = Math.max(2 * margin, 2 * (mInsets.left + mInsets.right));
+ } else if (mInsets.bottom > 0) {
widthUsed = mInsets.left + mInsets.right;
} else {
Rect padding = deviceProfile.workspacePadding;
@@ -114,18 +116,8 @@
2 * (mInsets.left + mInsets.right));
}
- if (deviceProfile.isTablet || deviceProfile.isTwoPanels) {
- // In large screen devices, we restrict the width of the widgets picker to show part of
- // the home screen. Let's ensure the minimum width used is at least the minimum width
- // that isn't taken by the widgets picker.
- int minUsedWidth = (int) (deviceProfile.availableWidthPx
- * (1 - MAX_WIDTH_SCALE_FOR_LARGER_SCREEN));
- widthUsed = Math.max(widthUsed, minUsedWidth);
- }
-
- int heightUsed = mInsets.top + deviceProfile.edgeMarginPx;
measureChildWithMargins(mContent, widthMeasureSpec,
- widthUsed, heightMeasureSpec, heightUsed);
+ widthUsed, heightMeasureSpec, deviceProfile.bottomSheetTopPadding);
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec),
MeasureSpec.getSize(heightMeasureSpec));
}
diff --git a/src/com/android/launcher3/widget/BaseWidgetSheet.java b/src/com/android/launcher3/widget/BaseWidgetSheet.java
index c7bb612..1bcba14 100644
--- a/src/com/android/launcher3/widget/BaseWidgetSheet.java
+++ b/src/com/android/launcher3/widget/BaseWidgetSheet.java
@@ -16,6 +16,8 @@
package com.android.launcher3.widget;
import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.util.AttributeSet;
@@ -23,6 +25,7 @@
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
+import android.view.WindowInsets;
import android.widget.Toast;
import androidx.annotation.GuardedBy;
@@ -43,6 +46,7 @@
import com.android.launcher3.touch.ItemLongClickListener;
import com.android.launcher3.util.SystemUiController;
import com.android.launcher3.util.Themes;
+import com.android.launcher3.util.window.WindowManagerProxy;
import com.android.launcher3.views.AbstractSlideInView;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.ArrowTipView;
@@ -55,11 +59,6 @@
PopupDataProvider.PopupDataChangeListener, Insettable {
/** The default number of cells that can fit horizontally in a widget sheet. */
protected static final int DEFAULT_MAX_HORIZONTAL_SPANS = 4;
- /**
- * The maximum scale, [0, 1], of the device screen width that the widgets picker can consume
- * on large screen devices.
- */
- protected static final float MAX_WIDTH_SCALE_FOR_LARGER_SCREEN = 0.89f;
protected static final String KEY_WIDGETS_EDUCATION_TIP_SEEN =
"launcher.widgets_education_tip_seen";
@@ -70,10 +69,15 @@
private int mContentHorizontalMarginInPx;
+ protected int mNavBarScrimHeight;
+ private final Paint mNavBarScrimPaint;
+
public BaseWidgetSheet(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mContentHorizontalMarginInPx = getResources().getDimensionPixelSize(
R.dimen.widget_list_horizontal_margin);
+ mNavBarScrimPaint = new Paint();
+ mNavBarScrimPaint.setColor(Themes.getAttrColor(context, R.attr.allAppsNavBarScrimColor));
}
protected int getScrimColor(Context context) {
@@ -83,6 +87,9 @@
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
+ WindowInsets windowInsets = WindowManagerProxy.INSTANCE.get(getContext())
+ .normalizeWindowInsets(getContext(), getRootWindowInsets(), new Rect());
+ mNavBarScrimHeight = getNavBarScrimHeight(windowInsets);
mActivityContext.getPopupDataProvider().setChangeListener(this);
}
@@ -136,6 +143,30 @@
}
}
+ private int getNavBarScrimHeight(WindowInsets insets) {
+ if (Utilities.ATLEAST_Q) {
+ return insets.getTappableElementInsets().bottom;
+ } else {
+ return insets.getStableInsetBottom();
+ }
+ }
+
+ @Override
+ public WindowInsets onApplyWindowInsets(WindowInsets insets) {
+ mNavBarScrimHeight = getNavBarScrimHeight(insets);
+ return super.onApplyWindowInsets(insets);
+ }
+
+ @Override
+ protected void dispatchDraw(Canvas canvas) {
+ super.dispatchDraw(canvas);
+
+ if (mNavBarScrimHeight > 0) {
+ canvas.drawRect(0, getHeight() - mNavBarScrimHeight, getWidth(), getHeight(),
+ mNavBarScrimPaint);
+ }
+ }
+
/** Called when the horizontal margin of the content view has changed. */
protected abstract void onContentHorizontalMarginChanged(int contentHorizontalMarginInPx);
@@ -147,7 +178,10 @@
protected void doMeasure(int widthMeasureSpec, int heightMeasureSpec) {
DeviceProfile deviceProfile = mActivityContext.getDeviceProfile();
int widthUsed;
- if (mInsets.bottom > 0) {
+ if (deviceProfile.isTablet) {
+ int margin = deviceProfile.allAppsLeftRightMargin;
+ widthUsed = Math.max(2 * margin, 2 * (mInsets.left + mInsets.right));
+ } else if (mInsets.bottom > 0) {
widthUsed = mInsets.left + mInsets.right;
} else {
Rect padding = deviceProfile.workspacePadding;
@@ -155,15 +189,6 @@
2 * (mInsets.left + mInsets.right));
}
- if (deviceProfile.isTablet || deviceProfile.isTwoPanels) {
- // In large screen devices, we restrict the width of the widgets picker to show part of
- // the home screen. Let's ensure the minimum width used is at least the minimum width
- // that isn't taken by the widgets picker.
- int minUsedWidth = (int) (deviceProfile.availableWidthPx
- * (1 - MAX_WIDTH_SCALE_FOR_LARGER_SCREEN));
- widthUsed = Math.max(widthUsed, minUsedWidth);
- }
-
measureChildWithMargins(mContent, widthMeasureSpec,
widthUsed, heightMeasureSpec, deviceProfile.bottomSheetTopPadding);
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec),
diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
index b152ddc..bf521cc 100644
--- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java
+++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
@@ -247,10 +247,12 @@
@Override
public void setInsets(Rect insets) {
super.setInsets(insets);
+ int bottomPadding = Math.max(insets.bottom, mNavBarScrimHeight);
mContent.setPadding(mContent.getPaddingStart(),
- mContent.getPaddingTop(), mContent.getPaddingEnd(), insets.bottom);
- if (insets.bottom > 0) {
+ mContent.getPaddingTop(), mContent.getPaddingEnd(),
+ bottomPadding);
+ if (bottomPadding > 0) {
setupNavBarColor();
} else {
clearNavBarColor();
diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
index 341cb5c..a49cdc0 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
@@ -328,15 +328,15 @@
@Override
public void setInsets(Rect insets) {
super.setInsets(insets);
-
- setBottomPadding(mAdapters.get(AdapterHolder.PRIMARY).mWidgetsRecyclerView, insets.bottom);
- setBottomPadding(mAdapters.get(AdapterHolder.SEARCH).mWidgetsRecyclerView, insets.bottom);
+ int bottomPadding = Math.max(insets.bottom, mNavBarScrimHeight);
+ setBottomPadding(mAdapters.get(AdapterHolder.PRIMARY).mWidgetsRecyclerView, bottomPadding);
+ setBottomPadding(mAdapters.get(AdapterHolder.SEARCH).mWidgetsRecyclerView, bottomPadding);
if (mHasWorkProfile) {
- setBottomPadding(mAdapters.get(AdapterHolder.WORK).mWidgetsRecyclerView, insets.bottom);
+ setBottomPadding(mAdapters.get(AdapterHolder.WORK).mWidgetsRecyclerView, bottomPadding);
}
- ((MarginLayoutParams) mNoWidgetsView.getLayoutParams()).bottomMargin = insets.bottom;
+ ((MarginLayoutParams) mNoWidgetsView.getLayoutParams()).bottomMargin = bottomPadding;
- if (insets.bottom > 0) {
+ if (bottomPadding > 0) {
setupNavBarColor();
} else {
clearNavBarColor();