Merge "Reenabling switching between nav modes in tests" into ub-launcher3-qt-dev
diff --git a/go/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java b/go/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
index d20910f..1b24fc8 100644
--- a/go/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
+++ b/go/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
@@ -52,12 +52,19 @@
public void onStateEnabled(Launcher launcher) {
IconRecentsView recentsView = launcher.getOverviewPanel();
recentsView.onBeginTransitionToOverview();
+ recentsView.setShowStatusBarForegroundScrim(true);
// Request orientation be set to unspecified, letting the system decide the best
// orientation.
launcher.getRotationHelper().setCurrentStateRequest(REQUEST_ROTATE);
}
@Override
+ public void onStateDisabled(Launcher launcher) {
+ IconRecentsView recentsView = launcher.getOverviewPanel();
+ recentsView.setShowStatusBarForegroundScrim(false);
+ }
+
+ @Override
public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) {
return new PageAlphaProvider(DEACCEL_2) {
@Override
diff --git a/go/quickstep/src/com/android/quickstep/RecentsActivity.java b/go/quickstep/src/com/android/quickstep/RecentsActivity.java
index f2ca368..9fb8067 100644
--- a/go/quickstep/src/com/android/quickstep/RecentsActivity.java
+++ b/go/quickstep/src/com/android/quickstep/RecentsActivity.java
@@ -37,6 +37,7 @@
mRecentsRootView = findViewById(R.id.drag_layer);
mIconRecentsView = findViewById(R.id.overview_panel);
mIconRecentsView.setRecentsToActivityHelper(new FallbackRecentsToActivityHelper(this));
+ mIconRecentsView.setShowStatusBarForegroundScrim(true);
}
@Override
diff --git a/go/quickstep/src/com/android/quickstep/TaskSwipeCallback.java b/go/quickstep/src/com/android/quickstep/TaskSwipeCallback.java
index 7686543..57f49d6 100644
--- a/go/quickstep/src/com/android/quickstep/TaskSwipeCallback.java
+++ b/go/quickstep/src/com/android/quickstep/TaskSwipeCallback.java
@@ -26,16 +26,18 @@
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
+import java.util.function.Consumer;
+
/**
* Callback for swipe input on {@link TaskHolder} views in the recents view.
*/
public final class TaskSwipeCallback extends ItemTouchHelper.SimpleCallback {
- private final TaskActionController mTaskActionController;
+ private final Consumer<TaskHolder> mOnTaskSwipeCallback;
- public TaskSwipeCallback(TaskActionController taskActionController) {
+ public TaskSwipeCallback(Consumer<TaskHolder> onTaskSwipeCallback) {
super(0 /* dragDirs */, RIGHT);
- mTaskActionController = taskActionController;
+ mOnTaskSwipeCallback = onTaskSwipeCallback;
}
@Override
@@ -47,7 +49,7 @@
@Override
public void onSwiped(ViewHolder viewHolder, int direction) {
if (direction == RIGHT) {
- mTaskActionController.removeTask((TaskHolder) viewHolder);
+ mOnTaskSwipeCallback.accept((TaskHolder) viewHolder);
}
}
diff --git a/go/quickstep/src/com/android/quickstep/ThumbnailDrawable.java b/go/quickstep/src/com/android/quickstep/ThumbnailDrawable.java
index a8cc0a1..922e68a 100644
--- a/go/quickstep/src/com/android/quickstep/ThumbnailDrawable.java
+++ b/go/quickstep/src/com/android/quickstep/ThumbnailDrawable.java
@@ -57,6 +57,7 @@
mCornerRadius = (int) res.getDimension(R.dimen.task_thumbnail_corner_radius);
mShader = new BitmapShader(mThumbnailData.thumbnail, CLAMP, CLAMP);
mPaint.setShader(mShader);
+ mPaint.setAntiAlias(true);
updateMatrix();
}
diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
index f951304..7225e57 100644
--- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
+++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
@@ -33,6 +33,7 @@
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
import android.util.ArraySet;
import android.util.AttributeSet;
import android.util.FloatProperty;
@@ -54,6 +55,7 @@
import com.android.launcher3.BaseActivity;
import com.android.launcher3.Insettable;
import com.android.launcher3.R;
+import com.android.launcher3.util.Themes;
import com.android.quickstep.ContentFillItemAnimator;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.RecentsToActivityHelper;
@@ -114,6 +116,8 @@
private final DefaultItemAnimator mDefaultItemAnimator = new DefaultItemAnimator();
private final ContentFillItemAnimator mLoadingContentItemAnimator =
new ContentFillItemAnimator();
+ private final BaseActivity mActivity;
+ private final Drawable mStatusBarForegroundScrim;
private RecentsToActivityHelper mActivityHelper;
private RecyclerView mTaskRecyclerView;
@@ -143,8 +147,10 @@
public IconRecentsView(Context context, AttributeSet attrs) {
super(context, attrs);
- BaseActivity activity = BaseActivity.fromContext(context);
+ mActivity = BaseActivity.fromContext(context);
mContext = context;
+ mStatusBarForegroundScrim =
+ Themes.getAttrDrawable(mContext, R.attr.workspaceStatusBarScrim);
mTaskLoader = new TaskListLoader(mContext);
mTaskAdapter = new TaskAdapter(mTaskLoader);
mTaskAdapter.setOnClearAllClickListener(view -> animateClearAllTasks());
@@ -162,7 +168,12 @@
mTaskRecyclerView.setAdapter(mTaskAdapter);
mTaskRecyclerView.setLayoutManager(mTaskLayoutManager);
ItemTouchHelper helper = new ItemTouchHelper(
- new TaskSwipeCallback(mTaskActionController));
+ new TaskSwipeCallback(holder -> {
+ mTaskActionController.removeTask(holder);
+ if (mTaskLoader.getCurrentTaskList().isEmpty()) {
+ mActivityHelper.leaveRecents();
+ }
+ }));
helper.attachToRecyclerView(mTaskRecyclerView);
mTaskRecyclerView.addOnChildAttachStateChangeListener(
new OnChildAttachStateChangeListener() {
@@ -339,6 +350,21 @@
}
/**
+ * Set whether or not to show the scrim in between the view and the top insets. This only works
+ * if the view is being insetted in the first place.
+ *
+ * The scrim is added to the activity's root view to prevent animations on this view
+ * affecting the scrim. As a result, it is the activity's responsibility to show/hide this
+ * scrim as appropriate.
+ *
+ * @param showStatusBarForegroundScrim true to show the scrim, false to hide
+ */
+ public void setShowStatusBarForegroundScrim(boolean showStatusBarForegroundScrim) {
+ boolean shouldShow = mInsets.top != 0 && showStatusBarForegroundScrim;
+ mActivity.getDragLayer().setForeground(shouldShow ? mStatusBarForegroundScrim : null);
+ }
+
+ /**
* Get the bottom most thumbnail view to animate to.
*
* @return the thumbnail view if laid out
@@ -438,7 +464,6 @@
if (mShowingContentView != mEmptyView && taskListSize == 0) {
mShowingContentView = mEmptyView;
crossfadeViews(mEmptyView, mContentView);
- mActivityHelper.leaveRecents();
}
if (mShowingContentView != mContentView && taskListSize > 0) {
mShowingContentView = mContentView;
diff --git a/go/quickstep/src/com/android/quickstep/views/TaskItemView.java b/go/quickstep/src/com/android/quickstep/views/TaskItemView.java
index a5f5728..6db8013 100644
--- a/go/quickstep/src/com/android/quickstep/views/TaskItemView.java
+++ b/go/quickstep/src/com/android/quickstep/views/TaskItemView.java
@@ -49,6 +49,7 @@
private ImageView mIconView;
private ImageView mThumbnailView;
private float mContentTransitionProgress;
+ private int mDisplayedOrientation;
/**
* Property representing the content transition progress of the view. 1.0f represents that the
@@ -179,13 +180,27 @@
}
@Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ onOrientationChanged(getResources().getConfiguration().orientation);
+ }
+
+ @Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
+ onOrientationChanged(newConfig.orientation);
+ }
+
+ private void onOrientationChanged(int newOrientation) {
+ if (mDisplayedOrientation == newOrientation) {
+ return;
+ }
+ mDisplayedOrientation = newOrientation;
int layerCount = mThumbnailDrawable.getNumberOfLayers();
for (int i = 0; i < layerCount; i++) {
Drawable drawable = mThumbnailDrawable.getDrawable(i);
if (drawable instanceof ThumbnailDrawable) {
- ((ThumbnailDrawable) drawable).setRequestedOrientation(newConfig.orientation);
+ ((ThumbnailDrawable) drawable).setRequestedOrientation(newOrientation);
}
}
mTaskIconThumbnailView.forceLayout();
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
index 61d329b..50f25fb 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
@@ -116,7 +116,7 @@
} else {
workspaceView = null;
}
- final Rect iconLocation = new Rect();
+ final RectF iconLocation = new RectF();
boolean canUseWorkspaceView = workspaceView != null && workspaceView.isAttachedToWindow();
final FloatingIconView floatingView = canUseWorkspaceView
? FloatingIconView.getFloatingIconView(activity, workspaceView,
@@ -138,7 +138,7 @@
final float targetCenterY = dp.availableHeightPx - dp.hotseatBarSizePx;
if (canUseWorkspaceView) {
- return new RectF(iconLocation);
+ return iconLocation;
} else {
// Fallback to animate to center of screen.
return new RectF(targetCenterX - halfIconSize, targetCenterY - halfIconSize,
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java
index 833a468..7fc5d50 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java
@@ -45,6 +45,7 @@
import android.view.WindowManager;
import com.android.launcher3.R;
+import com.android.launcher3.graphics.RotationMode;
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.RaceConditionTracker;
import com.android.launcher3.util.TraceHelper;
@@ -164,8 +165,10 @@
// Proxy events to recents view
if (mPassedDragSlop && mInteractionHandler != null
&& !mRecentsViewDispatcher.hasConsumer()) {
- mRecentsViewDispatcher.setConsumer(mInteractionHandler
- .getRecentsViewDispatcher(isNavBarOnLeft() || isNavBarOnRight()));
+ mRecentsViewDispatcher.setConsumer(mInteractionHandler.getRecentsViewDispatcher(
+ isNavBarOnLeft()
+ ? RotationMode.SEASCAPE
+ : (isNavBarOnRight() ? RotationMode.LANDSCAPE : RotationMode.NORMAL)));
}
int edgeFlags = ev.getEdgeFlags();
ev.setEdgeFlags(edgeFlags | EDGE_NAV_BAR);
@@ -402,15 +405,13 @@
}
private float getDisplacement(MotionEvent ev) {
- final float displacement;
if (isNavBarOnRight()) {
- displacement = ev.getX() - mDownPos.x;
+ return ev.getX() - mDownPos.x;
} else if (isNavBarOnLeft()) {
- displacement = mDownPos.x - ev.getX();
+ return mDownPos.x - ev.getX();
} else {
- displacement = ev.getY() - mDownPos.y;
+ return ev.getY() - mDownPos.y;
}
- return displacement;
}
@Override
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewInputConsumer.java
index b48e3de..bafc367 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewInputConsumer.java
@@ -22,13 +22,15 @@
import android.view.KeyEvent;
import android.view.MotionEvent;
+import androidx.annotation.Nullable;
+
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.Utilities;
import com.android.launcher3.views.BaseDragLayer;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.InputMonitorCompat;
-import androidx.annotation.Nullable;
+import java.util.function.Predicate;
/**
* Input consumer for handling touch on the recents/Launcher activity.
@@ -42,6 +44,7 @@
private final int[] mLocationOnScreen = new int[2];
private final boolean mProxyTouch;
+ private final Predicate<MotionEvent> mEventReceiver;
private final boolean mStartingInActivityBounds;
private boolean mTargetHandledTouch;
@@ -53,10 +56,15 @@
mStartingInActivityBounds = startingInActivityBounds;
mTarget = activity.getDragLayer();
- if (!startingInActivityBounds) {
+ if (startingInActivityBounds) {
+ mEventReceiver = mTarget::dispatchTouchEvent;
+ mProxyTouch = true;
+ } else {
+ // Only proxy touches to controllers if we are starting touch from nav bar.
+ mEventReceiver = mTarget::proxyTouchEvent;
mTarget.getLocationOnScreen(mLocationOnScreen);
+ mProxyTouch = mTarget.prepareProxyEventStarting();
}
- mProxyTouch = mTarget.prepareProxyEventStarting();
}
@Override
@@ -80,7 +88,7 @@
ev.setEdgeFlags(flags | Utilities.EDGE_NAV_BAR);
}
ev.offsetLocation(-mLocationOnScreen[0], -mLocationOnScreen[1]);
- boolean handled = mTarget.proxyTouchEvent(ev);
+ boolean handled = mEventReceiver.test(ev);
ev.offsetLocation(mLocationOnScreen[0], mLocationOnScreen[1]);
ev.setEdgeFlags(flags);
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
index 09a1f3b..b25865e 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
@@ -30,6 +30,7 @@
import android.app.KeyguardManager;
import android.app.Service;
import android.content.BroadcastReceiver;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -45,6 +46,7 @@
import android.os.Looper;
import android.os.Process;
import android.os.RemoteException;
+import android.text.TextUtils;
import android.util.Log;
import android.view.Choreographer;
import android.view.Display;
@@ -54,6 +56,7 @@
import android.view.WindowManager;
import com.android.launcher3.MainThreadExecutor;
+import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.logging.EventLogArray;
@@ -78,7 +81,7 @@
/**
* Service connected by system-UI for handling touch interaction.
*/
-@TargetApi(Build.VERSION_CODES.O)
+@TargetApi(Build.VERSION_CODES.Q)
public class TouchInteractionService extends Service implements
NavigationModeChangeListener, DisplayListener {
@@ -229,6 +232,7 @@
private Mode mMode = Mode.THREE_BUTTONS;
private int mDefaultDisplayId;
private final RectF mSwipeTouchRegion = new RectF();
+ private ComponentName mGestureBlockingActivity;
@Override
public void onCreate() {
@@ -250,6 +254,10 @@
mDefaultDisplayId = getSystemService(WindowManager.class).getDefaultDisplay()
.getDisplayId();
+
+ String blockingActivity = getString(R.string.gesture_blocking_activity);
+ mGestureBlockingActivity = TextUtils.isEmpty(blockingActivity) ? null :
+ ComponentName.unflattenFromString(blockingActivity);
sConnected = true;
}
@@ -464,6 +472,9 @@
} else if (ENABLE_QUICKSTEP_LIVE_TILE.get() &&
activityControl.isInLiveTileMode()) {
base = OverviewInputConsumer.newInstance(activityControl, mInputMonitorCompat, false);
+ } else if (mGestureBlockingActivity != null && runningTaskInfo != null
+ && mGestureBlockingActivity.equals(runningTaskInfo.topActivity)) {
+ base = InputConsumer.NO_OP;
} else {
base = createOtherActivityInputConsumer(event, runningTaskInfo);
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java
index 2471f64..9c6102e 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -77,6 +77,7 @@
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.Interpolators;
+import com.android.launcher3.graphics.RotationMode;
import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
@@ -220,6 +221,8 @@
protected Runnable mGestureEndCallback;
protected GestureEndTarget mGestureEndTarget;
+ // Either RectFSpringAnim (if animating home) or ObjectAnimator (from mCurrentShift) otherwise
+ private RunningWindowAnim mRunningWindowAnim;
private boolean mIsShelfPeeking;
private DeviceProfile mDp;
private int mTransitionDragLength;
@@ -531,8 +534,8 @@
return TaskView.getCurveScaleForInterpolation(interpolation);
}
- public Consumer<MotionEvent> getRecentsViewDispatcher(boolean isTransposed) {
- return mRecentsView != null ? mRecentsView.getEventDispatcher(isTransposed) : null;
+ public Consumer<MotionEvent> getRecentsViewDispatcher(RotationMode rotationMode) {
+ return mRecentsView != null ? mRecentsView.getEventDispatcher(rotationMode) : null;
}
@UiThread
@@ -805,7 +808,7 @@
@UiThread
private InputConsumer createNewInputProxyHandler() {
- mCurrentShift.finishAnimation();
+ endRunningWindowAnim();
if (mLauncherTransitionController != null) {
mLauncherTransitionController.getAnimationPlayer().end();
}
@@ -817,6 +820,12 @@
return OverviewInputConsumer.newInstance(mActivityControlHelper, null, true);
}
+ private void endRunningWindowAnim() {
+ if (mRunningWindowAnim != null) {
+ mRunningWindowAnim.end();
+ }
+ }
+
@UiThread
private void handleNormalGestureEnd(float endVelocity, boolean isFling, PointF velocity,
boolean isCancel) {
@@ -898,12 +907,15 @@
}
}
+ if (endTarget.isLauncher) {
+ mRecentsAnimationWrapper.enableInputProxy();
+ }
+
if (endTarget == HOME) {
setShelfState(ShelfAnimState.CANCEL, LINEAR, 0);
duration = Math.max(MIN_OVERSHOOT_DURATION, duration);
} else if (endTarget == RECENTS) {
mLiveTileOverlay.startIconAnimation();
- mRecentsAnimationWrapper.enableInputProxy();
if (mRecentsView != null) {
duration = Math.max(duration, mRecentsView.getScroller().getDuration());
}
@@ -984,6 +996,7 @@
}
});
windowAnim.start(velocityPxPerMs);
+ mRunningWindowAnim = RunningWindowAnim.wrap(windowAnim);
mLauncherTransitionController = null;
} else {
ValueAnimator windowAnim = mCurrentShift.animateToValue(start, end);
@@ -1002,6 +1015,7 @@
}
});
windowAnim.start();
+ mRunningWindowAnim = RunningWindowAnim.wrap(windowAnim);
}
// Always play the entire launcher animation when going home, since it is separate from
// the animation that has been controlled thus far.
@@ -1113,7 +1127,7 @@
false /* animate */, true /* freezeTaskList */);
});
}
- TOUCH_INTERACTION_LOG.addLog("finishRecentsAnimation", false);
+ TOUCH_INTERACTION_LOG.addLog("finishRecentsAnimation", true);
doLogGesture(NEW_TASK);
reset();
}
@@ -1135,7 +1149,7 @@
}
private void invalidateHandler() {
- mCurrentShift.finishAnimation();
+ endRunningWindowAnim();
if (mGestureEndCallback != null) {
mGestureEndCallback.run();
@@ -1283,4 +1297,16 @@
return app.isNotInRecents
|| app.activityType == RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME;
}
+
+ private interface RunningWindowAnim {
+ void end();
+
+ static RunningWindowAnim wrap(Animator animator) {
+ return animator::end;
+ }
+
+ static RunningWindowAnim wrap(RectFSpringAnim rectFSpringAnim) {
+ return rectFSpringAnim::end;
+ }
+ }
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/ClipAnimationHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/ClipAnimationHelper.java
index cb2bf1f..3109921 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/ClipAnimationHelper.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/ClipAnimationHelper.java
@@ -31,11 +31,12 @@
import android.os.Build;
import android.os.RemoteException;
+import androidx.annotation.Nullable;
+
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
-import com.android.launcher3.util.Themes;
import com.android.launcher3.views.BaseDragLayer;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.views.RecentsView;
@@ -50,8 +51,6 @@
import java.util.function.BiFunction;
-import androidx.annotation.Nullable;
-
/**
* Utility class to handle window clip animation
*/
@@ -327,12 +326,14 @@
float scale = mTargetRect.width() / mSourceRect.width();
float insetProgress = (1 - progress);
+ float windowCornerRadius = mUseRoundedCornersOnWindows
+ ? mWindowCornerRadius : 0;
ttv.drawOnCanvas(canvas,
-mSourceWindowClipInsets.left * insetProgress,
-mSourceWindowClipInsets.top * insetProgress,
ttv.getMeasuredWidth() + mSourceWindowClipInsets.right * insetProgress,
ttv.getMeasuredHeight() + mSourceWindowClipInsets.bottom * insetProgress,
- Utilities.mapRange(progress, mWindowCornerRadius * scale, ttv.getCornerRadius()));
+ Utilities.mapRange(progress, windowCornerRadius * scale, ttv.getCornerRadius()));
}
public RectF getTargetRect() {
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RectFSpringAnim.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RectFSpringAnim.java
index 2edeb3a..7159e7c 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RectFSpringAnim.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RectFSpringAnim.java
@@ -23,6 +23,9 @@
import android.graphics.RectF;
import android.util.FloatProperty;
+import androidx.dynamicanimation.animation.DynamicAnimation.OnAnimationEndListener;
+import androidx.dynamicanimation.animation.FloatPropertyCompat;
+
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.FlingSpringAnim;
@@ -30,9 +33,6 @@
import java.util.ArrayList;
import java.util.List;
-import androidx.dynamicanimation.animation.DynamicAnimation.OnAnimationEndListener;
-import androidx.dynamicanimation.animation.FloatPropertyCompat;
-
/**
* Applies spring forces to animate from a starting rect to a target rect,
* while providing update callbacks to the caller.
@@ -98,6 +98,10 @@
private float mCurrentCenterX;
private float mCurrentCenterY;
private float mCurrentScaleProgress;
+ private FlingSpringAnim mRectXAnim;
+ private FlingSpringAnim mRectYAnim;
+ private ValueAnimator mRectScaleAnim;
+ private boolean mAnimsStarted;
private boolean mRectXAnimEnded;
private boolean mRectYAnimEnded;
private boolean mRectScaleAnimEnded;
@@ -127,15 +131,15 @@
mRectYAnimEnded = true;
maybeOnEnd();
});
- FlingSpringAnim rectXAnim = new FlingSpringAnim(this, RECT_CENTER_X, mCurrentCenterX,
+ mRectXAnim = new FlingSpringAnim(this, RECT_CENTER_X, mCurrentCenterX,
mTargetRect.centerX(), velocityPxPerMs.x * 1000, onXEndListener);
- FlingSpringAnim rectYAnim = new FlingSpringAnim(this, RECT_CENTER_Y, mCurrentCenterY,
+ mRectYAnim = new FlingSpringAnim(this, RECT_CENTER_Y, mCurrentCenterY,
mTargetRect.centerY(), velocityPxPerMs.y * 1000, onYEndListener);
- ValueAnimator rectScaleAnim = ObjectAnimator.ofPropertyValuesHolder(this,
+ mRectScaleAnim = ObjectAnimator.ofPropertyValuesHolder(this,
PropertyValuesHolder.ofFloat(RECT_SCALE_PROGRESS, 1))
.setDuration(RECT_SCALE_DURATION);
- rectScaleAnim.addListener(new AnimationSuccessListener() {
+ mRectScaleAnim.addListener(new AnimationSuccessListener() {
@Override
public void onAnimationSuccess(Animator animator) {
mRectScaleAnimEnded = true;
@@ -143,14 +147,23 @@
}
});
- rectXAnim.start();
- rectYAnim.start();
- rectScaleAnim.start();
+ mRectXAnim.start();
+ mRectYAnim.start();
+ mRectScaleAnim.start();
+ mAnimsStarted = true;
for (Animator.AnimatorListener animatorListener : mAnimatorListeners) {
animatorListener.onAnimationStart(null);
}
}
+ public void end() {
+ if (mAnimsStarted) {
+ mRectXAnim.end();
+ mRectYAnim.end();
+ mRectScaleAnim.end();
+ }
+ }
+
private void onUpdate() {
if (!mOnUpdateListeners.isEmpty()) {
float currentWidth = Utilities.mapRange(mCurrentScaleProgress, mStartRect.width(),
@@ -166,7 +179,8 @@
}
private void maybeOnEnd() {
- if (mRectXAnimEnded && mRectYAnimEnded && mRectScaleAnimEnded) {
+ if (mAnimsStarted && mRectXAnimEnded && mRectYAnimEnded && mRectScaleAnimEnded) {
+ mAnimsStarted = false;
for (Animator.AnimatorListener animatorListener : mAnimatorListeners) {
animatorListener.onAnimationEnd(null);
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewDrawable.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewDrawable.java
index 10283bf..bb41e5d 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewDrawable.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewDrawable.java
@@ -25,6 +25,7 @@
import android.util.FloatProperty;
import android.view.View;
+import com.android.launcher3.BaseActivity;
import com.android.launcher3.Utilities;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskThumbnailView;
@@ -52,7 +53,7 @@
private final RecentsView mParent;
private final View mIconView;
- private final int[] mIconPos;
+ private final float[] mIconPos;
private final TaskView mTaskView;
private final TaskThumbnailView mThumbnailView;
@@ -68,13 +69,15 @@
mParent = parent;
mTaskView = tv;
mIconView = tv.getIconView();
- mIconPos = new int[2];
+ mIconPos = new float[2];
mIconScale = mIconView.getScaleX();
Utilities.getDescendantCoordRelativeToAncestor(mIconView, parent, mIconPos, true);
mThumbnailView = tv.getThumbnail();
mClipAnimationHelper = new ClipAnimationHelper(parent.getContext());
mClipAnimationHelper.fromTaskThumbnailView(mThumbnailView, parent);
+ mClipAnimationHelper.prepareAnimation(
+ BaseActivity.fromContext(tv.getContext()).getDeviceProfile(), true /* isOpening */);
}
public void setProgress(float progress) {
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
index 2fdfda1..b5f90a5 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
@@ -83,6 +83,7 @@
import com.android.launcher3.anim.PropertyListBuilder;
import com.android.launcher3.anim.SpringObjectAnimator;
import com.android.launcher3.config.FeatureFlags;
+import com.android.launcher3.graphics.RotationMode;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
@@ -1641,10 +1642,10 @@
return mClearAllButton;
}
- public Consumer<MotionEvent> getEventDispatcher(boolean isTransposed) {
- if (isTransposed) {
+ public Consumer<MotionEvent> getEventDispatcher(RotationMode rotationMode) {
+ if (rotationMode.isTransposed) {
Matrix transform = new Matrix();
- transform.setRotate(90);
+ transform.setRotate(-rotationMode.surfaceRotation);
if (getWidth() > 0 && getHeight() > 0) {
float scale = ((float) getWidth()) / getHeight();
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java
index 1117855..7e15d52 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -79,8 +79,8 @@
private final BaseActivity mActivity;
private final TaskOverlay mOverlay;
private final boolean mIsDarkTextTheme;
- private final Paint mPaint = new Paint();
- private final Paint mBackgroundPaint = new Paint();
+ private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ private final Paint mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private final Paint mClearPaint = new Paint();
private final Paint mDimmingPaintAfterClearing = new Paint();
@@ -210,9 +210,9 @@
mCurrentDrawnCornerRadius);
}
- public Rect getInsetsToDrawInFullscreen() {
- // Don't show insets in the wrong orientation.
- return mIsRotated ? EMPTY_RECT : mScaledInsets;
+ public Rect getInsetsToDrawInFullscreen(boolean isMultiWindowMode) {
+ // Don't show insets in the wrong orientation or in multi window mode.
+ return mIsRotated || isMultiWindowMode ? EMPTY_RECT : mScaledInsets;
}
public void setCurrentDrawnInsetsAndRadius(Rect insets, float radius) {
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java
index 7f32b84..6cd46d9 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java
@@ -18,7 +18,6 @@
import static android.widget.Toast.LENGTH_SHORT;
-import static com.android.launcher3.BaseActivity.fromContext;
import static com.android.launcher3.QuickstepAppTransitionManagerImpl.RECENTS_LAUNCH_DURATION;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.LINEAR;
@@ -71,6 +70,7 @@
import com.android.systemui.shared.system.ActivityOptionsCompat;
import com.android.systemui.shared.system.QuickStepContract;
+import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
@@ -99,6 +99,9 @@
public static final long SCALE_ICON_DURATION = 120;
private static final long DIM_ANIM_DURATION = 700;
+ private static final List<Rect> SYSTEM_GESTURE_EXCLUSION_RECT =
+ Collections.singletonList(new Rect());
+
public static final Property<TaskView, Float> ZOOM_SCALE =
new FloatProperty<TaskView>("zoomScale") {
@Override
@@ -164,8 +167,9 @@
private float mZoomScale;
private float mFullscreenProgress;
private final Rect mCurrentDrawnInsets = new Rect();
- private float mCornerRadius;
- private float mWindowCornerRadius;
+ private final float mCornerRadius;
+ private final float mWindowCornerRadius;
+ private final BaseDraggingActivity mActivity;
private ObjectAnimator mIconAndDimAnimator;
private float mIconScaleAnimStartProgress = 0;
@@ -187,6 +191,7 @@
public TaskView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
+ mActivity = BaseDraggingActivity.fromContext(context);
setOnClickListener((view) -> {
if (getTask() == null) {
return;
@@ -201,10 +206,10 @@
launchTask(true /* animate */);
}
- fromContext(context).getUserEventDispatcher().logTaskLaunchOrDismiss(
+ mActivity.getUserEventDispatcher().logTaskLaunchOrDismiss(
Touch.TAP, Direction.NONE, getRecentsView().indexOfChild(this),
TaskUtils.getLaunchComponentKeyForTask(getTask().key));
- fromContext(context).getStatsLogManager().logTaskLaunch(getRecentsView(),
+ mActivity.getStatsLogManager().logTaskLaunch(getRecentsView(),
TaskUtils.getLaunchComponentKeyForTask(getTask().key));
});
mCornerRadius = TaskCornerRadius.get(context);
@@ -303,8 +308,7 @@
if (mTask != null) {
final ActivityOptions opts;
if (animate) {
- opts = ((BaseDraggingActivity) fromContext(getContext()))
- .getActivityLaunchOptions(this);
+ opts = mActivity.getActivityLaunchOptions(this);
if (freezeTaskList) {
ActivityOptionsCompat.setFreezeRecentTasksList(opts);
}
@@ -492,6 +496,10 @@
super.onLayout(changed, left, top, right, bottom);
setPivotX((right - left) * 0.5f);
setPivotY(mSnapshotView.getTop() + mSnapshotView.getHeight() * 0.5f);
+ if (Utilities.ATLEAST_Q) {
+ SYSTEM_GESTURE_EXCLUSION_RECT.get(0).set(0, 0, getWidth(), getHeight());
+ setSystemGestureExclusionRects(SYSTEM_GESTURE_EXCLUSION_RECT);
+ }
}
public static float getCurveScaleForInterpolation(float linearInterpolation) {
@@ -564,13 +572,12 @@
getContext().getText(R.string.accessibility_close_task)));
final Context context = getContext();
- final BaseDraggingActivity activity = fromContext(context);
final List<TaskSystemShortcut> shortcuts =
mSnapshotView.getTaskOverlay().getEnabledShortcuts(this);
final int count = shortcuts.size();
for (int i = 0; i < count; ++i) {
final TaskSystemShortcut menuOption = shortcuts.get(i);
- OnClickListener onClickListener = menuOption.getOnClickListener(activity, this);
+ OnClickListener onClickListener = menuOption.getOnClickListener(mActivity, this);
if (onClickListener != null) {
info.addAction(menuOption.createAccessibilityAction(context));
}
@@ -610,8 +617,7 @@
for (int i = 0; i < count; ++i) {
final TaskSystemShortcut menuOption = shortcuts.get(i);
if (menuOption.hasHandlerForAction(action)) {
- OnClickListener onClickListener = menuOption.getOnClickListener(
- fromContext(getContext()), this);
+ OnClickListener onClickListener = menuOption.getOnClickListener(mActivity, this);
if (onClickListener != null) {
onClickListener.onClick(this);
}
@@ -651,13 +657,15 @@
setClipToPadding(!isFullscreen);
TaskThumbnailView thumbnail = getThumbnail();
- Rect insets = thumbnail.getInsetsToDrawInFullscreen();
+ boolean isMultiWindowMode = mActivity.getDeviceProfile().isMultiWindowMode;
+ Rect insets = thumbnail.getInsetsToDrawInFullscreen(isMultiWindowMode);
mCurrentDrawnInsets.set((int) (insets.left * mFullscreenProgress),
(int) (insets.top * mFullscreenProgress),
(int) (insets.right * mFullscreenProgress),
(int) (insets.bottom * mFullscreenProgress));
+ float fullscreenCornerRadius = isMultiWindowMode ? 0 : mWindowCornerRadius;
float cornerRadius = Utilities.mapRange(mFullscreenProgress, mCornerRadius,
- mWindowCornerRadius) / getRecentsView().getScaleX();
+ fullscreenCornerRadius) / getRecentsView().getScaleX();
thumbnail.setCurrentDrawnInsetsAndRadius(mCurrentDrawnInsets, cornerRadius);
mOutlineProvider.setCurrentDrawnInsetsAndRadius(mCurrentDrawnInsets, cornerRadius);
diff --git a/quickstep/res/values/config.xml b/quickstep/res/values/config.xml
index 95aea43..e84543b 100644
--- a/quickstep/res/values/config.xml
+++ b/quickstep/res/values/config.xml
@@ -18,6 +18,9 @@
<string name="overview_callbacks_class" translatable="false"></string>
+ <!-- Activity which blocks home gesture -->
+ <string name="gesture_blocking_activity" translatable="false"></string>
+
<string name="user_event_dispatcher_class" translatable="false">com.android.quickstep.logging.UserEventDispatcherExtension</string>
<string name="stats_log_manager_class" translatable="false">com.android.quickstep.logging.StatsLogCompatManager</string>
diff --git a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
index a8666f9..e1a115a 100644
--- a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
+++ b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
@@ -408,7 +408,7 @@
*/
private ValueAnimator getOpeningWindowAnimators(View v, RemoteAnimationTargetCompat[] targets,
Rect windowTargetBounds, boolean toggleVisibility) {
- Rect bounds = new Rect();
+ RectF bounds = new RectF();
mFloatingView = FloatingIconView.getFloatingIconView(mLauncher, v, toggleVisibility,
bounds, true /* isOpening */, mFloatingView);
Rect crop = new Rect();
@@ -423,8 +423,8 @@
// Scale the app icon to take up the entire screen. This simplifies the math when
// animating the app window position / scale.
float smallestSize = Math.min(windowTargetBounds.height(), windowTargetBounds.width());
- float maxScaleX = smallestSize / (float) bounds.width();
- float maxScaleY = smallestSize / (float) bounds.height();
+ float maxScaleX = smallestSize / bounds.width();
+ float maxScaleY = smallestSize / bounds.height();
float scale = Math.max(maxScaleX, maxScaleY);
float startScale = 1f;
if (v instanceof BubbleTextView && !(v.getParent() instanceof DeepShortcutView)) {
diff --git a/quickstep/src/com/android/quickstep/TestInformationProvider.java b/quickstep/src/com/android/quickstep/TestInformationProvider.java
index a948570..b37ddda 100644
--- a/quickstep/src/com/android/quickstep/TestInformationProvider.java
+++ b/quickstep/src/com/android/quickstep/TestInformationProvider.java
@@ -111,14 +111,6 @@
response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) distance);
break;
}
-
- case TestProtocol.REQUEST_ENABLE_DRAG_LOGGING:
- TestProtocol.sDebugTracing = true;
- break;
-
- case TestProtocol.REQUEST_DISABLE_DRAG_LOGGING:
- TestProtocol.sDebugTracing = false;
- break;
}
return response;
}
diff --git a/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java b/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java
index e6dbf87..1817135 100644
--- a/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java
+++ b/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java
@@ -27,6 +27,9 @@
import android.os.Process;
import android.view.View;
+import androidx.test.filters.LargeTest;
+import androidx.test.runner.AndroidJUnit4;
+
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.Launcher;
import com.android.launcher3.appprediction.PredictionRowView;
@@ -44,9 +47,6 @@
import java.util.ArrayList;
import java.util.List;
-import androidx.test.filters.LargeTest;
-import androidx.test.runner.AndroidJUnit4;
-
@LargeTest
@RunWith(AndroidJUnit4.class)
public class AppPredictionsUITests extends AbstractQuickStepTest {
@@ -85,7 +85,7 @@
* Test that prediction UI is updated as soon as we get predictions from the system
*/
@Test
- @Ignore // b/131188880
+ @Ignore // b/131772711: this really fails (when being run as a part of the whole test suite)!
public void testPredictionExistsInAllApps() {
mActivityMonitor.startLauncher();
mLauncher.pressHome().switchToAllApps();
@@ -101,7 +101,6 @@
* Test that prediction update is deferred if it is already visible
*/
@Test
- @Ignore // b/131188880
public void testPredictionsDeferredUntilHome() {
mActivityMonitor.startLauncher();
sendPredictionUpdate(mSampleApp1, mSampleApp2);
@@ -119,6 +118,7 @@
}
@Test
+ @Ignore // b/131772711 - this was failing in the lab
public void testPredictionsDisabled() {
mActivityMonitor.startLauncher();
sendPredictionUpdate();
diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java
index c6fd906..ccd9e25 100644
--- a/src/com/android/launcher3/BaseDraggingActivity.java
+++ b/src/com/android/launcher3/BaseDraggingActivity.java
@@ -36,6 +36,7 @@
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.uioverrides.DisplayRotationListener;
import com.android.launcher3.uioverrides.WallpaperColorInfo;
+import com.android.launcher3.util.Themes;
import androidx.annotation.Nullable;
@@ -69,7 +70,7 @@
// Update theme
WallpaperColorInfo wallpaperColorInfo = WallpaperColorInfo.getInstance(this);
wallpaperColorInfo.addOnChangeListener(this);
- int themeRes = getThemeRes(wallpaperColorInfo);
+ int themeRes = Themes.getActivityThemeRes(this);
if (themeRes != mThemeRes) {
mThemeRes = themeRes;
setTheme(themeRes);
@@ -88,31 +89,11 @@
}
private void updateTheme() {
- WallpaperColorInfo wallpaperColorInfo = WallpaperColorInfo.getInstance(this);
- if (mThemeRes != getThemeRes(wallpaperColorInfo)) {
+ if (mThemeRes != Themes.getActivityThemeRes(this)) {
recreate();
}
}
- protected int getThemeRes(WallpaperColorInfo wallpaperColorInfo) {
- boolean darkTheme;
- if (Utilities.ATLEAST_Q) {
- Configuration configuration = getResources().getConfiguration();
- int nightMode = configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK;
- darkTheme = nightMode == Configuration.UI_MODE_NIGHT_YES;
- } else {
- darkTheme = wallpaperColorInfo.isDark();
- }
-
- if (darkTheme) {
- return wallpaperColorInfo.supportsDarkText() ?
- R.style.AppTheme_Dark_DarkText : R.style.AppTheme_Dark;
- } else {
- return wallpaperColorInfo.supportsDarkText() ?
- R.style.AppTheme_DarkText : R.style.AppTheme;
- }
- }
-
@Override
public void onActionModeStarted(ActionMode mode) {
super.onActionModeStarted(mode);
diff --git a/src/com/android/launcher3/BaseRecyclerView.java b/src/com/android/launcher3/BaseRecyclerView.java
index f300ef7..c84be4d 100644
--- a/src/com/android/launcher3/BaseRecyclerView.java
+++ b/src/com/android/launcher3/BaseRecyclerView.java
@@ -123,12 +123,12 @@
* @param ev MotionEvent in {@param eventSource}
*/
public boolean shouldContainerScroll(MotionEvent ev, View eventSource) {
- int[] point = new int[2];
- point[0] = (int) ev.getX();
- point[1] = (int) ev.getY();
+ float[] point = new float[2];
+ point[0] = ev.getX();
+ point[1] = ev.getY();
Utilities.mapCoordInSelfToDescendant(mScrollbar, eventSource, point);
// IF the MotionEvent is inside the thumb, container should not be pulled down.
- if (mScrollbar.shouldBlockIntercept(point[0], point[1])) {
+ if (mScrollbar.shouldBlockIntercept((int) point[0], (int) point[1])) {
return false;
}
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 3611ad4..8291acc 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -142,7 +142,6 @@
public BubbleTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mActivity = ActivityContext.lookupContext(context);
- DeviceProfile grid = mActivity.getDeviceProfile();
mSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
TypedArray a = context.obtainStyledAttributes(attrs,
@@ -150,18 +149,24 @@
mLayoutHorizontal = a.getBoolean(R.styleable.BubbleTextView_layoutHorizontal, false);
int display = a.getInteger(R.styleable.BubbleTextView_iconDisplay, DISPLAY_WORKSPACE);
- int defaultIconSize = grid.iconSizePx;
+ final int defaultIconSize;
if (display == DISPLAY_WORKSPACE) {
+ DeviceProfile grid = mActivity.getWallpaperDeviceProfile();
setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.iconTextSizePx);
setCompoundDrawablePadding(grid.iconDrawablePaddingPx);
+ defaultIconSize = grid.iconSizePx;
} else if (display == DISPLAY_ALL_APPS) {
+ DeviceProfile grid = mActivity.getDeviceProfile();
setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.allAppsIconTextSizePx);
setCompoundDrawablePadding(grid.allAppsIconDrawablePaddingPx);
defaultIconSize = grid.allAppsIconSizePx;
} else if (display == DISPLAY_FOLDER) {
+ DeviceProfile grid = mActivity.getDeviceProfile();
setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.folderChildTextSizePx);
setCompoundDrawablePadding(grid.folderChildDrawablePaddingPx);
defaultIconSize = grid.folderChildIconSizePx;
+ } else {
+ defaultIconSize = mActivity.getDeviceProfile().iconSizePx;
}
mCenterVertically = a.getBoolean(R.styleable.BubbleTextView_centerVertically, false);
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 9d9a639..3eb01e6 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -48,6 +48,9 @@
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
+import androidx.annotation.IntDef;
+import androidx.core.view.ViewCompat;
+
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.accessibility.DragAndDropAccessibilityDelegate;
import com.android.launcher3.accessibility.FolderAccessibilityHelper;
@@ -57,12 +60,14 @@
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.folder.PreviewBackground;
import com.android.launcher3.graphics.DragPreviewProvider;
+import com.android.launcher3.graphics.RotationMode;
import com.android.launcher3.util.CellAndSpan;
import com.android.launcher3.util.GridOccupancy;
import com.android.launcher3.util.ParcelableSparseArray;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.views.ActivityContext;
+import com.android.launcher3.views.Transposable;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
import java.lang.annotation.Retention;
@@ -73,10 +78,7 @@
import java.util.Comparator;
import java.util.Stack;
-import androidx.annotation.IntDef;
-import androidx.core.view.ViewCompat;
-
-public class CellLayout extends ViewGroup {
+public class CellLayout extends ViewGroup implements Transposable {
public static final int WORKSPACE_ACCESSIBILITY_DRAG = 2;
public static final int FOLDER_ACCESSIBILITY_DRAG = 1;
@@ -182,6 +184,7 @@
// Related to accessible drag and drop
private DragAndDropAccessibilityDelegate mTouchHelper;
private boolean mUseTouchHelper = false;
+ private RotationMode mRotationMode = RotationMode.NORMAL;
public CellLayout(Context context) {
this(context, null);
@@ -203,7 +206,7 @@
setClipToPadding(false);
mActivity = ActivityContext.lookupContext(context);
- DeviceProfile grid = mActivity.getDeviceProfile();
+ DeviceProfile grid = mActivity.getWallpaperDeviceProfile();
mCellWidth = mCellHeight = -1;
mFixedCellWidth = mFixedCellHeight = -1;
@@ -317,6 +320,24 @@
}
}
+ public void setRotationMode(RotationMode mode) {
+ if (mRotationMode != mode) {
+ mRotationMode = mode;
+ requestLayout();
+ }
+ }
+
+ @Override
+ public RotationMode getRotationMode() {
+ return mRotationMode;
+ }
+
+ @Override
+ public void setPadding(int left, int top, int right, int bottom) {
+ mRotationMode.mapRect(left, top, right, bottom, mTempRect);
+ super.setPadding(mTempRect.left, mTempRect.top, mTempRect.right, mTempRect.bottom);
+ }
+
@Override
public boolean dispatchHoverEvent(MotionEvent event) {
// Always attempt to dispatch hover events to accessibility first.
@@ -339,6 +360,10 @@
mShortcutsAndWidgets.setLayerType(hasLayer ? LAYER_TYPE_HARDWARE : LAYER_TYPE_NONE, sPaint);
}
+ public boolean isHardwareLayerEnabled() {
+ return mShortcutsAndWidgets.getLayerType() == LAYER_TYPE_HARDWARE;
+ }
+
public void setCellDimensions(int width, int height) {
mFixedCellWidth = mCellWidth = width;
mFixedCellHeight = mCellHeight = height;
@@ -745,6 +770,14 @@
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
int childWidthSize = widthSize - (getPaddingLeft() + getPaddingRight());
int childHeightSize = heightSize - (getPaddingTop() + getPaddingBottom());
+
+ mShortcutsAndWidgets.setRotation(mRotationMode.surfaceRotation);
+ if (mRotationMode.isTransposed) {
+ int tmp = childWidthSize;
+ childWidthSize = childHeightSize;
+ childHeightSize = tmp;
+ }
+
if (mFixedCellWidth < 0 || mFixedCellHeight < 0) {
int cw = DeviceProfile.calculateCellWidth(childWidthSize, mCountX);
int ch = DeviceProfile.calculateCellHeight(childHeightSize, mCountY);
@@ -787,7 +820,6 @@
int top = getPaddingTop();
int bottom = b - t - getPaddingBottom();
- mShortcutsAndWidgets.layout(left, top, right, bottom);
// Expand the background drawing bounds by the padding baked into the background drawable
mBackground.getPadding(mTempRect);
mBackground.setBounds(
@@ -795,6 +827,16 @@
top - mTempRect.top - getPaddingTop(),
right + mTempRect.right + getPaddingRight(),
bottom + mTempRect.bottom + getPaddingBottom());
+
+ if (mRotationMode.isTransposed) {
+ int halfW = mShortcutsAndWidgets.getMeasuredWidth() / 2;
+ int halfH = mShortcutsAndWidgets.getMeasuredHeight() / 2;
+ int cX = (left + right) / 2;
+ int cY = (top + bottom) / 2;
+ mShortcutsAndWidgets.layout(cX - halfW, cY - halfH, cX + halfW, cY + halfH);
+ } else {
+ mShortcutsAndWidgets.layout(left, top, right, bottom);
+ }
}
/**
@@ -929,7 +971,7 @@
if (resize) {
cellToRect(cellX, cellY, spanX, spanY, r);
if (v instanceof LauncherAppWidgetHostView) {
- DeviceProfile profile = mActivity.getDeviceProfile();
+ DeviceProfile profile = mActivity.getWallpaperDeviceProfile();
Utilities.shrinkRect(r, profile.appWidgetScale.x, profile.appWidgetScale.y);
}
} else {
diff --git a/src/com/android/launcher3/CheckLongPressHelper.java b/src/com/android/launcher3/CheckLongPressHelper.java
index b86e7c0..639c173 100644
--- a/src/com/android/launcher3/CheckLongPressHelper.java
+++ b/src/com/android/launcher3/CheckLongPressHelper.java
@@ -33,20 +33,12 @@
class CheckForLongPress implements Runnable {
public void run() {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "CheckForLongPress1");
- }
if ((mView.getParent() != null) && mView.hasWindowFocus()
&& !mHasPerformedLongPress) {
boolean handled;
if (mListener != null) {
handled = mListener.onLongClick(mView);
} else {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "CheckForLongPress2");
- }
handled = mView.performLongClick();
}
if (handled) {
@@ -81,21 +73,11 @@
}
mView.postDelayed(mPendingCheckForLongPress,
(long) (ViewConfiguration.getLongPressTimeout() * mLongPressTimeoutFactor));
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "postCheckForLongPress: " + ViewConfiguration.getLongPressTimeout() + " "
- + mLongPressTimeoutFactor);
- }
}
public void cancelLongPress() {
mHasPerformedLongPress = false;
if (mPendingCheckForLongPress != null) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "cancelLongPress @ " + android.util.Log.getStackTraceString(
- new Throwable()));
- }
mView.removeCallbacks(mPendingCheckForLongPress);
mPendingCheckForLongPress = null;
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 6a3a26f..c0affb9 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -419,6 +419,10 @@
updateWorkspacePadding();
}
+ /**
+ * The current device insets. This is generally same as the insets being dispatched to
+ * {@link Insettable} elements, but can differ if the element is using a different profile.
+ */
public Rect getInsets() {
return mInsets;
}
@@ -582,45 +586,6 @@
}
}
- /**
- * Gets an item's location on the home screen. This is useful if the home screen
- * is animating, otherwise use {@link View#getLocationOnScreen(int[])}.
- * @param pageDiff The page difference relative to the current page.
- */
- public void getItemLocation(int cellX, int cellY, int spanX, int spanY, int container,
- int pageDiff, Rect outBounds) {
- outBounds.setEmpty();
- if (container == CONTAINER_HOTSEAT) {
- final int actualHotseatCellHeight;
- if (isVerticalBarLayout()) {
- actualHotseatCellHeight = availableHeightPx / inv.numRows;
- if (mIsSeascape) {
- outBounds.left = mHotseatPadding.left;
- } else {
- outBounds.left = availableWidthPx - hotseatBarSizePx + mHotseatPadding.left;
- }
- outBounds.right = outBounds.left + iconSizePx;
- outBounds.top = mHotseatPadding.top
- + actualHotseatCellHeight * (inv.numRows - cellX - 1);
- outBounds.bottom = outBounds.top + actualHotseatCellHeight;
- } else {
- actualHotseatCellHeight = hotseatBarSizePx - hotseatBarBottomPaddingPx
- - hotseatBarTopPaddingPx;
- outBounds.left = mInsets.left + workspacePadding.left + cellLayoutPaddingLeftRightPx
- + (cellX * getCellSize().x);
- outBounds.right = outBounds.left + getCellSize().x;
- outBounds.top = mInsets.top + availableHeightPx - hotseatBarSizePx;
- outBounds.bottom = outBounds.top + actualHotseatCellHeight;
- }
- } else {
- outBounds.left = mInsets.left + workspacePadding.left + cellLayoutPaddingLeftRightPx
- + (cellX * getCellSize().x) + (pageDiff * availableWidthPx);
- outBounds.right = outBounds.left + (getCellSize().x * spanX);
- outBounds.top = mInsets.top + workspacePadding.top + (cellY * getCellSize().y);
- outBounds.bottom = outBounds.top + (getCellSize().y * spanY);
- }
- }
-
private static Context getContext(Context c, int orientation) {
Configuration context = new Configuration(c.getResources().getConfiguration());
context.orientation = orientation;
diff --git a/src/com/android/launcher3/DropTargetBar.java b/src/com/android/launcher3/DropTargetBar.java
index 0543e8d..ca001a3 100644
--- a/src/com/android/launcher3/DropTargetBar.java
+++ b/src/com/android/launcher3/DropTargetBar.java
@@ -204,7 +204,7 @@
return visibleCount;
}
- private void animateToVisibility(boolean isVisible) {
+ public void animateToVisibility(boolean isVisible) {
if (mVisible != isVisible) {
mVisible = isVisible;
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 4da7907..00acdcd 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -26,11 +26,13 @@
import android.view.ViewGroup;
import android.widget.FrameLayout;
+import com.android.launcher3.graphics.RotationMode;
import com.android.launcher3.logging.StatsLogUtils.LogContainerProvider;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
+import com.android.launcher3.views.Transposable;
-public class Hotseat extends CellLayout implements LogContainerProvider, Insettable {
+public class Hotseat extends CellLayout implements LogContainerProvider, Insettable, Transposable {
@ViewDebug.ExportedProperty(category = "launcher")
private boolean mHasVerticalHotseat;
@@ -77,7 +79,8 @@
@Override
public void setInsets(Rect insets) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
- DeviceProfile grid = mActivity.getDeviceProfile();
+ DeviceProfile grid = mActivity.getWallpaperDeviceProfile();
+ insets = grid.getInsets();
if (grid.isVerticalBarLayout()) {
lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
@@ -105,4 +108,9 @@
// Don't let if follow through to workspace
return true;
}
+
+ @Override
+ public RotationMode getRotationMode() {
+ return Launcher.getLauncher(getContext()).getRotationMode();
+ }
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index fda674f..417c5a2 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -53,6 +53,7 @@
import android.content.res.Configuration;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Point;
+import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
@@ -71,6 +72,7 @@
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
+import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.OvershootInterpolator;
import android.widget.Toast;
@@ -93,6 +95,7 @@
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.folder.FolderIconPreviewVerifier;
+import com.android.launcher3.graphics.RotationMode;
import com.android.launcher3.icons.IconCache;
import com.android.launcher3.keyboard.CustomActionsPopup;
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
@@ -272,6 +275,9 @@
private float mCurrentAssistantVisibility = 0f;
+ private DeviceProfile mStableDeviceProfile;
+ private RotationMode mRotationMode = RotationMode.NORMAL;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
RaceConditionTracker.onEvent(ON_CREATE_EVT, ENTER);
@@ -390,6 +396,12 @@
}
}
});
+
+ if (FeatureFlags.FAKE_LANDSCAPE_UI.get()) {
+ WindowManager.LayoutParams lp = getWindow().getAttributes();
+ lp.rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS;
+ getWindow().setAttributes(lp);
+ }
}
@Override
@@ -418,6 +430,10 @@
@Override
protected void reapplyUi() {
+ if (FeatureFlags.FAKE_LANDSCAPE_UI.get()) {
+ mRotationMode = mStableDeviceProfile == null ? RotationMode.NORMAL :
+ (mDeviceProfile.isSeascape() ? RotationMode.SEASCAPE : RotationMode.LANDSCAPE);
+ }
getRootView().dispatchInsets();
getStateManager().reapplyState(true /* cancelCurrentAnimation */);
}
@@ -469,8 +485,41 @@
display.getSize(mwSize);
mDeviceProfile = mDeviceProfile.getMultiWindowProfile(this, mwSize);
}
+
+ if (FeatureFlags.FAKE_LANDSCAPE_UI.get() && mDeviceProfile.isVerticalBarLayout()
+ && !mDeviceProfile.isMultiWindowMode) {
+ mStableDeviceProfile = mDeviceProfile.inv.portraitProfile;
+ mRotationMode = mDeviceProfile.isSeascape()
+ ? RotationMode.SEASCAPE : RotationMode.LANDSCAPE;
+ } else {
+ mStableDeviceProfile = null;
+ mRotationMode = RotationMode.NORMAL;
+ }
+
onDeviceProfileInitiated();
- mModelWriter = mModel.getWriter(mDeviceProfile.isVerticalBarLayout(), true);
+ mModelWriter = mModel.getWriter(getWallpaperDeviceProfile().isVerticalBarLayout(), true);
+ }
+
+ public void updateInsets(Rect insets) {
+ mDeviceProfile.updateInsets(insets);
+ if (mStableDeviceProfile != null) {
+ mStableDeviceProfile.updateInsets(insets);
+ }
+ }
+
+ @Override
+ public RotationMode getRotationMode() {
+ return mRotationMode;
+ }
+
+ /**
+ * Device profile to be used by UI elements which are shown directly on top of the wallpaper
+ * and whose presentation is tied to the wallpaper (and physical device) and not the activity
+ * configuration.
+ */
+ @Override
+ public DeviceProfile getWallpaperDeviceProfile() {
+ return mStableDeviceProfile == null ? mDeviceProfile : mStableDeviceProfile;
}
public RotationHelper getRotationHelper() {
@@ -879,7 +928,7 @@
super.onPause();
mDragController.cancelDrag();
mDragController.resetLastGestureUpTime();
-
+ mDropTargetBar.animateToVisibility(false);
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onPause();
}
@@ -1812,7 +1861,7 @@
mAppWidgetHost.clearViews();
if (mHotseat != null) {
- mHotseat.resetLayout(mDeviceProfile.isVerticalBarLayout());
+ mHotseat.resetLayout(getWallpaperDeviceProfile().isVerticalBarLayout());
}
TraceHelper.endSection("startBinding");
}
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index e788ceb..e7b4ff4 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -213,7 +213,6 @@
synchronized (mLock) {
Preconditions.assertUIThread();
mCallbacks = new WeakReference<>(callbacks);
- android.util.Log.d("b/131170582", "mCallbacks = " + mCallbacks);
}
}
@@ -331,7 +330,6 @@
// Stop any existing loaders first, so they don't set mModelLoaded to true later
stopLoader();
mModelLoaded = false;
- android.util.Log.d("b/131170582", "1 mModelLoaded = " + mModelLoaded);
}
// Start the loader if launcher is already running, otherwise the loader will run,
@@ -392,7 +390,6 @@
synchronized (mLock) {
LoaderTask oldTask = mLoaderTask;
mLoaderTask = null;
- android.util.Log.d("b/131170582", "1 mLoaderTask = " + mLoaderTask);
if (oldTask != null) {
oldTask.stopLocked();
}
@@ -403,7 +400,6 @@
synchronized (mLock) {
stopLoader();
mLoaderTask = new LoaderTask(mApp, mBgAllAppsList, sBgDataModel, results);
- android.util.Log.d("b/131170582", "2 mLoaderTask = " + mLoaderTask);
runOnWorkerThread(mLoaderTask);
}
}
@@ -448,7 +444,6 @@
mTask = task;
mIsLoaderTaskRunning = true;
mModelLoaded = false;
- android.util.Log.d("b/131170582", "2 mModelLoaded = " + mModelLoaded);
}
}
@@ -456,7 +451,6 @@
synchronized (mLock) {
// Everything loaded bind the data.
mModelLoaded = true;
- android.util.Log.d("b/131170582", "3 mModelLoaded = " + mModelLoaded);
}
}
@@ -466,7 +460,6 @@
// If we are still the last one to be scheduled, remove ourselves.
if (mLoaderTask == mTask) {
mLoaderTask = null;
- android.util.Log.d("b/131170582", "3 mLoaderTask = " + mLoaderTask);
}
mIsLoaderTaskRunning = false;
}
diff --git a/src/com/android/launcher3/LauncherRootView.java b/src/com/android/launcher3/LauncherRootView.java
index 90e673b..20eec05 100644
--- a/src/com/android/launcher3/LauncherRootView.java
+++ b/src/com/android/launcher3/LauncherRootView.java
@@ -81,7 +81,7 @@
UI_STATE_ROOT_VIEW, drawInsetBar ? FLAG_DARK_NAV : 0);
// Update device profile before notifying th children.
- mLauncher.getDeviceProfile().updateInsets(insets);
+ mLauncher.updateInsets(insets);
boolean resetState = !insets.equals(mInsets);
setInsets(insets);
@@ -114,7 +114,7 @@
}
public void dispatchInsets() {
- mLauncher.getDeviceProfile().updateInsets(mInsets);
+ mLauncher.updateInsets(mInsets);
super.setInsets(mInsets);
}
@@ -186,14 +186,4 @@
void onWindowVisibilityChanged(int visibility);
}
-
- @Override
- public void requestLayout() {
- super.requestLayout();
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "requestLayout @ " + android.util.Log.getStackTraceString(
- new Throwable()));
- }
- }
}
\ No newline at end of file
diff --git a/src/com/android/launcher3/ShortcutAndWidgetContainer.java b/src/com/android/launcher3/ShortcutAndWidgetContainer.java
index 30f418d..1bd8263 100644
--- a/src/com/android/launcher3/ShortcutAndWidgetContainer.java
+++ b/src/com/android/launcher3/ShortcutAndWidgetContainer.java
@@ -93,7 +93,7 @@
public void setupLp(View child) {
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
if (child instanceof LauncherAppWidgetHostView) {
- DeviceProfile profile = mActivity.getDeviceProfile();
+ DeviceProfile profile = mActivity.getWallpaperDeviceProfile();
lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX,
profile.appWidgetScale.x, profile.appWidgetScale.y);
} else {
@@ -108,12 +108,12 @@
public int getCellContentHeight() {
return Math.min(getMeasuredHeight(),
- mActivity.getDeviceProfile().getCellHeight(mContainerType));
+ mActivity.getWallpaperDeviceProfile().getCellHeight(mContainerType));
}
public void measureChild(View child) {
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
- final DeviceProfile profile = mActivity.getDeviceProfile();
+ final DeviceProfile profile = mActivity.getWallpaperDeviceProfile();
if (child instanceof LauncherAppWidgetHostView) {
lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX,
diff --git a/src/com/android/launcher3/TestProtocol.java b/src/com/android/launcher3/TestProtocol.java
index dab4282..ecbaa5b 100644
--- a/src/com/android/launcher3/TestProtocol.java
+++ b/src/com/android/launcher3/TestProtocol.java
@@ -63,9 +63,4 @@
"all-apps-to-overview-swipe-height";
public static final String REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT =
"home-to-all-apps-swipe-height";
-
- public static boolean sDebugTracing = false;
- public static final String NO_DRAG_TAG = "b/129434166";
- public static final String REQUEST_ENABLE_DRAG_LOGGING = "enable-drag-logging";
- public static final String REQUEST_DISABLE_DRAG_LOGGING = "disable-drag-logging";
}
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 382eedd..26364be 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -16,9 +16,6 @@
package com.android.launcher3;
-import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;
-import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT;
-
import android.animation.ValueAnimator;
import android.app.ActivityManager;
import android.app.WallpaperManager;
@@ -63,13 +60,12 @@
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.ShortcutConfigActivityInfo;
import com.android.launcher3.config.FeatureFlags;
-import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.FolderAdaptiveIcon;
-import com.android.launcher3.folder.FolderIcon;
+import com.android.launcher3.graphics.RotationMode;
import com.android.launcher3.shortcuts.DeepShortcutManager;
-import com.android.launcher3.shortcuts.DeepShortcutView;
import com.android.launcher3.shortcuts.ShortcutKey;
import com.android.launcher3.util.IntArray;
+import com.android.launcher3.views.Transposable;
import com.android.launcher3.widget.PendingAddShortcutInfo;
import java.io.Closeable;
@@ -97,7 +93,6 @@
private static final int[] sLoc0 = new int[2];
private static final int[] sLoc1 = new int[2];
- private static final float[] sPoint = new float[2];
private static final Matrix sMatrix = new Matrix();
private static final Matrix sInverseMatrix = new Matrix();
@@ -143,7 +138,7 @@
*/
public static final Executor THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(
CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE,
- TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
+ TimeUnit.SECONDS, new LinkedBlockingQueue<>());
public static boolean IS_RUNNING_IN_TEST_HARNESS =
ActivityManager.isRunningInTestHarness();
@@ -170,37 +165,60 @@
* assumption fails, we will need to return a pair of scale factors.
*/
public static float getDescendantCoordRelativeToAncestor(
- View descendant, View ancestor, int[] coord, boolean includeRootScroll) {
- sPoint[0] = coord[0];
- sPoint[1] = coord[1];
+ View descendant, View ancestor, float[] coord, boolean includeRootScroll) {
+ return getDescendantCoordRelativeToAncestor(descendant, ancestor, coord, includeRootScroll,
+ false);
+ }
+ /**
+ * Given a coordinate relative to the descendant, find the coordinate in a parent view's
+ * coordinates.
+ *
+ * @param descendant The descendant to which the passed coordinate is relative.
+ * @param ancestor The root view to make the coordinates relative to.
+ * @param coord The coordinate that we want mapped.
+ * @param includeRootScroll Whether or not to account for the scroll of the descendant:
+ * sometimes this is relevant as in a child's coordinates within the descendant.
+ * @param ignoreTransform If true, view transform is ignored
+ * @return The factor by which this descendant is scaled relative to this DragLayer. Caution
+ * this scale factor is assumed to be equal in X and Y, and so if at any point this
+ * assumption fails, we will need to return a pair of scale factors.
+ */
+ public static float getDescendantCoordRelativeToAncestor(View descendant, View ancestor,
+ float[] coord, boolean includeRootScroll, boolean ignoreTransform) {
float scale = 1.0f;
View v = descendant;
while(v != ancestor && v != null) {
// For TextViews, scroll has a meaning which relates to the text position
// which is very strange... ignore the scroll.
if (v != descendant || includeRootScroll) {
- sPoint[0] -= v.getScrollX();
- sPoint[1] -= v.getScrollY();
+ offsetPoints(coord, -v.getScrollX(), -v.getScrollY());
}
- v.getMatrix().mapPoints(sPoint);
- sPoint[0] += v.getLeft();
- sPoint[1] += v.getTop();
+ if (ignoreTransform) {
+ if (v instanceof Transposable) {
+ RotationMode m = ((Transposable) v).getRotationMode();
+ if (m.isTransposed) {
+ sMatrix.setRotate(m.surfaceRotation, v.getPivotX(), v.getPivotY());
+ sMatrix.mapPoints(coord);
+ }
+ }
+ } else {
+ v.getMatrix().mapPoints(coord);
+ }
+ offsetPoints(coord, v.getLeft(), v.getTop());
scale *= v.getScaleX();
v = (View) v.getParent();
}
-
- coord[0] = Math.round(sPoint[0]);
- coord[1] = Math.round(sPoint[1]);
return scale;
}
+
/**
- * Inverse of {@link #getDescendantCoordRelativeToAncestor(View, View, int[], boolean)}.
+ * Inverse of {@link #getDescendantCoordRelativeToAncestor(View, View, float[], boolean)}.
*/
- public static void mapCoordInSelfToDescendant(View descendant, View root, int[] coord) {
+ public static void mapCoordInSelfToDescendant(View descendant, View root, float[] coord) {
sMatrix.reset();
View v = descendant;
while(v != root) {
@@ -211,12 +229,23 @@
}
sMatrix.postTranslate(-v.getScrollX(), -v.getScrollY());
sMatrix.invert(sInverseMatrix);
+ sInverseMatrix.mapPoints(coord);
+ }
- sPoint[0] = coord[0];
- sPoint[1] = coord[1];
- sInverseMatrix.mapPoints(sPoint);
- coord[0] = Math.round(sPoint[0]);
- coord[1] = Math.round(sPoint[1]);
+ /**
+ * Sets {@param out} to be same as {@param in} by rounding individual values
+ */
+ public static void roundArray(float[] in, int[] out) {
+ for (int i = 0; i < in.length; i++) {
+ out[i] = Math.round(in[i]);
+ }
+ }
+
+ public static void offsetPoints(float[] points, float offsetX, float offsetY) {
+ for (int i = 0; i < points.length; i += 2) {
+ points[i] += offsetX;
+ points[i + 1] += offsetY;
+ }
}
/**
@@ -569,53 +598,6 @@
return String.format(Locale.ENGLISH, "%d,%d", x, y);
}
- /**
- * Returns the location bounds of a view.
- * - For DeepShortcutView, we return the bounds of the icon view.
- * - For BubbleTextView, we return the icon bounds.
- */
- public static void getLocationBoundsForView(Launcher launcher, View v, Rect outRect) {
- final DragLayer dragLayer = launcher.getDragLayer();
- final boolean isBubbleTextView = v instanceof BubbleTextView;
- final boolean isFolderIcon = v instanceof FolderIcon;
- final Rect rect = new Rect();
-
- // Deep shortcut views have their icon drawn in a separate view.
- final boolean fromDeepShortcutView = v.getParent() instanceof DeepShortcutView;
- if (v instanceof DeepShortcutView) {
- dragLayer.getDescendantRectRelativeToSelf(((DeepShortcutView) v).getIconView(), rect);
- } else if (fromDeepShortcutView) {
- DeepShortcutView view = (DeepShortcutView) v.getParent();
- dragLayer.getDescendantRectRelativeToSelf(view.getIconView(), rect);
- } else if ((isBubbleTextView || isFolderIcon) && v.getTag() instanceof ItemInfo
- && (((ItemInfo) v.getTag()).container == CONTAINER_DESKTOP
- || ((ItemInfo) v.getTag()).container == CONTAINER_HOTSEAT)) {
- CellLayout pageViewIsOn = ((CellLayout) v.getParent().getParent());
- int pageNum = launcher.getWorkspace().indexOfChild(pageViewIsOn);
-
- DeviceProfile dp = launcher.getDeviceProfile();
- ItemInfo info = ((ItemInfo) v.getTag());
- dp.getItemLocation(info.cellX, info.cellY, info.spanX, info.spanY,
- info.container, pageNum - launcher.getCurrentWorkspaceScreen(), rect);
- } else {
- dragLayer.getDescendantRectRelativeToSelf(v, rect);
- }
- int viewLocationLeft = rect.left;
- int viewLocationTop = rect.top;
-
- if (isBubbleTextView && !fromDeepShortcutView) {
- ((BubbleTextView) v).getIconBounds(rect);
- } else if (isFolderIcon) {
- ((FolderIcon) v).getPreviewBounds(rect);
- } else {
- rect.set(0, 0, rect.width(), rect.height());
- }
- viewLocationLeft += rect.left;
- viewLocationTop += rect.top;
- outRect.set(viewLocationLeft, viewLocationTop, viewLocationLeft + rect.width(),
- viewLocationTop + rect.height());
- }
-
public static void unregisterReceiverSafely(Context context, BroadcastReceiver receiver) {
try {
context.unregisterReceiver(receiver);
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 8849768..0f4c42d 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -82,6 +82,7 @@
import com.android.launcher3.folder.PreviewBackground;
import com.android.launcher3.graphics.DragPreviewProvider;
import com.android.launcher3.graphics.PreloadIconDrawable;
+import com.android.launcher3.graphics.RotationMode;
import com.android.launcher3.pageindicators.WorkspacePageIndicator;
import com.android.launcher3.popup.PopupContainerWithArrow;
import com.android.launcher3.shortcuts.ShortcutDragPreviewProvider;
@@ -175,7 +176,9 @@
@Thunk final Launcher mLauncher;
@Thunk DragController mDragController;
+ private final Rect mTempRect = new Rect();
private final int[] mTempXY = new int[2];
+ private final float[] mTempFXY = new float[2];
@Thunk float[] mDragViewVisualCenter = new float[2];
private final float[] mTempTouchCoordinates = new float[2];
@@ -285,18 +288,23 @@
@Override
public void setInsets(Rect insets) {
- mInsets.set(insets);
-
DeviceProfile grid = mLauncher.getDeviceProfile();
- mMaxDistanceForFolderCreation = grid.isTablet
- ? 0.75f * grid.iconSizePx
- : 0.55f * grid.iconSizePx;
+ DeviceProfile stableGrid = mLauncher.getWallpaperDeviceProfile();
+
+ mMaxDistanceForFolderCreation = stableGrid.isTablet
+ ? 0.75f * stableGrid.iconSizePx
+ : 0.55f * stableGrid.iconSizePx;
mWorkspaceFadeInAdjacentScreens = grid.shouldFadeAdjacentWorkspaceScreens();
- Rect padding = grid.workspacePadding;
- setPadding(padding.left, padding.top, padding.right, padding.bottom);
+ Rect padding = stableGrid.workspacePadding;
- if (grid.shouldFadeAdjacentWorkspaceScreens()) {
+ RotationMode rotationMode = mLauncher.getRotationMode();
+
+ rotationMode.mapRect(padding, mTempRect);
+ setPadding(mTempRect.left, mTempRect.top, mTempRect.right, mTempRect.bottom);
+ rotationMode.mapRect(insets, mInsets);
+
+ if (mWorkspaceFadeInAdjacentScreens) {
// In landscape mode the page spacing is set to the default.
setPageSpacing(grid.edgeMarginPx);
} else {
@@ -306,11 +314,13 @@
setPageSpacing(Math.max(grid.edgeMarginPx, padding.left + 1));
}
- int paddingLeftRight = grid.cellLayoutPaddingLeftRightPx;
- int paddingBottom = grid.cellLayoutBottomPaddingPx;
+
+ int paddingLeftRight = stableGrid.cellLayoutPaddingLeftRightPx;
+ int paddingBottom = stableGrid.cellLayoutBottomPaddingPx;
for (int i = mWorkspaceScreens.size() - 1; i >= 0; i--) {
- mWorkspaceScreens.valueAt(i)
- .setPadding(paddingLeftRight, 0, paddingLeftRight, paddingBottom);
+ CellLayout page = mWorkspaceScreens.valueAt(i);
+ page.setRotationMode(rotationMode);
+ page.setPadding(paddingLeftRight, 0, paddingLeftRight, paddingBottom);
}
}
@@ -330,7 +340,7 @@
float scale = 1;
if (isWidget) {
- DeviceProfile profile = mLauncher.getDeviceProfile();
+ DeviceProfile profile = mLauncher.getWallpaperDeviceProfile();
scale = Utilities.shrinkRect(r, profile.appWidgetScale.x, profile.appWidgetScale.y);
}
size[0] = r.width();
@@ -550,8 +560,10 @@
// created CellLayout.
CellLayout newScreen = (CellLayout) LayoutInflater.from(getContext()).inflate(
R.layout.workspace_screen, this, false /* attachToRoot */);
- int paddingLeftRight = mLauncher.getDeviceProfile().cellLayoutPaddingLeftRightPx;
- int paddingBottom = mLauncher.getDeviceProfile().cellLayoutBottomPaddingPx;
+ DeviceProfile grid = mLauncher.getWallpaperDeviceProfile();
+ int paddingLeftRight = grid.cellLayoutPaddingLeftRightPx;
+ int paddingBottom = grid.cellLayoutBottomPaddingPx;
+ newScreen.setRotationMode(mLauncher.getRotationMode());
newScreen.setPadding(paddingLeftRight, 0, paddingLeftRight, paddingBottom);
mWorkspaceScreens.put(screenId, newScreen);
@@ -1440,10 +1452,6 @@
public DragView beginDragShared(View child, DragSource source, ItemInfo dragObject,
DragPreviewProvider previewProvider, DragOptions dragOptions) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "beginDragShared");
- }
float iconScale = 1f;
if (child instanceof BubbleTextView) {
Drawable icon = ((BubbleTextView) child).getIcon();
@@ -1934,18 +1942,9 @@
if (child == null) {
return;
}
+
ShortcutAndWidgetContainer boundingLayout = child.getShortcutsAndWidgets();
-
- // Use the absolute left instead of the child left, as we want the visible area
- // irrespective of the visible child. Since the view can only scroll horizontally, the
- // top position is not affected.
- mTempXY[0] = getPaddingLeft() + boundingLayout.getLeft();
- mTempXY[1] = child.getTop() + boundingLayout.getTop();
-
- float scale = mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempXY);
- outArea.set(mTempXY[0], mTempXY[1],
- (int) (mTempXY[0] + scale * boundingLayout.getMeasuredWidth()),
- (int) (mTempXY[1] + scale * boundingLayout.getMeasuredHeight()));
+ mLauncher.getDragLayer().getDescendantRectRelativeToSelf(boundingLayout, outArea);
}
@Override
@@ -2098,14 +2097,14 @@
}
boolean isPointInSelfOverHotseat(int x, int y) {
- mTempXY[0] = x;
- mTempXY[1] = y;
- mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempXY, true);
+ mTempFXY[0] = x;
+ mTempFXY[1] = y;
+ mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempFXY, true);
View hotseat = mLauncher.getHotseat();
- return mTempXY[0] >= hotseat.getLeft() &&
- mTempXY[0] <= hotseat.getRight() &&
- mTempXY[1] >= hotseat.getTop() &&
- mTempXY[1] <= hotseat.getBottom();
+ return mTempFXY[0] >= hotseat.getLeft() &&
+ mTempFXY[0] <= hotseat.getRight() &&
+ mTempFXY[1] >= hotseat.getTop() &&
+ mTempFXY[1] <= hotseat.getBottom();
}
/**
@@ -2115,13 +2114,8 @@
*/
private void mapPointFromDropLayout(CellLayout layout, float[] xy) {
if (mLauncher.isHotseatLayout(layout)) {
- mTempXY[0] = (int) xy[0];
- mTempXY[1] = (int) xy[1];
- mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempXY, true);
- mLauncher.getDragLayer().mapCoordInSelfToDescendant(layout, mTempXY);
-
- xy[0] = mTempXY[0];
- xy[1] = mTempXY[1];
+ mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, xy, true);
+ mLauncher.getDragLayer().mapCoordInSelfToDescendant(layout, xy);
} else {
mapPointFromSelfToChild(layout, xy);
}
@@ -2612,13 +2606,14 @@
DeviceProfile profile = mLauncher.getDeviceProfile();
Utilities.shrinkRect(r, profile.appWidgetScale.x, profile.appWidgetScale.y);
}
- loc[0] = r.left;
- loc[1] = r.top;
+ mTempFXY[0] = r.left;
+ mTempFXY[1] = r.top;
setFinalTransitionTransform();
float cellLayoutScale =
- mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(layout, loc, true);
+ mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(layout, mTempFXY, true);
resetTransitionTransform();
+ Utilities.roundArray(mTempFXY, loc);
if (scale) {
float dragViewScaleX = (1.0f * r.width()) / dragView.getMeasuredWidth();
@@ -2911,14 +2906,11 @@
&& info.user.equals(user);
final Workspace.ItemOperator packageAndUserAndApp = (ItemInfo info, View view) ->
packageAndUser.evaluate(info, view) && info.itemType == ITEM_TYPE_APPLICATION;
- final Workspace.ItemOperator packageAndUserAndShortcut = (ItemInfo info, View view) ->
- packageAndUser.evaluate(info, view) && (info.itemType == ITEM_TYPE_SHORTCUT
- || info.itemType == ITEM_TYPE_DEEP_SHORTCUT);
- final Workspace.ItemOperator packageAndUserInFolder = (info, view) -> {
+ final Workspace.ItemOperator packageAndUserAndAppInFolder = (info, view) -> {
if (info instanceof FolderInfo) {
FolderInfo folderInfo = (FolderInfo) info;
for (WorkspaceItemInfo shortcutInfo : folderInfo.contents) {
- if (packageAndUser.evaluate(shortcutInfo, view)) {
+ if (packageAndUserAndApp.evaluate(shortcutInfo, view)) {
return true;
}
}
@@ -2926,15 +2918,15 @@
return false;
};
- // Order: App icons, shortcuts, app/shortcut in folder. Items in hotseat get returned first.
+ // Order: App icons, app in folder. Items in hotseat get returned first.
if (ADAPTIVE_ICON_WINDOW_ANIM.get()) {
return getFirstMatch(new CellLayout[] { getHotseat(), currentPage },
- packageAndUserAndApp, packageAndUserAndShortcut, packageAndUserInFolder);
+ packageAndUserAndApp, packageAndUserAndAppInFolder);
} else {
// Do not use Folder as a criteria, since it'll cause a crash when trying to draw
// FolderAdaptiveIcon as the background.
return getFirstMatch(new CellLayout[] { getHotseat(), currentPage },
- packageAndUserAndApp, packageAndUserAndShortcut);
+ packageAndUserAndApp);
}
}
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index 99a8801..8d0259d 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -93,14 +93,16 @@
Interpolator scaleInterpolator = builder.getInterpolator(ANIM_WORKSPACE_SCALE, ZOOM_OUT);
propertySetter.setFloat(mWorkspace, 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]);
+ if (!hotseat.getRotationMode().isTransposed) {
+ // Set the hotseat's pivot point to match the workspace's, so that it scales together.
+ DragLayer dragLayer = mLauncher.getDragLayer();
+ float[] workspacePivot =
+ new float[]{ mWorkspace.getPivotX(), mWorkspace.getPivotY() };
+ dragLayer.getDescendantCoordRelativeToSelf(mWorkspace, workspacePivot);
+ dragLayer.mapCoordInSelfToDescendant(hotseat, workspacePivot);
+ hotseat.setPivotX(workspacePivot[0]);
+ hotseat.setPivotY(workspacePivot[1]);
+ }
float hotseatScale = hotseatScaleAndTranslation.scale;
propertySetter.setFloat(hotseat, SCALE_PROPERTY, hotseatScale, scaleInterpolator);
diff --git a/src/com/android/launcher3/anim/FlingSpringAnim.java b/src/com/android/launcher3/anim/FlingSpringAnim.java
index 3d21d82..45d49e8 100644
--- a/src/com/android/launcher3/anim/FlingSpringAnim.java
+++ b/src/com/android/launcher3/anim/FlingSpringAnim.java
@@ -34,6 +34,7 @@
private static final float SPRING_DAMPING = SpringForce.DAMPING_RATIO_LOW_BOUNCY;
private final FlingAnimation mFlingAnim;
+ private SpringAnimation mSpringAnim;
public <K> FlingSpringAnim(K object, FloatPropertyCompat<K> property, float startPosition,
float targetPosition, float startVelocity, OnAnimationEndListener onEndListener) {
@@ -44,17 +45,24 @@
.setMinValue(Math.min(startPosition, targetPosition))
.setMaxValue(Math.max(startPosition, targetPosition));
mFlingAnim.addEndListener(((animation, canceled, value, velocity) -> {
- SpringAnimation springAnim = new SpringAnimation(object, property)
+ mSpringAnim = new SpringAnimation(object, property)
.setStartVelocity(velocity)
.setSpring(new SpringForce(targetPosition)
.setStiffness(SPRING_STIFFNESS)
.setDampingRatio(SPRING_DAMPING));
- springAnim.addEndListener(onEndListener);
- springAnim.start();
+ mSpringAnim.addEndListener(onEndListener);
+ mSpringAnim.start();
}));
}
public void start() {
mFlingAnim.start();
}
+
+ public void end() {
+ mFlingAnim.cancel();
+ if (mSpringAnim.canSkipToEnd()) {
+ mSpringAnim.skipToEnd();
+ }
+ }
}
diff --git a/src/com/android/launcher3/config/BaseFlags.java b/src/com/android/launcher3/config/BaseFlags.java
index a55ea82..70df97a 100644
--- a/src/com/android/launcher3/config/BaseFlags.java
+++ b/src/com/android/launcher3/config/BaseFlags.java
@@ -110,6 +110,10 @@
"ENABLE_HINTS_IN_OVERVIEW", false,
"Show chip hints and gleams on the overview screen");
+ public static final TogglableFlag FAKE_LANDSCAPE_UI = new TogglableFlag(
+ "FAKE_LANDSCAPE_UI", false,
+ "Rotate launcher UI instead of using transposed layout");
+
public static void initialize(Context context) {
// Avoid the disk read for user builds
if (Utilities.IS_DEBUG_DEVICE) {
diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java
index 7210759..f92e00a 100644
--- a/src/com/android/launcher3/dragndrop/DragController.java
+++ b/src/com/android/launcher3/dragndrop/DragController.java
@@ -219,9 +219,6 @@
}
private void callOnDragStart() {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, "callOnDragStart");
- }
if (mOptions.preDragCondition != null) {
mOptions.preDragCondition.onPreDragEnd(mDragObject, true /* dragStarted*/);
}
@@ -475,9 +472,6 @@
}
private void handleMoveEvent(int x, int y) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, "handleMoveEvent1");
- }
mDragObject.dragView.move(x, y);
// Drop on someone?
@@ -494,10 +488,6 @@
if (mIsInPreDrag && mOptions.preDragCondition != null
&& mOptions.preDragCondition.shouldStartDrag(mDistanceSinceScroll)) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "handleMoveEvent2");
- }
callOnDragStart();
}
}
@@ -535,10 +525,6 @@
* Call this from a drag source view.
*/
public boolean onControllerTouchEvent(MotionEvent ev) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "onControllerTouchEvent1");
- }
if (mDragDriver == null || mOptions == null || mOptions.isAccessibleDrag) {
return false;
}
@@ -559,10 +545,6 @@
break;
}
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "onControllerTouchEvent2");
- }
return mDragDriver.onTouchEvent(ev);
}
diff --git a/src/com/android/launcher3/dragndrop/DragDriver.java b/src/com/android/launcher3/dragndrop/DragDriver.java
index 551f2d0..84fc94d 100644
--- a/src/com/android/launcher3/dragndrop/DragDriver.java
+++ b/src/com/android/launcher3/dragndrop/DragDriver.java
@@ -45,18 +45,10 @@
public void onDragViewAnimationEnd() { }
public boolean onTouchEvent(MotionEvent ev) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "onTouchEvent " + ev);
- }
final int action = ev.getAction();
switch (action) {
case MotionEvent.ACTION_MOVE:
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "onTouchEvent MOVE");
- }
mEventListener.onDriverDragMove(ev.getX(), ev.getY());
break;
case MotionEvent.ACTION_UP:
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index 9f902ed..8de2f57 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -17,6 +17,10 @@
package com.android.launcher3.dragndrop;
+import static android.view.View.MeasureSpec.EXACTLY;
+import static android.view.View.MeasureSpec.getMode;
+import static android.view.View.MeasureSpec.getSize;
+
import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent;
import android.animation.Animator;
@@ -29,12 +33,14 @@
import android.graphics.Canvas;
import android.graphics.Rect;
import android.util.AttributeSet;
+import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.animation.Interpolator;
+import android.widget.FrameLayout;
import android.widget.TextView;
import com.android.launcher3.AbstractFloatingView;
@@ -42,6 +48,7 @@
import com.android.launcher3.DropTargetBar;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
+import com.android.launcher3.graphics.RotationMode;
import com.android.launcher3.ShortcutAndWidgetContainer;
import com.android.launcher3.Workspace;
import com.android.launcher3.anim.Interpolators;
@@ -52,6 +59,7 @@
import com.android.launcher3.uioverrides.UiFactory;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.views.BaseDragLayer;
+import com.android.launcher3.views.Transposable;
import java.util.ArrayList;
@@ -126,10 +134,6 @@
protected boolean findActiveController(MotionEvent ev) {
if (mActivity.getStateManager().getState().disableInteraction) {
// You Shall Not Pass!!!
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "mActiveController = null");
- }
mActiveController = null;
return true;
}
@@ -264,10 +268,10 @@
Rect r = new Rect();
getViewRectRelativeToSelf(dragView, r);
- int coord[] = new int[2];
+ float coord[] = new float[2];
float childScale = child.getScaleX();
- coord[0] = lp.x + (int) (child.getMeasuredWidth() * (1 - childScale) / 2);
- coord[1] = lp.y + (int) (child.getMeasuredHeight() * (1 - childScale) / 2);
+ coord[0] = lp.x + (child.getMeasuredWidth() * (1 - childScale) / 2);
+ coord[1] = lp.y + (child.getMeasuredHeight() * (1 - childScale) / 2);
// Since the child hasn't necessarily been laid out, we force the lp to be updated with
// the correct coordinates (above) and use these to determine the final location
@@ -275,8 +279,8 @@
// We need to account for the scale of the child itself, as the above only accounts for
// for the scale in parents.
scale *= childScale;
- int toX = coord[0];
- int toY = coord[1];
+ int toX = Math.round(coord[0]);
+ int toY = Math.round(coord[1]);
float toScale = scale;
if (child instanceof TextView) {
TextView tv = (TextView) child;
@@ -555,4 +559,159 @@
public WorkspaceAndHotseatScrim getScrim() {
return mScrim;
}
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ RotationMode rotation = mActivity.getRotationMode();
+ int count = getChildCount();
+
+ if (!rotation.isTransposed
+ || getMode(widthMeasureSpec) != EXACTLY
+ || getMode(heightMeasureSpec) != EXACTLY) {
+
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+ child.setRotation(rotation.surfaceRotation);
+ }
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ } else {
+
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+ if (child.getVisibility() == GONE) {
+ continue;
+ }
+ if (!(child instanceof Transposable)) {
+ measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
+ } else {
+ measureChildWithMargins(child, heightMeasureSpec, 0, widthMeasureSpec, 0);
+
+ child.setPivotX(child.getMeasuredWidth() / 2);
+ child.setPivotY(child.getMeasuredHeight() / 2);
+ child.setRotation(rotation.surfaceRotation);
+ }
+ }
+ setMeasuredDimension(getSize(widthMeasureSpec), getSize(heightMeasureSpec));
+ }
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ RotationMode rotation = mActivity.getRotationMode();
+ if (!rotation.isTransposed) {
+ super.onLayout(changed, left, top, right, bottom);
+ return;
+ }
+
+ final int count = getChildCount();
+
+ final int parentWidth = right - left;
+ final int parentHeight = bottom - top;
+
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+ if (child.getVisibility() == GONE) {
+ continue;
+ }
+
+ final FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) child.getLayoutParams();
+
+ if (lp instanceof LayoutParams) {
+ final LayoutParams dlp = (LayoutParams) lp;
+ if (dlp.customPosition) {
+ child.layout(dlp.x, dlp.y, dlp.x + dlp.width, dlp.y + dlp.height);
+ continue;
+ }
+ }
+
+ final int width = child.getMeasuredWidth();
+ final int height = child.getMeasuredHeight();
+
+ int childLeft;
+ int childTop;
+
+ int gravity = lp.gravity;
+ if (gravity == -1) {
+ gravity = Gravity.TOP | Gravity.START;
+ }
+
+ final int layoutDirection = getLayoutDirection();
+
+ int absoluteGravity = Gravity.getAbsoluteGravity(gravity, layoutDirection);
+ int horizontalGravity = absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
+ int verticalGravity = absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK;
+
+ if (child instanceof Transposable) {
+ if (rotation == RotationMode.SEASCAPE) {
+ if (horizontalGravity == Gravity.RIGHT) {
+ horizontalGravity = Gravity.LEFT;
+ } else if (horizontalGravity == Gravity.LEFT) {
+ horizontalGravity = Gravity.RIGHT;
+ }
+
+ if (verticalGravity == Gravity.TOP) {
+ verticalGravity = Gravity.BOTTOM;
+ } else if (verticalGravity == Gravity.BOTTOM) {
+ verticalGravity = Gravity.TOP;
+ }
+ }
+
+ switch (horizontalGravity) {
+ case Gravity.CENTER_HORIZONTAL:
+ childTop = (parentHeight - height) / 2 +
+ lp.topMargin - lp.bottomMargin;
+ break;
+ case Gravity.RIGHT:
+ childTop = width / 2 + lp.rightMargin - height / 2;
+ break;
+ case Gravity.LEFT:
+ default:
+ childTop = parentHeight - lp.leftMargin - width / 2 - height / 2;
+ }
+
+ switch (verticalGravity) {
+ case Gravity.CENTER_VERTICAL:
+ childLeft = (parentWidth - width) / 2 +
+ lp.leftMargin - lp.rightMargin;
+ break;
+ case Gravity.BOTTOM:
+ childLeft = parentWidth - width / 2 - height / 2 - lp.bottomMargin;
+ break;
+ case Gravity.TOP:
+ default:
+ childLeft = height / 2 - width / 2 + lp.topMargin;
+ }
+ } else {
+ switch (horizontalGravity) {
+ case Gravity.CENTER_HORIZONTAL:
+ childLeft = (parentWidth - width) / 2 +
+ lp.leftMargin - lp.rightMargin;
+ break;
+ case Gravity.RIGHT:
+ childLeft = parentWidth - width - lp.rightMargin;
+ break;
+ case Gravity.LEFT:
+ default:
+ childLeft = lp.leftMargin;
+ }
+
+ switch (verticalGravity) {
+ case Gravity.TOP:
+ childTop = lp.topMargin;
+ break;
+ case Gravity.CENTER_VERTICAL:
+ childTop = (parentHeight - height) / 2 +
+ lp.topMargin - lp.bottomMargin;
+ break;
+ case Gravity.BOTTOM:
+ childTop = parentHeight - height - lp.bottomMargin;
+ break;
+ default:
+ childTop = lp.topMargin;
+ }
+ }
+
+ child.layout(childLeft, childTop, childLeft + width, childTop + height);
+ }
+ }
}
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index 4dbff1c..389e852 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -24,6 +24,7 @@
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.annotation.SuppressLint;
+import android.appwidget.AppWidgetHostView;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
@@ -61,8 +62,10 @@
import com.android.launcher3.OnAlarmListener;
import com.android.launcher3.PagedView;
import com.android.launcher3.R;
-import com.android.launcher3.WorkspaceItemInfo;
+import com.android.launcher3.ShortcutAndWidgetContainer;
+import com.android.launcher3.Workspace;
import com.android.launcher3.Workspace.ItemOperator;
+import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.accessibility.AccessibleDragListenerAdapter;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DragController;
@@ -121,6 +124,7 @@
private static final int REORDER_DELAY = 250;
private static final int ON_EXIT_CLOSE_DELAY = 400;
private static final Rect sTempRect = new Rect();
+ private static final int MIN_FOLDERS_FOR_HARDWARE_OPTIMIZATION = 10;
private static String sDefaultFolderName;
private static String sHintText;
@@ -430,21 +434,44 @@
if (mCurrentAnimator != null && mCurrentAnimator.isRunning()) {
mCurrentAnimator.cancel();
}
+ final Workspace workspace = mLauncher.getWorkspace();
+ final CellLayout currentCellLayout =
+ (CellLayout) workspace.getChildAt(workspace.getCurrentPage());
+ final boolean useHardware = shouldUseHardwareLayerForAnimation(currentCellLayout);
+ final boolean wasHardwareAccelerated = currentCellLayout.isHardwareLayerEnabled();
+
a.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
+ if (useHardware) {
+ currentCellLayout.enableHardwareLayer(true);
+ }
mState = STATE_ANIMATING;
mCurrentAnimator = a;
}
@Override
public void onAnimationEnd(Animator animation) {
+ if (useHardware) {
+ currentCellLayout.enableHardwareLayer(wasHardwareAccelerated);
+ }
mCurrentAnimator = null;
}
});
a.start();
}
+ private boolean shouldUseHardwareLayerForAnimation(CellLayout currentCellLayout) {
+ int folderCount = 0;
+ final ShortcutAndWidgetContainer container = currentCellLayout.getShortcutsAndWidgets();
+ for (int i = container.getChildCount() - 1; i >= 0; --i) {
+ final View child = container.getChildAt(i);
+ if (child instanceof AppWidgetHostView) return false;
+ if (child instanceof FolderIcon) ++folderCount;
+ }
+ return folderCount >= MIN_FOLDERS_FOR_HARDWARE_OPTIMIZATION;
+ }
+
/**
* Opens the user folder described by the specified tag. The opening of the folder
* is animated relative to the specified View. If the View is null, no animation
@@ -869,7 +896,7 @@
DeviceProfile grid = mLauncher.getDeviceProfile();
DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
- DragLayer parent = (DragLayer) mLauncher.findViewById(R.id.drag_layer);
+ DragLayer parent = mLauncher.getDragLayer();
int width = getFolderWidth();
int height = getFolderHeight();
@@ -881,8 +908,7 @@
// We need to bound the folder to the currently visible workspace area
if (mLauncher.getStateManager().getState().overviewUi) {
- mLauncher.getDragLayer().getDescendantRectRelativeToSelf(mLauncher.getOverviewPanel(),
- sTempRect);
+ parent.getDescendantRectRelativeToSelf(mLauncher.getOverviewPanel(), sTempRect);
} else {
mLauncher.getWorkspace().getPageAreaRelativeToDragLayer(sTempRect);
}
diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java
index 02242a3..6fa9ba9 100644
--- a/src/com/android/launcher3/folder/FolderIcon.java
+++ b/src/com/android/launcher3/folder/FolderIcon.java
@@ -159,7 +159,7 @@
"is dependent on this");
}
- DeviceProfile grid = launcher.getDeviceProfile();
+ DeviceProfile grid = launcher.getWallpaperDeviceProfile();
FolderIcon icon = (FolderIcon) LayoutInflater.from(group.getContext())
.inflate(resId, group, false);
@@ -174,7 +174,7 @@
icon.setOnClickListener(ItemClickHandler.INSTANCE);
icon.mInfo = folderInfo;
icon.mLauncher = launcher;
- icon.mDotRenderer = launcher.getDeviceProfile().mDotRenderer;
+ icon.mDotRenderer = grid.mDotRenderer;
icon.setContentDescription(launcher.getString(R.string.folder_name_format, folderInfo.title));
Folder folder = Folder.fromXml(launcher);
folder.setDragController(launcher.getDragController());
@@ -508,7 +508,8 @@
public void drawDot(Canvas canvas) {
if ((mDotInfo != null && mDotInfo.hasDot()) || mDotScale > 0) {
Rect iconBounds = mDotParams.iconBounds;
- BubbleTextView.getIconBounds(this, iconBounds, mLauncher.getDeviceProfile().iconSizePx);
+ BubbleTextView.getIconBounds(this, iconBounds,
+ mLauncher.getWallpaperDeviceProfile().iconSizePx);
// If we are animating to the accepting state, animate the dot out.
mDotParams.scale = Math.max(0, mDotScale - mBackground.getScaleProgress());
diff --git a/src/com/android/launcher3/folder/PreviewBackground.java b/src/com/android/launcher3/folder/PreviewBackground.java
index ac908f4..46df77a 100644
--- a/src/com/android/launcher3/folder/PreviewBackground.java
+++ b/src/com/android/launcher3/folder/PreviewBackground.java
@@ -42,7 +42,6 @@
import com.android.launcher3.CellLayout;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
-import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ActivityContext;
/**
@@ -135,7 +134,7 @@
mBgColor = ta.getColor(R.styleable.FolderIconPreview_android_colorPrimary, 0);
ta.recycle();
- DeviceProfile grid = activity.getDeviceProfile();
+ DeviceProfile grid = activity.getWallpaperDeviceProfile();
previewSize = grid.folderIconSizePx;
basePreviewOffsetX = (availableSpaceX - previewSize) / 2;
diff --git a/src/com/android/launcher3/graphics/RotationMode.java b/src/com/android/launcher3/graphics/RotationMode.java
new file mode 100644
index 0000000..1b2cbdb
--- /dev/null
+++ b/src/com/android/launcher3/graphics/RotationMode.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2019 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.graphics;
+
+import android.graphics.Rect;
+
+public abstract class RotationMode {
+
+ public final float surfaceRotation;
+ public final boolean isTransposed;
+
+ private RotationMode(float surfaceRotation) {
+ this.surfaceRotation = surfaceRotation;
+ isTransposed = surfaceRotation != 0;
+ }
+
+ public final void mapRect(Rect rect, Rect out) {
+ mapRect(rect.left, rect.top, rect.right, rect.bottom, out);
+ }
+
+ public void mapRect(int left, int top, int right, int bottom, Rect out) {
+ out.set(left, top, right, bottom);
+ }
+
+ public static RotationMode NORMAL = new RotationMode(0) { };
+
+ public static RotationMode LANDSCAPE = new RotationMode(-90) {
+ @Override
+ public void mapRect(int left, int top, int right, int bottom, Rect out) {
+ out.left = top;
+ out.top = right;
+ out.right = bottom;
+ out.bottom = left;
+ }
+ };
+
+ public static RotationMode SEASCAPE = new RotationMode(90) {
+ @Override
+ public void mapRect(int left, int top, int right, int bottom, Rect out) {
+ out.left = bottom;
+ out.top = left;
+ out.right = top;
+ out.bottom = right;
+ }
+ };
+}
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index c7d93fe..047f486 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -190,10 +190,6 @@
* @return the container if shown or null.
*/
public static PopupContainerWithArrow showForIcon(BubbleTextView icon) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "PopupContainerWithArrow.showForIcon");
- }
Launcher launcher = Launcher.getLauncher(icon.getContext());
if (getOpen(launcher) != null) {
// There is already an items container open, so don't open this one.
diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
index a1871ff..35fc873 100644
--- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
+++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
@@ -233,11 +233,6 @@
@Override
public void onDragStart(boolean start) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "AbstractStateChangeTouchController.onDragStart() called with: start = [" +
- start + "]");
- }
mStartState = mLauncher.getStateManager().getState();
if (mStartState == ALL_APPS) {
mStartContainerType = LauncherLogProto.ContainerType.ALLAPPS;
@@ -269,11 +264,6 @@
public boolean onDrag(float displacement) {
float deltaProgress = mProgressMultiplier * (displacement - mDisplacementShift);
float progress = deltaProgress + mStartProgress;
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "AbstractStateChangeTouchController.onDrag() called with: displacement = [" +
- displacement + "], progress = [" + progress + "]");
- }
updateProgress(progress);
boolean isDragTowardPositive = mSwipeDirection.isPositive(
displacement - mDisplacementShift);
@@ -393,12 +383,6 @@
? MIN_PROGRESS_TO_ALL_APPS : SUCCESS_TRANSITION_PROGRESS;
targetState = (interpolatedProgress > successProgress) ? mToState : mFromState;
}
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "AbstractStateChangeTouchController.onDragEnd() called with: velocity = [" +
- velocity + "], fling = [" + fling + "], target state: " +
- targetState.getClass().getSimpleName());
- }
final float endProgress;
final float startProgress;
diff --git a/src/com/android/launcher3/touch/ItemClickHandler.java b/src/com/android/launcher3/touch/ItemClickHandler.java
index 026770c..0650001 100644
--- a/src/com/android/launcher3/touch/ItemClickHandler.java
+++ b/src/com/android/launcher3/touch/ItemClickHandler.java
@@ -66,14 +66,6 @@
}
private static void onClick(View v, String sourceContainer) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "onClick() called with: v = [" + v.getClass().getSimpleName() +
- "], sourceContainer = [" +
- (sourceContainer != null ?
- sourceContainer.getClass().getSimpleName() : "null")
- + "]");
- }
// Make sure that rogue clicks don't get through while allapps is launching, or after the
// view has detached (it's possible for this to happen if the view is removed mid touch).
if (v.getWindowToken() == null) {
diff --git a/src/com/android/launcher3/touch/ItemLongClickListener.java b/src/com/android/launcher3/touch/ItemLongClickListener.java
index 003b442..babbcdd 100644
--- a/src/com/android/launcher3/touch/ItemLongClickListener.java
+++ b/src/com/android/launcher3/touch/ItemLongClickListener.java
@@ -74,10 +74,6 @@
}
private static boolean onAllAppsItemLongClick(View v) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "onAllAppsItemLongClick");
- }
Launcher launcher = Launcher.getLauncher(v.getContext());
if (!canStartDrag(launcher)) return false;
// When we have exited all apps or are in transition, disregard long clicks
diff --git a/src/com/android/launcher3/util/Themes.java b/src/com/android/launcher3/util/Themes.java
index a45f17d..0c44012 100644
--- a/src/com/android/launcher3/util/Themes.java
+++ b/src/com/android/launcher3/util/Themes.java
@@ -17,6 +17,7 @@
package com.android.launcher3.util;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.ColorMatrix;
@@ -26,12 +27,34 @@
import android.util.TypedValue;
import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
+import com.android.launcher3.uioverrides.WallpaperColorInfo;
/**
* Various utility methods associated with theming.
*/
public class Themes {
+ public static int getActivityThemeRes(Context context) {
+ WallpaperColorInfo wallpaperColorInfo = WallpaperColorInfo.getInstance(context);
+ boolean darkTheme;
+ if (Utilities.ATLEAST_Q) {
+ Configuration configuration = context.getResources().getConfiguration();
+ int nightMode = configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK;
+ darkTheme = nightMode == Configuration.UI_MODE_NIGHT_YES;
+ } else {
+ darkTheme = wallpaperColorInfo.isDark();
+ }
+
+ if (darkTheme) {
+ return wallpaperColorInfo.supportsDarkText() ?
+ R.style.AppTheme_Dark_DarkText : R.style.AppTheme_Dark;
+ } else {
+ return wallpaperColorInfo.supportsDarkText() ?
+ R.style.AppTheme_DarkText : R.style.AppTheme;
+ }
+ }
+
public static String getDefaultBodyFont(Context context) {
TypedArray ta = context.obtainStyledAttributes(android.R.style.TextAppearance_DeviceDefault,
new int[]{android.R.attr.fontFamily});
diff --git a/src/com/android/launcher3/views/ActivityContext.java b/src/com/android/launcher3/views/ActivityContext.java
index c9cdeff..0331a86 100644
--- a/src/com/android/launcher3/views/ActivityContext.java
+++ b/src/com/android/launcher3/views/ActivityContext.java
@@ -22,6 +22,7 @@
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.ItemInfo;
+import com.android.launcher3.graphics.RotationMode;
import com.android.launcher3.dot.DotInfo;
/**
@@ -56,6 +57,19 @@
DeviceProfile getDeviceProfile();
+ /**
+ * Device profile to be used by UI elements which are shown directly on top of the wallpaper
+ * and whose presentation is tied to the wallpaper (and physical device) and not the activity
+ * configuration.
+ */
+ default DeviceProfile getWallpaperDeviceProfile() {
+ return getDeviceProfile();
+ }
+
+ default RotationMode getRotationMode() {
+ return RotationMode.NORMAL;
+ }
+
static ActivityContext lookupContext(Context context) {
if (context instanceof ActivityContext) {
return (ActivityContext) context;
diff --git a/src/com/android/launcher3/views/BaseDragLayer.java b/src/com/android/launcher3/views/BaseDragLayer.java
index 8a15220..3c81bcf 100644
--- a/src/com/android/launcher3/views/BaseDragLayer.java
+++ b/src/com/android/launcher3/views/BaseDragLayer.java
@@ -88,7 +88,8 @@
// Touch is being dispatched through a proxy from InputMonitor
private static final int TOUCH_DISPATCHING_PROXY = 1 << 2;
- protected final int[] mTmpXY = new int[2];
+ protected final float[] mTmpXY = new float[2];
+ protected final float[] mTmpRectPoints = new float[4];
protected final Rect mHitRect = new Rect();
@ViewDebug.ExportedProperty(category = "launcher")
@@ -148,23 +149,13 @@
}
protected boolean findActiveController(MotionEvent ev) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "mActiveController = null");
- }
mActiveController = null;
if ((mTouchDispatchState & (TOUCH_DISPATCHING_GESTURE | TOUCH_DISPATCHING_PROXY)) == 0) {
// Only look for controllers if we are not dispatching from gesture area and proxy is
// not active
mActiveController = findControllerToHandleTouch(ev);
- if (mActiveController != null) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "setting controller1: " + mActiveController.getClass().getSimpleName());
- }
- return true;
- }
+ if (mActiveController != null) return true;
}
return false;
}
@@ -231,17 +222,8 @@
}
if (mActiveController != null) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "BaseDragLayer before onControllerTouchEvent " +
- mActiveController.getClass().getSimpleName());
- }
return mActiveController.onControllerTouchEvent(ev);
} else {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
- "BaseDragLayer no controller");
- }
// In case no child view handled the touch event, we may not get onIntercept anymore
return findActiveController(ev);
}
@@ -325,14 +307,16 @@
* @return The factor by which this descendant is scaled relative to this DragLayer.
*/
public float getDescendantRectRelativeToSelf(View descendant, Rect r) {
- mTmpXY[0] = 0;
- mTmpXY[1] = 0;
- float scale = getDescendantCoordRelativeToSelf(descendant, mTmpXY);
-
- r.set(mTmpXY[0], mTmpXY[1],
- (int) (mTmpXY[0] + scale * descendant.getMeasuredWidth()),
- (int) (mTmpXY[1] + scale * descendant.getMeasuredHeight()));
- return scale;
+ mTmpRectPoints[0] = 0;
+ mTmpRectPoints[1] = 0;
+ mTmpRectPoints[2] = descendant.getWidth();
+ mTmpRectPoints[3] = descendant.getHeight();
+ float s = getDescendantCoordRelativeToSelf(descendant, mTmpRectPoints);
+ r.left = Math.round(Math.min(mTmpRectPoints[0], mTmpRectPoints[2]));
+ r.top = Math.round(Math.min(mTmpRectPoints[1], mTmpRectPoints[3]));
+ r.right = Math.round(Math.max(mTmpRectPoints[0], mTmpRectPoints[2]));
+ r.bottom = Math.round(Math.max(mTmpRectPoints[1], mTmpRectPoints[3]));
+ return s;
}
public float getLocationInDragLayer(View child, int[] loc) {
@@ -342,6 +326,14 @@
}
public float getDescendantCoordRelativeToSelf(View descendant, int[] coord) {
+ mTmpXY[0] = coord[0];
+ mTmpXY[1] = coord[1];
+ float scale = getDescendantCoordRelativeToSelf(descendant, mTmpXY);
+ Utilities.roundArray(mTmpXY, coord);
+ return scale;
+ }
+
+ public float getDescendantCoordRelativeToSelf(View descendant, float[] coord) {
return getDescendantCoordRelativeToSelf(descendant, coord, false);
}
@@ -357,17 +349,27 @@
* this scale factor is assumed to be equal in X and Y, and so if at any point this
* assumption fails, we will need to return a pair of scale factors.
*/
- public float getDescendantCoordRelativeToSelf(View descendant, int[] coord,
+ public float getDescendantCoordRelativeToSelf(View descendant, float[] coord,
boolean includeRootScroll) {
return Utilities.getDescendantCoordRelativeToAncestor(descendant, this,
coord, includeRootScroll);
}
/**
+ * Inverse of {@link #getDescendantCoordRelativeToSelf(View, float[])}.
+ */
+ public void mapCoordInSelfToDescendant(View descendant, float[] coord) {
+ Utilities.mapCoordInSelfToDescendant(descendant, this, coord);
+ }
+
+ /**
* Inverse of {@link #getDescendantCoordRelativeToSelf(View, int[])}.
*/
public void mapCoordInSelfToDescendant(View descendant, int[] coord) {
- Utilities.mapCoordInSelfToDescendant(descendant, this, coord);
+ mTmpXY[0] = coord[0];
+ mTmpXY[1] = coord[1];
+ Utilities.mapCoordInSelfToDescendant(descendant, this, mTmpXY);
+ Utilities.roundArray(mTmpXY, coord);
}
public void getViewRectRelativeToSelf(View v, Rect r) {
diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java
index 77f278a..24a8be5 100644
--- a/src/com/android/launcher3/views/FloatingIconView.java
+++ b/src/com/android/launcher3/views/FloatingIconView.java
@@ -15,6 +15,9 @@
*/
package com.android.launcher3.views;
+import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;
+import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT;
+import static com.android.launcher3.Utilities.mapToRange;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM;
@@ -23,6 +26,7 @@
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
+import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
@@ -61,17 +65,16 @@
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
-import static com.android.launcher3.Utilities.mapToRange;
-
/**
* A view that is created to look like another view with the purpose of creating fluid animations.
*/
-
+@TargetApi(Build.VERSION_CODES.Q)
public class FloatingIconView extends View implements Animator.AnimatorListener, ClipPathView {
public static final float SHAPE_PROGRESS_DURATION = 0.15f;
private static final int FADE_DURATION_MS = 200;
private static final Rect sTmpRect = new Rect();
+ private static final Object[] sTmpObjArray = new Object[1];
private Runnable mEndRunnable;
private CancellationSignal mLoadIconSignal;
@@ -186,14 +189,16 @@
* @param v The view to copy
* @param positionOut Rect that will hold the size and position of v.
*/
- private void matchPositionOf(Launcher launcher, View v, Rect positionOut) {
- Utilities.getLocationBoundsForView(launcher, v, positionOut);
- final LayoutParams lp = new LayoutParams(positionOut.width(), positionOut.height());
+ private void matchPositionOf(Launcher launcher, View v, RectF positionOut) {
+ getLocationBoundsForView(launcher, v, positionOut);
+ final LayoutParams lp = new LayoutParams(
+ Math.round(positionOut.width()),
+ Math.round(positionOut.height()));
lp.ignoreInsets = true;
// Position the floating view exactly on top of the original
- lp.leftMargin = positionOut.left;
- lp.topMargin = positionOut.top;
+ lp.leftMargin = Math.round(positionOut.left);
+ lp.topMargin = Math.round(positionOut.top);
setLayoutParams(lp);
// Set the properties here already to make sure they are available when running the first
// animation frame.
@@ -201,6 +206,57 @@
+ lp.height);
}
+ /**
+ * Returns the location bounds of a view.
+ * - For DeepShortcutView, we return the bounds of the icon view.
+ * - For BubbleTextView, we return the icon bounds.
+ */
+ private void getLocationBoundsForView(Launcher launcher, View v, RectF outRect) {
+ final boolean isBubbleTextView = v instanceof BubbleTextView;
+ final boolean isFolderIcon = v instanceof FolderIcon;
+
+ // Deep shortcut views have their icon drawn in a separate view.
+ final boolean fromDeepShortcutView = v.getParent() instanceof DeepShortcutView;
+
+ final View targetView;
+ boolean ignoreTransform = false;
+
+ if (v instanceof DeepShortcutView) {
+ targetView = ((DeepShortcutView) v).getIconView();
+ } else if (fromDeepShortcutView) {
+ DeepShortcutView view = (DeepShortcutView) v.getParent();
+ targetView = view.getIconView();
+ } else if ((isBubbleTextView || isFolderIcon) && v.getTag() instanceof ItemInfo
+ && (((ItemInfo) v.getTag()).container == CONTAINER_DESKTOP
+ || ((ItemInfo) v.getTag()).container == CONTAINER_HOTSEAT)) {
+ targetView = v;
+ ignoreTransform = true;
+ } else {
+ targetView = v;
+ }
+
+ float[] points = new float[] {0, 0, targetView.getWidth(), targetView.getHeight()};
+ Utilities.getDescendantCoordRelativeToAncestor(targetView, launcher.getDragLayer(), points,
+ false, ignoreTransform);
+
+ float viewLocationLeft = Math.min(points[0], points[2]);
+ float viewLocationTop = Math.min(points[1], points[3]);
+
+ final Rect iconRect = new Rect();
+ if (isBubbleTextView && !fromDeepShortcutView) {
+ ((BubbleTextView) v).getIconBounds(iconRect);
+ } else if (isFolderIcon) {
+ ((FolderIcon) v).getPreviewBounds(iconRect);
+ } else {
+ iconRect.set(0, 0, Math.abs(Math.round(points[2] - points[0])),
+ Math.abs(Math.round(points[3] - points[1])));
+ }
+ viewLocationLeft += iconRect.left;
+ viewLocationTop += iconRect.top;
+ outRect.set(viewLocationLeft, viewLocationTop, viewLocationLeft + iconRect.width(),
+ viewLocationTop + iconRect.height());
+ }
+
@WorkerThread
private void getIcon(Launcher launcher, View v, ItemInfo info, boolean isOpening,
Runnable onIconLoadedRunnable, CancellationSignal loadIconSignal) {
@@ -208,10 +264,7 @@
Drawable drawable = null;
boolean supportsAdaptiveIcons = ADAPTIVE_ICON_WINDOW_ANIM.get()
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
- if (!supportsAdaptiveIcons && v instanceof BubbleTextView) {
- // Similar to DragView, we simply use the BubbleTextView icon here.
- drawable = ((BubbleTextView) v).getIcon();
- }
+ Drawable btvIcon = v instanceof BubbleTextView ? ((BubbleTextView) v).getIcon() : null;
if (info instanceof SystemShortcut) {
if (v instanceof ImageView) {
drawable = ((ImageView) v).getDrawable();
@@ -220,10 +273,24 @@
} else {
drawable = v.getBackground();
}
- }
- if (drawable == null) {
- drawable = Utilities.getFullDrawable(launcher, info, lp.width, lp.height,
- false, new Object[1]);
+ } else {
+ if (supportsAdaptiveIcons) {
+ drawable = Utilities.getFullDrawable(launcher, info, lp.width, lp.height,
+ false, sTmpObjArray);
+ if (!(drawable instanceof AdaptiveIconDrawable)) {
+ // The drawable we get back is not an adaptive icon, so we need to use the
+ // BubbleTextView icon that is already legacy treated.
+ drawable = btvIcon;
+ }
+ } else {
+ if (v instanceof BubbleTextView) {
+ // Similar to DragView, we simply use the BubbleTextView icon here.
+ drawable = btvIcon;
+ } else {
+ drawable = Utilities.getFullDrawable(launcher, info, lp.width, lp.height,
+ false, sTmpObjArray);
+ }
+ }
}
Drawable finalDrawable = drawable == null ? null
@@ -411,7 +478,7 @@
* @param isOpening True if this view replaces the icon for app open animation.
*/
public static FloatingIconView getFloatingIconView(Launcher launcher, View originalView,
- boolean hideOriginal, Rect positionOut, boolean isOpening, FloatingIconView recycle) {
+ boolean hideOriginal, RectF positionOut, boolean isOpening, FloatingIconView recycle) {
if (recycle != null) {
recycle.recycle();
}
diff --git a/src/com/android/launcher3/views/Transposable.java b/src/com/android/launcher3/views/Transposable.java
new file mode 100644
index 0000000..929c1aa
--- /dev/null
+++ b/src/com/android/launcher3/views/Transposable.java
@@ -0,0 +1,26 @@
+/**
+ * Copyright (C) 2019 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.views;
+
+import com.android.launcher3.graphics.RotationMode;
+
+/**
+ * Indicates that a view can be transposed.
+ */
+public interface Transposable {
+
+ RotationMode getRotationMode();
+}
diff --git a/tests/src/com/android/launcher3/ui/DefaultLayoutProviderTest.java b/tests/src/com/android/launcher3/ui/DefaultLayoutProviderTest.java
index 357e029..48335a6 100644
--- a/tests/src/com/android/launcher3/ui/DefaultLayoutProviderTest.java
+++ b/tests/src/com/android/launcher3/ui/DefaultLayoutProviderTest.java
@@ -71,7 +71,7 @@
}
@Test
- @Ignore // Convert test to TAPL and enable them; b/131116002
+ // Convert test to TAPL; b/131116002
public void testCustomProfileLoaded_with_icon_on_hotseat() throws Exception {
writeLayout(new LauncherLayoutBuilder().atHotseat(0).putApp(SETTINGS_APP, SETTINGS_APP));
@@ -86,7 +86,7 @@
}
@Test
- @Ignore // Convert test to TAPL and enable them; b/131116002
+ // Convert test to TAPL; b/131116002
public void testCustomProfileLoaded_with_widget() throws Exception {
// A non-restored widget with no config screen gets restored automatically.
LauncherAppWidgetProviderInfo info = TestViewHelpers.findWidgetProvider(this, false);
@@ -106,7 +106,7 @@
}
@Test
- @Ignore // Convert test to TAPL and enable them; b/131116002
+ // Convert test to TAPL; b/131116002
public void testCustomProfileLoaded_with_folder() throws Exception {
writeLayout(new LauncherLayoutBuilder().atHotseat(0).putFolder(android.R.string.copy)
.addApp(SETTINGS_APP, SETTINGS_APP)
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index 2a69757..581e886 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -33,7 +33,6 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
-import com.android.launcher3.TestProtocol;
import com.android.launcher3.popup.ArrowPopup;
import com.android.launcher3.tapl.AllApps;
import com.android.launcher3.tapl.AppIcon;
@@ -323,24 +322,19 @@
@Test
@PortraitLandscape
public void testDragAppIcon() throws Throwable {
- try {
- TestProtocol.sDebugTracing = true;
- // 1. Open all apps and wait for load complete.
- // 2. Drag icon to homescreen.
- // 3. Verify that the icon works on homescreen.
- mLauncher.getWorkspace().
- switchToAllApps().
- getAppIcon(APP_NAME).
- dragToWorkspace().
- getWorkspaceAppIcon(APP_NAME).
- launch(getAppPackageName());
- executeOnLauncher(launcher -> assertTrue(
- "Launcher activity is the top activity; expecting another activity to be the "
- + "top one",
- isInBackground(launcher)));
- } finally {
- TestProtocol.sDebugTracing = false;
- }
+ // 1. Open all apps and wait for load complete.
+ // 2. Drag icon to homescreen.
+ // 3. Verify that the icon works on homescreen.
+ mLauncher.getWorkspace().
+ switchToAllApps().
+ getAppIcon(APP_NAME).
+ dragToWorkspace().
+ getWorkspaceAppIcon(APP_NAME).
+ launch(getAppPackageName());
+ executeOnLauncher(launcher -> assertTrue(
+ "Launcher activity is the top activity; expecting another activity to be the top "
+ + "one",
+ isInBackground(launcher)));
}
@Test
diff --git a/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java
index 84452b4..06a8bca 100644
--- a/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java
+++ b/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java
@@ -71,25 +71,25 @@
}
@Test
- @Ignore // Convert test to TAPL and enable them; b/131116002
+ // Convert test to TAPL b/131116002
public void testWidgetConfig() throws Throwable {
runTest(false, true);
}
@Test
- @Ignore // Convert test to TAPL and enable them; b/131116002
+ @Ignore // b/121280703
public void testWidgetConfig_rotate() throws Throwable {
runTest(true, true);
}
@Test
- @Ignore // Convert test to TAPL and enable them; b/131116002
+ // Convert test to TAPL b/131116002
public void testConfigCancelled() throws Throwable {
runTest(false, false);
}
@Test
- @Ignore // Convert test to TAPL and enable them; b/131116002
+ @Ignore // b/121280703
public void testConfigCancelled_rotate() throws Throwable {
runTest(true, false);
}
diff --git a/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java
index 90c339f..e802acb 100644
--- a/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java
+++ b/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java
@@ -49,19 +49,19 @@
@Rule public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind();
@Test
- @Ignore // Convert test to TAPL and enable them; b/131116002
public void testDragIcon_portrait() throws Throwable {
lockRotation(true);
performTest();
}
@Test
- @Ignore // Convert test to TAPL and enable them; b/131116002
+ @Ignore // b/121280703
public void testDragIcon_landscape() throws Throwable {
lockRotation(false);
performTest();
}
+ // Convert to TAPL b/131116002
private void performTest() throws Throwable {
clearHomescreen();
mActivityMonitor.startLauncher();
diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java
index 4685c7d..19c5047 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllApps.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java
@@ -69,6 +69,8 @@
if (mLauncher.getNavigationModel() != ZERO_BUTTON) {
final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame");
allAppsContainer.setGestureMargins(0, 0, 0, navBar.getVisibleBounds().height() + 1);
+ } else {
+ allAppsContainer.setGestureMargins(0, 0, 0, 100);
}
final BySelector appIconSelector = AppIcon.getAppIconSelector(appName, mLauncher);
if (!hasClickableIcon(allAppsContainer, appIconSelector)) {
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index 85e112a..9a47aef 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -143,7 +143,6 @@
static void dragIconToWorkspace(
LauncherInstrumentation launcher, Launchable launchable, Point dest,
String longPressIndicator) {
- launcher.getTestInfo(TestProtocol.REQUEST_ENABLE_DRAG_LOGGING);
LauncherInstrumentation.log("dragIconToWorkspace: begin");
final Point launchableCenter = launchable.getObject().getVisibleCenter();
final long downTime = SystemClock.uptimeMillis();
@@ -157,7 +156,6 @@
downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, dest);
LauncherInstrumentation.log("dragIconToWorkspace: end");
launcher.waitUntilGone("drop_target_bar");
- launcher.getTestInfo(TestProtocol.REQUEST_DISABLE_DRAG_LOGGING);
}
/**