*/
-->
-<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>
+++ /dev/null
-<?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
+++ /dev/null
-<?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>
+++ /dev/null
-<?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>
<!-- 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>
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;
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;
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;
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));
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();
}
}
public final Rect defaultWidgetPadding;
private final int defaultPageSpacingPx;
private final int topWorkspacePadding;
- private float dragViewScale;
public float workspaceSpringLoadShrinkFactor;
public final int workspaceSpringLoadedBottomSpace;
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;
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
}
// 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);
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,
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;
* 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";
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;
}
}
- 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() {
// 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;
}
mDropToLayout = null;
setDropLayoutForDragObject(d);
-
- if (!workspaceInModalState() && FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND) {
- mLauncher.getDragLayer().showPageHints();
- }
}
@Override
// 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) {
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) {
@Override
public boolean supportsAppInfoDropTarget() {
- return !FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND;
+ return true;
}
@Override
}
}
- @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
*/
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;
}
});
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;
}
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;
* 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.
/** 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];
* 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);
}
&& !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);
private void endDrag() {
if (isDragging()) {
mDragDriver = null;
- clearScrollRunnable();
boolean isDeferred = false;
if (mDragObject.dragView != null) {
isDeferred = mDragObject.deferDragViewCleanupPostAnimation;
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);
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)) {
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.
*/
// 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;
}
return null;
}
- public void setDragScroller(DragScroller scroller) {
- mDragScroller = scroller;
- }
-
public void setWindowToken(IBinder token) {
mWindowToken = token;
}
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;
- }
- }
}
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;
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;
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);
}
}
}
- 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();
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;
+++ /dev/null
-/*
- * 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();
-}
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;
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;
/**
* 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.
private final int mMaterialExpandDuration;
private final int mMaterialExpandStagger;
- private final InputMethodManager mInputMethodManager;
-
protected final Launcher mLauncher;
protected DragController mDragController;
public FolderInfo mInfo;
// 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.
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);
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;
}
}
}
mOnScrollHintAlarm.cancelAlarm();
mScrollPauseAlarm.cancelAlarm();
- if (mScrollHintDir != DragController.SCROLL_NONE) {
+ if (mScrollHintDir != SCROLL_NONE) {
mContent.clearScrollHint();
- mScrollHintDir = DragController.SCROLL_NONE;
+ mScrollHintDir = SCROLL_NONE;
}
}
@Override
public boolean supportsAppInfoDropTarget() {
- return !FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND;
+ return true;
}
@Override
*/
@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);
}
}
* 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;
// 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;