Snap for 11959661 from 8f2a4e0854 to 24Q3-release

Change-Id: I750873cb534e9e20aea871a8cda9a37da12315e6
This commit is contained in:
Android Build Coastguard Worker committed 2024-06-12 23:22:45 +00:00
commit 6f61e0cf75
12 files changed
+185 -87

No files matched your search

@@ -347,6 +347,11 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
float allAppIconTranslateRange = mapRange(scale, transientTaskbarAllAppsOffset,
persistentTaskbarAllAppsOffset);
// no x translation required when all apps button is the only icon in taskbar.
if (iconViews.length <= 1) {
allAppIconTranslateRange = 0f;
}
if (mIsRtl) {
allAppIconTranslateRange *= -1;
}
@@ -377,7 +382,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
-finalMarginScale * (iconIndex - halfIconCount));
}
if (iconView.equals(mTaskbarView.getAllAppsButtonView()) && iconViews.length > 1) {
if (iconView.equals(mTaskbarView.getAllAppsButtonView())) {
((IconButtonView) iconView).setTranslationXForTaskbarAllAppsIcon(
allAppIconTranslateRange);
}
@@ -98,6 +98,8 @@ public class BubbleBarView extends FrameLayout {
// During fade in animation we shift the bubble bar 1/60th of the screen width
private static final float FADE_IN_ANIM_POSITION_SHIFT = 1 / 60f;
private static final int SCALE_IN_ANIMATION_DURATION_MS = 250;
/**
* Custom property to set alpha value for the bar view while a bubble is being dragged.
* Skips applying alpha to the dragged bubble.
@@ -157,6 +159,10 @@ public class BubbleBarView extends FrameLayout {
// collapsed state and 1 to the fully expanded state.
private final ValueAnimator mWidthAnimator = ValueAnimator.ofFloat(0, 1);
/** An animator used for scaling in a new bubble to the bubble bar while expanded. */
@Nullable
private ValueAnimator mNewBubbleScaleInAnimator = null;
@Nullable
private Animator mBubbleBarLocationAnimator = null;
@@ -212,7 +218,7 @@ public class BubbleBarView extends FrameLayout {
mWidthAnimator.setDuration(WIDTH_ANIMATION_DURATION_MS);
mWidthAnimator.addUpdateListener(animation -> {
updateChildrenRenderNodeProperties(mBubbleBarLocation);
updateBubblesLayoutProperties(mBubbleBarLocation);
invalidate();
});
mWidthAnimator.addListener(new Animator.AnimatorListener() {
@@ -298,7 +304,7 @@ public class BubbleBarView extends FrameLayout {
if (!mDragging) {
// Position the views when not dragging
updateChildrenRenderNodeProperties(mBubbleBarLocation);
updateBubblesLayoutProperties(mBubbleBarLocation);
}
}
@@ -444,7 +450,7 @@ public class BubbleBarView extends FrameLayout {
mBubbleBarLocationAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
updateChildrenRenderNodeProperties(bubbleBarLocation);
updateBubblesLayoutProperties(bubbleBarLocation);
mBubbleBarBackground.setAnchorLeft(bubbleBarLocation.isOnLeft(isLayoutRtl()));
// Animate it in
@@ -613,6 +619,45 @@ public class BubbleBarView extends FrameLayout {
mIsAnimatingNewBubble = false;
}
/** Add a new bubble to the bubble bar. */
public void addBubble(View bubble, FrameLayout.LayoutParams lp) {
if (isExpanded()) {
// if we're expanded scale the new bubble in
bubble.setScaleX(0f);
bubble.setScaleY(0f);
addView(bubble, 0, lp);
createNewBubbleScaleInAnimator(bubble);
mNewBubbleScaleInAnimator.start();
} else {
addView(bubble, 0, lp);
}
}
private void createNewBubbleScaleInAnimator(View bubble) {
mNewBubbleScaleInAnimator = ValueAnimator.ofFloat(0, 1);
mNewBubbleScaleInAnimator.setDuration(SCALE_IN_ANIMATION_DURATION_MS);
mNewBubbleScaleInAnimator.addUpdateListener(animation -> {
float animatedFraction = animation.getAnimatedFraction();
bubble.setScaleX(animatedFraction);
bubble.setScaleY(animatedFraction);
updateBubblesLayoutProperties(mBubbleBarLocation);
invalidate();
});
mNewBubbleScaleInAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
bubble.setScaleX(1);
bubble.setScaleY(1);
}
@Override
public void onAnimationEnd(Animator animation) {
updateWidth();
mNewBubbleScaleInAnimator = null;
}
});
}
// TODO: (b/280605790) animate it
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
@@ -663,7 +708,7 @@ public class BubbleBarView extends FrameLayout {
* Updates the z order, positions, and badge visibility of the bubble views in the bar based
* on the expanded state.
*/
private void updateChildrenRenderNodeProperties(BubbleBarLocation bubbleBarLocation) {
private void updateBubblesLayoutProperties(BubbleBarLocation bubbleBarLocation) {
final float widthState = (float) mWidthAnimator.getAnimatedValue();
final float currentWidth = getWidth();
final float expandedWidth = expandedWidth();
@@ -752,17 +797,63 @@ public class BubbleBarView extends FrameLayout {
mBubbleBarBackground.setWidth(interpolatedWidth);
}
private float getExpandedBubbleTranslationX(int bubbleIndex, int bubbleCount,
boolean onLeft) {
private float getExpandedBubbleTranslationX(int bubbleIndex, int bubbleCount, boolean onLeft) {
if (bubbleIndex < 0 || bubbleIndex >= bubbleCount) {
return 0;
}
if (onLeft) {
// If bar is on the left, bubbles are ordered right to left
return (bubbleCount - bubbleIndex - 1) * (mIconSize + mExpandedBarIconsSpacing);
final float iconAndSpacing = mIconSize + mExpandedBarIconsSpacing;
if (mNewBubbleScaleInAnimator != null && mNewBubbleScaleInAnimator.isRunning()) {
return getExpandedBubbleTranslationXDuringScaleAnimation(
bubbleIndex, bubbleCount, onLeft);
} else if (onLeft) {
return (bubbleCount - bubbleIndex - 1) * iconAndSpacing;
} else {
// Bubbles ordered left to right, don't move the first bubble
return bubbleIndex * (mIconSize + mExpandedBarIconsSpacing);
return bubbleIndex * iconAndSpacing;
}
}
/**
* Returns the translation X for the bubble at index {@code bubbleIndex} when the bubble bar is
* expanded <b>and</b> a new bubble is animating in.
*
* <p>This method assumes that the animation is running so callers are expected to verify that
* before calling it.
*/
private float getExpandedBubbleTranslationXDuringScaleAnimation(
int bubbleIndex, int bubbleCount, boolean onLeft) {
// when the new bubble scale animation is running, a new bubble is animating in while the
// bubble bar is expanded, so we have at least 2 bubbles in the bubble bar - the expanded
// one, and the new one animating in.
if (mNewBubbleScaleInAnimator == null) {
// callers of this method are expected to verify that the animation is running, but the
// compiler doesn't know that.
return 0;
}
final float iconAndSpacing = mIconSize + mExpandedBarIconsSpacing;
final float newBubbleScale = mNewBubbleScaleInAnimator.getAnimatedFraction();
// the new bubble is scaling in from the center, so we need to adjust its translation so
// that the distance to the adjacent bubble scales at the same rate.
final float pivotAdjustment = -(1 - newBubbleScale) * mIconSize / 2f;
if (onLeft) {
if (bubbleIndex == 0) {
// this is the animating bubble. use scaled spacing between it and the bubble to
// its left
return (bubbleCount - 1) * mIconSize
+ (bubbleCount - 2) * mExpandedBarIconsSpacing
+ newBubbleScale * mExpandedBarIconsSpacing
+ pivotAdjustment;
}
// when the bubble bar is on the left, only the translation of the right-most bubble
// is affected by the scale animation.
return (bubbleCount - bubbleIndex - 1) * iconAndSpacing;
} else if (bubbleIndex == 0) {
// the bubble bar is on the right, and this is the animating bubble. it only needs
// to be adjusted for the scaling pivot.
return pivotAdjustment;
} else {
return iconAndSpacing * (bubbleIndex - 1 + newBubbleScale);
}
}
@@ -804,7 +895,7 @@ public class BubbleBarView extends FrameLayout {
addViewInLayout(child, i, child.getLayoutParams());
}
}
updateChildrenRenderNodeProperties(mBubbleBarLocation);
updateBubblesLayoutProperties(mBubbleBarLocation);
updateContentDescription();
}
}
@@ -883,15 +974,9 @@ public class BubbleBarView extends FrameLayout {
private float arrowPositionForSelectedWhenExpanded(BubbleBarLocation bubbleBarLocation) {
final int index = indexOfChild(mSelectedBubbleView);
final int bubblePosition;
if (bubbleBarLocation.isOnLeft(isLayoutRtl())) {
// Bubble positions are reversed. First bubble is on the right.
bubblePosition = getChildCount() - index - 1;
} else {
bubblePosition = index;
}
return getPaddingStart() + bubblePosition * (mIconSize + mExpandedBarIconsSpacing)
+ mIconSize / 2f;
final float selectedBubbleTranslationX = getExpandedBubbleTranslationX(
index, getChildCount(), bubbleBarLocation.isOnLeft(isLayoutRtl()));
return getPaddingStart() + selectedBubbleTranslationX + mIconSize / 2f;
}
private float arrowPositionForSelectedWhenCollapsed(BubbleBarLocation bubbleBarLocation) {
@@ -954,8 +1039,19 @@ public class BubbleBarView extends FrameLayout {
final int childCount = getChildCount();
final int horizontalPadding = getPaddingStart() + getPaddingEnd();
// spaces amount is less than child count by 1, or 0 if no child views
int spacesCount = Math.max(childCount - 1, 0);
return childCount * mIconSize + spacesCount * mExpandedBarIconsSpacing + horizontalPadding;
final float totalSpace;
final float totalIconSize;
if (mNewBubbleScaleInAnimator != null && mNewBubbleScaleInAnimator.isRunning()) {
// when this animation is running, a new bubble is animating in while the bubble bar is
// expanded, so we have at least 2 bubbles in the bubble bar.
final float newBubbleScale = mNewBubbleScaleInAnimator.getAnimatedFraction();
totalSpace = (childCount - 2 + newBubbleScale) * mExpandedBarIconsSpacing;
totalIconSize = (childCount - 1 + newBubbleScale) * mIconSize;
} else {
totalSpace = Math.max(childCount - 1, 0) * mExpandedBarIconsSpacing;
totalIconSize = childCount * mIconSize;
}
return totalIconSize + totalSpace + horizontalPadding;
}
private float collapsedWidth() {
@@ -402,8 +402,8 @@ public class BubbleBarViewController {
*/
public void addBubble(BubbleBarItem b, boolean isExpanding, boolean suppressAnimation) {
if (b != null) {
mBarView.addView(b.getView(), 0,
new FrameLayout.LayoutParams(mIconSize, mIconSize, Gravity.LEFT));
mBarView.addBubble(
b.getView(), new FrameLayout.LayoutParams(mIconSize, mIconSize, Gravity.LEFT));
b.getView().setOnClickListener(mBubbleClickListener);
mBubbleDragController.setupBubbleView(b.getView());
@@ -75,7 +75,7 @@ public class RecentTasksList {
private ArrayList<ActivityManager.RunningTaskInfo> mRunningTasks;
public RecentTasksList(LooperExecutor mainThreadExecutor, KeyguardManager keyguardManager,
SystemUiProxy sysUiProxy) {
SystemUiProxy sysUiProxy, TopTaskTracker topTaskTracker) {
mMainThreadExecutor = mainThreadExecutor;
mKeyguardManager = keyguardManager;
mChangeId = 1;
@@ -106,6 +106,13 @@ public class RecentTasksList {
RecentTasksList.this.onRunningTaskChanged(taskInfo);
});
}
@Override
public void onTaskMovedToFront(ActivityManager.RunningTaskInfo taskInfo) {
mMainThreadExecutor.execute(() -> {
topTaskTracker.onTaskMovedToFront(taskInfo);
});
}
});
// We may receive onRunningTaskAppeared events later for tasks which have already been
// included in the list returned by mSysUiProxy.getRunningTasks(), or may receive
@@ -135,7 +142,7 @@ public class RecentTasksList {
* Asynchronously fetches the list of recent tasks, reusing cached list if available.
*
* @param loadKeysOnly Whether to load other associated task data, or just the key
* @param callback The callback to receive the list of recent tasks
* @param callback The callback to receive the list of recent tasks
* @return The change id of the current task list
*/
public synchronized int getTasks(boolean loadKeysOnly,
@@ -200,7 +207,7 @@ public class RecentTasksList {
mChangeId++;
}
/**
/**
* Registers a listener for running tasks
*/
public void registerRunningTasksListener(RecentsModel.RunningTasksListener listener) {
@@ -90,7 +90,8 @@ public class RecentsModel implements RecentTasksDataSource, IconChangeListener,
this(context,
new RecentTasksList(MAIN_EXECUTOR,
context.getSystemService(KeyguardManager.class),
SystemUiProxy.INSTANCE.get(context)),
SystemUiProxy.INSTANCE.get(context),
TopTaskTracker.INSTANCE.get(context)),
new TaskIconCache(context, RECENTS_MODEL_EXECUTOR, iconProvider),
new TaskThumbnailCache(context, RECENTS_MODEL_EXECUTOR),
iconProvider,
@@ -64,7 +64,7 @@ public class TopTaskTracker extends ISplitScreenListener.Stub
implements TaskStackChangeListener, SafeCloseable {
private static final String TAG = "TopTaskTracker";
private static final boolean DEBUG = true;
public static MainThreadInitializedObject<TopTaskTracker> INSTANCE =
@@ -204,7 +204,7 @@ public class TopTaskTracker extends ISplitScreenListener.Stub
/**
* @return index 0 will be task in left/top position, index 1 in right/bottom position.
* Will return empty array if device is not in staged split
* Will return empty array if device is not in staged split
*/
public int[] getRunningSplitTaskIds() {
if (mMainStagePosition.taskId == INVALID_TASK_ID
@@ -337,7 +337,7 @@ public class TopTaskTracker extends ISplitScreenListener.Stub
*/
public Task[] getPlaceholderTasks() {
return mTopTask == null ? new Task[0]
: new Task[] {Task.from(new TaskKey(mTopTask), mTopTask, false)};
: new Task[]{Task.from(new TaskKey(mTopTask), mTopTask, false)};
}
/**
@@ -510,6 +510,9 @@ public class TouchInteractionService extends Service {
private boolean isTrackpadDevice(int deviceId) {
InputDevice inputDevice = mInputManager.getInputDevice(deviceId);
if (inputDevice == null) {
return false;
}
return inputDevice.getSources() == (InputDevice.SOURCE_MOUSE
| InputDevice.SOURCE_TOUCHPAD);
}
@@ -576,6 +579,7 @@ public class TouchInteractionService extends Service {
mMainChoreographer = Choreographer.getInstance();
mAM = ActivityManagerWrapper.getInstance();
mDeviceState = new RecentsAnimationDeviceState(this, true);
mRotationTouchHelper = mDeviceState.getRotationTouchHelper();
mAllAppsActionManager = new AllAppsActionManager(
this, UI_HELPER_EXECUTOR, this::createAllAppsPendingIntent);
mInputManager = getSystemService(InputManager.class);
@@ -588,7 +592,6 @@ public class TouchInteractionService extends Service {
}
}
mTaskbarManager = new TaskbarManager(this, mAllAppsActionManager, mNavCallbacks);
mRotationTouchHelper = mDeviceState.getRotationTouchHelper();
mInputConsumer = InputConsumerController.getRecentsAnimationInputConsumer();
// Call runOnUserUnlocked() before any other callbacks to ensure everything is initialized.
@@ -48,6 +48,8 @@ public class RecentTasksListTest {
@Mock
private SystemUiProxy mockSystemUiProxy;
@Mock
private TopTaskTracker mTopTaskTracker;
// Class under test
private RecentTasksList mRecentTasksList;
@@ -58,7 +60,7 @@ public class RecentTasksListTest {
LooperExecutor mockMainThreadExecutor = mock(LooperExecutor.class);
KeyguardManager mockKeyguardManager = mock(KeyguardManager.class);
mRecentTasksList = new RecentTasksList(mockMainThreadExecutor, mockKeyguardManager,
mockSystemUiProxy);
mockSystemUiProxy, mTopTaskTracker);
}
@Test
@@ -49,6 +49,7 @@ public class TaplPrivateSpaceTest extends AbstractQuickStepTest {
private static final String PRIVATE_PROFILE_NAME = "LauncherPrivateProfile";
private static final String INSTALLED_APP_NAME = "Aardwolf";
private static final int MAX_STATE_TOGGLE_TRIES = 2;
private static final String TAG = "TaplPrivateSpaceTest";
@Override
@@ -172,7 +173,9 @@ public class TaplPrivateSpaceTest extends AbstractQuickStepTest {
HomeAllApps homeAllApps = mLauncher.getAllApps();
// Disable Private Space
togglePrivateSpace(PrivateProfileManager.STATE_DISABLED, homeAllApps);
togglePrivateSpaceWithRetry(PrivateProfileManager.STATE_DISABLED, homeAllApps);
// Scroll to the bottom of All Apps
executeOnLauncher(launcher -> launcher.getAppsView().resetAndScrollToPrivateSpaceHeader());
homeAllApps.freeze();
try {
@@ -184,7 +187,9 @@ public class TaplPrivateSpaceTest extends AbstractQuickStepTest {
}
// Enable Private Space
togglePrivateSpace(PrivateProfileManager.STATE_ENABLED, homeAllApps);
togglePrivateSpaceWithRetry(PrivateProfileManager.STATE_ENABLED, homeAllApps);
// Scroll to the bottom of All Apps
executeOnLauncher(launcher -> launcher.getAppsView().resetAndScrollToPrivateSpaceHeader());
homeAllApps.freeze();
try {
@@ -217,6 +222,25 @@ public class TaplPrivateSpaceTest extends AbstractQuickStepTest {
waitForLauncherUIUpdate();
}
private void togglePrivateSpaceWithRetry(int state, HomeAllApps homeAllApps) {
int togglePsCount = 0;
boolean shouldRetry;
do {
togglePsCount ++;
try {
togglePrivateSpace(state, homeAllApps);
// No need to retry if the toggle was successful.
shouldRetry = false;
} catch (AssertionError error) {
if (togglePsCount < MAX_STATE_TOGGLE_TRIES) {
shouldRetry = true;
} else {
throw error;
}
}
} while (shouldRetry);
}
private void waitForPrivateSpaceSetup() {
waitForLauncherCondition("Private Profile not setup",
launcher -> launcher.getAppsView().hasPrivateProfile(),
+3 -1
View File
@@ -164,6 +164,7 @@ import androidx.annotation.VisibleForTesting;
import androidx.core.os.BuildCompat;
import androidx.window.embedding.RuleController;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DropTarget.DragObject;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.allapps.ActivityAllAppsContainerView;
@@ -2783,7 +2784,8 @@ public class Launcher extends StatefulActivity<LauncherState>
}
private void updateDisallowBack() {
if (BuildCompat.isAtLeastV() && Flags.enableDesktopWindowingMode()) {
if (BuildCompat.isAtLeastV() && Flags.enableDesktopWindowingMode()
&& mDeviceProfile.isTablet) {
// TODO(b/330183377) disable back in launcher when when we productionize
return;
}
@@ -17,9 +17,8 @@
package com.android.launcher3
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.test.platform.app.InstrumentationRegistry
@@ -27,28 +26,20 @@ import com.android.launcher3.UtilitiesKt.CLIP_CHILDREN_FALSE_MODIFIER
import com.android.launcher3.UtilitiesKt.CLIP_TO_PADDING_FALSE_MODIFIER
import com.android.launcher3.UtilitiesKt.modifyAttributesOnViewTree
import com.android.launcher3.UtilitiesKt.restoreAttributesOnViewTree
import com.android.launcher3.tests.R
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@SmallTest
@RunWith(AndroidJUnit4::class)
class UtilitiesKtTest {
val context: Context = InstrumentationRegistry.getInstrumentation().context
private lateinit var rootView: ViewGroup
private lateinit var midView: ViewGroup
private lateinit var childView: View
@Before
fun setup() {
rootView =
LayoutInflater.from(context).inflate(R.layout.utilities_test_view, null) as ViewGroup
midView = rootView.requireViewById(R.id.mid_view)
childView = rootView.requireViewById(R.id.child_view)
}
private val childView = TextView(context)
private val midView = LinearLayout(context).apply { addView(childView) }
private val rootView = LinearLayout(context).apply { addView(midView) }
@Test
fun set_clipChildren_false() {
-33
View File
@@ -1,33 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2024 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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/root_view">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/mid_view">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/child_view" />
</LinearLayout>
</LinearLayout>