Merge "switching animation to screenshot to avoid visual jank" into udc-dev
diff --git a/quickstep/res/layout/redesigned_gesture_tutorial_fragment.xml b/quickstep/res/layout/redesigned_gesture_tutorial_fragment.xml
index 7d5505e..a1bcad0 100644
--- a/quickstep/res/layout/redesigned_gesture_tutorial_fragment.xml
+++ b/quickstep/res/layout/redesigned_gesture_tutorial_fragment.xml
@@ -124,7 +124,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
- android:scaleType="centerCrop"
+ android:scaleType="matrix"
app:lottie_loop="true" />
</RelativeLayout>
diff --git a/quickstep/res/values/strings.xml b/quickstep/res/values/strings.xml
index 3b82784..6d0dbae 100644
--- a/quickstep/res/values/strings.xml
+++ b/quickstep/res/values/strings.xml
@@ -98,16 +98,17 @@
<string name="gesture_tutorial_rotation_prompt_title">Rotate your device</string>
<!-- Prompt shown before the gesture navigation tutorial to users who need to rotate their screen to begin. [CHAR LIMIT=100] -->
<string name="gesture_tutorial_rotation_prompt">Please rotate your device to complete the gesture navigation tutorial</string>
+
<!-- Feedback shown during interactive parts of Back gesture tutorial for right edge when the gesture is too far from the edge. [CHAR LIMIT=100] -->
- <string name="back_gesture_feedback_swipe_too_far_from_edge">Make sure you swipe from the far-right or far-left edge.</string>
+ <string name="back_gesture_feedback_swipe_too_far_from_edge">Make sure you swipe from the far-right or far-left edge</string>
<!-- Feedback shown during interactive parts of Back gesture tutorial for right edge when the gesture is cancelled. [CHAR LIMIT=100] -->
- <string name="back_gesture_feedback_cancelled">Make sure you swipe from the right or left edge to the middle of the screen and let go.</string>
+ <string name="back_gesture_feedback_cancelled">Make sure you swipe from the right or left edge to the middle of the screen and let go</string>
<!-- Feedback shown after completing the back gesture step if the user is following the full gesture tutorial flow. [CHAR LIMIT=100] -->
<string name="back_gesture_feedback_complete_with_overview_follow_up">You learned how to swipe from the right to go back. Next up, learn how to switch apps.</string>
<!-- Feedback shown after completing the back gesture step if the user started this tutorial individually. [CHAR LIMIT=100] -->
- <string name="back_gesture_feedback_complete_without_follow_up">You completed the go back gesture.</string>
+ <string name="back_gesture_feedback_complete_without_follow_up">You completed the go back gesture</string>
<!-- Feedback shown during interactive parts of Back gesture tutorial when the gesture is within the nav bar region. [CHAR LIMIT=100] -->
- <string name="back_gesture_feedback_swipe_in_nav_bar">Make sure you don\'t swipe too close to the bottom of the screen.</string>
+ <string name="back_gesture_feedback_swipe_in_nav_bar">Make sure you don\'t swipe too close to the bottom of the screen</string>
<!-- Subtitle shown on the confirmation screen after successful gesture. [CHAR LIMIT=60] -->
<string name="back_gesture_tutorial_confirm_subtitle">To change the sensitivity of the back gesture, go to Settings</string>
<!-- Feedback shown during interactive parts of Home gesture tutorial when the gesture is started too far from the edge. [CHAR LIMIT=100] -->
@@ -119,16 +120,18 @@
<string name="back_gesture_spoken_intro_subtitle">To go back to the last screen, swipe with 2 fingers from the left or right edge to the middle of the screen.</string>
<!-- Title of the gesture tutorial section educating users on how to go back to the previous screen. [CHAR LIMIT=100] -->
<string name="back_gesture_tutorial_title">Go back</string>
+ <!-- Subtitle of the gesture tutorial section educating users on how to go to back to the previous screen [CHAR LIMIT=100] -->
+ <string name="back_gesture_tutorial_subtitle">Swipe from the left or right edge to the middle of the screen</string>
- <string name="home_gesture_feedback_swipe_too_far_from_edge">Make sure you swipe up from the bottom edge of the screen.</string>
+ <string name="home_gesture_feedback_swipe_too_far_from_edge">Make sure you swipe up from the bottom edge of the screen</string>
<!-- Feedback shown during interactive parts of Home gesture tutorial when the Overview gesture is detected. [CHAR LIMIT=100] -->
- <string name="home_gesture_feedback_overview_detected">Make sure you don\'t pause before letting go.</string>
+ <string name="home_gesture_feedback_overview_detected">Make sure you don\'t pause before letting go</string>
<!-- Feedback shown during interactive parts of Home gesture tutorial when the gesture is horizontal instead of vertical. [CHAR LIMIT=100] -->
- <string name="home_gesture_feedback_wrong_swipe_direction">Make sure you swipe straight up.</string>
+ <string name="home_gesture_feedback_wrong_swipe_direction">Make sure you swipe straight up</string>
<!-- Feedback shown after completing the home gesture step if the user is following the full gesture tutorial flow. [CHAR LIMIT=100] -->
- <string name="home_gesture_feedback_complete_with_follow_up">You completed the go Home gesture. Next up, learn how to go back.</string>
+ <string name="home_gesture_feedback_complete_with_follow_up">You completed the go home gesture. Next up, learn how to go back.</string>
<!-- Feedback shown after completing the home gesture step if the user started this tutorial individually. [CHAR LIMIT=100] -->
- <string name="home_gesture_feedback_complete_without_follow_up">You completed the go Home gesture.</string>
+ <string name="home_gesture_feedback_complete_without_follow_up">You completed the go home gesture</string>
<!-- Introduction title for the Home gesture tutorial. [CHAR LIMIT=100] -->
<string name="home_gesture_intro_title">Swipe to go home</string>
<!-- Introduction subtitle for the Home gesture tutorial. [CHAR LIMIT=100] -->
@@ -138,18 +141,20 @@
<!-- Title of the gesture tutorial section educating users on how to go to the home screen. [CHAR LIMIT=100] -->
<string name="home_gesture_tutorial_title">Go home</string>
<!-- Subtitle of the gesture tutorial section educating users on how to go to the home screen [CHAR LIMIT=100] -->
- <string name="home_gesture_tutorial_subtitle">To go to your home screen at any time, swipe up from the bottom of your screen</string>
+ <string name="home_gesture_tutorial_subtitle">Swipe up from the bottom of your screen</string>
+ <!-- Title message when users successfully learn to go to the home screen [CHAR LIMIT=100] -->
+ <string name="home_gesture_tutorial_success">Great job!</string>
<!-- Feedback shown during interactive parts of Overview gesture tutorial when the gesture is started too far from the edge. [CHAR LIMIT=100] -->
- <string name="overview_gesture_feedback_swipe_too_far_from_edge">Make sure you swipe up from the bottom edge of the screen.</string>
+ <string name="overview_gesture_feedback_swipe_too_far_from_edge">Make sure you swipe up from the bottom edge of the screen</string>
<!-- Feedback shown during interactive parts of Overview gesture tutorial when the Home gesture is detected. The window refers to the current app's window during the gesture. [CHAR LIMIT=100] -->
- <string name="overview_gesture_feedback_home_detected">Try holding the window for longer before releasing.</string>
+ <string name="overview_gesture_feedback_home_detected">Try holding the window for longer before releasing</string>
<!-- Feedback shown during interactive parts of Overview gesture tutorial when the gesture is horizontal instead of vertical. [CHAR LIMIT=100] -->
- <string name="overview_gesture_feedback_wrong_swipe_direction">Make sure you swipe straight up, then pause.</string>
+ <string name="overview_gesture_feedback_wrong_swipe_direction">Make sure you swipe straight up, then pause</string>
<!-- Feedback shown after completing the overview gesture step if the user is following the full gesture tutorial flow. [CHAR LIMIT=100] -->
<string name="overview_gesture_feedback_complete_with_follow_up">You learned how to use gestures. To turn off gestures, go to Settings.</string>
<!-- Feedback shown after completing the overview gesture step if the user started this tutorial individually. [CHAR LIMIT=100] -->
- <string name="overview_gesture_feedback_complete_without_follow_up">You completed the switch apps gesture.</string>
+ <string name="overview_gesture_feedback_complete_without_follow_up">You completed the switch apps gesture</string>
<!-- Introduction title for the Overview gesture tutorial. [CHAR LIMIT=100] -->
<string name="overview_gesture_intro_title">Swipe to switch apps</string>
<!-- Introduction subtitle for the Overview gesture tutorial. [CHAR LIMIT=100] -->
@@ -158,6 +163,11 @@
<string name="overview_gesture_spoken_intro_subtitle">To switch between apps, swipe up with 2 fingers from the bottom of your screen, hold, then release.</string>
<!-- Title of the gesture tutorial section educating users on how to switch between apps. [CHAR LIMIT=100] -->
<string name="overview_gesture_tutorial_title">Switch apps</string>
+ <!-- Subtitle of the gesture tutorial section educating users on how to switch between apps [CHAR LIMIT=100] -->
+ <string name="overview_gesture_tutorial_subtitle">Swipe up from the bottom of your screen, hold, then release</string>
+ <!-- Title message when users successfully learn to switch between apps [CHAR LIMIT=100] -->
+ <string name="overview_gesture_tutorial_success">Well done!</string>
+
<!-- Title shown during interactive part of Assistant gesture tutorial. [CHAR LIMIT=30] -->
<string name="assistant_gesture_tutorial_playground_title" translatable="false">Tutorial: Assistant</string>
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index 008f5f6..17e7e1b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -551,6 +551,12 @@
// updateValue ensures onIconAlignmentRatioChanged will be called if there is an actual
// change in value
mIconAlignment.updateValue(toAlignment);
+
+ // Make sure FLAG_IN_APP is set when launching applications from keyguard.
+ if (!isInLauncher) {
+ mControllers.taskbarStashController.updateStateForFlag(FLAG_IN_APP, true);
+ mControllers.taskbarStashController.applyState(0);
+ }
} else if (mIconAlignment.isAnimatingToValue(toAlignment)
|| mIconAlignment.isSettledOnValue(toAlignment)) {
// Already at desired value, but make sure we run the callback at the end.
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
index 4710721..7e767fa 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
@@ -111,7 +111,8 @@
// Currently any flag that causes us to stash in an app is included, except for IME or All Apps
// since those cover the underlying app anyway and thus the app shouldn't change insets.
private static final int FLAGS_REPORT_STASHED_INSETS_TO_APP = FLAGS_STASHED_IN_APP
- & ~FLAG_STASHED_IN_APP_IME & ~FLAG_STASHED_IN_TASKBAR_ALL_APPS;
+ & ~FLAG_STASHED_IN_APP_IME & ~FLAG_STASHED_IN_TASKBAR_ALL_APPS
+ & ~FLAG_STASHED_IN_APP_SYSUI;
// If any of these flags are enabled, the taskbar must be stashed.
private static final int FLAGS_FORCE_STASHED = FLAG_STASHED_SYSUI | FLAG_STASHED_DEVICE_LOCKED
diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java
index 6becf0f..395833f 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java
@@ -30,8 +30,6 @@
import android.view.Window;
import android.view.WindowManager;
-import androidx.annotation.VisibleForTesting;
-
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
@@ -52,13 +50,12 @@
private final Launcher mLauncher;
private final SystemUiProxy mSystemUiProxy;
- @VisibleForTesting final float mTouchSlop;
+ private final float mTouchSlop;
private int mLastAction;
private final SparseArray<PointF> mDownEvents;
/* If {@code false}, this controller should not handle the input {@link MotionEvent}.*/
- @VisibleForTesting
- boolean mCanIntercept;
+ private boolean mCanIntercept;
public StatusBarTouchController(Launcher l) {
mLauncher = l;
@@ -85,9 +82,9 @@
@Override
public final boolean onControllerInterceptTouchEvent(MotionEvent ev) {
- final int action = ev.getActionMasked();
- final int idx = ev.getActionIndex();
- final int pid = ev.getPointerId(idx);
+ int action = ev.getActionMasked();
+ int idx = ev.getActionIndex();
+ int pid = ev.getPointerId(idx);
if (action == ACTION_DOWN) {
mCanIntercept = canInterceptTouch(ev);
if (!mCanIntercept) {
@@ -95,14 +92,14 @@
}
mDownEvents.clear();
mDownEvents.put(pid, new PointF(ev.getX(), ev.getY()));
- } else if (action == MotionEvent.ACTION_POINTER_DOWN) {
+ } else if (ev.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) {
// Check!! should only set it only when threshold is not entered.
mDownEvents.put(pid, new PointF(ev.getX(idx), ev.getY(idx)));
}
if (!mCanIntercept) {
return false;
}
- if (action == ACTION_MOVE && mDownEvents.contains(pid)) {
+ if (action == ACTION_MOVE) {
float dy = ev.getY(idx) - mDownEvents.get(pid).y;
float dx = ev.getX(idx) - mDownEvents.get(pid).x;
// Currently input dispatcher will not do touch transfer if there are more than
@@ -129,6 +126,7 @@
mLauncher.getStatsLogManager().logger()
.log(LAUNCHER_SWIPE_DOWN_WORKSPACE_NOTISHADE_OPEN);
setWindowSlippery(false);
+ return true;
}
return true;
}
@@ -142,8 +140,7 @@
* Touches can slide out of the window but they cannot necessarily slide
* back in (unless the other window with touch focus permits it).
*/
- @VisibleForTesting
- void setWindowSlippery(boolean enable) {
+ private void setWindowSlippery(boolean enable) {
Window w = mLauncher.getWindow();
WindowManager.LayoutParams wlp = w.getAttributes();
if (enable) {
diff --git a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialController.java b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialController.java
index 9083d51..5d25279 100644
--- a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialController.java
+++ b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialController.java
@@ -66,7 +66,9 @@
@Override
public int getIntroductionSubtitle() {
- return R.string.back_gesture_intro_subtitle;
+ return ENABLE_NEW_GESTURE_NAV_TUTORIAL.get()
+ ? R.string.back_gesture_tutorial_subtitle
+ : R.string.back_gesture_intro_subtitle;
}
@Override
@@ -75,6 +77,11 @@
}
@Override
+ public int getSuccessFeedbackTitle() {
+ return R.string.gesture_tutorial_nice;
+ }
+
+ @Override
public int getSuccessFeedbackSubtitle() {
return mTutorialFragment.isAtFinalStep()
? R.string.back_gesture_feedback_complete_without_follow_up
diff --git a/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialController.java b/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialController.java
index 333ecbb..bce8b98 100644
--- a/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialController.java
+++ b/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialController.java
@@ -74,6 +74,13 @@
}
@Override
+ public int getSuccessFeedbackTitle() {
+ return ENABLE_NEW_GESTURE_NAV_TUTORIAL.get()
+ ? R.string.home_gesture_tutorial_success
+ : R.string.gesture_tutorial_nice;
+ }
+
+ @Override
public int getSuccessFeedbackSubtitle() {
return mTutorialFragment.isAtFinalStep()
? R.string.home_gesture_feedback_complete_without_follow_up
diff --git a/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java b/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java
index 09a6bbe..454dd17 100644
--- a/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java
+++ b/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java
@@ -77,7 +77,9 @@
@Override
public int getIntroductionSubtitle() {
- return R.string.overview_gesture_intro_subtitle;
+ return ENABLE_NEW_GESTURE_NAV_TUTORIAL.get()
+ ? R.string.overview_gesture_tutorial_subtitle
+ : R.string.overview_gesture_intro_subtitle;
}
@Override
@@ -86,6 +88,13 @@
}
@Override
+ public int getSuccessFeedbackTitle() {
+ return ENABLE_NEW_GESTURE_NAV_TUTORIAL.get()
+ ? R.string.overview_gesture_tutorial_success
+ : R.string.gesture_tutorial_nice;
+ }
+
+ @Override
public int getSuccessFeedbackSubtitle() {
return mTutorialFragment.getNumSteps() > 1 && mTutorialFragment.isAtFinalStep()
? R.string.overview_gesture_feedback_complete_with_follow_up
diff --git a/quickstep/src/com/android/quickstep/interaction/TutorialController.java b/quickstep/src/com/android/quickstep/interaction/TutorialController.java
index a58f453..16fe2d3 100644
--- a/quickstep/src/com/android/quickstep/interaction/TutorialController.java
+++ b/quickstep/src/com/android/quickstep/interaction/TutorialController.java
@@ -30,6 +30,7 @@
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.Color;
+import android.graphics.Matrix;
import android.graphics.Outline;
import android.graphics.Rect;
import android.graphics.drawable.AnimatedVectorDrawable;
@@ -67,6 +68,7 @@
import com.android.systemui.shared.system.QuickStepContract;
import com.airbnb.lottie.LottieAnimationView;
+import com.airbnb.lottie.LottieComposition;
import java.util.ArrayList;
@@ -175,6 +177,8 @@
mExitingAppStartingCornerRadius = QuickStepContract.getWindowCornerRadius(mContext);
mExitingAppEndingCornerRadius = mContext.getResources().getDimensionPixelSize(
R.dimen.gesture_tutorial_back_gesture_end_corner_radius);
+ mAnimatedGestureDemonstration.addLottieOnCompositionLoadedListener(
+ this::createScalingMatrix);
mFeedbackTitleView.setText(getIntroductionTitle());
mFeedbackSubtitleView.setText(getIntroductionSubtitle());
@@ -214,6 +218,24 @@
};
}
+ /** Scale the Lottie gesture animation to fit the device based on device dimensions */
+ private void createScalingMatrix(LottieComposition composition) {
+ Rect animationBoundsRect = composition.getBounds();
+ if (animationBoundsRect == null) {
+ mAnimatedGestureDemonstration.setScaleType(ImageView.ScaleType.CENTER_CROP);
+ return;
+ }
+ Matrix scaleMatrix = new Matrix();
+ float pivotX = mScreenWidth / 2f;
+ float pivotY = mScreenHeight;
+ float scaleFactor = mScreenWidth / animationBoundsRect.width();
+
+ scaleMatrix.postScale(scaleFactor, scaleFactor, pivotX, pivotY);
+ scaleMatrix.postTranslate(0,
+ mTutorialFragment.getDeviceProfile().heightPx - animationBoundsRect.height());
+ mAnimatedGestureDemonstration.setImageMatrix(scaleMatrix);
+ }
+
private void showSkipTutorialDialog() {
if (mSkipTutorialDialog != null) {
mSkipTutorialDialog.show();
@@ -321,6 +343,11 @@
return NO_ID;
}
+ @StringRes
+ public int getSuccessFeedbackTitle() {
+ return NO_ID;
+ }
+
@StyleRes
public int getTitleTextAppearance() {
return NO_ID;
@@ -392,7 +419,7 @@
void showFeedback(int subtitleResId, boolean isGestureSuccessful) {
showFeedback(
isGestureSuccessful
- ? R.string.gesture_tutorial_nice : R.string.gesture_tutorial_try_again,
+ ? getSuccessFeedbackTitle() : R.string.gesture_tutorial_try_again,
subtitleResId,
NO_ID,
isGestureSuccessful,
diff --git a/quickstep/tests/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchControllerTest.kt b/quickstep/tests/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchControllerTest.kt
deleted file mode 100644
index b2f13c7..0000000
--- a/quickstep/tests/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchControllerTest.kt
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 202 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.
- */
-package com.android.launcher3.uioverrides.touchcontrollers
-
-import android.view.MotionEvent
-import android.view.WindowManager
-import androidx.test.filters.SmallTest
-import androidx.test.runner.AndroidJUnit4
-import com.android.launcher3.Launcher
-import com.android.launcher3.ui.AbstractLauncherUiTest
-import com.android.launcher3.ui.TaplTestsLauncher3
-import junit.framework.Assert.assertEquals
-import junit.framework.Assert.assertFalse
-import junit.framework.Assert.assertTrue
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@SmallTest
-@RunWith(AndroidJUnit4::class)
-class StatusBarTouchControllerTest : AbstractLauncherUiTest() {
- @Before
- @Throws(Exception::class)
- fun setup() {
- TaplTestsLauncher3.initialize(this)
- }
-
- @Test
- fun interceptActionDown_canIntercept() {
- executeOnLauncher { launcher: Launcher? ->
- val underTest = StatusBarTouchController(launcher)
- assertFalse(underTest.mCanIntercept)
- val downEvent = MotionEvent.obtain(1, 1, MotionEvent.ACTION_DOWN, 0f, 0f, 0)
-
- underTest.onControllerInterceptTouchEvent(downEvent)
-
- assertTrue(underTest.mCanIntercept)
- }
- }
-
- @Test
- fun interceptActionMove_handledAndSetSlippery() {
- executeOnLauncher { launcher: Launcher ->
- val underTest = StatusBarTouchController(launcher)
- val downEvent = MotionEvent.obtain(1, 1, MotionEvent.ACTION_DOWN, 0f, 0f, 0)
- underTest.onControllerInterceptTouchEvent(downEvent)
- val w = launcher.window
- assertEquals(0, w.attributes.flags and WindowManager.LayoutParams.FLAG_SLIPPERY)
- val moveEvent =
- MotionEvent.obtain(
- 2,
- 2,
- MotionEvent.ACTION_MOVE,
- underTest.mTouchSlop,
- underTest.mTouchSlop + 10,
- 0
- )
-
- val handled = underTest.onControllerInterceptTouchEvent(moveEvent)
-
- assertTrue(handled)
- assertEquals(
- WindowManager.LayoutParams.FLAG_SLIPPERY,
- w.attributes.flags and WindowManager.LayoutParams.FLAG_SLIPPERY
- )
- }
- }
-
- @Test
- fun interceptActionMove_not_handled() {
- executeOnLauncher { launcher: Launcher? ->
- val underTest = StatusBarTouchController(launcher)
- val downEvent = MotionEvent.obtain(1, 1, MotionEvent.ACTION_DOWN, 0f, 0f, 0)
- underTest.onControllerInterceptTouchEvent(downEvent)
- val moveEvent =
- MotionEvent.obtain(
- 2,
- 2,
- MotionEvent.ACTION_MOVE,
- underTest.mTouchSlop + 10,
- underTest.mTouchSlop,
- 0
- )
-
- val handled = underTest.onControllerInterceptTouchEvent(moveEvent)
-
- assertFalse(handled)
- }
- }
-
- @Test
- fun interceptActionMoveAsFirstGestureEvent_notCrashedNorHandled() {
- executeOnLauncher { launcher: Launcher? ->
- val underTest = StatusBarTouchController(launcher)
- underTest.mCanIntercept = true
- val moveEvent = MotionEvent.obtain(2, 2, MotionEvent.ACTION_MOVE, 10f, 10f, 0)
-
- val handled = underTest.onControllerInterceptTouchEvent(moveEvent)
-
- assertFalse(handled)
- }
- }
-
- @Test
- fun handleActionUp_setNotSlippery() {
- executeOnLauncher { launcher: Launcher ->
- val underTest = StatusBarTouchController(launcher)
- underTest.mCanIntercept = true
- underTest.setWindowSlippery(true)
- val moveEvent = MotionEvent.obtain(2, 2, MotionEvent.ACTION_UP, 10f, 10f, 0)
-
- val handled = underTest.onControllerTouchEvent(moveEvent)
-
- assertTrue(handled)
- assertEquals(
- 0,
- launcher.window.attributes.flags and WindowManager.LayoutParams.FLAG_SLIPPERY
- )
- }
- }
-
- @Test
- fun handleActionCancel_setNotSlippery() {
- executeOnLauncher { launcher: Launcher ->
- val underTest = StatusBarTouchController(launcher)
- underTest.mCanIntercept = true
- underTest.setWindowSlippery(true)
- val moveEvent = MotionEvent.obtain(2, 2, MotionEvent.ACTION_CANCEL, 10f, 10f, 0)
-
- val handled = underTest.onControllerTouchEvent(moveEvent)
-
- assertTrue(handled)
- assertEquals(
- 0,
- launcher.window.attributes.flags and WindowManager.LayoutParams.FLAG_SLIPPERY
- )
- }
- }
-}