Loading src/com/android/launcher3/Launcher.java +11 −6 Original line number Diff line number Diff line Loading @@ -1188,7 +1188,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, mScrimView = findViewById(R.id.scrim_view); // Setup the drag controller (drop targets have to be added in reverse order in priority) mDragController.setMoveTarget(mWorkspace); mDropTargetBar.setup(mDragController); mAllAppsController.setupViews(mAppsView); Loading Loading @@ -1488,11 +1487,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, target.pageIndex = mWorkspace.getCurrentPage(); ued.logActionCommand(Action.Command.HOME_INTENT, target, newContainerTarget(ContainerType.WORKSPACE)); final View v = getWindow().peekDecorView(); if (v != null && v.getWindowToken() != null) { UiThreadHelper.hideKeyboardAsync(this, v.getWindowToken()); } hideKeyboard(); if (mLauncherCallbacks != null) { mLauncherCallbacks.onHomeIntent(internalStateHandled); Loading @@ -1503,6 +1498,16 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, TraceHelper.INSTANCE.endSection(traceToken); } /** * Hides the keyboard if visible */ public void hideKeyboard() { final View v = getWindow().peekDecorView(); if (v != null && v.getWindowToken() != null) { UiThreadHelper.hideKeyboardAsync(this, v.getWindowToken()); } } @Override public void onRestoreInstanceState(Bundle state) { super.onRestoreInstanceState(state); Loading src/com/android/launcher3/Workspace.java +1 −4 Original line number Diff line number Diff line Loading @@ -43,7 +43,6 @@ import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.os.Parcelable; import android.os.UserHandle; Loading Loading @@ -1224,10 +1223,8 @@ public class Workspace extends PagedView<WorkspacePageIndicator> protected void onAttachedToWindow() { super.onAttachedToWindow(); IBinder windowToken = getWindowToken(); mWallpaperOffset.setWindowToken(windowToken); mWallpaperOffset.setWindowToken(getWindowToken()); computeScroll(); mDragController.setWindowToken(windowToken); } protected void onDetachedFromWindow() { Loading src/com/android/launcher3/dragndrop/DragController.java +6 −31 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Point; import android.graphics.Rect; import android.os.IBinder; import android.view.DragEvent; import android.view.HapticFeedbackConstants; import android.view.KeyEvent; Loading @@ -44,7 +43,6 @@ import com.android.launcher3.WorkspaceItemInfo; import com.android.launcher3.accessibility.DragViewStateAnnouncer; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.TouchController; import com.android.launcher3.util.UiThreadHelper; import java.util.ArrayList; Loading Loading @@ -86,21 +84,14 @@ public class DragController implements DragDriver.EventListener, TouchController private DropTarget.DragObject mDragObject; /** Who can receive drop events */ private ArrayList<DropTarget> mDropTargets = new ArrayList<>(); private ArrayList<DragListener> mListeners = new ArrayList<>(); /** The window token used as the parent for the DragView. */ private IBinder mWindowToken; private View mMoveTarget; private final ArrayList<DropTarget> mDropTargets = new ArrayList<>(); private final ArrayList<DragListener> mListeners = new ArrayList<>(); private DropTarget mLastDropTarget; private int mLastTouchClassification; private int mDistanceSinceScroll = 0; private Rect mDragLayerRect = new Rect(); private boolean mIsInPreDrag; /** Loading Loading @@ -153,8 +144,7 @@ public class DragController implements DragDriver.EventListener, TouchController android.os.Debug.startMethodTracing("Launcher"); } // Hide soft keyboard, if visible UiThreadHelper.hideKeyboardAsync(mLauncher, mWindowToken); mLauncher.hideKeyboard(); AbstractFloatingView.closeOpenViews(mLauncher, false, TYPE_DISCOVERY_BOUNCE); mOptions = options; Loading Loading @@ -362,9 +352,9 @@ public class DragController implements DragDriver.EventListener, TouchController * Clamps the position to the drag layer bounds. */ private Point getClampedDragLayerPos(float x, float y) { mLauncher.getDragLayer().getLocalVisibleRect(mDragLayerRect); mTmpPoint.x = (int) Math.max(mDragLayerRect.left, Math.min(x, mDragLayerRect.right - 1)); mTmpPoint.y = (int) Math.max(mDragLayerRect.top, Math.min(y, mDragLayerRect.bottom - 1)); mLauncher.getDragLayer().getLocalVisibleRect(mRectTemp); mTmpPoint.x = (int) Math.max(mRectTemp.left, Math.min(x, mRectTemp.right - 1)); mTmpPoint.y = (int) Math.max(mRectTemp.top, Math.min(y, mRectTemp.bottom - 1)); return mTmpPoint; } Loading Loading @@ -439,17 +429,6 @@ public class DragController implements DragDriver.EventListener, TouchController return mDragDriver != null && mDragDriver.onDragEvent(event); } /** * Sets the view that should handle move events. */ public void setMoveTarget(View view) { mMoveTarget = view; } public boolean dispatchUnhandledMove(View focused, int direction) { return mMoveTarget != null && mMoveTarget.dispatchUnhandledMove(focused, direction); } private void handleMoveEvent(int x, int y) { mDragObject.dragView.move(x, y); Loading Loading @@ -593,10 +572,6 @@ public class DragController implements DragDriver.EventListener, TouchController return mLauncher.getWorkspace(); } public void setWindowToken(IBinder token) { mWindowToken = token; } /** * Sets the drag listener which will be notified when a drag starts or ends. */ Loading src/com/android/launcher3/dragndrop/DragLayer.java +17 −14 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ 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.anim.Interpolators.DEACCEL_1_5; import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent; import android.animation.Animator; Loading Loading @@ -49,7 +50,6 @@ import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.ShortcutAndWidgetContainer; import com.android.launcher3.Workspace; import com.android.launcher3.anim.Interpolators; import com.android.launcher3.folder.Folder; import com.android.launcher3.graphics.OverviewScrim; import com.android.launcher3.graphics.RotationMode; Loading @@ -74,11 +74,11 @@ public class DragLayer extends BaseDragLayer<Launcher> { public static final int ANIMATION_END_DISAPPEAR = 0; public static final int ANIMATION_END_REMAIN_VISIBLE = 2; @Thunk DragController mDragController; private DragController mDragController; // Variables relating to animation of views after drop private ValueAnimator mDropAnim = null; private final TimeInterpolator mCubicEaseOutInterpolator = Interpolators.DEACCEL_1_5; @Thunk DragView mDropView = null; @Thunk int mAnchorViewInitialScrollX = 0; @Thunk View mAnchorView = null; Loading @@ -88,13 +88,14 @@ public class DragLayer extends BaseDragLayer<Launcher> { private int mTopViewIndex; private int mChildCountOnLastUpdate = -1; private Rect mTmpRect = new Rect(); // Related to adjacent page hints private final ViewGroupFocusHelper mFocusIndicatorHelper; private final WorkspaceAndHotseatScrim mWorkspaceScrim; private final OverviewScrim mOverviewScrim; // View that should handle move events private View mMoveTarget; /** * Used to create a new DragLayer from XML. * Loading @@ -116,6 +117,7 @@ public class DragLayer extends BaseDragLayer<Launcher> { public void setup(DragController dragController, Workspace workspace) { mDragController = dragController; mWorkspaceScrim.setWorkspace(workspace); mMoveTarget = workspace; recreateControllers(); } Loading Loading @@ -223,7 +225,7 @@ public class DragLayer extends BaseDragLayer<Launcher> { @Override public boolean dispatchUnhandledMove(View focused, int direction) { return super.dispatchUnhandledMove(focused, direction) || mDragController.dispatchUnhandledMove(focused, direction); || mMoveTarget.dispatchUnhandledMove(focused, direction); } @Override Loading Loading @@ -260,9 +262,10 @@ public class DragLayer extends BaseDragLayer<Launcher> { parentChildren.measureChild(child); parentChildren.layoutChild(child); getViewRectRelativeToSelf(dragView, mTmpRect); final int fromX = mTmpRect.left; final int fromY = mTmpRect.top; Rect dragViewBounds = new Rect(); getViewRectRelativeToSelf(dragView, dragViewBounds); final int fromX = dragViewBounds.left; final int fromY = dragViewBounds.top; float coord[] = new float[2]; float childScale = child.getScaleX(); Loading @@ -283,15 +286,15 @@ public class DragLayer extends BaseDragLayer<Launcher> { if (child instanceof DraggableView) { DraggableView d = (DraggableView) child; d.getVisualDragBounds(mTmpRect); d.getVisualDragBounds(dragViewBounds); // This accounts for the offset of the DragView created by scaling it about its // center as it animates into place. float scaleShiftX = dragView.getMeasuredWidth() * (1 - scale) / 2; float scaleShiftY = dragView.getMeasuredHeight() * (1 - scale) / 2; toX += scale * (mTmpRect.left - dragView.getBlurSizeOutline() / 2) - scaleShiftX; toY += scale * (mTmpRect.top - dragView.getBlurSizeOutline() / 2) - scaleShiftY; toX += scale * (dragViewBounds.left - dragView.getBlurSizeOutline() / 2) - scaleShiftX; toY += scale * (dragViewBounds.top - dragView.getBlurSizeOutline() / 2) - scaleShiftY; } child.setVisibility(INVISIBLE); Loading Loading @@ -348,7 +351,7 @@ public class DragLayer extends BaseDragLayer<Launcher> { if (duration < 0) { duration = res.getInteger(R.integer.config_dropAnimMaxDuration); if (dist < maxDist) { duration *= mCubicEaseOutInterpolator.getInterpolation(dist / maxDist); duration *= DEACCEL_1_5.getInterpolation(dist / maxDist); } duration = Math.max(duration, res.getInteger(R.integer.config_dropAnimMinDuration)); } Loading @@ -356,7 +359,7 @@ public class DragLayer extends BaseDragLayer<Launcher> { // Fall back to cubic ease out interpolator for the animation if none is specified TimeInterpolator interpolator = null; if (alphaInterpolator == null || motionInterpolator == null) { interpolator = mCubicEaseOutInterpolator; interpolator = DEACCEL_1_5; } // Animate the view Loading Loading
src/com/android/launcher3/Launcher.java +11 −6 Original line number Diff line number Diff line Loading @@ -1188,7 +1188,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, mScrimView = findViewById(R.id.scrim_view); // Setup the drag controller (drop targets have to be added in reverse order in priority) mDragController.setMoveTarget(mWorkspace); mDropTargetBar.setup(mDragController); mAllAppsController.setupViews(mAppsView); Loading Loading @@ -1488,11 +1487,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, target.pageIndex = mWorkspace.getCurrentPage(); ued.logActionCommand(Action.Command.HOME_INTENT, target, newContainerTarget(ContainerType.WORKSPACE)); final View v = getWindow().peekDecorView(); if (v != null && v.getWindowToken() != null) { UiThreadHelper.hideKeyboardAsync(this, v.getWindowToken()); } hideKeyboard(); if (mLauncherCallbacks != null) { mLauncherCallbacks.onHomeIntent(internalStateHandled); Loading @@ -1503,6 +1498,16 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, TraceHelper.INSTANCE.endSection(traceToken); } /** * Hides the keyboard if visible */ public void hideKeyboard() { final View v = getWindow().peekDecorView(); if (v != null && v.getWindowToken() != null) { UiThreadHelper.hideKeyboardAsync(this, v.getWindowToken()); } } @Override public void onRestoreInstanceState(Bundle state) { super.onRestoreInstanceState(state); Loading
src/com/android/launcher3/Workspace.java +1 −4 Original line number Diff line number Diff line Loading @@ -43,7 +43,6 @@ import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.os.Parcelable; import android.os.UserHandle; Loading Loading @@ -1224,10 +1223,8 @@ public class Workspace extends PagedView<WorkspacePageIndicator> protected void onAttachedToWindow() { super.onAttachedToWindow(); IBinder windowToken = getWindowToken(); mWallpaperOffset.setWindowToken(windowToken); mWallpaperOffset.setWindowToken(getWindowToken()); computeScroll(); mDragController.setWindowToken(windowToken); } protected void onDetachedFromWindow() { Loading
src/com/android/launcher3/dragndrop/DragController.java +6 −31 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Point; import android.graphics.Rect; import android.os.IBinder; import android.view.DragEvent; import android.view.HapticFeedbackConstants; import android.view.KeyEvent; Loading @@ -44,7 +43,6 @@ import com.android.launcher3.WorkspaceItemInfo; import com.android.launcher3.accessibility.DragViewStateAnnouncer; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.TouchController; import com.android.launcher3.util.UiThreadHelper; import java.util.ArrayList; Loading Loading @@ -86,21 +84,14 @@ public class DragController implements DragDriver.EventListener, TouchController private DropTarget.DragObject mDragObject; /** Who can receive drop events */ private ArrayList<DropTarget> mDropTargets = new ArrayList<>(); private ArrayList<DragListener> mListeners = new ArrayList<>(); /** The window token used as the parent for the DragView. */ private IBinder mWindowToken; private View mMoveTarget; private final ArrayList<DropTarget> mDropTargets = new ArrayList<>(); private final ArrayList<DragListener> mListeners = new ArrayList<>(); private DropTarget mLastDropTarget; private int mLastTouchClassification; private int mDistanceSinceScroll = 0; private Rect mDragLayerRect = new Rect(); private boolean mIsInPreDrag; /** Loading Loading @@ -153,8 +144,7 @@ public class DragController implements DragDriver.EventListener, TouchController android.os.Debug.startMethodTracing("Launcher"); } // Hide soft keyboard, if visible UiThreadHelper.hideKeyboardAsync(mLauncher, mWindowToken); mLauncher.hideKeyboard(); AbstractFloatingView.closeOpenViews(mLauncher, false, TYPE_DISCOVERY_BOUNCE); mOptions = options; Loading Loading @@ -362,9 +352,9 @@ public class DragController implements DragDriver.EventListener, TouchController * Clamps the position to the drag layer bounds. */ private Point getClampedDragLayerPos(float x, float y) { mLauncher.getDragLayer().getLocalVisibleRect(mDragLayerRect); mTmpPoint.x = (int) Math.max(mDragLayerRect.left, Math.min(x, mDragLayerRect.right - 1)); mTmpPoint.y = (int) Math.max(mDragLayerRect.top, Math.min(y, mDragLayerRect.bottom - 1)); mLauncher.getDragLayer().getLocalVisibleRect(mRectTemp); mTmpPoint.x = (int) Math.max(mRectTemp.left, Math.min(x, mRectTemp.right - 1)); mTmpPoint.y = (int) Math.max(mRectTemp.top, Math.min(y, mRectTemp.bottom - 1)); return mTmpPoint; } Loading Loading @@ -439,17 +429,6 @@ public class DragController implements DragDriver.EventListener, TouchController return mDragDriver != null && mDragDriver.onDragEvent(event); } /** * Sets the view that should handle move events. */ public void setMoveTarget(View view) { mMoveTarget = view; } public boolean dispatchUnhandledMove(View focused, int direction) { return mMoveTarget != null && mMoveTarget.dispatchUnhandledMove(focused, direction); } private void handleMoveEvent(int x, int y) { mDragObject.dragView.move(x, y); Loading Loading @@ -593,10 +572,6 @@ public class DragController implements DragDriver.EventListener, TouchController return mLauncher.getWorkspace(); } public void setWindowToken(IBinder token) { mWindowToken = token; } /** * Sets the drag listener which will be notified when a drag starts or ends. */ Loading
src/com/android/launcher3/dragndrop/DragLayer.java +17 −14 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ 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.anim.Interpolators.DEACCEL_1_5; import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent; import android.animation.Animator; Loading Loading @@ -49,7 +50,6 @@ import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.ShortcutAndWidgetContainer; import com.android.launcher3.Workspace; import com.android.launcher3.anim.Interpolators; import com.android.launcher3.folder.Folder; import com.android.launcher3.graphics.OverviewScrim; import com.android.launcher3.graphics.RotationMode; Loading @@ -74,11 +74,11 @@ public class DragLayer extends BaseDragLayer<Launcher> { public static final int ANIMATION_END_DISAPPEAR = 0; public static final int ANIMATION_END_REMAIN_VISIBLE = 2; @Thunk DragController mDragController; private DragController mDragController; // Variables relating to animation of views after drop private ValueAnimator mDropAnim = null; private final TimeInterpolator mCubicEaseOutInterpolator = Interpolators.DEACCEL_1_5; @Thunk DragView mDropView = null; @Thunk int mAnchorViewInitialScrollX = 0; @Thunk View mAnchorView = null; Loading @@ -88,13 +88,14 @@ public class DragLayer extends BaseDragLayer<Launcher> { private int mTopViewIndex; private int mChildCountOnLastUpdate = -1; private Rect mTmpRect = new Rect(); // Related to adjacent page hints private final ViewGroupFocusHelper mFocusIndicatorHelper; private final WorkspaceAndHotseatScrim mWorkspaceScrim; private final OverviewScrim mOverviewScrim; // View that should handle move events private View mMoveTarget; /** * Used to create a new DragLayer from XML. * Loading @@ -116,6 +117,7 @@ public class DragLayer extends BaseDragLayer<Launcher> { public void setup(DragController dragController, Workspace workspace) { mDragController = dragController; mWorkspaceScrim.setWorkspace(workspace); mMoveTarget = workspace; recreateControllers(); } Loading Loading @@ -223,7 +225,7 @@ public class DragLayer extends BaseDragLayer<Launcher> { @Override public boolean dispatchUnhandledMove(View focused, int direction) { return super.dispatchUnhandledMove(focused, direction) || mDragController.dispatchUnhandledMove(focused, direction); || mMoveTarget.dispatchUnhandledMove(focused, direction); } @Override Loading Loading @@ -260,9 +262,10 @@ public class DragLayer extends BaseDragLayer<Launcher> { parentChildren.measureChild(child); parentChildren.layoutChild(child); getViewRectRelativeToSelf(dragView, mTmpRect); final int fromX = mTmpRect.left; final int fromY = mTmpRect.top; Rect dragViewBounds = new Rect(); getViewRectRelativeToSelf(dragView, dragViewBounds); final int fromX = dragViewBounds.left; final int fromY = dragViewBounds.top; float coord[] = new float[2]; float childScale = child.getScaleX(); Loading @@ -283,15 +286,15 @@ public class DragLayer extends BaseDragLayer<Launcher> { if (child instanceof DraggableView) { DraggableView d = (DraggableView) child; d.getVisualDragBounds(mTmpRect); d.getVisualDragBounds(dragViewBounds); // This accounts for the offset of the DragView created by scaling it about its // center as it animates into place. float scaleShiftX = dragView.getMeasuredWidth() * (1 - scale) / 2; float scaleShiftY = dragView.getMeasuredHeight() * (1 - scale) / 2; toX += scale * (mTmpRect.left - dragView.getBlurSizeOutline() / 2) - scaleShiftX; toY += scale * (mTmpRect.top - dragView.getBlurSizeOutline() / 2) - scaleShiftY; toX += scale * (dragViewBounds.left - dragView.getBlurSizeOutline() / 2) - scaleShiftX; toY += scale * (dragViewBounds.top - dragView.getBlurSizeOutline() / 2) - scaleShiftY; } child.setVisibility(INVISIBLE); Loading Loading @@ -348,7 +351,7 @@ public class DragLayer extends BaseDragLayer<Launcher> { if (duration < 0) { duration = res.getInteger(R.integer.config_dropAnimMaxDuration); if (dist < maxDist) { duration *= mCubicEaseOutInterpolator.getInterpolation(dist / maxDist); duration *= DEACCEL_1_5.getInterpolation(dist / maxDist); } duration = Math.max(duration, res.getInteger(R.integer.config_dropAnimMinDuration)); } Loading @@ -356,7 +359,7 @@ public class DragLayer extends BaseDragLayer<Launcher> { // Fall back to cubic ease out interpolator for the animation if none is specified TimeInterpolator interpolator = null; if (alphaInterpolator == null || motionInterpolator == null) { interpolator = mCubicEaseOutInterpolator; interpolator = DEACCEL_1_5; } // Animate the view Loading