Merge "Enforce Swipe Up gesture to be enabled based on the shipped SDK version" into ub-launcher3-edmonton
diff --git a/quickstep/libs/sysui_shared.jar b/quickstep/libs/sysui_shared.jar
index 398bd3c..11d5694 100644
--- a/quickstep/libs/sysui_shared.jar
+++ b/quickstep/libs/sysui_shared.jar
Binary files differ
diff --git a/quickstep/src/com/android/launcher3/uioverrides/DisplayRotationListener.java b/quickstep/src/com/android/launcher3/uioverrides/DisplayRotationListener.java
new file mode 100644
index 0000000..2d9a161
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/uioverrides/DisplayRotationListener.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2018 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;
+
+import android.content.Context;
+import android.os.Handler;
+
+import com.android.systemui.shared.system.RotationWatcher;
+
+/**
+ * Utility class for listening for rotation changes
+ */
+public class DisplayRotationListener extends RotationWatcher {
+
+ private final Runnable mCallback;
+ private Handler mHandler;
+
+ public DisplayRotationListener(Context context, Runnable callback) {
+ super(context);
+ mCallback = callback;
+ }
+
+ @Override
+ public void enable() {
+ if (mHandler == null) {
+ mHandler = new Handler();
+ }
+ super.enable();
+ }
+
+ @Override
+ protected void onRotationChanged(int i) {
+ mHandler.post(mCallback);
+ }
+}
diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java
index 1359b3a..20ecde9 100644
--- a/quickstep/src/com/android/quickstep/RecentsActivity.java
+++ b/quickstep/src/com/android/quickstep/RecentsActivity.java
@@ -121,6 +121,11 @@
dispatchDeviceProfileChanged();
mRecentsRootView.setup();
+ reapplyUi();
+ }
+
+ @Override
+ protected void reapplyUi() {
mRecentsRootView.dispatchInsets();
}
@@ -140,6 +145,7 @@
? new InvariantDeviceProfile(this).getDeviceProfile(this)
: appState.getInvariantDeviceProfile().getDeviceProfile(this).copy(this);
}
+ onDeviceProfileInitiated();
}
@Override
diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
index 2fa3875..2f7aef8 100644
--- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -43,6 +43,7 @@
import android.util.Log;
import android.view.View;
import android.view.ViewTreeObserver.OnDrawListener;
+import android.view.WindowManager;
import android.view.animation.Interpolator;
import com.android.launcher3.AbstractFloatingView;
@@ -541,6 +542,7 @@
dp = dp.copy(mContext);
dp.updateInsets(insets);
}
+ dp.updateIsSeascape(mContext.getSystemService(WindowManager.class));
if (runningTaskTarget != null) {
mClipAnimationHelper.updateSource(overviewStackBounds, runningTaskTarget);
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 82a5bdc..8c3e1a2 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -406,7 +406,6 @@
taskView.bind(task);
}
resetTaskVisuals();
- applyIconScale(false /* animate */);
if (oldChildCount != getChildCount()) {
mQuickScrubController.snapToNextTaskIfAvailable();
@@ -426,6 +425,7 @@
if (mRunningTaskTileHidden) {
setRunningTaskHidden(mRunningTaskTileHidden);
}
+ applyIconScale(false /* animate */);
updateCurveProperties();
// Update the set of visible task's data
diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java
index a41edc0..bd38bf0 100644
--- a/src/com/android/launcher3/BaseActivity.java
+++ b/src/com/android/launcher3/BaseActivity.java
@@ -213,19 +213,6 @@
return mForceInvisible != 0;
}
- /**
- * Sets the device profile, adjusting it accordingly in case of multi-window
- */
- protected void setDeviceProfile(DeviceProfile dp) {
- mDeviceProfile = dp;
- if (isInMultiWindowModeCompat()) {
- Display display = getWindowManager().getDefaultDisplay();
- Point mwSize = new Point();
- display.getSize(mwSize);
- mDeviceProfile = mDeviceProfile.getMultiWindowProfile(this, mwSize);
- }
- }
-
public interface MultiWindowModeChangedListener {
void onMultiWindowModeChanged(boolean isInMultiWindowMode);
}
diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java
index 1400432..e47dbe5 100644
--- a/src/com/android/launcher3/BaseDraggingActivity.java
+++ b/src/com/android/launcher3/BaseDraggingActivity.java
@@ -28,12 +28,14 @@
import android.os.UserHandle;
import android.util.Log;
import android.view.ActionMode;
+import android.view.Surface;
import android.view.View;
import android.widget.Toast;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.badge.BadgeInfo;
import com.android.launcher3.compat.LauncherAppsCompat;
+import com.android.launcher3.uioverrides.DisplayRotationListener;
import com.android.launcher3.uioverrides.WallpaperColorInfo;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.views.BaseDragLayer;
@@ -61,10 +63,13 @@
private int mThemeRes = R.style.LauncherTheme;
+ private DisplayRotationListener mRotationListener;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mIsSafeModeEnabled = getPackageManager().isSafeMode();
+ mRotationListener = new DisplayRotationListener(this, this::onDeviceRotationChanged);
// Update theme
WallpaperColorInfo wallpaperColorInfo = WallpaperColorInfo.getInstance(this);
@@ -237,12 +242,30 @@
protected void onDestroy() {
super.onDestroy();
WallpaperColorInfo.getInstance(this).removeOnChangeListener(this);
+ mRotationListener.disable();
}
public <T extends BaseDraggingActivity> void setOnStartCallback(OnStartCallback<T> callback) {
mOnStartCallback = callback;
}
+ protected void onDeviceProfileInitiated() {
+ if (mDeviceProfile.isVerticalBarLayout()) {
+ mRotationListener.enable();
+ mDeviceProfile.updateIsSeascape(getWindowManager());
+ } else {
+ mRotationListener.disable();
+ }
+ }
+
+ private void onDeviceRotationChanged() {
+ if (mDeviceProfile.updateIsSeascape(getWindowManager())) {
+ reapplyUi();
+ }
+ }
+
+ protected abstract void reapplyUi();
+
/**
* Callback for listening for onStart
*/
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 4deed73..4f9920c 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -25,6 +25,8 @@
import android.graphics.PointF;
import android.graphics.Rect;
import android.util.DisplayMetrics;
+import android.view.Surface;
+import android.view.WindowManager;
import com.android.launcher3.CellLayout.ContainerType;
import com.android.launcher3.badge.BadgeRenderer;
@@ -118,6 +120,7 @@
private final Rect mInsets = new Rect();
public final Rect workspacePadding = new Rect();
private final Rect mHotseatPadding = new Rect();
+ private boolean mIsSeascape;
// Icon badges
public BadgeRenderer mBadgeRenderer;
@@ -519,9 +522,22 @@
return isLandscape && transposeLayoutWithOrientation;
}
+ /**
+ * Updates orientation information and returns true if it has changed from the previous value.
+ */
+ public boolean updateIsSeascape(WindowManager wm) {
+ if (isVerticalBarLayout()) {
+ boolean isSeascape = wm.getDefaultDisplay().getRotation() == Surface.ROTATION_270;
+ if (mIsSeascape != isSeascape) {
+ mIsSeascape = isSeascape;
+ return true;
+ }
+ }
+ return false;
+ }
+
public boolean isSeascape() {
- // TODO: This might not hold true for multi window mode, use configuration insead.
- return isVerticalBarLayout() && mInsets.left > mInsets.right;
+ return isVerticalBarLayout() && mIsSeascape;
}
public boolean shouldFadeAdjacentWorkspaceScreens() {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index d8bb90a..8088f64 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -45,6 +45,7 @@
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.database.sqlite.SQLiteDatabase;
+import android.graphics.Point;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
@@ -57,6 +58,7 @@
import android.text.method.TextKeyListener;
import android.util.Log;
import android.util.SparseArray;
+import android.view.Display;
import android.view.KeyEvent;
import android.view.KeyboardShortcutGroup;
import android.view.KeyboardShortcutInfo;
@@ -359,9 +361,7 @@
mUserEventDispatcher = null;
initDeviceProfile(mDeviceProfile.inv);
dispatchDeviceProfileChanged();
-
- getRootView().dispatchInsets();
- getStateManager().reapplyState(true /* cancelCurrentAnimation */);
+ reapplyUi();
// Recreate touch controllers
mDragLayer.setup(mDragController);
@@ -376,6 +376,12 @@
}
@Override
+ protected void reapplyUi() {
+ getRootView().dispatchInsets();
+ getStateManager().reapplyState(true /* cancelCurrentAnimation */);
+ }
+
+ @Override
public void rebindModel() {
int currentPage = mWorkspace.getNextPage();
if (mModel.startLoader(currentPage)) {
@@ -386,7 +392,14 @@
private void initDeviceProfile(InvariantDeviceProfile idp) {
// Load configuration-specific DeviceProfile
- setDeviceProfile(idp.getDeviceProfile(this));
+ mDeviceProfile = idp.getDeviceProfile(this);
+ if (isInMultiWindowModeCompat()) {
+ Display display = getWindowManager().getDefaultDisplay();
+ Point mwSize = new Point();
+ display.getSize(mwSize);
+ mDeviceProfile = mDeviceProfile.getMultiWindowProfile(this, mwSize);
+ }
+ onDeviceProfileInitiated();
mModelWriter = mModel.getWriter(mDeviceProfile.isVerticalBarLayout(), true);
}
diff --git a/src/com/android/launcher3/LauncherRootView.java b/src/com/android/launcher3/LauncherRootView.java
index ad1456a2..ae0e7a7 100644
--- a/src/com/android/launcher3/LauncherRootView.java
+++ b/src/com/android/launcher3/LauncherRootView.java
@@ -21,12 +21,9 @@
private final Launcher mLauncher;
private final Paint mOpaquePaint;
+
@ViewDebug.ExportedProperty(category = "launcher")
- private boolean mDrawSideInsetBar;
- @ViewDebug.ExportedProperty(category = "launcher")
- private int mLeftInsetBarWidth;
- @ViewDebug.ExportedProperty(category = "launcher")
- private int mRightInsetBarWidth;
+ private final Rect mConsumedInsets = new Rect();
private View mAlignedView;
private WindowStateListener mWindowStateListener;
@@ -54,18 +51,26 @@
@TargetApi(23)
@Override
protected boolean fitSystemWindows(Rect insets) {
- mDrawSideInsetBar = (insets.right > 0 || insets.left > 0) &&
+ mConsumedInsets.setEmpty();
+ boolean drawInsetBar = false;
+ if (mLauncher.isInMultiWindowModeCompat()
+ && (insets.left > 0 || insets.right > 0 || insets.bottom > 0)) {
+ mConsumedInsets.left = insets.left;
+ mConsumedInsets.right = insets.right;
+ mConsumedInsets.bottom = insets.bottom;
+ insets = new Rect(0, insets.top, 0, 0);
+ drawInsetBar = true;
+ } else if ((insets.right > 0 || insets.left > 0) &&
(!Utilities.ATLEAST_MARSHMALLOW ||
- getContext().getSystemService(ActivityManager.class).isLowRamDevice());
- if (mDrawSideInsetBar) {
- mLeftInsetBarWidth = insets.left;
- mRightInsetBarWidth = insets.right;
+ getContext().getSystemService(ActivityManager.class).isLowRamDevice())) {
+ mConsumedInsets.left = insets.left;
+ mConsumedInsets.right = insets.right;
insets = new Rect(0, insets.top, 0, insets.bottom);
- } else {
- mLeftInsetBarWidth = mRightInsetBarWidth = 0;
+ drawInsetBar = true;
}
+
mLauncher.getSystemUiController().updateUiState(
- UI_STATE_ROOT_VIEW, mDrawSideInsetBar ? FLAG_DARK_NAV : 0);
+ UI_STATE_ROOT_VIEW, drawInsetBar ? FLAG_DARK_NAV : 0);
// Update device profile before notifying th children.
mLauncher.getDeviceProfile().updateInsets(insets);
@@ -73,11 +78,14 @@
setInsets(insets);
if (mAlignedView != null) {
- // Apply margins on aligned view to handle left/right insets.
+ // Apply margins on aligned view to handle consumed insets.
MarginLayoutParams lp = (MarginLayoutParams) mAlignedView.getLayoutParams();
- if (lp.leftMargin != mLeftInsetBarWidth || lp.rightMargin != mRightInsetBarWidth) {
- lp.leftMargin = mLeftInsetBarWidth;
- lp.rightMargin = mRightInsetBarWidth;
+ if (lp.leftMargin != mConsumedInsets.left || lp.rightMargin != mConsumedInsets.right ||
+ lp.bottomMargin != mConsumedInsets.bottom) {
+ lp.leftMargin = mConsumedInsets.left;
+ lp.rightMargin = mConsumedInsets.right;
+ lp.topMargin = mConsumedInsets.top;
+ lp.bottomMargin = mConsumedInsets.bottom;
mAlignedView.setLayoutParams(lp);
}
}
@@ -109,14 +117,16 @@
super.dispatchDraw(canvas);
// If the right inset is opaque, draw a black rectangle to ensure that is stays opaque.
- if (mDrawSideInsetBar) {
- if (mRightInsetBarWidth > 0) {
- int width = getWidth();
- canvas.drawRect(width - mRightInsetBarWidth, 0, width, getHeight(), mOpaquePaint);
- }
- if (mLeftInsetBarWidth > 0) {
- canvas.drawRect(0, 0, mLeftInsetBarWidth, getHeight(), mOpaquePaint);
- }
+ if (mConsumedInsets.right > 0) {
+ int width = getWidth();
+ canvas.drawRect(width - mConsumedInsets.right, 0, width, getHeight(), mOpaquePaint);
+ }
+ if (mConsumedInsets.left > 0) {
+ canvas.drawRect(0, 0, mConsumedInsets.left, getHeight(), mOpaquePaint);
+ }
+ if (mConsumedInsets.bottom > 0) {
+ int height = getHeight();
+ canvas.drawRect(0, height - mConsumedInsets.bottom, getWidth(), height, mOpaquePaint);
}
}
diff --git a/src/com/android/launcher3/anim/AnimatorPlaybackController.java b/src/com/android/launcher3/anim/AnimatorPlaybackController.java
index 8e729e8..84085cb 100644
--- a/src/com/android/launcher3/anim/AnimatorPlaybackController.java
+++ b/src/com/android/launcher3/anim/AnimatorPlaybackController.java
@@ -206,6 +206,10 @@
mOnCancelRunnable = runnable;
}
+ public Runnable getOnCancelRunnable() {
+ return mOnCancelRunnable;
+ }
+
public static class AnimatorPlaybackControllerVL extends AnimatorPlaybackController {
private final ValueAnimator[] mChildAnimations;
diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
index 658af95..bad4976 100644
--- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
+++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
@@ -244,8 +244,13 @@
endProgress - Math.max(progress, 0));
}
} else {
+ // Let the state manager know that the animation didn't go to the target state,
+ // but don't cancel ourselves (we already clean up when the animation completes).
+ Runnable onCancel = mCurrentAnimation.getOnCancelRunnable();
mCurrentAnimation.setOnCancelRunnable(null);
mCurrentAnimation.dispatchOnCancel();
+ mCurrentAnimation.setOnCancelRunnable(onCancel);
+
endProgress = 0;
if (progress <= 0) {
duration = 0;
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/DisplayRotationListener.java b/src_ui_overrides/com/android/launcher3/uioverrides/DisplayRotationListener.java
new file mode 100644
index 0000000..b1a67e9
--- /dev/null
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/DisplayRotationListener.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2018 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;
+
+import android.content.Context;
+import android.view.OrientationEventListener;
+
+/**
+ * Utility class for listening for rotation changes
+ */
+public class DisplayRotationListener extends OrientationEventListener {
+
+ private final Runnable mCallback;
+
+ public DisplayRotationListener(Context context, Runnable callback) {
+ super(context);
+ mCallback = callback;
+ }
+
+ @Override
+ public void onOrientationChanged(int i) {
+ mCallback.run();
+ }
+}