diff --git a/res/drawable/bg_celllayout.xml b/res/drawable/bg_celllayout.xml new file mode 100644 index 0000000000..0ce083e7a5 --- /dev/null +++ b/res/drawable/bg_celllayout.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/drawable/bg_screenpanel.xml b/res/drawable/bg_screenpanel.xml index cdb71dfa18..346fca013c 100644 --- a/res/drawable/bg_screenpanel.xml +++ b/res/drawable/bg_screenpanel.xml @@ -18,6 +18,7 @@ */ --> + diff --git a/res/values/config.xml b/res/values/config.xml index 4efffffe16..90df997874 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -21,12 +21,12 @@ - 55 + 30 100 250 - 80 + 90 70 diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index b09723de5d..d283a328f2 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -32,6 +32,7 @@ import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; +import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.TransitionDrawable; import android.os.Build; import android.os.Parcelable; @@ -45,7 +46,6 @@ import android.view.ViewDebug; import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; import android.view.animation.DecelerateInterpolator; -import android.widget.Toast; import com.android.launcher3.BubbleTextView.BubbleTextShadowHandler; import com.android.launcher3.FolderIcon.FolderRingAnimator; @@ -53,6 +53,7 @@ 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.util.ParcelableSparseArray; import com.android.launcher3.util.Thunk; @@ -205,7 +206,9 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler { final Resources res = getResources(); mHotseatScale = (float) grid.hotseatIconSizePx / grid.iconSizePx; - mBackground = (TransitionDrawable) res.getDrawable(R.drawable.bg_screenpanel); + mBackground = (TransitionDrawable) res.getDrawable( + FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND ? R.drawable.bg_screenpanel + : R.drawable.bg_celllayout); mBackground.setCallback(this); mBackground.setAlpha((int) (mBackgroundAlpha * 255)); diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index ce3e39c54b..ce01bad36e 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -33,6 +33,8 @@ import android.view.ViewGroup.MarginLayoutParams; import android.widget.FrameLayout; import android.widget.LinearLayout; +import com.android.launcher3.config.FeatureFlags; + public class DeviceProfile { public final InvariantDeviceProfile inv; @@ -242,7 +244,8 @@ public class DeviceProfile { FontMetrics fm = textPaint.getFontMetrics(); cellWidthPx = iconSizePx; cellHeightPx = iconSizePx + iconDrawablePaddingPx + (int) Math.ceil(fm.bottom - fm.top); - final float scaleDps = res.getDimensionPixelSize(R.dimen.dragViewScale); + final float scaleDps = !FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND ? 0f + : res.getDimensionPixelSize(R.dimen.dragViewScale); dragViewScale = (iconSizePx + scaleDps) / iconSizePx; // Hotseat diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java index abb9f3d926..e849309e1a 100644 --- a/src/com/android/launcher3/Folder.java +++ b/src/com/android/launcher3/Folder.java @@ -56,6 +56,7 @@ import com.android.launcher3.FolderInfo.FolderListener; import com.android.launcher3.UninstallDropTarget.UninstallSource; import com.android.launcher3.Workspace.ItemOperator; import com.android.launcher3.accessibility.LauncherAccessibilityDelegate.AccessibilityDragSource; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.dragndrop.DragController.DragListener; import com.android.launcher3.dragndrop.DragLayer; @@ -291,7 +292,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList } mFooter.setImportantForAccessibility(enable ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS : - IMPORTANT_FOR_ACCESSIBILITY_AUTO); + IMPORTANT_FOR_ACCESSIBILITY_AUTO); mLauncher.getWorkspace().setAddNewPageOnDrag(!enable); } @@ -968,7 +969,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList @Override public boolean supportsAppInfoDropTarget() { - return Workspace.IS_SPRING_LOADED; + return !FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND; } @Override diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 02579a2e25..ea37569553 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -101,6 +101,7 @@ import com.android.launcher3.compat.LauncherActivityInfoCompat; import com.android.launcher3.compat.LauncherAppsCompat; import com.android.launcher3.compat.UserHandleCompat; import com.android.launcher3.compat.UserManagerCompat; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.config.ProviderConfig; import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.dragndrop.DragLayer; @@ -3476,7 +3477,7 @@ public class Launcher extends Activity mState = State.APPS_SPRING_LOADED; } else if (isWidgetsViewVisible()) { mState = State.WIDGETS_SPRING_LOADED; - } else if (Workspace.IS_SPRING_LOADED) { + } else if (!FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND) { mState = State.WORKSPACE_SPRING_LOADED; } else { mState = State.WORKSPACE; @@ -3505,7 +3506,7 @@ public class Launcher extends Activity }, delay); } - private boolean isStateSpringLoaded() { + boolean isStateSpringLoaded() { return mState == State.WORKSPACE_SPRING_LOADED || mState == State.APPS_SPRING_LOADED || mState == State.WIDGETS_SPRING_LOADED; } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index a881aa6d52..86b562ab9b 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -61,6 +61,7 @@ import com.android.launcher3.accessibility.LauncherAccessibilityDelegate.Accessi import com.android.launcher3.accessibility.OverviewScreenAccessibilityDelegate; import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper; import com.android.launcher3.compat.UserHandleCompat; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.config.ProviderConfig; import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.dragndrop.DragLayer; @@ -90,7 +91,6 @@ public class Workspace extends PagedView Insettable, UninstallSource, AccessibilityDragSource, Stats.LaunchSourceProvider { private static final String TAG = "Launcher.Workspace"; - public static final boolean IS_SPRING_LOADED = true; private static boolean ENFORCE_DRAG_EVENT_ORDER = false; private static final int SNAP_OFF_EMPTY_SCREEN_DURATION = 400; @@ -402,11 +402,6 @@ public class Workspace extends PagedView mLauncher.onInteractionEnd(); } - /** Returns a scale factor to apply to workspace icons when dragging them from the workspace. */ - public float getDragShrinkFactor() { - return IS_SPRING_LOADED ? mSpringLoadedShrinkFactor : 1f; - } - /** * Initializes various states for this workspace. */ @@ -1797,7 +1792,14 @@ public class Workspace extends PagedView } int getSpringLoadedTranslationY() { - return getOverviewModeTranslationY(); + DeviceProfile grid = mLauncher.getDeviceProfile(); + Rect workspacePadding = grid.getWorkspacePadding(Utilities.isRtl(getResources())); + int scaledHeight = (int) (mSpringLoadedShrinkFactor * getNormalChildHeight()); + int workspaceTop = mInsets.top + workspacePadding.top; + int workspaceBottom = getViewportHeight() - mInsets.bottom - workspacePadding.bottom; + int workspaceHeight = workspaceBottom - workspaceTop; + // Center the spring-loaded pages by translating it up by half of the reduced height. + return -(workspaceHeight - scaledHeight) / 2; } /** @@ -2145,7 +2147,7 @@ public class Workspace extends PagedView b.recycle(); - if (IS_SPRING_LOADED) { + if (!FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND) { mLauncher.enterSpringLoadedDragMode(); } } @@ -2197,7 +2199,7 @@ public class Workspace extends PagedView // Recycle temporary bitmaps tmpB.recycle(); - if (IS_SPRING_LOADED) { + if (!FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND) { mLauncher.enterSpringLoadedDragMode(); } } @@ -2639,7 +2641,7 @@ public class Workspace extends PagedView setCurrentDropLayout(layout); setCurrentDragOverlappingLayout(layout); - if (!workspaceInModalState() && !IS_SPRING_LOADED) { + if (!workspaceInModalState() && FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND) { mLauncher.getDragLayer().showPageHints(); } } @@ -3561,7 +3563,7 @@ public class Workspace extends PagedView @Override public boolean supportsAppInfoDropTarget() { - return IS_SPRING_LOADED; + return !FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND; } @Override diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java index d32ce73779..c0eb7eda35 100644 --- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java +++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java @@ -198,6 +198,7 @@ public class WorkspaceStateTransitionAnimation { @Thunk int mAllAppsTransitionTime; @Thunk int mOverviewTransitionTime; @Thunk int mOverlayTransitionTime; + @Thunk int mSpringLoadedTransitionTime; @Thunk boolean mWorkspaceFadeInAdjacentScreens; public WorkspaceStateTransitionAnimation(Launcher launcher, Workspace workspace) { @@ -209,6 +210,7 @@ public class WorkspaceStateTransitionAnimation { mAllAppsTransitionTime = res.getInteger(R.integer.config_allAppsTransitionTime); mOverviewTransitionTime = res.getInteger(R.integer.config_overviewTransitionTime); mOverlayTransitionTime = res.getInteger(R.integer.config_overlayTransitionTime); + mSpringLoadedTransitionTime = mOverlayTransitionTime / 2; mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100f; mOverviewModeShrinkFactor = @@ -259,6 +261,9 @@ public class WorkspaceStateTransitionAnimation { return mAllAppsTransitionTime; } else if (states.workspaceToOverview || states.overviewToWorkspace) { return mOverviewTransitionTime; + } else if (mLauncher.mState == Launcher.State.WORKSPACE_SPRING_LOADED + || states.oldStateIsNormal && states.stateIsSpringLoaded) { + return mSpringLoadedTransitionTime; } else { return mOverlayTransitionTime; } @@ -282,8 +287,8 @@ public class WorkspaceStateTransitionAnimation { // Update the workspace state float finalBackgroundAlpha = (states.stateIsSpringLoaded || states.stateIsOverview) ? 1.0f : 0f; - float finalHotseatAndPageIndicatorAlpha = (states.stateIsNormal || states.stateIsSpringLoaded) ? - 1f : 0f; + float finalHotseatAlpha = (states.stateIsNormal || states.stateIsSpringLoaded) ? 1f : 0f; + float finalPageIndicatorAlpha = states.stateIsNormal ? 1f : 0f; float finalOverviewPanelAlpha = states.stateIsOverview ? 1f : 0f; float finalWorkspaceTranslationY = 0; @@ -393,7 +398,7 @@ public class WorkspaceStateTransitionAnimation { Animator pageIndicatorAlpha; if (pageIndicator != null) { pageIndicatorAlpha = new LauncherViewPropertyAnimator(pageIndicator) - .alpha(finalHotseatAndPageIndicatorAlpha).withLayer(); + .alpha(finalPageIndicatorAlpha).withLayer(); pageIndicatorAlpha.addListener(new AlphaUpdateListener(pageIndicator, accessibilityEnabled)); } else { @@ -402,7 +407,7 @@ public class WorkspaceStateTransitionAnimation { } LauncherViewPropertyAnimator hotseatAlpha = new LauncherViewPropertyAnimator(hotseat) - .alpha(finalHotseatAndPageIndicatorAlpha); + .alpha(finalHotseatAlpha); hotseatAlpha.addListener(new AlphaUpdateListener(hotseat, accessibilityEnabled)); LauncherViewPropertyAnimator overviewPanelAlpha = @@ -456,10 +461,10 @@ public class WorkspaceStateTransitionAnimation { } else { overviewPanel.setAlpha(finalOverviewPanelAlpha); AlphaUpdateListener.updateVisibility(overviewPanel, accessibilityEnabled); - hotseat.setAlpha(finalHotseatAndPageIndicatorAlpha); + hotseat.setAlpha(finalHotseatAlpha); AlphaUpdateListener.updateVisibility(hotseat, accessibilityEnabled); if (pageIndicator != null) { - pageIndicator.setAlpha(finalHotseatAndPageIndicatorAlpha); + pageIndicator.setAlpha(finalPageIndicatorAlpha); AlphaUpdateListener.updateVisibility(pageIndicator, accessibilityEnabled); } mWorkspace.updateCustomContentVisibility(); diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 50127085a2..b0b602c8cb 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -24,7 +24,6 @@ package com.android.launcher3.config; * Use LAUNCHER3_ prefix for prevent namespace conflicts. */ public final class FeatureFlags { - private FeatureFlags() {} public static boolean IS_DEV_BUILD = false; @@ -33,5 +32,6 @@ public final class FeatureFlags { // Custom flags go below this public static boolean LAUNCHER3_ICON_NORMALIZATION = false; - + // As opposed to the new spring-loaded workspace. + public static boolean LAUNCHER3_LEGACY_WORKSPACE_DND = false; } diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java index 704da0e76d..80f9e46650 100644 --- a/src/com/android/launcher3/dragndrop/DragController.java +++ b/src/com/android/launcher3/dragndrop/DragController.java @@ -43,6 +43,7 @@ import com.android.launcher3.PagedView; import com.android.launcher3.R; import com.android.launcher3.ShortcutInfo; import com.android.launcher3.Utilities; +import com.android.launcher3.Workspace; import com.android.launcher3.accessibility.DragViewStateAnnouncer; import com.android.launcher3.util.Thunk; @@ -245,10 +246,9 @@ public class DragController implements DragDriver.EventListener { mDragObject = new DropTarget.DragObject(); - float finalDragViewScale = mLauncher.getWorkspace().getDragShrinkFactor(); final DragView dragView = mDragObject.dragView = new DragView(mLauncher, b, registrationX, registrationY, 0, 0, b.getWidth(), b.getHeight(), - initialDragViewScale, finalDragViewScale); + initialDragViewScale); mDragObject.dragComplete = false; if (mIsAccessibleDrag) { @@ -572,7 +572,7 @@ public class DragController implements DragDriver.EventListener { if (mScrollState == SCROLL_OUTSIDE_ZONE) { mScrollState = SCROLL_WAITING_IN_ZONE; if (mDragScroller.onEnterScrollArea(x, y, forwardDirection)) { - dragLayer.onEnterScrollArea(forwardDirection); + dragLayer.onEnterScrollArea(); mScrollRunnable.setDirection(forwardDirection); mHandler.postDelayed(mScrollRunnable, delay); } @@ -581,7 +581,7 @@ public class DragController implements DragDriver.EventListener { if (mScrollState == SCROLL_OUTSIDE_ZONE) { mScrollState = SCROLL_WAITING_IN_ZONE; if (mDragScroller.onEnterScrollArea(x, y, backwardsDirection)) { - dragLayer.onEnterScrollArea(backwardsDirection); + dragLayer.onEnterScrollArea(); mScrollRunnable.setDirection(backwardsDirection); mHandler.postDelayed(mScrollRunnable, delay); } diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java index ded7fae379..1ad8e95b77 100644 --- a/src/com/android/launcher3/dragndrop/DragLayer.java +++ b/src/com/android/launcher3/dragndrop/DragLayer.java @@ -897,7 +897,7 @@ public class DragLayer extends InsettableFrameLayout { } } - void onEnterScrollArea(int direction) { + void onEnterScrollArea() { mInScrollArea = true; invalidate(); } diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java index 01189d0e99..b1df41b9d5 100644 --- a/src/com/android/launcher3/dragndrop/DragView.java +++ b/src/com/android/launcher3/dragndrop/DragView.java @@ -39,6 +39,7 @@ import android.view.animation.DecelerateInterpolator; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAnimUtils; import com.android.launcher3.Utilities; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.util.Thunk; import com.android.launcher3.R; @@ -84,15 +85,15 @@ public class DragView extends View { */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public DragView(Launcher launcher, Bitmap bitmap, int registrationX, int registrationY, - int left, int top, int width, int height, final float initialScale, - float finalDragViewScale) { + int left, int top, int width, int height, final float initialScale) { super(launcher); mDragLayer = launcher.getDragLayer(); mDragController = launcher.getDragController(); final Resources res = getResources(); - final float scaleDps = res.getDimensionPixelSize(R.dimen.dragViewScale); - final float scale = finalDragViewScale * (width + scaleDps) / width; + final float scaleDps = !FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND ? 0f + : res.getDimensionPixelSize(R.dimen.dragViewScale); + final float scale = (width + scaleDps) / width; // Set the initial scale to avoid any jumps setScaleX(initialScale);