summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2012-02-21 15:48:35 -0800
committerWinson Chung <winsonc@google.com>2012-02-23 10:32:03 -0800
commit867ca62c0e4b811d46734ff940d59c7a787525c8 (patch)
treef5551fdbf3038f1c4e5fae8ac3463a078404e687
parent7a326648c54922c60c32088e173c93068a82d107 (diff)
downloadandroid_packages_apps_Trebuchet-867ca62c0e4b811d46734ff940d59c7a787525c8.tar.gz
android_packages_apps_Trebuchet-867ca62c0e4b811d46734ff940d59c7a787525c8.tar.bz2
android_packages_apps_Trebuchet-867ca62c0e4b811d46734ff940d59c7a787525c8.zip
Fading out workspace when dragging to higlight dragged object.
Change-Id: I540ce145168a65a029d820d6c14a1e3070f8a5b0
-rw-r--r--res/values-sw600dp/dimens.xml2
-rw-r--r--res/values/config.xml4
-rw-r--r--res/values/dimens.xml2
-rw-r--r--src/com/android/launcher2/DragView.java8
-rw-r--r--src/com/android/launcher2/PagedView.java2
-rw-r--r--src/com/android/launcher2/Workspace.java17
6 files changed, 26 insertions, 9 deletions
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index 2d72e1041..81fe13bf2 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -74,7 +74,7 @@
<dimen name="dragViewOffsetY">-12dp</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>
+ <dimen name="dragViewScale">8dp</dimen>
<!-- Folders -->
<!-- The size of the image which sits behind the preview of the folder contents -->
diff --git a/res/values/config.xml b/res/values/config.xml
index 70e65c9ac..259385f51 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -71,6 +71,10 @@
<!-- The distance at which the animation should take the max duration -->
<integer name="config_dropAnimMaxDist">800</integer>
+ <!-- Properties controlling the workspace fade-out during dragging -->
+ <integer name="config_dragFadeOutAlpha">80</integer>
+ <integer name="config_dragFadeOutDuration">250</integer>
+
<!-- Workspace screens are cached to bitmaps only when they're smaller than a certain size
(maxScaleForUsingWorkspaceScreenBitmapCache), since the bitmap cache itself is smaller
than the view itself (workspaceScreenBitmapCacheScale) -->
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index c4a66ac1f..c6dfb49af 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -112,7 +112,7 @@
<dimen name="dragViewOffsetY">-8dp</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>
+ <dimen name="dragViewScale">8dp</dimen>
<!-- Padding applied to AppWidgets -->
<dimen name="app_widget_preview_padding_left">8dp</dimen>
diff --git a/src/com/android/launcher2/DragView.java b/src/com/android/launcher2/DragView.java
index 90b2083a0..79f9b8139 100644
--- a/src/com/android/launcher2/DragView.java
+++ b/src/com/android/launcher2/DragView.java
@@ -32,7 +32,7 @@ import android.view.animation.DecelerateInterpolator;
import com.android.launcher.R;
public class DragView extends View {
- private static float sDragAlpha = 0.8f;
+ private static float sDragAlpha = 1f;
private Bitmap mBitmap;
private Bitmap mCrossFadeBitmap;
@@ -75,7 +75,7 @@ public class DragView extends View {
// Animate the view into the correct position
mAnim = ValueAnimator.ofFloat(0.0f, 1.0f);
mAnim.setDuration(150);
- mAnim.setInterpolator(new DecelerateInterpolator(2.5f));
+ mAnim.setInterpolator(new DecelerateInterpolator(1.5f));
mAnim.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
@@ -88,7 +88,9 @@ public class DragView extends View {
mOffsetY += deltaY;
setScaleX(1f + (value * (scale - 1f)));
setScaleY(1f + (value * (scale - 1f)));
- setAlpha(sDragAlpha * value + (1f - value));
+ if (sDragAlpha != 1f) {
+ setAlpha(sDragAlpha * value + (1f - value));
+ }
if (getParent() == null) {
animation.cancel();
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 184ea7a3c..a615b59f2 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -67,7 +67,7 @@ public abstract class PagedView extends ViewGroup {
private static final float OVERSCROLL_ACCELERATE_FACTOR = 2;
private static final float OVERSCROLL_DAMP_FACTOR = 0.14f;
-
+
private static final float RETURN_TO_ORIGINAL_PAGE_THRESHOLD = 0.33f;
// The page is moved more than halfway, automatically move to the next page on touch up.
private static final float SIGNIFICANT_MOVE_THRESHOLD = 0.4f;
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 0d7498ab0..1643be537 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -210,6 +210,10 @@ public class Workspace extends SmoothPagedView
public static final int COMPLETE_TWO_STAGE_WIDGET_DROP_ANIMATION = 1;
public static final int CANCEL_TWO_STAGE_WIDGET_DROP_ANIMATION = 2;
+ // Relating to workspace drag fade out
+ private float mDragFadeOutAlpha;
+ private int mDragFadeOutDuration;
+
// These variables are used for storing the initial and final values during workspace animations
private int mSavedScrollX;
private float mSavedRotationY;
@@ -261,8 +265,10 @@ public class Workspace extends SmoothPagedView
// With workspace, data is available straight from the get-go
setDataIsReady();
- mFadeInAdjacentScreens =
- getResources().getBoolean(R.bool.config_workspaceFadeAdjacentScreens);
+ final Resources res = getResources();
+ mFadeInAdjacentScreens = res.getBoolean(R.bool.config_workspaceFadeAdjacentScreens);
+ mDragFadeOutAlpha = res.getInteger(R.integer.config_dragFadeOutAlpha) / 100f;
+ mDragFadeOutDuration = res.getInteger(R.integer.config_dragFadeOutDuration);
mWallpaperManager = WallpaperManager.getInstance(context);
int cellCountX = DEFAULT_CELL_COUNT_X;
@@ -271,7 +277,6 @@ public class Workspace extends SmoothPagedView
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.Workspace, defStyle, 0);
- final Resources res = context.getResources();
if (LauncherApplication.isScreenLarge()) {
// Determine number of rows/columns dynamically
// TODO: This code currently fails on tablets with an aspect ratio < 1.3.
@@ -358,12 +363,18 @@ public class Workspace extends SmoothPagedView
mIsDragOccuring = true;
updateChildrenLayersEnabled();
mLauncher.lockScreenOrientationOnLargeUI();
+
+ // Fade out the workspace slightly to highlight the currently dragging item
+ animate().alpha(mDragFadeOutAlpha).setDuration(mDragFadeOutDuration).start();
}
public void onDragEnd() {
mIsDragOccuring = false;
updateChildrenLayersEnabled();
mLauncher.unlockScreenOrientationOnLargeUI();
+
+ // Fade the workspace back in after we have completed dragging
+ animate().alpha(1f).setDuration(mDragFadeOutDuration).start();
}
/**