From 61212d12f949ebc00f15d163a0ff9a62d2263696 Mon Sep 17 00:00:00 2001 From: y Date: Wed, 25 Aug 2021 11:58:46 -0700 Subject: [PATCH 1/4] [Work] Fix duplicate work button issue Bug: 195623679 Test: manual Change-Id: I882c5f7a196e07fa0dab3a2f27437abd233ec782 (cherry picked from commit cb5bb989e3e8b2d0b43f8a97aeefdfc1389eeaae) --- .../allapps/AllAppsContainerView.java | 20 ++++++++++--------- .../launcher3/allapps/WorkModeSwitch.java | 12 +++++------ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index f420ec2f08..9c61c1b69f 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -454,7 +454,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo mAllAppsStore.unregisterIconContainer(mAH[AdapterHolder.WORK].recyclerView); if (mUsingTabs) { - setupWorkToggle(); mAH[AdapterHolder.MAIN].setup(mViewPager.getChildAt(0), mPersonalMatcher); mAH[AdapterHolder.WORK].setup(mViewPager.getChildAt(1), mWorkMatcher); mAH[AdapterHolder.WORK].recyclerView.setId(R.id.apps_list_view_work); @@ -485,6 +484,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo } private void setupWorkToggle() { + removeWorkToggle(); if (Utilities.ATLEAST_P) { mWorkModeSwitch = (WorkModeSwitch) mLauncher.getLayoutInflater().inflate( R.layout.work_mode_fab, this, false); @@ -497,6 +497,14 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo } } + private void removeWorkToggle() { + if (mWorkModeSwitch == null) return; + if (mWorkModeSwitch.getParent() == this) { + this.removeView(mWorkModeSwitch); + } + mWorkModeSwitch = null; + } + private void replaceRVContainer(boolean showTabs) { for (int i = 0; i < mAH.length; i++) { AllAppsRecyclerView rv = mAH[i].recyclerView; @@ -519,8 +527,10 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo mViewPager = (AllAppsPagedView) newView; mViewPager.initParentViews(this); mViewPager.getPageIndicator().setOnActivePageChangedListener(this); + setupWorkToggle(); } else { mViewPager = null; + removeWorkToggle(); } } @@ -539,14 +549,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo mWorkModeSwitch.setWorkTabVisible(currentActivePage == AdapterHolder.WORK && mAllAppsStore.hasModelFlag( FLAG_HAS_SHORTCUT_PERMISSION | FLAG_QUIET_MODE_CHANGE_PERMISSION)); - - if (currentActivePage == AdapterHolder.WORK) { - if (mWorkModeSwitch.getParent() == null) { - addView(mWorkModeSwitch); - } - } else { - removeView(mWorkModeSwitch); - } } } diff --git a/src/com/android/launcher3/allapps/WorkModeSwitch.java b/src/com/android/launcher3/allapps/WorkModeSwitch.java index a800d34758..5d3af08b46 100644 --- a/src/com/android/launcher3/allapps/WorkModeSwitch.java +++ b/src/com/android/launcher3/allapps/WorkModeSwitch.java @@ -51,6 +51,7 @@ public class WorkModeSwitch extends Button implements Insettable, View.OnClickLi @Nullable private KeyboardInsetAnimationCallback mKeyboardInsetAnimationCallback; + private boolean mWorkTabVisible; public WorkModeSwitch(Context context) { this(context, null, 0); @@ -91,11 +92,10 @@ public class WorkModeSwitch extends Button implements Insettable, View.OnClickLi */ public void setWorkTabVisible(boolean workTabVisible) { clearAnimation(); - if (workTabVisible) { + mWorkTabVisible = workTabVisible; + if (workTabVisible && mWorkEnabled) { setEnabled(true); - if (mWorkEnabled) { - setVisibility(VISIBLE); - } + setVisibility(VISIBLE); setAlpha(0); animate().alpha(1).start(); } else { @@ -105,7 +105,7 @@ public class WorkModeSwitch extends Button implements Insettable, View.OnClickLi @Override public void onClick(View view) { - if (Utilities.ATLEAST_P) { + if (Utilities.ATLEAST_P && mWorkTabVisible) { setEnabled(false); Launcher.fromContext(getContext()).getStatsLogManager().logger().log( LAUNCHER_TURN_OFF_WORK_APPS_TAP); @@ -137,7 +137,7 @@ public class WorkModeSwitch extends Button implements Insettable, View.OnClickLi @Override public WindowInsets onApplyWindowInsets(WindowInsets insets) { - if (Utilities.ATLEAST_R) { + if (Utilities.ATLEAST_R && mWorkTabVisible) { setTranslationY(0); if (insets.isVisible(WindowInsets.Type.ime())) { Insets keyboardInsets = insets.getInsets(WindowInsets.Type.ime()); From 5a36b919b5bd91ba37f907ae98df96c2f749e094 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Fri, 3 Sep 2021 15:00:08 -0700 Subject: [PATCH 2/4] Call onUserUnlocked() before adding callbacks This gives us a chance to initialize things in onUserUnlocked() if we're already unlocked, before doing any other logic that might use those variables. Test: None (unable to reproduce) Fixes: 184773649 Change-Id: I72ed91ae6202ec816f9bdceb4d9fd03b9a002816 --- .../com/android/quickstep/TouchInteractionService.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index db5c93c503..0f5671c543 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -331,12 +331,14 @@ public class TouchInteractionService extends Service implements PluginListener Date: Fri, 3 Sep 2021 16:33:35 -0700 Subject: [PATCH 3/4] Use max of corners when deciding gestures and add logs for corners Bug: 197326121 Test: Pre/postsubmit Change-Id: I1c083dc9234354f66cf1537f0cfe8c21f1e1be3b --- .../com/android/launcher3/tapl/LauncherInstrumentation.java | 4 +++- tests/tapl/com/android/launcher3/tapl/Workspace.java | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index e3f35e1f8c..98d081b70a 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -1561,6 +1561,7 @@ public final class LauncherInstrumentation { float getWindowCornerRadius() { final Resources resources = getResources(); if (!supportsRoundedCornersOnWindows(resources)) { + Log.d(TAG, "No rounded corners"); return 0f; } @@ -1579,7 +1580,8 @@ public final class LauncherInstrumentation { // Always use the smallest radius to make sure the rounded corners will // completely cover the display. - return Math.min(topRadius, bottomRadius); + Log.d(TAG, "Rounded corners top: " + topRadius + " bottom: " + bottomRadius); + return Math.max(topRadius, bottomRadius); } private static boolean supportsRoundedCornersOnWindows(Resources resources) { diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java index db2e250bd3..288c85319b 100644 --- a/tests/tapl/com/android/launcher3/tapl/Workspace.java +++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java @@ -83,9 +83,9 @@ public final class Workspace extends Home { + mLauncher.getTouchSlop()); mLauncher.swipeToState( - 0, + windowCornerRadius, startY, - 0, + windowCornerRadius, startY - swipeHeight - mLauncher.getTouchSlop(), 12, ALL_APPS_STATE_ORDINAL, LauncherInstrumentation.GestureScope.INSIDE); From 58dd901bc17c8cb24309df4863f5c12fbcb71632 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Fri, 3 Sep 2021 16:31:29 -0700 Subject: [PATCH 4/4] Select remote apps based on stagePosition instead of hardcoded values * LauncherSplitScreenListener returns taskIds guaranteeing index 0 to be leftTop task and index 1 to be rightBottom. Use that instead of assuming remote target index 0 will be leftTop and index 1 is right bottom as provided Bug: 181704764 Change-Id: I2bc358ff3c2f2d127b81e10824e2c13f3ad718df --- .../src/com/android/quickstep/SwipeUpAnimationLogic.java | 6 ++++-- .../src/com/android/quickstep/util/TaskViewSimulator.java | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java index e14dbb181b..78de3004b4 100644 --- a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java +++ b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java @@ -289,9 +289,11 @@ public abstract class SwipeUpAnimationLogic implements mRemoteTargetHandles[0].mTaskViewSimulator.setPreview(primaryTaskTarget); } } else { + int[] taskIds = LauncherSplitScreenListener.INSTANCE.getNoCreate() + .getRunningSplitTaskIds(); // We're in staged split - primaryTaskTarget = targets.apps[0]; - secondaryTaskTarget = targets.apps[1]; + primaryTaskTarget = targets.findTask(taskIds[0]); + secondaryTaskTarget = targets.findTask(taskIds[1]); mStagedSplitBounds = new SplitConfigurationOptions.StagedSplitBounds( primaryTaskTarget.screenSpaceBounds, secondaryTaskTarget.screenSpaceBounds, dividerTarget.screenSpaceBounds); diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index 9960fd341c..a089e7304c 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -51,8 +51,8 @@ import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat. */ public class TaskViewSimulator implements TransformParams.BuilderProxy { - private final String TAG = "TaskViewSimulator"; - private final boolean DEBUG = false; + private static final String TAG = "TaskViewSimulator"; + private static final boolean DEBUG = false; private final Rect mTmpCropRect = new Rect(); private final RectF mTempRectF = new RectF();