Merge "Removing dependency on XmlResourceParser in default layout parsing" into ub-launcher3-master
diff --git a/quickstep/src/com/android/quickstep/OverviewInteractionState.java b/quickstep/src/com/android/quickstep/OverviewInteractionState.java
index 411e593..a0ab301 100644
--- a/quickstep/src/com/android/quickstep/OverviewInteractionState.java
+++ b/quickstep/src/com/android/quickstep/OverviewInteractionState.java
@@ -175,7 +175,7 @@
}
}
- public void notifySwipeUpSettingChanged(boolean swipeUpEnabled) {
+ private void notifySwipeUpSettingChanged(boolean swipeUpEnabled) {
mUiHandler.removeMessages(MSG_SET_SWIPE_UP_ENABLED);
mUiHandler.obtainMessage(MSG_SET_SWIPE_UP_ENABLED, swipeUpEnabled ? 1 : 0, 0).
sendToTarget();
diff --git a/quickstep/tests/src/com/android/quickstep/QuickStepOnOffRule.java b/quickstep/tests/src/com/android/quickstep/QuickStepOnOffRule.java
index 7274090..c5975a9 100644
--- a/quickstep/tests/src/com/android/quickstep/QuickStepOnOffRule.java
+++ b/quickstep/tests/src/com/android/quickstep/QuickStepOnOffRule.java
@@ -19,6 +19,11 @@
import static com.android.quickstep.QuickStepOnOffRule.Mode.BOTH;
import static com.android.quickstep.QuickStepOnOffRule.Mode.OFF;
import static com.android.quickstep.QuickStepOnOffRule.Mode.ON;
+import static com.android.systemui.shared.system.SettingsCompat.SWIPE_UP_SETTING_NAME;
+
+import static org.junit.Assert.assertTrue;
+
+import android.provider.Settings;
import androidx.test.InstrumentationRegistry;
@@ -69,38 +74,52 @@
@Override
public void evaluate() throws Throwable {
try {
- if (mode == ON || mode == BOTH) {
- evaluateWithQuickstepOn();
- }
- if (mode == OFF || mode == BOTH) {
- evaluateWithQuickstepOff();
+ if (SwipeUpSetting.isSwipeUpSettingAvailable()) {
+ if (mode == ON || mode == BOTH) {
+ evaluateWithQuickstepOn();
+ }
+ if (mode == OFF || mode == BOTH) {
+ evaluateWithQuickstepOff();
+ }
+ } else {
+ // Execute without changing the setting, if the requested mode is
+ // compatible.
+ final boolean swipeUpEnabledDefaultValue =
+ SwipeUpSetting.isSwipeUpEnabledDefaultValue();
+ if (mode == BOTH ||
+ mode == ON && swipeUpEnabledDefaultValue ||
+ mode == OFF && !swipeUpEnabledDefaultValue) {
+ evaluateWithoutChangingSetting(base);
+ }
}
} finally {
- overrideSwipeUpEnabled(null);
+ setSwipeUpSetting(null);
+
}
}
- private void evaluateWithQuickstepOff() throws Throwable {
- overrideSwipeUpEnabled(false);
+ public void setSwipeUpSetting(String value) {
+ assertTrue("Couldn't change Quickstep mode",
+ Settings.Secure.putString(
+ InstrumentationRegistry.getInstrumentation().getTargetContext().
+ getContentResolver(),
+ SWIPE_UP_SETTING_NAME,
+ value));
+ }
+
+ public void evaluateWithoutChangingSetting(Statement base) throws Throwable {
base.evaluate();
}
+ private void evaluateWithQuickstepOff() throws Throwable {
+ setSwipeUpSetting("0");
+ evaluateWithoutChangingSetting(base);
+ }
+
private void evaluateWithQuickstepOn() throws Throwable {
- overrideSwipeUpEnabled(true);
+ setSwipeUpSetting("1");
base.evaluate();
}
-
- private void overrideSwipeUpEnabled(Boolean swipeUpEnabledOverride)
- throws Throwable {
- mLauncher.overrideSwipeUpEnabled(swipeUpEnabledOverride);
- mMainThreadExecutor.execute(() -> OverviewInteractionState.INSTANCE.get(
- InstrumentationRegistry.getInstrumentation().getTargetContext()).
- notifySwipeUpSettingChanged(mLauncher.isSwipeUpEnabled()));
- // TODO(b/124236673): avoid using sleep().
- mLauncher.getDevice().waitForIdle();
- Thread.sleep(2000);
- mLauncher.getDevice().waitForIdle();
- }
};
} else {
return base;
diff --git a/res/layout/snackbar.xml b/res/layout/snackbar.xml
index bca3308..b818943 100644
--- a/res/layout/snackbar.xml
+++ b/res/layout/snackbar.xml
@@ -29,7 +29,7 @@
android:ellipsize="end"
android:textSize="@dimen/snackbar_max_text_size"
android:textColor="?android:attr/textColorPrimary"
- android:theme="@style/TextTitle"/>
+ style="@style/TextTitle"/>
<TextView
android:id="@+id/action"
android:layout_height="@dimen/snackbar_content_height"
@@ -42,6 +42,6 @@
android:textStyle="bold"
android:textSize="@dimen/snackbar_max_text_size"
android:textColor="?android:attr/colorAccent"
- android:theme="@style/TextTitle"
+ style="@style/TextTitle"
android:capitalize="sentences"/>
</merge>
\ No newline at end of file
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index b49578b..cee1c26 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -187,11 +187,9 @@
return new float[] {1, 0, 0};
}
- /**
- * @return Whether we should scale the hotseat as if it were part of the workspace.
- */
- public boolean scaleHotseatWithWorkspace() {
- return true;
+ public float[] getHotseatScaleAndTranslation(Launcher launcher) {
+ // For most states, treat the hotseat as if it were part of the workspace.
+ return getWorkspaceScaleAndTranslation(launcher);
}
/**
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index 1c595ab..0507470 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -72,6 +72,7 @@
private void setWorkspaceProperty(LauncherState state, PropertySetter propertySetter,
AnimatorSetBuilder builder, AnimationConfig config) {
float[] scaleAndTranslation = state.getWorkspaceScaleAndTranslation(mLauncher);
+ float[] hotseatScaleAndTranslation = state.getHotseatScaleAndTranslation(mLauncher);
mNewScale = scaleAndTranslation[0];
PageAlphaProvider pageAlphaProvider = state.getWorkspacePageAlphaProvider(mLauncher);
final int childCount = mWorkspace.getChildCount();
@@ -89,16 +90,16 @@
Interpolator scaleInterpolator = builder.getInterpolator(ANIM_WORKSPACE_SCALE, ZOOM_OUT);
propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, scaleInterpolator);
- if (state.scaleHotseatWithWorkspace()) {
- DragLayer dragLayer = mLauncher.getDragLayer();
- int[] workspacePivot = new int[]{(int) mWorkspace.getPivotX(),
- (int) mWorkspace.getPivotY()};
- dragLayer.getDescendantCoordRelativeToSelf(mWorkspace, workspacePivot);
- dragLayer.mapCoordInSelfToDescendant(hotseat, workspacePivot);
- hotseat.setPivotX(workspacePivot[0]);
- hotseat.setPivotY(workspacePivot[1]);
- propertySetter.setFloat(hotseat, SCALE_PROPERTY, mNewScale, scaleInterpolator);
- }
+ // Set the hotseat's pivot point to match the workspace's, so that it scales together.
+ DragLayer dragLayer = mLauncher.getDragLayer();
+ int[] workspacePivot = new int[]{(int) mWorkspace.getPivotX(),
+ (int) mWorkspace.getPivotY()};
+ dragLayer.getDescendantCoordRelativeToSelf(mWorkspace, workspacePivot);
+ dragLayer.mapCoordInSelfToDescendant(hotseat, workspacePivot);
+ hotseat.setPivotX(workspacePivot[0]);
+ hotseat.setPivotY(workspacePivot[1]);
+ float hotseatScale = hotseatScaleAndTranslation[0];
+ propertySetter.setFloat(hotseat, SCALE_PROPERTY, hotseatScale, scaleInterpolator);
float hotseatIconsAlpha = (elements & HOTSEAT_ICONS) != 0 ? 1 : 0;
propertySetter.setViewAlpha(hotseat, hotseatIconsAlpha, fadeInterpolator);
@@ -116,12 +117,11 @@
scaleAndTranslation[1], translationInterpolator);
propertySetter.setFloat(mWorkspace, View.TRANSLATION_Y,
scaleAndTranslation[2], translationInterpolator);
- if (state.scaleHotseatWithWorkspace()) {
- propertySetter.setFloat(hotseat, View.TRANSLATION_Y,
- scaleAndTranslation[2], translationInterpolator);
- propertySetter.setFloat(mWorkspace.getPageIndicator(), View.TRANSLATION_Y,
- scaleAndTranslation[2], translationInterpolator);
- }
+
+ propertySetter.setFloat(hotseat, View.TRANSLATION_Y,
+ hotseatScaleAndTranslation[2], translationInterpolator);
+ propertySetter.setFloat(mWorkspace.getPageIndicator(), View.TRANSLATION_Y,
+ hotseatScaleAndTranslation[2], translationInterpolator);
// Set scrim
WorkspaceAndHotseatScrim scrim = mLauncher.getDragLayer().getScrim();
diff --git a/src/com/android/launcher3/config/BaseFlags.java b/src/com/android/launcher3/config/BaseFlags.java
index 8c57f46..b350767 100644
--- a/src/com/android/launcher3/config/BaseFlags.java
+++ b/src/com/android/launcher3/config/BaseFlags.java
@@ -116,7 +116,7 @@
"ENABLE_HINTS_IN_OVERVIEW", false,
"Show chip hints and gleams on the overview screen");
- public static final TogglableFlag ENABLE_ASSISTANT_GESTURE = new TogglableFlag(
+ public static final TogglableFlag ENABLE_ASSISTANT_GESTURE = new ToggleableGlobalSettingsFlag(
"ENABLE_ASSISTANT_GESTURE", false,
"Enable swipe up from the bottom right corner to start assistant");
diff --git a/src/com/android/launcher3/states/SpringLoadedState.java b/src/com/android/launcher3/states/SpringLoadedState.java
index d49dfbb..fcace98 100644
--- a/src/com/android/launcher3/states/SpringLoadedState.java
+++ b/src/com/android/launcher3/states/SpringLoadedState.java
@@ -73,8 +73,8 @@
}
@Override
- public boolean scaleHotseatWithWorkspace() {
- return false;
+ public float[] getHotseatScaleAndTranslation(Launcher launcher) {
+ return new float[] {1, 0, 0};
}
@Override
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 7473189..93b4cc6 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -93,8 +93,6 @@
private static WeakReference<VisibleContainer> sActiveContainer = new WeakReference<>(null);
private final UiDevice mDevice;
- private final boolean mSwipeUpEnabled;
- private Boolean mSwipeUpEnabledOverride = null;
private final Instrumentation mInstrumentation;
private int mExpectedRotation = Surface.ROTATION_0;
@@ -104,13 +102,6 @@
public LauncherInstrumentation(Instrumentation instrumentation) {
mInstrumentation = instrumentation;
mDevice = UiDevice.getInstance(instrumentation);
- final boolean swipeUpEnabledDefaultValue = SwipeUpSetting.isSwipeUpEnabledDefaultValue();
- mSwipeUpEnabled = SwipeUpSetting.isSwipeUpSettingAvailable() ?
- Settings.Secure.getInt(
- instrumentation.getTargetContext().getContentResolver(),
- SWIPE_UP_SETTING_NAME,
- swipeUpEnabledDefaultValue ? 1 : 0) == 1 :
- swipeUpEnabledDefaultValue;
// Launcher should run in test harness so that custom accessibility protocol between
// Launcher and TAPL is enabled. In-process tests enable this protocol with a direct call
@@ -119,17 +110,18 @@
TestHelpers.isInLauncherProcess() || ActivityManager.isRunningInTestHarness());
}
- // Used only by TaplTests.
- public void overrideSwipeUpEnabled(Boolean swipeUpEnabledOverride) {
- mSwipeUpEnabledOverride = swipeUpEnabledOverride;
- }
-
void setActiveContainer(VisibleContainer container) {
sActiveContainer = new WeakReference<>(container);
}
public boolean isSwipeUpEnabled() {
- return mSwipeUpEnabledOverride != null ? mSwipeUpEnabledOverride : mSwipeUpEnabled;
+ final boolean swipeUpEnabledDefaultValue = SwipeUpSetting.isSwipeUpEnabledDefaultValue();
+ return SwipeUpSetting.isSwipeUpSettingAvailable() ?
+ Settings.Secure.getInt(
+ mInstrumentation.getTargetContext().getContentResolver(),
+ SWIPE_UP_SETTING_NAME,
+ swipeUpEnabledDefaultValue ? 1 : 0) == 1 :
+ swipeUpEnabledDefaultValue;
}
static void log(String message) {