summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2016-02-08 11:37:04 -0800
committerTony Wickham <twickham@google.com>2016-02-08 11:37:19 -0800
commite0c332365604976d999eb25d4bdcc49ec75b7a1c (patch)
tree5f7a903ecf9bec5b5c902de95e1b79448a738a15 /src
parent3c4906949f9d7a978caa5ffe9dfe8e6e153876ef (diff)
downloadandroid_packages_apps_Trebuchet-e0c332365604976d999eb25d4bdcc49ec75b7a1c.tar.gz
android_packages_apps_Trebuchet-e0c332365604976d999eb25d4bdcc49ec75b7a1c.tar.bz2
android_packages_apps_Trebuchet-e0c332365604976d999eb25d4bdcc49ec75b7a1c.zip
Tweak spring-loaded workspace.
- No page indicators in spring-loaded mode - Don’t move workspace up as high - Scale workspace at 90% instead of 80% on phones - Increase speed of workspace -> spring-loaded -> workspace - Widgets were being scaled down twice when dragging from widget picker - Don't scale up icons when dragging (scaling other stuff down is enough) - Make scrim less dark and panels more transparent - Thin white border around page instead of highlight when hovering Change-Id: I963e91c20d4c0340480d165e0f3b8064783c0cb2
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/CellLayout.java7
-rw-r--r--src/com/android/launcher3/DeviceProfile.java5
-rw-r--r--src/com/android/launcher3/Folder.java5
-rw-r--r--src/com/android/launcher3/Launcher.java5
-rw-r--r--src/com/android/launcher3/Workspace.java24
-rw-r--r--src/com/android/launcher3/WorkspaceStateTransitionAnimation.java17
-rw-r--r--src/com/android/launcher3/config/FeatureFlags.java4
-rw-r--r--src/com/android/launcher3/dragndrop/DragController.java8
-rw-r--r--src/com/android/launcher3/dragndrop/DragLayer.java2
-rw-r--r--src/com/android/launcher3/dragndrop/DragView.java9
10 files changed, 51 insertions, 35 deletions
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index b09723de5..d283a328f 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 ce3e39c54..ce01bad36 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 abb9f3d92..e849309e1 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 02579a2e2..ea3756955 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 a881aa6d5..86b562ab9 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 d32ce7377..c0eb7eda3 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 50127085a..b0b602c8c 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 704da0e76..80f9e4665 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 ded7fae37..1ad8e95b7 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 01189d0e9..b1df41b9d 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);