Merge "Fix Taskbar Y-Translation with Visible Bottom Sheet" into main

This commit is contained in:
Sukesh Ram
2024-10-15 01:34:41 +00:00
committed by Android (Google) Code Review
6 changed files with 71 additions and 26 deletions
@@ -36,6 +36,7 @@ import com.android.launcher3.Flags;
import com.android.launcher3.LauncherState;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatedFloat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.InstanceId;
import com.android.launcher3.logging.InstanceIdSequence;
import com.android.launcher3.model.data.ItemInfo;
@@ -68,14 +69,17 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
public static final int ALL_APPS_PAGE_PROGRESS_INDEX = 1;
public static final int WIDGETS_PAGE_PROGRESS_INDEX = 2;
public static final int SYSUI_SURFACE_PROGRESS_INDEX = 3;
public static final int LAUNCHER_PAUSE_PROGRESS_INDEX = 4;
public static final int DISPLAY_PROGRESS_COUNT = 4;
public static final int DISPLAY_PROGRESS_COUNT = 5;
private final AnimatedFloat mTaskbarInAppDisplayProgress = new AnimatedFloat(
this::onInAppDisplayProgressChanged);
private final MultiPropertyFactory<AnimatedFloat> mTaskbarInAppDisplayProgressMultiProp =
new MultiPropertyFactory<>(mTaskbarInAppDisplayProgress,
AnimatedFloat.VALUE, DISPLAY_PROGRESS_COUNT, Float::max);
private final AnimatedFloat mLauncherPauseProgress = new AnimatedFloat(
this::launcherPauseProgressUpdate);
private final QuickstepLauncher mLauncher;
private final HomeVisibilityState mHomeState;
@@ -190,6 +194,33 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
placeholderDuration));
}
/**
* Called when Launcher Activity is paused/resumed.
* <p>
* To avoid UI clash between taskbar & bottom sheet, shift nav buttons down on launcher
* pause/resume at home.
* @param paused if launcher is currently paused.
*/
public void onLauncherPausedOrResumed(boolean paused) {
if (!FeatureFlags.enableHomeTransitionListener()) {
onLauncherVisibilityChanged(mLauncher.hasBeenResumed());
return;
}
// Animate navbar iff pause/resume from home, NOT to/from app (avoid overriding existing
// animations).
boolean launcherPauseOrResumeFromHome = mHomeState.isHomeVisible() && mControllers
.taskbarAutohideSuspendController.isSuspendedForTransientTaskbarInLauncher();
if (launcherPauseOrResumeFromHome) {
mLauncherPauseProgress.animateToValue(paused ? 1.0f : 0.0f).start();
}
}
private void launcherPauseProgressUpdate() {
onTaskbarInAppDisplayProgressUpdate(
mLauncherPauseProgress.value, LAUNCHER_PAUSE_PROGRESS_INDEX);
}
/**
* Should be called from onResume() and onPause(), and animates the Taskbar accordingly.
*/
@@ -364,18 +395,20 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
}
if (mControllers.uiController.isIconAlignedWithHotseat()
&& !mTaskbarLauncherStateController.isAnimatingToLauncher()) {
// Only animate the nav buttons while home and not animating home, otherwise let
// Only animate nav button position while home and not animating home, otherwise let
// the TaskbarViewController handle it.
mControllers.navbarButtonsViewController
.getTaskbarNavButtonTranslationYForInAppDisplay()
.getNavButtonTranslationYForInAppDisplay()
.updateValue(mLauncher.getDeviceProfile().getTaskbarOffsetY()
* mTaskbarInAppDisplayProgress.value);
mControllers.navbarButtonsViewController
.getOnTaskbarBackgroundNavButtonColorOverride().updateValue(progress);
if (!mLauncher.isPaused()) {
mControllers.navbarButtonsViewController
.getOnTaskbarBackgroundNavButtonColorOverride().updateValue(progress);
}
}
}
/** Returns true iff any in-app display progress > 0. */
@Override
public boolean shouldUseInAppLayout() {
return mTaskbarInAppDisplayProgress.value > 0;
}
@@ -183,7 +183,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
private final AnimatedFloat mTaskbarNavButtonTranslationY = new AnimatedFloat(
this::updateNavButtonTranslationY);
private final AnimatedFloat mTaskbarNavButtonTranslationYForInAppDisplay = new AnimatedFloat(
private final AnimatedFloat mNavButtonTranslationYForInAppDisplay = new AnimatedFloat(
this::updateNavButtonTranslationY);
private final AnimatedFloat mTaskbarNavButtonTranslationYForIme = new AnimatedFloat(
this::updateNavButtonTranslationY);
@@ -704,8 +704,8 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
}
/** Use to set the translationY for the all nav+contextual buttons when in Launcher */
public AnimatedFloat getTaskbarNavButtonTranslationYForInAppDisplay() {
return mTaskbarNavButtonTranslationYForInAppDisplay;
public AnimatedFloat getNavButtonTranslationYForInAppDisplay() {
return mNavButtonTranslationYForInAppDisplay;
}
/** Use to set the dark intensity for the all nav+contextual buttons */
@@ -751,20 +751,22 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
if (mContext.isPhoneButtonNavMode()) {
return;
}
final float normalTranslationY = mTaskbarNavButtonTranslationY.value;
final float imeAdjustmentTranslationY = mTaskbarNavButtonTranslationYForIme.value;
TaskbarUIController uiController = mControllers.uiController;
final float inAppDisplayAdjustmentTranslationY =
(uiController instanceof LauncherTaskbarUIController
&& ((LauncherTaskbarUIController) uiController).shouldUseInAppLayout())
? mTaskbarNavButtonTranslationYForInAppDisplay.value : 0;
mLastSetNavButtonTranslationY = normalTranslationY
+ imeAdjustmentTranslationY
+ inAppDisplayAdjustmentTranslationY;
mLastSetNavButtonTranslationY = calculateNavButtonTranslationY();
mNavButtonsView.setTranslationY(mLastSetNavButtonTranslationY);
}
/**
* Calculates the translationY of the nav buttons based on the current device state.
*/
private float calculateNavButtonTranslationY() {
float translationY =
mTaskbarNavButtonTranslationY.value + mTaskbarNavButtonTranslationYForIme.value;
if (mControllers.uiController.shouldUseInAppLayout()) {
translationY += mNavButtonTranslationYForInAppDisplay.value;
}
return translationY;
}
/**
* Sets Taskbar 3-button mode icon colors based on the
* {@link #mTaskbarNavButtonDarkIntensity} value piped in from Framework. For certain cases
@@ -1162,7 +1164,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
pw.println(prefix + "\t\tmTaskbarNavButtonTranslationY="
+ mTaskbarNavButtonTranslationY.value);
pw.println(prefix + "\t\tmTaskbarNavButtonTranslationYForInAppDisplay="
+ mTaskbarNavButtonTranslationYForInAppDisplay.value);
+ mNavButtonTranslationYForInAppDisplay.value);
pw.println(prefix + "\t\tmTaskbarNavButtonTranslationYForIme="
+ mTaskbarNavButtonTranslationYForIme.value);
pw.println(prefix + "\t\tmTaskbarNavButtonDarkIntensity="
@@ -90,6 +90,14 @@ public class TaskbarUIController implements BubbleBarController.BubbleBarLocatio
protected void onStashedInAppChanged() { }
/**
* Whether the Taskbar should use in-app layout.
* @return {@code true} iff in-app display progress > 0 or Launcher Activity paused.
*/
public boolean shouldUseInAppLayout() {
return false;
}
/**
* Called when taskbar icon layout bounds change.
*/
@@ -234,7 +234,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
mTaskbarNavButtonTranslationY =
controllers.navbarButtonsViewController.getTaskbarNavButtonTranslationY();
mTaskbarNavButtonTranslationYForInAppDisplay = controllers.navbarButtonsViewController
.getTaskbarNavButtonTranslationYForInAppDisplay();
.getNavButtonTranslationYForInAppDisplay();
mActivity.addOnDeviceProfileChangeListener(mDeviceProfileChangeListener);
@@ -419,10 +419,8 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer,
mDepthController.setActivityStarted(isStarted());
}
if ((changeBits & ACTIVITY_STATE_RESUMED) != 0) {
if (!FeatureFlags.enableHomeTransitionListener() && mTaskbarUIController != null) {
mTaskbarUIController.onLauncherVisibilityChanged(hasBeenResumed());
}
if ((changeBits & ACTIVITY_STATE_RESUMED) != 0 && mTaskbarUIController != null) {
mTaskbarUIController.onLauncherPausedOrResumed(isPaused());
}
super.onActivityFlagsChanged(changeBits);
@@ -306,6 +306,10 @@ public abstract class BaseActivity extends Activity implements ActivityContext {
removeActivityFlags(ACTIVITY_STATE_RESUMED | ACTIVITY_STATE_DEFERRED_RESUMED);
}
public boolean isPaused() {
return !hasBeenResumed() && (mActivityFlags & ACTIVITY_STATE_DEFERRED_RESUMED) == 0;
}
/**
* Sets the activity to appear as resumed.
*/