Merge "Make divider bar flings smoother when snap-to-dismiss split" into sc-v2-dev am: 70fb265591
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15480930 Change-Id: Ic09439e999fe5b3ac55471eb719a81ef806fd05a
This commit is contained in:
@@ -41,6 +41,7 @@ import android.window.WindowContainerTransaction;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.policy.DividerSnapAlgorithm;
|
||||
import com.android.wm.shell.ShellTaskOrganizer;
|
||||
import com.android.wm.shell.animation.Interpolators;
|
||||
@@ -249,15 +250,15 @@ public final class SplitLayout {
|
||||
public void snapToTarget(int currentPosition, DividerSnapAlgorithm.SnapTarget snapTarget) {
|
||||
switch (snapTarget.flag) {
|
||||
case FLAG_DISMISS_START:
|
||||
mSplitLayoutHandler.onSnappedToDismiss(false /* bottomOrRight */);
|
||||
mSplitWindowManager.setResizingSplits(false);
|
||||
flingDividePosition(currentPosition, snapTarget.position,
|
||||
() -> mSplitLayoutHandler.onSnappedToDismiss(false /* bottomOrRight */));
|
||||
break;
|
||||
case FLAG_DISMISS_END:
|
||||
mSplitLayoutHandler.onSnappedToDismiss(true /* bottomOrRight */);
|
||||
mSplitWindowManager.setResizingSplits(false);
|
||||
flingDividePosition(currentPosition, snapTarget.position,
|
||||
() -> mSplitLayoutHandler.onSnappedToDismiss(true /* bottomOrRight */));
|
||||
break;
|
||||
default:
|
||||
flingDividePosition(currentPosition, snapTarget.position);
|
||||
flingDividePosition(currentPosition, snapTarget.position, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -287,7 +288,8 @@ public final class SplitLayout {
|
||||
isLandscape ? DOCKED_LEFT : DOCKED_TOP /* dockSide */);
|
||||
}
|
||||
|
||||
private void flingDividePosition(int from, int to) {
|
||||
@VisibleForTesting
|
||||
void flingDividePosition(int from, int to, @Nullable Runnable flingFinishedCallback) {
|
||||
if (from == to) {
|
||||
// No animation run, it should stop resizing here.
|
||||
mSplitWindowManager.setResizingSplits(false);
|
||||
@@ -303,6 +305,9 @@ public final class SplitLayout {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
setDividePosition(to);
|
||||
if (flingFinishedCallback != null) {
|
||||
flingFinishedCallback.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,6 +24,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.content.res.Configuration;
|
||||
@@ -42,6 +43,8 @@ import com.android.wm.shell.common.DisplayImeController;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
@@ -53,19 +56,20 @@ public class SplitLayoutTests extends ShellTestCase {
|
||||
@Mock SurfaceControl mRootLeash;
|
||||
@Mock DisplayImeController mDisplayImeController;
|
||||
@Mock ShellTaskOrganizer mTaskOrganizer;
|
||||
@Captor ArgumentCaptor<Runnable> mRunnableCaptor;
|
||||
private SplitLayout mSplitLayout;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mSplitLayout = new SplitLayout(
|
||||
mSplitLayout = spy(new SplitLayout(
|
||||
"TestSplitLayout",
|
||||
mContext,
|
||||
getConfiguration(),
|
||||
mSplitLayoutHandler,
|
||||
b -> b.setParent(mRootLeash),
|
||||
mDisplayImeController,
|
||||
mTaskOrganizer);
|
||||
mTaskOrganizer));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -109,18 +113,33 @@ public class SplitLayoutTests extends ShellTestCase {
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testSnapToDismissTarget() {
|
||||
public void testSnapToDismissStart() {
|
||||
// verify it callbacks properly when the snap target indicates dismissing split.
|
||||
DividerSnapAlgorithm.SnapTarget snapTarget = getSnapTarget(0 /* position */,
|
||||
DividerSnapAlgorithm.SnapTarget.FLAG_DISMISS_START);
|
||||
|
||||
mSplitLayout.snapToTarget(0 /* currentPosition */, snapTarget);
|
||||
waitDividerFlingFinished();
|
||||
verify(mSplitLayoutHandler).onSnappedToDismiss(eq(false));
|
||||
snapTarget = getSnapTarget(0 /* position */,
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testSnapToDismissEnd() {
|
||||
// verify it callbacks properly when the snap target indicates dismissing split.
|
||||
DividerSnapAlgorithm.SnapTarget snapTarget = getSnapTarget(0 /* position */,
|
||||
DividerSnapAlgorithm.SnapTarget.FLAG_DISMISS_END);
|
||||
|
||||
mSplitLayout.snapToTarget(0 /* currentPosition */, snapTarget);
|
||||
waitDividerFlingFinished();
|
||||
verify(mSplitLayoutHandler).onSnappedToDismiss(eq(true));
|
||||
}
|
||||
|
||||
private void waitDividerFlingFinished() {
|
||||
verify(mSplitLayout).flingDividePosition(anyInt(), anyInt(), mRunnableCaptor.capture());
|
||||
mRunnableCaptor.getValue().run();
|
||||
}
|
||||
|
||||
private static Configuration getConfiguration() {
|
||||
final Configuration configuration = new Configuration();
|
||||
configuration.unset();
|
||||
|
||||
Reference in New Issue
Block a user