Merge "Using the extracted color for plaecholder loading icons" into ub-launcher3-master
diff --git a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
index f5ac9c9..6034791 100644
--- a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
+++ b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
@@ -17,6 +17,7 @@
package com.android.quickstep;
import static androidx.test.InstrumentationRegistry.getInstrumentation;
+
import static com.android.quickstep.NavigationModeSwitchRule.Mode.ALL;
import static com.android.quickstep.NavigationModeSwitchRule.Mode.THREE_BUTTON;
import static com.android.quickstep.NavigationModeSwitchRule.Mode.TWO_BUTTON;
@@ -26,18 +27,22 @@
import android.content.Context;
import android.util.Log;
+
import androidx.test.uiautomator.UiDevice;
+
import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.tapl.TestHelpers;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+
import org.junit.Assert;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
/**
* Test rule that allows executing a test with Quickstep on and then Quickstep off.
* The test should be annotated with @QuickstepOnOff.
diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
index 4205188..74a17ce 100644
--- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
+++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
@@ -48,8 +48,7 @@
mLauncher.addContextLayer("want to fling forward in overview")) {
LauncherInstrumentation.log("Overview.flingForward before fling");
final UiObject2 overview = verifyActiveContainer();
- final int margin = (int) (50 * mLauncher.getDisplayDensity()) + 1;
- overview.setGestureMargins(margin, 0, 0, 0);
+ overview.setGestureMargins(mLauncher.getEdgeSensitivityWidth(), 0, 0, 0);
overview.fling(Direction.LEFT, (int) (FLING_SPEED * mLauncher.getDisplayDensity()));
mLauncher.waitForIdle();
verifyActiveContainer();
@@ -86,8 +85,7 @@
mLauncher.addContextLayer("want to fling backward in overview")) {
LauncherInstrumentation.log("Overview.flingBackward before fling");
final UiObject2 overview = verifyActiveContainer();
- final int margin = (int) (50 * mLauncher.getDisplayDensity()) + 1;
- overview.setGestureMargins(0, 0, margin, 0);
+ overview.setGestureMargins(0, 0, mLauncher.getEdgeSensitivityWidth(), 0);
overview.fling(Direction.RIGHT, (int) (FLING_SPEED * mLauncher.getDisplayDensity()));
mLauncher.waitForIdle();
verifyActiveContainer();
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index ef3cb1f..40c488d 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -65,8 +65,6 @@
public final class LauncherInstrumentation {
private static final String TAG = "Tapl";
- private static final String NAV_BAR_INTERACTION_MODE_RES_NAME =
- "config_navBarInteractionMode";
private static final int ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME = 20;
// Types for launcher containers that the user is interacting with. "Background" is a
@@ -611,18 +609,19 @@
}
public static boolean isGesturalMode(Context context) {
- return QuickStepContract.isGesturalMode(
- getSystemIntegerRes(context, NAV_BAR_INTERACTION_MODE_RES_NAME));
+ return QuickStepContract.isGesturalMode(getCurrentInteractionMode(context));
}
public static boolean isSwipeUpMode(Context context) {
- return QuickStepContract.isSwipeUpMode(
- getSystemIntegerRes(context, NAV_BAR_INTERACTION_MODE_RES_NAME));
+ return QuickStepContract.isSwipeUpMode(getCurrentInteractionMode(context));
}
public static boolean isLegacyMode(Context context) {
- return QuickStepContract.isLegacyMode(
- getSystemIntegerRes(context, NAV_BAR_INTERACTION_MODE_RES_NAME));
+ return QuickStepContract.isLegacyMode(getCurrentInteractionMode(context));
+ }
+
+ private static int getCurrentInteractionMode(Context context) {
+ return getSystemIntegerRes(context, "config_navBarInteractionMode");
}
private static int getSystemIntegerRes(Context context, String resName) {
@@ -637,10 +636,34 @@
}
}
+ private static int getSystemDimensionResId(Context context, String resName) {
+ Resources res = context.getResources();
+ int resId = res.getIdentifier(resName, "dimen", "android");
+
+ if (resId != 0) {
+ return resId;
+ } else {
+ Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?");
+ return -1;
+ }
+ }
+
static void sleep(int duration) {
try {
Thread.sleep(duration);
} catch (InterruptedException e) {
}
}
+
+ int getEdgeSensitivityWidth() {
+ try {
+ final Context context = mInstrumentation.getTargetContext().createPackageContext(
+ "android", 0);
+ return context.getResources().getDimensionPixelSize(
+ getSystemDimensionResId(context, "config_backGestureInset")) + 1;
+ } catch (PackageManager.NameNotFoundException e) {
+ fail("Can't get edge sensitivity: " + e);
+ return 0;
+ }
+ }
}
\ No newline at end of file
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index 68b007e..f04afa0 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -148,8 +148,7 @@
*/
public void flingForward() {
final UiObject2 workspace = verifyActiveContainer();
- final int margin = (int) (50 * mLauncher.getDisplayDensity()) + 1;
- workspace.setGestureMargins(0, 0, margin, 0);
+ workspace.setGestureMargins(0, 0, mLauncher.getEdgeSensitivityWidth(), 0);
workspace.fling(Direction.RIGHT, (int) (FLING_SPEED * mLauncher.getDisplayDensity()));
mLauncher.waitForIdle();
verifyActiveContainer();
@@ -161,8 +160,7 @@
*/
public void flingBackward() {
final UiObject2 workspace = verifyActiveContainer();
- final int margin = (int) (50 * mLauncher.getDisplayDensity()) + 1;
- workspace.setGestureMargins(margin, 0, 0, 0);
+ workspace.setGestureMargins(mLauncher.getEdgeSensitivityWidth(), 0, 0, 0);
workspace.fling(Direction.LEFT, (int) (FLING_SPEED * mLauncher.getDisplayDensity()));
mLauncher.waitForIdle();
verifyActiveContainer();