Merge "Reapply "add more unit tests for WorkspaceItemProcessor"" into main
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
index 110c30f..db069d5 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
@@ -120,6 +120,7 @@
// Whether the bar is expanded (i.e. the bubble activity is being displayed).
private boolean mIsBarExpanded = false;
// The currently selected bubble view.
+ @Nullable
private BubbleView mSelectedBubbleView;
private BubbleBarLocation mBubbleBarLocation = BubbleBarLocation.DEFAULT;
// The click listener when the bubble bar is collapsed.
@@ -205,6 +206,7 @@
// If the bar was just collapsed and the overflow was the last bubble that was
// selected, set the first bubble as selected.
if (!mIsBarExpanded && mUpdateSelectedBubbleAfterCollapse != null
+ && mSelectedBubbleView != null
&& mSelectedBubbleView.getBubble() instanceof BubbleBarOverflow) {
BubbleView firstBubble = (BubbleView) getChildAt(0);
mUpdateSelectedBubbleAfterCollapse.accept(firstBubble.getBubble().getKey());
@@ -534,6 +536,10 @@
@Override
public void removeView(View view) {
super.removeView(view);
+ if (view == mSelectedBubbleView) {
+ mSelectedBubbleView = null;
+ mBubbleBarBackground.showArrow(false);
+ }
updateWidth();
}
@@ -689,8 +695,12 @@
* Sets which bubble view should be shown as selected.
*/
public void setSelectedBubble(BubbleView view) {
+ BubbleView previouslySelectedBubble = mSelectedBubbleView;
mSelectedBubbleView = view;
- updateArrowForSelected(/* shouldAnimate= */ true);
+ mBubbleBarBackground.showArrow(view != null);
+ // TODO: (b/283309949) remove animation should be implemented first, so than arrow
+ // animation is adjusted, skip animation for now
+ updateArrowForSelected(previouslySelectedBubble != null);
}
/**
@@ -715,6 +725,10 @@
// Find the center of the bubble when it's expanded, set the arrow position to it.
final float tx = arrowPositionForSelectedWhenExpanded();
final float currentArrowPosition = mBubbleBarBackground.getArrowPositionX();
+ if (tx == currentArrowPosition) {
+ // arrow position remains unchanged
+ return;
+ }
if (shouldAnimate && currentArrowPosition > expandedWidth()) {
Log.d(TAG, "arrow out of bounds of expanded view, skip animation");
shouldAnimate = false;
diff --git a/quickstep/src/com/android/quickstep/views/DesktopTaskView.java b/quickstep/src/com/android/quickstep/views/DesktopTaskView.java
index 87820f2..93059b2 100644
--- a/quickstep/src/com/android/quickstep/views/DesktopTaskView.java
+++ b/quickstep/src/com/android/quickstep/views/DesktopTaskView.java
@@ -39,7 +39,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.desktop.DesktopRecentsTransitionController;
@@ -309,16 +308,7 @@
@Override
protected void setThumbnailOrientation(RecentsOrientedState orientationState) {
- DeviceProfile deviceProfile = mContainer.getDeviceProfile();
- int thumbnailTopMargin = deviceProfile.overviewTaskThumbnailTopMarginPx;
-
- LayoutParams snapshotParams = (LayoutParams) mTaskThumbnailViewDeprecated.getLayoutParams();
- snapshotParams.topMargin = thumbnailTopMargin;
-
- for (int i = 0; i < mSnapshotViewMap.size(); i++) {
- TaskThumbnailViewDeprecated thumbnailView = mSnapshotViewMap.valueAt(i);
- thumbnailView.setLayoutParams(snapshotParams);
- }
+ // no-op
}
@Override
diff --git a/quickstep/tests/src/com/android/quickstep/AbstractTaplTestsTaskbar.java b/quickstep/tests/src/com/android/quickstep/AbstractTaplTestsTaskbar.java
index ca5fb70..fc757b4 100644
--- a/quickstep/tests/src/com/android/quickstep/AbstractTaplTestsTaskbar.java
+++ b/quickstep/tests/src/com/android/quickstep/AbstractTaplTestsTaskbar.java
@@ -55,7 +55,7 @@
"com.android.launcher3.testcomponent.BaseTestingActivity");
mLauncherLayout = TestUtil.setLauncherDefaultLayout(mTargetContext, layoutBuilder);
AbstractLauncherUiTest.initialize(this);
- startAppFastInFullscreen(CALCULATOR_APP_PACKAGE);
+ startAppFast(CALCULATOR_APP_PACKAGE);
mLauncher.enableBlockTimeout(true);
mLauncher.showTaskbarIfHidden();
}
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsKeyboardQuickSwitch.java b/quickstep/tests/src/com/android/quickstep/TaplTestsKeyboardQuickSwitch.java
index 7ab72f2..43ebb17 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsKeyboardQuickSwitch.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsKeyboardQuickSwitch.java
@@ -65,7 +65,7 @@
public void setUp() throws Exception {
Assume.assumeTrue(mLauncher.isTablet());
super.setUp();
- startAppFastInFullscreen(CALCULATOR_APP_PACKAGE);
+ startAppFast(CALCULATOR_APP_PACKAGE);
startTestActivity(2);
}
diff --git a/res/layout/private_space_header.xml b/res/layout/private_space_header.xml
index 84554e4..cefe394 100644
--- a/res/layout/private_space_header.xml
+++ b/res/layout/private_space_header.xml
@@ -25,7 +25,9 @@
android:clipToOutline="true"
android:gravity="center_vertical"
android:textDirection="locale"
- android:orientation="horizontal">
+ android:orientation="horizontal"
+ android:contentDescription="@string/ps_container_lock_button_content_description"
+ android:importantForAccessibility="yes">
<LinearLayout
android:id="@+id/settingsAndLockGroup"
@@ -49,7 +51,7 @@
android:background="@drawable/ps_lock_background"
android:gravity="center_vertical"
android:layout_marginEnd="@dimen/ps_lock_button_margin_end"
- android:contentDescription="@string/ps_container_lock_unlock_button">
+ android:contentDescription="@string/ps_container_lock_button_content_description">
<ImageView
android:id="@+id/lock_icon"
android:layout_width="@dimen/ps_lock_icon_size"
@@ -95,6 +97,7 @@
android:gravity="center_vertical"
android:layout_marginStart="@dimen/ps_header_layout_margin"
android:text="@string/ps_container_title"
- android:theme="@style/PrivateSpaceHeaderTextStyle"/>
+ android:theme="@style/PrivateSpaceHeaderTextStyle"
+ android:importantForAccessibility="no"/>
</RelativeLayout>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e1c7d64..da5b709 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -487,8 +487,10 @@
<string name="ps_container_title">Private</string>
<!-- Description for Private Space Settings button -->
<string name="ps_container_settings">Private Space Settings</string>
- <!-- Description for Private Space Lock/Unlock button -->
- <string name="ps_container_lock_unlock_button">Lock/Unlock Private Space</string>
+ <!-- Description for Private Space Unlock button -->
+ <string name="ps_container_unlock_button_content_description">Private, unlocked.</string>
+ <!-- Description for Private Space Lock button -->
+ <string name="ps_container_lock_button_content_description">Private, locked.</string>
<string name="ps_container_lock_title">Lock</string>
<!-- Description for Private Space Transition button -->
<string name="ps_container_transition">Private Space Transitioning</string>
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 1c23644..cc9f08e 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -485,7 +485,10 @@
super.onVisibilityAggregated(isVisible);
}
- protected boolean isPageInTransition() {
+ /**
+ * Returns true if the page is in the middle of transition to another page
+ */
+ public boolean isPageInTransition() {
return mIsPageInTransition;
}
diff --git a/src/com/android/launcher3/allapps/PrivateProfileManager.java b/src/com/android/launcher3/allapps/PrivateProfileManager.java
index 7e975df..551fa94 100644
--- a/src/com/android/launcher3/allapps/PrivateProfileManager.java
+++ b/src/com/android/launcher3/allapps/PrivateProfileManager.java
@@ -112,6 +112,8 @@
private Runnable mOnPSHeaderAdded;
@Nullable
private RelativeLayout mPSHeader;
+ private final String mLockedStateContentDesc;
+ private final String mUnLockedStateContentDesc;
public PrivateProfileManager(UserManager userManager,
ActivityAllAppsContainerView<?> allApps,
@@ -125,6 +127,10 @@
UI_HELPER_EXECUTOR.post(() -> initializeInBackgroundThread(appContext));
mPsHeaderHeight = mAllApps.getContext().getResources().getDimensionPixelSize(
R.dimen.ps_header_height);
+ mLockedStateContentDesc = mAllApps.getContext()
+ .getString(R.string.ps_container_lock_button_content_description);
+ mUnLockedStateContentDesc = mAllApps.getContext()
+ .getString(R.string.ps_container_unlock_button_content_description);
}
/** Adds Private Space Header to the layout. */
@@ -398,11 +404,13 @@
lockText.setVisibility(VISIBLE);
lockButton.setVisibility(VISIBLE);
lockButton.setOnClickListener(view -> lockingAction(/* lock */ true));
+ lockButton.setContentDescription(mUnLockedStateContentDesc);
}
case STATE_DISABLED -> {
lockText.setVisibility(GONE);
lockButton.setVisibility(VISIBLE);
lockButton.setOnClickListener(view -> lockingAction(/* lock */ false));
+ lockButton.setContentDescription(mLockedStateContentDesc);
}
default -> lockButton.setVisibility(GONE);
}
@@ -412,9 +420,14 @@
if (getCurrentState() == STATE_DISABLED) {
header.setOnClickListener(view -> lockingAction(/* lock */ false));
header.setClickable(true);
+ // Add header as accessibility target when disabled.
+ header.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
+ header.setContentDescription(mLockedStateContentDesc);
} else {
header.setOnClickListener(null);
header.setClickable(false);
+ // Remove header from accessibility target when enabled.
+ header.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
}
}
diff --git a/src/com/android/launcher3/keyboard/ItemFocusIndicatorHelper.java b/src/com/android/launcher3/keyboard/ItemFocusIndicatorHelper.java
index 456cde8..480e8f3 100644
--- a/src/com/android/launcher3/keyboard/ItemFocusIndicatorHelper.java
+++ b/src/com/android/launcher3/keyboard/ItemFocusIndicatorHelper.java
@@ -246,7 +246,8 @@
protected void setCurrentItem(T item) {
mCurrentItem = item;
- mShift = 0;
+ // Set it to end value directly to skip the animation for outline
+ mShift = Flags.enableFocusOutline() ? 1 : 0;
mTargetItem = null;
}
diff --git a/src/com/android/launcher3/keyboard/ViewGroupFocusHelper.java b/src/com/android/launcher3/keyboard/ViewGroupFocusHelper.java
index 4653bf1..21d157a 100644
--- a/src/com/android/launcher3/keyboard/ViewGroupFocusHelper.java
+++ b/src/com/android/launcher3/keyboard/ViewGroupFocusHelper.java
@@ -19,6 +19,7 @@
import android.graphics.Rect;
import android.view.View;
+import com.android.launcher3.Flags;
import com.android.launcher3.PagedView;
/**
@@ -35,6 +36,28 @@
}
@Override
+ protected boolean shouldDraw(View item) {
+ if (Flags.enableFocusOutline()) {
+ // Not draw outline in page transition because the outline just remains fully
+ // persistent during the transition and does not look smooth
+ return super.shouldDraw(item) && !isInPageTransition(item);
+ } else {
+ return super.shouldDraw(item);
+ }
+ }
+
+ private boolean isInPageTransition(View view) {
+ if (view == null || !(view.getParent() instanceof View)) {
+ return false;
+ }
+ boolean isInTransition = false;
+ if (view instanceof PagedView) {
+ isInTransition = ((PagedView<?>) view).isPageInTransition();
+ }
+ return isInTransition || isInPageTransition((View) view.getParent());
+ }
+
+ @Override
public void viewToRect(View v, Rect outRect) {
// Using FocusedRect here allows views to provide their custom rect for drawing outline,
// e.g. making the Rect bigger than the content to leave some padding between view and
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index 9c289d6..99e15ba 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -15,10 +15,7 @@
*/
package com.android.launcher3.ui;
-import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
-import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.platform.test.flag.junit.SetFlagsRule.DefaultInitValueType.DEVICE_DEFAULT;
-import static android.view.Display.DEFAULT_DISPLAY;
import static androidx.test.InstrumentationRegistry.getInstrumentation;
@@ -29,7 +26,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import android.app.ActivityOptions;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -575,21 +571,6 @@
true /* newTask */);
}
- /** alternative of startAppFast where app is guaranteed to launch in fullscreen mode */
- public static void startAppFastInFullscreen(String packageName) {
- ActivityOptions options = ActivityOptions.makeBasic();
- options.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN);
- options.setLaunchDisplayId(DEFAULT_DISPLAY);
- options.setLaunchActivityType(ACTIVITY_TYPE_STANDARD);
-
- startIntent(
- getInstrumentation().getContext().getPackageManager().getLaunchIntentForPackage(
- packageName),
- By.pkg(packageName).depth(0),
- true /* newTask */,
- options);
- }
-
public static void startTestActivity(String activityName, String activityLabel) {
final String packageName = getAppPackageName();
final Intent intent = getInstrumentation().getContext().getPackageManager().
@@ -625,8 +606,7 @@
false /* newTask */);
}
- private static void startIntent(
- Intent intent, BySelector selector, boolean newTask, ActivityOptions options) {
+ private static void startIntent(Intent intent, BySelector selector, boolean newTask) {
intent.addCategory(Intent.CATEGORY_LAUNCHER);
if (newTask) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
@@ -634,12 +614,7 @@
intent.addFlags(
Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
}
-
- if (options != null) {
- getInstrumentation().getTargetContext().startActivity(intent, options.toBundle());
- } else {
- getInstrumentation().getTargetContext().startActivity(intent);
- }
+ getInstrumentation().getTargetContext().startActivity(intent);
assertTrue("App didn't start: " + selector,
TestHelpers.wait(Until.hasObject(selector), DEFAULT_UI_TIMEOUT));
@@ -650,10 +625,6 @@
DEFAULT_ACTIVITY_TIMEOUT, launcherInstrumentation);
}
- private static void startIntent(Intent intent, BySelector selector, boolean newTask) {
- startIntent(intent, selector, newTask, null);
- }
-
public static ActivityInfo resolveSystemAppInfo(String category) {
return getInstrumentation().getContext().getPackageManager().resolveActivity(
new Intent(Intent.ACTION_MAIN).addCategory(category),
diff --git a/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java b/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java
index 9afde0d..490cff2 100644
--- a/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java
+++ b/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java
@@ -29,6 +29,7 @@
import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.util.LauncherLayoutBuilder;
import com.android.launcher3.util.TestUtil;
+import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord;
import org.junit.After;
import org.junit.Before;
@@ -67,6 +68,7 @@
* move between workspaces. After, make sure we can launch an app from the Workspace.
* @throws Exception if we can't set the defaults icons that will appear at the beginning.
*/
+ @ScreenRecord // b/331261431
@Test
public void testWorkspace() throws Exception {
// Set workspace that includes the chrome Activity app icon on the hotseat.