Merge "Tweak spring-loaded workspace." into ub-launcher3-calgary

This commit is contained in:
Tony Wickham
2016-02-08 19:55:26 +00:00
committed by Android (Google) Code Review
13 changed files with 88 additions and 37 deletions
+5 -2
View File
@@ -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));
+4 -1
View File
@@ -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
+2 -2
View File
@@ -292,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);
}
@@ -971,7 +971,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
+3 -2
View File
@@ -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;
}
+13 -11
View File
@@ -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
@@ -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();
@@ -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;
}
@@ -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);
}
@@ -897,7 +897,7 @@ public class DragLayer extends InsettableFrameLayout {
}
}
void onEnterScrollArea(int direction) {
void onEnterScrollArea() {
mInScrollArea = true;
invalidate();
}
@@ -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);