diff options
40 files changed, 54 insertions, 494 deletions
diff --git a/res/drawable-hdpi/page_hover_left.9.png b/res/drawable-hdpi/page_hover_left.9.png Binary files differdeleted file mode 100644 index 3f11d0b33..000000000 --- a/res/drawable-hdpi/page_hover_left.9.png +++ /dev/null diff --git a/res/drawable-hdpi/page_hover_left_active.9.png b/res/drawable-hdpi/page_hover_left_active.9.png Binary files differdeleted file mode 100644 index abe4c31a9..000000000 --- a/res/drawable-hdpi/page_hover_left_active.9.png +++ /dev/null diff --git a/res/drawable-hdpi/page_hover_right.9.png b/res/drawable-hdpi/page_hover_right.9.png Binary files differdeleted file mode 100644 index 3bcf19195..000000000 --- a/res/drawable-hdpi/page_hover_right.9.png +++ /dev/null diff --git a/res/drawable-hdpi/page_hover_right_active.9.png b/res/drawable-hdpi/page_hover_right_active.9.png Binary files differdeleted file mode 100644 index 101e4dc0f..000000000 --- a/res/drawable-hdpi/page_hover_right_active.9.png +++ /dev/null diff --git a/res/drawable-hdpi/screenpanel.9.png b/res/drawable-hdpi/screenpanel.9.png Binary files differdeleted file mode 100644 index 5bccd3356..000000000 --- a/res/drawable-hdpi/screenpanel.9.png +++ /dev/null diff --git a/res/drawable-hdpi/screenpanel_hover.9.png b/res/drawable-hdpi/screenpanel_hover.9.png Binary files differdeleted file mode 100644 index f6b8c62ff..000000000 --- a/res/drawable-hdpi/screenpanel_hover.9.png +++ /dev/null diff --git a/res/drawable-mdpi/page_hover_left.9.png b/res/drawable-mdpi/page_hover_left.9.png Binary files differdeleted file mode 100644 index 2b6094cf6..000000000 --- a/res/drawable-mdpi/page_hover_left.9.png +++ /dev/null diff --git a/res/drawable-mdpi/page_hover_left_active.9.png b/res/drawable-mdpi/page_hover_left_active.9.png Binary files differdeleted file mode 100644 index 9eb00a282..000000000 --- a/res/drawable-mdpi/page_hover_left_active.9.png +++ /dev/null diff --git a/res/drawable-mdpi/page_hover_right.9.png b/res/drawable-mdpi/page_hover_right.9.png Binary files differdeleted file mode 100644 index c2e598351..000000000 --- a/res/drawable-mdpi/page_hover_right.9.png +++ /dev/null diff --git a/res/drawable-mdpi/page_hover_right_active.9.png b/res/drawable-mdpi/page_hover_right_active.9.png Binary files differdeleted file mode 100644 index d2771a1a5..000000000 --- a/res/drawable-mdpi/page_hover_right_active.9.png +++ /dev/null diff --git a/res/drawable-mdpi/screenpanel.9.png b/res/drawable-mdpi/screenpanel.9.png Binary files differdeleted file mode 100644 index 9603c122a..000000000 --- a/res/drawable-mdpi/screenpanel.9.png +++ /dev/null diff --git a/res/drawable-mdpi/screenpanel_hover.9.png b/res/drawable-mdpi/screenpanel_hover.9.png Binary files differdeleted file mode 100644 index 7f28ce0e0..000000000 --- a/res/drawable-mdpi/screenpanel_hover.9.png +++ /dev/null diff --git a/res/drawable-xhdpi/page_hover_left.9.png b/res/drawable-xhdpi/page_hover_left.9.png Binary files differdeleted file mode 100644 index dbcc0abd2..000000000 --- a/res/drawable-xhdpi/page_hover_left.9.png +++ /dev/null diff --git a/res/drawable-xhdpi/page_hover_left_active.9.png b/res/drawable-xhdpi/page_hover_left_active.9.png Binary files differdeleted file mode 100644 index 3233efe28..000000000 --- a/res/drawable-xhdpi/page_hover_left_active.9.png +++ /dev/null diff --git a/res/drawable-xhdpi/page_hover_right.9.png b/res/drawable-xhdpi/page_hover_right.9.png Binary files differdeleted file mode 100644 index d82f809bf..000000000 --- a/res/drawable-xhdpi/page_hover_right.9.png +++ /dev/null diff --git a/res/drawable-xhdpi/page_hover_right_active.9.png b/res/drawable-xhdpi/page_hover_right_active.9.png Binary files differdeleted file mode 100644 index 819ea195c..000000000 --- a/res/drawable-xhdpi/page_hover_right_active.9.png +++ /dev/null diff --git a/res/drawable-xhdpi/screenpanel.9.png b/res/drawable-xhdpi/screenpanel.9.png Binary files differdeleted file mode 100644 index 75343f78d..000000000 --- a/res/drawable-xhdpi/screenpanel.9.png +++ /dev/null diff --git a/res/drawable-xhdpi/screenpanel_hover.9.png b/res/drawable-xhdpi/screenpanel_hover.9.png Binary files differdeleted file mode 100644 index 55b4d6ed2..000000000 --- a/res/drawable-xhdpi/screenpanel_hover.9.png +++ /dev/null diff --git a/res/drawable-xxhdpi/page_hover_left.9.png b/res/drawable-xxhdpi/page_hover_left.9.png Binary files differdeleted file mode 100644 index c81f86c02..000000000 --- a/res/drawable-xxhdpi/page_hover_left.9.png +++ /dev/null diff --git a/res/drawable-xxhdpi/page_hover_left_active.9.png b/res/drawable-xxhdpi/page_hover_left_active.9.png Binary files differdeleted file mode 100644 index 858a3b2ab..000000000 --- a/res/drawable-xxhdpi/page_hover_left_active.9.png +++ /dev/null diff --git a/res/drawable-xxhdpi/page_hover_right.9.png b/res/drawable-xxhdpi/page_hover_right.9.png Binary files differdeleted file mode 100644 index c5297703e..000000000 --- a/res/drawable-xxhdpi/page_hover_right.9.png +++ /dev/null diff --git a/res/drawable-xxhdpi/page_hover_right_active.9.png b/res/drawable-xxhdpi/page_hover_right_active.9.png Binary files differdeleted file mode 100644 index 99005536b..000000000 --- a/res/drawable-xxhdpi/page_hover_right_active.9.png +++ /dev/null diff --git a/res/drawable-xxhdpi/screenpanel.9.png b/res/drawable-xxhdpi/screenpanel.9.png Binary files differdeleted file mode 100644 index b221b378f..000000000 --- a/res/drawable-xxhdpi/screenpanel.9.png +++ /dev/null diff --git a/res/drawable-xxhdpi/screenpanel_hover.9.png b/res/drawable-xxhdpi/screenpanel_hover.9.png Binary files differdeleted file mode 100644 index 418cf0a62..000000000 --- a/res/drawable-xxhdpi/screenpanel_hover.9.png +++ /dev/null diff --git a/res/drawable/bg_celllayout.xml b/res/drawable/bg_celllayout.xml index d2219b36c..b81b37f06 100644 --- a/res/drawable/bg_celllayout.xml +++ b/res/drawable/bg_celllayout.xml @@ -18,20 +18,18 @@ */ --> -<transition xmlns:android="http://schemas.android.com/apk/res/android" > - - <item> - <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_active="true" > + <shape android:shape="rectangle" > + <stroke + android:width="@dimen/spring_loaded_panel_border" + android:color="@color/spring_loaded_highlighted_panel_border_color" /> <solid android:color="@color/spring_loaded_panel_color" /> </shape> </item> <item> - <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > - <stroke - android:width="@dimen/spring_loaded_panel_border" - android:color="@color/spring_loaded_highlighted_panel_border_color" /> - <solid android:color="@android:color/transparent" /> + <shape android:shape="rectangle" > + <solid android:color="@color/spring_loaded_panel_color" /> </shape> </item> - -</transition>
\ No newline at end of file +</selector> diff --git a/res/drawable/bg_screenpanel.xml b/res/drawable/bg_screenpanel.xml deleted file mode 100644 index 346fca013..000000000 --- a/res/drawable/bg_screenpanel.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2015, 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. -*/ ---> - -<!-- TODO(twickham): Remove this file and the screenpanel drawables --> -<transition xmlns:android="http://schemas.android.com/apk/res/android" > - - <item android:drawable="@drawable/screenpanel"/> - <item android:drawable="@drawable/screenpanel_hover"/> - -</transition>
\ No newline at end of file diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml deleted file mode 100644 index 514980fe0..000000000 --- a/res/values-sw720dp-land/dimens.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2011 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. ---> - -<resources> - <!-- the area at the edge of the screen that makes the workspace go left - or right while you're dragging. --> - <dimen name="scroll_zone">100dip</dimen> -</resources> diff --git a/res/values-sw720dp-port/dimens.xml b/res/values-sw720dp-port/dimens.xml deleted file mode 100644 index 6f594d518..000000000 --- a/res/values-sw720dp-port/dimens.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2010 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. ---> - -<resources> -<!-- Workspace --> - <!-- the area at the edge of the screen that makes the workspace go left - or right while you're dragging. --> - <dimen name="scroll_zone">40dp</dimen> -</resources> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 188f98fa6..a8a25af3e 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -109,14 +109,6 @@ <!-- the distance an icon must be dragged before button drop targets accept it --> <dimen name="drag_distanceThreshold">30dp</dimen> - <!-- the area at the edge of the screen that makes the workspace go left - or right while you're dragging. --> - <dimen name="scroll_zone">20dp</dimen> - - <!-- When dragging an item, how much bigger (fixed dps) the dragged view - should be. If 0, it will not be scaled at all. --> - <dimen name="dragViewScale">12dp</dimen> - <!-- Elevation for the drag view. It should be larger than elevation of all other drag sources and drop targets like all-apps and folders --> <dimen name="drag_elevation">30dp</dimen> diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index 2eed26492..aef94c1eb 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -33,7 +33,6 @@ import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; -import android.graphics.drawable.TransitionDrawable; import android.os.Build; import android.os.Parcelable; import android.support.annotation.IntDef; @@ -53,7 +52,6 @@ import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.accessibility.DragAndDropAccessibilityDelegate; import com.android.launcher3.accessibility.FolderAccessibilityHelper; import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper; -import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.config.ProviderConfig; import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.graphics.DragPreviewProvider; @@ -112,9 +110,9 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler { private float mBackgroundAlpha; - private static final int BACKGROUND_ACTIVATE_DURATION = - FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND ? 120 : 0; - private final TransitionDrawable mBackground; + private static final int[] BACKGROUND_STATE_ACTIVE = new int[] { android.R.attr.state_active }; + private static final int[] BACKGROUND_STATE_DEFAULT = new int[0]; + private final Drawable mBackground; // These values allow a fixed measurement to be set on the CellLayout. private int mFixedWidth = -1; @@ -227,9 +225,7 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler { setAlwaysDrawnWithCacheEnabled(false); final Resources res = getResources(); - mBackground = (TransitionDrawable) res.getDrawable( - FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND ? R.drawable.bg_screenpanel - : R.drawable.bg_celllayout); + mBackground = res.getDrawable(R.drawable.bg_celllayout); mBackground.setCallback(this); mBackground.setAlpha((int) (mBackgroundAlpha * 255)); @@ -424,15 +420,8 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler { void setIsDragOverlapping(boolean isDragOverlapping) { if (mIsDragOverlapping != isDragOverlapping) { mIsDragOverlapping = isDragOverlapping; - if (mIsDragOverlapping) { - mBackground.startTransition(BACKGROUND_ACTIVATE_DURATION); - } else { - if (mBackgroundAlpha > 0f) { - mBackground.reverseTransition(BACKGROUND_ACTIVATE_DURATION); - } else { - mBackground.resetTransition(); - } - } + mBackground.setState(mIsDragOverlapping + ? BACKGROUND_STATE_ACTIVE : BACKGROUND_STATE_DEFAULT); invalidate(); } } diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index f79d66659..27afdc03d 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -75,7 +75,6 @@ public class DeviceProfile { public final Rect defaultWidgetPadding; private final int defaultPageSpacingPx; private final int topWorkspacePadding; - private float dragViewScale; public float workspaceSpringLoadShrinkFactor; public final int workspaceSpringLoadedBottomSpace; @@ -284,9 +283,6 @@ public class DeviceProfile { cellWidthPx = iconSizePx; cellHeightPx = iconSizePx + iconDrawablePaddingPx + Utilities.calculateTextHeight(iconTextSizePx); - final float scaleDps = !FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND ? 0f - : res.getDimensionPixelSize(R.dimen.dragViewScale); - dragViewScale = (iconSizePx + scaleDps) / iconSizePx; // Hotseat hotseatCellWidthPx = iconSizePx; @@ -417,12 +413,11 @@ public class DeviceProfile { if (isTablet) { // Pad the left and right of the workspace to ensure consistent spacing // between all icons - float gapScale = 1f + (dragViewScale - 1f) / 2f; int width = getCurrentWidth(); int height = getCurrentHeight(); // The amount of screen space available for left/right padding. - int availablePaddingX = Math.max(0, width - (int) ((inv.numColumns * cellWidthPx) + - ((inv.numColumns - 1) * gapScale * cellWidthPx))); + int availablePaddingX = Math.max(0, width - ((inv.numColumns * cellWidthPx) + + ((inv.numColumns - 1) * cellWidthPx))); availablePaddingX = (int) Math.min(availablePaddingX, width * MAX_HORIZONTAL_PADDING_PERCENT); int availablePaddingY = Math.max(0, height - topWorkspacePadding - paddingBottom diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 7775a6bc5..8bb4a5b8f 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1332,8 +1332,6 @@ public class Launcher extends Activity } // Setup the drag controller (drop targets have to be added in reverse order in priority) - mDragController.setDragScroller(mWorkspace); - mDragController.setScrollView(mDragLayer); mDragController.setMoveTarget(mWorkspace); mDragController.addDropTarget(mWorkspace); mDropTargetBar.setup(mDragController); @@ -3024,16 +3022,7 @@ public class Launcher extends Activity mStateTransitionAnimation.startAnimationToWorkspace(mState, mWorkspace.getState(), Workspace.State.SPRING_LOADED, true /* animated */, null /* onCompleteRunnable */); - - if (isAppsViewVisible()) { - mState = State.APPS_SPRING_LOADED; - } else if (isWidgetsViewVisible()) { - mState = State.WIDGETS_SPRING_LOADED; - } else if (!FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND) { - mState = State.WORKSPACE_SPRING_LOADED; - } else { - mState = State.WORKSPACE; - } + mState = State.WORKSPACE_SPRING_LOADED; } public void exitSpringLoadedDragModeDelayed(final boolean successfulDrop, int delay, diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 3ba461a1a..6520a2b6f 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -67,7 +67,6 @@ import com.android.launcher3.config.ProviderConfig; import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.dragndrop.DragOptions; -import com.android.launcher3.dragndrop.DragScroller; import com.android.launcher3.dragndrop.DragView; import com.android.launcher3.dragndrop.SpringLoadedDragController; import com.android.launcher3.folder.Folder; @@ -94,7 +93,7 @@ import java.util.HashSet; * interact with. A workspace is meant to be used with a fixed width only. */ public class Workspace extends PagedView - implements DropTarget, DragSource, DragScroller, View.OnTouchListener, + implements DropTarget, DragSource, View.OnTouchListener, DragController.DragListener, ViewGroup.OnHierarchyChangeListener, Insettable, DropTargetSource { private static final String TAG = "Launcher.Workspace"; @@ -248,9 +247,6 @@ public class Workspace extends PagedView private boolean mStripScreensOnPageStopMoving = false; - /** Is the user is dragging an item near the edge of a page? */ - private boolean mInScrollArea = false; - private DragPreviewProvider mOutlineProvider = null; public static final int DRAG_BITMAP_PADDING = DragPreviewProvider.DRAG_BITMAP_PADDING; private boolean mWorkspaceFadeInAdjacentScreens; @@ -484,10 +480,8 @@ public class Workspace extends PagedView } } - if (!FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND) { - // Always enter the spring loaded mode - mLauncher.enterSpringLoadedDragMode(); - } + // Always enter the spring loaded mode + mLauncher.enterSpringLoadedDragMode(); } public void deferRemoveExtraEmptyScreen() { @@ -2572,7 +2566,7 @@ public class Workspace extends PagedView // If the item being dropped is a shortcut and the nearest drop // cell also contains a shortcut, then create a folder with the two shortcuts. - if (!mInScrollArea && createUserFolderIfNecessary(cell, container, + if (createUserFolderIfNecessary(cell, container, dropTargetLayout, mTargetCell, distance, false, d.dragView, null)) { return; } @@ -2787,10 +2781,6 @@ public class Workspace extends PagedView mDropToLayout = null; setDropLayoutForDragObject(d); - - if (!workspaceInModalState() && FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND) { - mLauncher.getDragLayer().showPageHints(); - } } @Override @@ -2801,32 +2791,18 @@ public class Workspace extends PagedView // Here we store the final page that will be dropped to, if the workspace in fact // receives the drop - if (mInScrollArea) { - if (isPageInTransition()) { - // If the user drops while the page is scrolling, we should use that page as the - // destination instead of the page that is being hovered over. - mDropToLayout = (CellLayout) getPageAt(getNextPage()); - } else { - mDropToLayout = mDragOverlappingLayout; - } - } else { - mDropToLayout = mDragTargetLayout; - } - + mDropToLayout = mDragTargetLayout; if (mDragMode == DRAG_MODE_CREATE_FOLDER) { mCreateUserFolderOnDrop = true; } else if (mDragMode == DRAG_MODE_ADD_TO_FOLDER) { mAddToExistingFolderOnDrop = true; } - // Reset the scroll area and previous drag target - onResetScrollArea(); + // Reset the previous drag target setCurrentDropLayout(null); setCurrentDragOverlappingLayout(null); mSpringLoadedDragController.cancel(); - - mLauncher.getDragLayer().hidePageHints(); } private void enforceDragParity(String event, int update, int expectedValue) { @@ -3043,7 +3019,7 @@ public class Workspace extends PagedView public void onDragOver(DragObject d) { // Skip drag over events while we are dragging over side pages - if (mInScrollArea || !transitionStateShouldAllowDrop()) return; + if (!transitionStateShouldAllowDrop()) return; ItemInfo item = d.dragInfo; if (item == null) { @@ -3743,7 +3719,7 @@ public class Workspace extends PagedView @Override public boolean supportsAppInfoDropTarget() { - return !FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND; + return true; } @Override @@ -3806,65 +3782,6 @@ public class Workspace extends PagedView } } - @Override - public boolean onEnterScrollArea(int x, int y, int direction) { - // Ignore the scroll area if we are dragging over the hot seat - boolean isPortrait = !mLauncher.getDeviceProfile().isLandscape; - if (mLauncher.getHotseat() != null && isPortrait) { - Rect r = new Rect(); - mLauncher.getHotseat().getHitRect(r); - if (r.contains(x, y)) { - return false; - } - } - - boolean result = false; - if (!workspaceInModalState() && !mIsSwitchingState && Folder.getOpen(mLauncher) == null) { - mInScrollArea = true; - - final int page = getNextPage() + - (direction == DragController.SCROLL_LEFT ? -1 : 1); - // We always want to exit the current layout to ensure parity of enter / exit - setCurrentDropLayout(null); - - if (0 <= page && page < getChildCount()) { - // Ensure that we are not dragging over to the custom content screen - if (getScreenIdForPageIndex(page) == CUSTOM_CONTENT_SCREEN_ID) { - return false; - } - - CellLayout layout = (CellLayout) getChildAt(page); - setCurrentDragOverlappingLayout(layout); - - // Workspace is responsible for drawing the edge glow on adjacent pages, - // so we need to redraw the workspace when this may have changed. - invalidate(); - result = true; - } - } - return result; - } - - @Override - public boolean onExitScrollArea() { - boolean result = false; - if (mInScrollArea) { - invalidate(); - CellLayout layout = getCurrentDropLayout(); - setCurrentDropLayout(layout); - setCurrentDragOverlappingLayout(layout); - - result = true; - mInScrollArea = false; - } - return result; - } - - private void onResetScrollArea() { - setCurrentDragOverlappingLayout(null); - mInScrollArea = false; - } - /** * Returns a specific CellLayout */ diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index 24fb06601..97e0d984a 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -51,7 +51,6 @@ import com.android.launcher3.dragndrop.DragOptions; import com.android.launcher3.folder.Folder; import com.android.launcher3.graphics.TintedDrawableSpan; import com.android.launcher3.keyboard.FocusedItemDecorator; -import com.android.launcher3.shortcuts.DeepShortcutsContainer; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; import com.android.launcher3.util.ComponentKey; @@ -387,12 +386,6 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc } }); mLauncher.getWorkspace().beginDragShared(v, this, new DragOptions()); - if (FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND) { - // Enter spring loaded mode (the new workspace does this in - // onDragStart(), so we don't want to do it here) - mLauncher.enterSpringLoadedDragMode(); - } - return false; } diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java index a5a54c1ec..745776db3 100644 --- a/src/com/android/launcher3/dragndrop/DragController.java +++ b/src/com/android/launcher3/dragndrop/DragController.java @@ -21,24 +21,20 @@ import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Point; import android.graphics.Rect; -import android.os.Handler; import android.os.IBinder; import android.view.DragEvent; import android.view.HapticFeedbackConstants; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; -import android.view.ViewConfiguration; import android.view.inputmethod.InputMethodManager; import com.android.launcher3.DragSource; import com.android.launcher3.DropTarget; import com.android.launcher3.ItemInfo; import com.android.launcher3.Launcher; -import com.android.launcher3.PagedView; import com.android.launcher3.R; import com.android.launcher3.ShortcutInfo; -import com.android.launcher3.Utilities; import com.android.launcher3.accessibility.DragViewStateAnnouncer; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.util.ItemInfoMatcher; @@ -51,26 +47,14 @@ import java.util.ArrayList; * Class for initiating a drag within a view or across multiple views. */ public class DragController implements DragDriver.EventListener, TouchController { - public static final int SCROLL_DELAY = 500; - public static final int RESCROLL_DELAY = PagedView.PAGE_SNAP_ANIMATION_DURATION + 150; - private static final boolean PROFILE_DRAWING_DURING_DRAG = false; - private static final int SCROLL_OUTSIDE_ZONE = 0; - private static final int SCROLL_WAITING_IN_ZONE = 1; - - public static final int SCROLL_NONE = -1; - public static final int SCROLL_LEFT = 0; - public static final int SCROLL_RIGHT = 1; - @Thunk Launcher mLauncher; - private Handler mHandler; private FlingToDeleteHelper mFlingToDeleteHelper; // temporaries to avoid gc thrash private Rect mRectTemp = new Rect(); private final int[] mCoordinatesTemp = new int[2]; - private final boolean mIsRtl; /** * Drag driver for the current drag/drop operation, or null if there is no active DND operation. @@ -87,29 +71,17 @@ public class DragController implements DragDriver.EventListener, TouchController /** Y coordinate of the down event. */ private int mMotionDownY; - /** the area at the edge of the screen that makes the workspace go left - * or right while you're dragging. - */ - private final int mScrollZone; - private DropTarget.DragObject mDragObject; /** Who can receive drop events */ - private ArrayList<DropTarget> mDropTargets = new ArrayList<DropTarget>(); - private ArrayList<DragListener> mListeners = new ArrayList<DragListener>(); + 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; - /** The view that will be scrolled when dragging to the left and right edges of the screen. */ - private View mScrollView; - private View mMoveTarget; - @Thunk DragScroller mDragScroller; - @Thunk int mScrollState = SCROLL_OUTSIDE_ZONE; - private ScrollRunnable mScrollRunnable = new ScrollRunnable(); - private DropTarget mLastDropTarget; @Thunk int mLastTouch[] = new int[2]; @@ -143,11 +115,7 @@ public class DragController implements DragDriver.EventListener, TouchController * Used to create a new DragLayer from XML. */ public DragController(Launcher launcher) { - Resources r = launcher.getResources(); mLauncher = launcher; - mHandler = new Handler(); - mScrollZone = r.getDimensionPixelSize(R.dimen.scroll_zone); - mIsRtl = Utilities.isRtl(r); mFlingToDeleteHelper = new FlingToDeleteHelper(launcher); } @@ -216,11 +184,8 @@ public class DragController implements DragDriver.EventListener, TouchController && !mOptions.preDragCondition.shouldStartDrag(0); final Resources res = mLauncher.getResources(); - final float scaleDps = FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND - ? res.getDimensionPixelSize(R.dimen.dragViewScale) - : mIsInPreDrag - ? res.getDimensionPixelSize(R.dimen.pre_drag_view_scale) - : 0f; + final float scaleDps = mIsInPreDrag + ? res.getDimensionPixelSize(R.dimen.pre_drag_view_scale) : 0f; final DragView dragView = mDragObject.dragView = new DragView(mLauncher, b, registrationX, registrationY, initialDragViewScale, scaleDps); @@ -333,7 +298,6 @@ public class DragController implements DragDriver.EventListener, TouchController private void endDrag() { if (isDragging()) { mDragDriver = null; - clearScrollRunnable(); boolean isDeferred = false; if (mDragObject.dragView != null) { isDeferred = mDragObject.deferDragViewCleanupPostAnimation; @@ -507,16 +471,6 @@ public class DragController implements DragDriver.EventListener, TouchController return mMoveTarget != null && mMoveTarget.dispatchUnhandledMove(focused, direction); } - private void clearScrollRunnable() { - mHandler.removeCallbacks(mScrollRunnable); - if (mScrollState == SCROLL_WAITING_IN_ZONE) { - mScrollState = SCROLL_OUTSIDE_ZONE; - mScrollRunnable.setDirection(SCROLL_RIGHT); - mDragScroller.onExitScrollArea(); - mLauncher.getDragLayer().onExitScrollArea(); - } - } - private void handleMoveEvent(int x, int y) { mDragObject.dragView.move(x, y); @@ -531,7 +485,6 @@ public class DragController implements DragDriver.EventListener, TouchController mDistanceSinceScroll += Math.hypot(mLastTouch[0] - x, mLastTouch[1] - y); mLastTouch[0] = x; mLastTouch[1] = y; - checkScrollState(x, y); if (mIsInPreDrag && mOptions.preDragCondition != null && mOptions.preDragCondition.shouldStartDrag(mDistanceSinceScroll)) { @@ -568,36 +521,6 @@ public class DragController implements DragDriver.EventListener, TouchController mLastDropTarget = dropTarget; } - @Thunk void checkScrollState(int x, int y) { - final int slop = ViewConfiguration.get(mLauncher).getScaledWindowTouchSlop(); - final int delay = mDistanceSinceScroll < slop ? RESCROLL_DELAY : SCROLL_DELAY; - final DragLayer dragLayer = mLauncher.getDragLayer(); - final int forwardDirection = mIsRtl ? SCROLL_RIGHT : SCROLL_LEFT; - final int backwardsDirection = mIsRtl ? SCROLL_LEFT : SCROLL_RIGHT; - - if (x < mScrollZone) { - if (mScrollState == SCROLL_OUTSIDE_ZONE) { - mScrollState = SCROLL_WAITING_IN_ZONE; - if (mDragScroller.onEnterScrollArea(x, y, forwardDirection)) { - dragLayer.onEnterScrollArea(); - mScrollRunnable.setDirection(forwardDirection); - mHandler.postDelayed(mScrollRunnable, delay); - } - } - } else if (x > mScrollView.getWidth() - mScrollZone) { - if (mScrollState == SCROLL_OUTSIDE_ZONE) { - mScrollState = SCROLL_WAITING_IN_ZONE; - if (mDragScroller.onEnterScrollArea(x, y, backwardsDirection)) { - dragLayer.onEnterScrollArea(); - mScrollRunnable.setDirection(backwardsDirection); - mHandler.postDelayed(mScrollRunnable, delay); - } - } - } else { - clearScrollRunnable(); - } - } - /** * Call this from a drag source view. */ @@ -619,17 +542,6 @@ public class DragController implements DragDriver.EventListener, TouchController // Remember where the motion event started mMotionDownX = dragLayerX; mMotionDownY = dragLayerY; - - if ((dragLayerX < mScrollZone) || (dragLayerX > mScrollView.getWidth() - mScrollZone)) { - mScrollState = SCROLL_WAITING_IN_ZONE; - mHandler.postDelayed(mScrollRunnable, SCROLL_DELAY); - } else { - mScrollState = SCROLL_OUTSIDE_ZONE; - } - break; - case MotionEvent.ACTION_UP: - case MotionEvent.ACTION_CANCEL: - mHandler.removeCallbacks(mScrollRunnable); break; } @@ -729,10 +641,6 @@ public class DragController implements DragDriver.EventListener, TouchController return null; } - public void setDragScroller(DragScroller scroller) { - mDragScroller = scroller; - } - public void setWindowToken(IBinder token) { mWindowToken = token; } @@ -765,40 +673,4 @@ public class DragController implements DragDriver.EventListener, TouchController mDropTargets.remove(target); } - /** - * Set which view scrolls for touch events near the edge of the screen. - */ - public void setScrollView(View v) { - mScrollView = v; - } - - private class ScrollRunnable implements Runnable { - private int mDirection; - - ScrollRunnable() { - } - - public void run() { - if (mDragScroller != null) { - if (mDirection == SCROLL_LEFT) { - mDragScroller.scrollLeft(); - } else { - mDragScroller.scrollRight(); - } - mScrollState = SCROLL_OUTSIDE_ZONE; - mDistanceSinceScroll = 0; - mDragScroller.onExitScrollArea(); - mLauncher.getDragLayer().onExitScrollArea(); - - if (isDragging()) { - // Check the scroll again so that we can requeue the scroller if necessary - checkScrollState(mLastTouch[0], mLastTouch[1]); - } - } - } - - void setDirection(int direction) { - mDirection = direction; - } - } } diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java index 9de44526d..d656c8446 100644 --- a/src/com/android/launcher3/dragndrop/DragLayer.java +++ b/src/com/android/launcher3/dragndrop/DragLayer.java @@ -33,7 +33,6 @@ import android.graphics.Color; import android.graphics.Point; import android.graphics.Rect; import android.graphics.Region; -import android.graphics.drawable.Drawable; import android.os.Build; import android.util.AttributeSet; import android.view.DragEvent; @@ -117,13 +116,6 @@ public class DragLayer extends InsettableFrameLayout { private final Rect mScrollChildPosition = new Rect(); private final ViewGroupFocusHelper mFocusIndicatorHelper; - private boolean mInScrollArea; - private boolean mShowPageHints; - private Drawable mLeftHoverDrawable; - private Drawable mRightHoverDrawable; - private Drawable mLeftHoverDrawableActive; - private Drawable mRightHoverDrawableActive; - // Related to pinch-to-go-to-overview gesture. private PinchToOverviewListener mPinchListener = null; @@ -144,14 +136,7 @@ public class DragLayer extends InsettableFrameLayout { setMotionEventSplittingEnabled(false); setChildrenDrawingOrderEnabled(true); - final Resources res = getResources(); - if (FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND) { - mLeftHoverDrawable = res.getDrawable(R.drawable.page_hover_left); - mRightHoverDrawable = res.getDrawable(R.drawable.page_hover_right); - mLeftHoverDrawableActive = res.getDrawable(R.drawable.page_hover_left_active); - mRightHoverDrawableActive = res.getDrawable(R.drawable.page_hover_right_active); - } - mIsRtl = Utilities.isRtl(res); + mIsRtl = Utilities.isRtl(getResources()); mFocusIndicatorHelper = new ViewGroupFocusHelper(this); } @@ -911,29 +896,6 @@ public class DragLayer extends InsettableFrameLayout { } } - void onEnterScrollArea() { - mInScrollArea = true; - invalidate(); - } - - void onExitScrollArea() { - mInScrollArea = false; - invalidate(); - } - - public void showPageHints() { - mShowPageHints = true; - Workspace workspace = mLauncher.getWorkspace(); - getDescendantRectRelativeToSelf(workspace.getChildAt(workspace.numCustomPages()), - mScrollChildPosition); - invalidate(); - } - - public void hidePageHints() { - mShowPageHints = false; - invalidate(); - } - public void invalidateScrim() { if (mBackgroundAlpha > 0.0f) { invalidate(); @@ -963,41 +925,6 @@ public class DragLayer extends InsettableFrameLayout { super.dispatchDraw(canvas); } - private void drawPageHints(Canvas canvas) { - if (mShowPageHints) { - Workspace workspace = mLauncher.getWorkspace(); - int width = getMeasuredWidth(); - int page = workspace.getNextPage(); - CellLayout leftPage = (CellLayout) workspace.getChildAt(mIsRtl ? page + 1 : page - 1); - CellLayout rightPage = (CellLayout) workspace.getChildAt(mIsRtl ? page - 1 : page + 1); - - if (leftPage != null && leftPage.isDragTarget()) { - Drawable left = mInScrollArea && leftPage.getIsDragOverlapping() ? - mLeftHoverDrawableActive : mLeftHoverDrawable; - left.setBounds(0, mScrollChildPosition.top, - left.getIntrinsicWidth(), mScrollChildPosition.bottom); - left.draw(canvas); - } - if (rightPage != null && rightPage.isDragTarget()) { - Drawable right = mInScrollArea && rightPage.getIsDragOverlapping() ? - mRightHoverDrawableActive : mRightHoverDrawable; - right.setBounds(width - right.getIntrinsicWidth(), - mScrollChildPosition.top, width, mScrollChildPosition.bottom); - right.draw(canvas); - } - } - } - - protected boolean drawChild(Canvas canvas, View child, long drawingTime) { - boolean ret = super.drawChild(canvas, child, drawingTime); - - // We want to draw the page hints above the workspace, but below the drag view. - if (child instanceof Workspace) { - drawPageHints(canvas); - } - return ret; - } - public void setBackgroundAlpha(float alpha) { if (alpha != mBackgroundAlpha) { mBackgroundAlpha = alpha; diff --git a/src/com/android/launcher3/dragndrop/DragScroller.java b/src/com/android/launcher3/dragndrop/DragScroller.java deleted file mode 100644 index 165d0b11c..000000000 --- a/src/com/android/launcher3/dragndrop/DragScroller.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2008 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.dragndrop; - -/** - * Handles scrolling while dragging - * - */ -public interface DragScroller { - void scrollLeft(); - void scrollRight(); - - /** - * The touch point has entered the scroll area; a scroll is imminent. - * This event will only occur while a drag is active. - * - * @param direction The scroll direction - */ - boolean onEnterScrollArea(int x, int y, int direction); - - /** - * The touch point has left the scroll area. - * NOTE: This may not be called, if a drop occurs inside the scroll area. - */ - boolean onExitScrollArea(); -} diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index 315f5118e..7018811d5 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -43,7 +43,6 @@ import android.view.accessibility.AccessibilityEvent; import android.view.animation.AccelerateInterpolator; import android.view.animation.AnimationUtils; import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodManager; import android.widget.TextView; import com.android.launcher3.AbstractFloatingView; @@ -63,6 +62,7 @@ import com.android.launcher3.LauncherModel; import com.android.launcher3.LauncherSettings; import com.android.launcher3.LogDecelerateInterpolator; import com.android.launcher3.OnAlarmListener; +import com.android.launcher3.PagedView; import com.android.launcher3.R; import com.android.launcher3.ShortcutInfo; import com.android.launcher3.UninstallDropTarget.DropTargetSource; @@ -108,7 +108,12 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC /** * Time for which the scroll hint is shown before automatically changing page. */ - public static final int SCROLL_HINT_DURATION = DragController.SCROLL_DELAY; + public static final int SCROLL_HINT_DURATION = 500; + public static final int RESCROLL_DELAY = PagedView.PAGE_SNAP_ANIMATION_DURATION + 150; + + public static final int SCROLL_NONE = -1; + public static final int SCROLL_LEFT = 0; + public static final int SCROLL_RIGHT = 1; /** * Fraction of icon width which behave as scroll region. @@ -135,8 +140,6 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC private final int mMaterialExpandDuration; private final int mMaterialExpandStagger; - private final InputMethodManager mInputMethodManager; - protected final Launcher mLauncher; protected DragController mDragController; public FolderInfo mInfo; @@ -184,8 +187,8 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC // Folder scrolling private int mScrollAreaOffset; - @Thunk int mScrollHintDir = DragController.SCROLL_NONE; - @Thunk int mCurrentScrollDir = DragController.SCROLL_NONE; + @Thunk int mScrollHintDir = SCROLL_NONE; + @Thunk int mCurrentScrollDir = SCROLL_NONE; /** * Used to inflate the Workspace from XML. @@ -196,9 +199,6 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC public Folder(Context context, AttributeSet attrs) { super(context, attrs); setAlwaysDrawnWithCacheEnabled(false); - mInputMethodManager = (InputMethodManager) - getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - Resources res = getResources(); mExpandDuration = res.getInteger(R.integer.config_folderExpandDuration); mMaterialExpandDuration = res.getInteger(R.integer.config_materialFolderExpandDuration); @@ -833,15 +833,15 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC boolean isOutsideRightEdge = x > (getWidth() - cellOverlap); if (currentPage > 0 && (mContent.mIsRtl ? isOutsideRightEdge : isOutsideLeftEdge)) { - showScrollHint(DragController.SCROLL_LEFT, d); + showScrollHint(SCROLL_LEFT, d); } else if (currentPage < (mContent.getPageCount() - 1) && (mContent.mIsRtl ? isOutsideLeftEdge : isOutsideRightEdge)) { - showScrollHint(DragController.SCROLL_RIGHT, d); + showScrollHint(SCROLL_RIGHT, d); } else { mOnScrollHintAlarm.cancelAlarm(); - if (mScrollHintDir != DragController.SCROLL_NONE) { + if (mScrollHintDir != SCROLL_NONE) { mContent.clearScrollHint(); - mScrollHintDir = DragController.SCROLL_NONE; + mScrollHintDir = SCROLL_NONE; } } } @@ -899,9 +899,9 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC mOnScrollHintAlarm.cancelAlarm(); mScrollPauseAlarm.cancelAlarm(); - if (mScrollHintDir != DragController.SCROLL_NONE) { + if (mScrollHintDir != SCROLL_NONE) { mContent.clearScrollHint(); - mScrollHintDir = DragController.SCROLL_NONE; + mScrollHintDir = SCROLL_NONE; } } @@ -1008,7 +1008,7 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC @Override public boolean supportsAppInfoDropTarget() { - return !FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND; + return true; } @Override @@ -1464,21 +1464,21 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC */ @Override public void onAlarm(Alarm alarm) { - if (mCurrentScrollDir == DragController.SCROLL_LEFT) { + if (mCurrentScrollDir == SCROLL_LEFT) { mContent.scrollLeft(); - mScrollHintDir = DragController.SCROLL_NONE; - } else if (mCurrentScrollDir == DragController.SCROLL_RIGHT) { + mScrollHintDir = SCROLL_NONE; + } else if (mCurrentScrollDir == SCROLL_RIGHT) { mContent.scrollRight(); - mScrollHintDir = DragController.SCROLL_NONE; + mScrollHintDir = SCROLL_NONE; } else { // This should not happen return; } - mCurrentScrollDir = DragController.SCROLL_NONE; + mCurrentScrollDir = SCROLL_NONE; // Pause drag event until the scrolling is finished mScrollPauseAlarm.setOnAlarmListener(new OnScrollFinishedListener(mDragObject)); - mScrollPauseAlarm.setAlarm(DragController.RESCROLL_DELAY); + mScrollPauseAlarm.setAlarm(RESCROLL_DELAY); } } diff --git a/src/com/android/launcher3/folder/FolderPagedView.java b/src/com/android/launcher3/folder/FolderPagedView.java index 8aaeb9e37..650ca1931 100644 --- a/src/com/android/launcher3/folder/FolderPagedView.java +++ b/src/com/android/launcher3/folder/FolderPagedView.java @@ -486,7 +486,7 @@ public class FolderPagedView extends PagedView { * Scrolls the current view by a fraction */ public void showScrollHint(int direction) { - float fraction = (direction == DragController.SCROLL_LEFT) ^ mIsRtl + float fraction = (direction == Folder.SCROLL_LEFT) ^ mIsRtl ? -SCROLL_HINT_FRACTION : SCROLL_HINT_FRACTION; int hint = (int) (fraction * getWidth()); int scroll = getScrollForPage(getNextPage()) + hint; diff --git a/src_config/com/android/launcher3/config/FeatureFlags.java b/src_config/com/android/launcher3/config/FeatureFlags.java index 8ee549753..99d2654a4 100644 --- a/src_config/com/android/launcher3/config/FeatureFlags.java +++ b/src_config/com/android/launcher3/config/FeatureFlags.java @@ -24,8 +24,6 @@ public final class FeatureFlags { // Custom flags go below this public static boolean LAUNCHER3_DISABLE_ICON_NORMALIZATION = false; - // As opposed to the new spring-loaded workspace. - public static boolean LAUNCHER3_LEGACY_WORKSPACE_DND = false; public static boolean LAUNCHER3_LEGACY_FOLDER_ICON = false; public static boolean LAUNCHER3_USE_SYSTEM_DRAG_DRIVER = true; public static boolean LAUNCHER3_DISABLE_PINCH_TO_OVERVIEW = false; |