OSDN Git Service

-> Made outline of current page fade out
authorAdam Cohen <adamcohen@google.com>
Thu, 28 Oct 2010 18:11:18 +0000 (11:11 -0700)
committerAdam Cohen <adamcohen@google.com>
Thu, 28 Oct 2010 18:45:12 +0000 (11:45 -0700)
-> Added new assets for homescreen outlines

Change-Id: Ic19b32a749fd4109bd5601c8b220759aab56603c

res/drawable-xlarge/home_screen_bg.9.png
res/drawable-xlarge/home_screen_bg_hover.9.png
res/drawable-xlarge/mini_home_screen_bg.9.png
res/drawable-xlarge/mini_home_screen_bg_accepts_drops.9.png
res/drawable-xlarge/mini_home_screen_bg_hover.9.png
src/com/android/launcher2/CellLayout.java
src/com/android/launcher2/Workspace.java

index d939d5c..413e492 100644 (file)
Binary files a/res/drawable-xlarge/home_screen_bg.9.png and b/res/drawable-xlarge/home_screen_bg.9.png differ
index c85bcab..73696bf 100644 (file)
Binary files a/res/drawable-xlarge/home_screen_bg_hover.9.png and b/res/drawable-xlarge/home_screen_bg_hover.9.png differ
index e5b2d72..4602609 100644 (file)
Binary files a/res/drawable-xlarge/mini_home_screen_bg.9.png and b/res/drawable-xlarge/mini_home_screen_bg.9.png differ
index 4bd8637..b1aa98b 100644 (file)
Binary files a/res/drawable-xlarge/mini_home_screen_bg_accepts_drops.9.png and b/res/drawable-xlarge/mini_home_screen_bg_accepts_drops.9.png differ
index fb0fb63..a30e992 100644 (file)
Binary files a/res/drawable-xlarge/mini_home_screen_bg_hover.9.png and b/res/drawable-xlarge/mini_home_screen_bg_hover.9.png differ
index 3c82290..b7491ba 100644 (file)
@@ -85,6 +85,7 @@ public class CellLayout extends ViewGroup implements Dimmable {
     private OnTouchListener mInterceptTouchListener;
 
     private float mBackgroundAlpha;
+    private float mBackgroundAlphaMultiplier = 1.0f;
 
     private Drawable mBackground;
     private Drawable mBackgroundMini;
@@ -348,7 +349,7 @@ public class CellLayout extends ViewGroup implements Dimmable {
                 bg = mHover ? mBackgroundHover : mBackground;
             }
             if (bg != null) {
-                bg.setAlpha((int) (mBackgroundAlpha * 255));
+                bg.setAlpha((int) (mBackgroundAlpha * mBackgroundAlphaMultiplier * 255));
                 bg.setBounds(mBackgroundRect);
                 bg.draw(canvas);
             }
@@ -864,6 +865,10 @@ public class CellLayout extends ViewGroup implements Dimmable {
         return mBackgroundAlpha;
     }
 
+    public void setBackgroundAlphaMultiplier(float multiplier) {
+        mBackgroundAlphaMultiplier = multiplier;
+    }
+
     public void setBackgroundAlpha(float alpha) {
         mBackgroundAlpha = alpha;
         invalidate();
index 07faed1..239f6de 100644 (file)
@@ -78,9 +78,9 @@ public class Workspace extends SmoothPagedView
 
     // These are extra scale factors to apply to the mini home screens
     // so as to achieve the desired transform
-    private static final float EXTRA_SCALE_FACTOR_0 = 0.97f;
+    private static final float EXTRA_SCALE_FACTOR_0 = 0.972f;
     private static final float EXTRA_SCALE_FACTOR_1 = 1.0f;
-    private static final float EXTRA_SCALE_FACTOR_2 = 1.08f;
+    private static final float EXTRA_SCALE_FACTOR_2 = 1.10f;
 
     private static final int BACKGROUND_FADE_OUT_DELAY = 300;
     private static final int BACKGROUND_FADE_OUT_DURATION = 300;
@@ -145,6 +145,7 @@ public class Workspace extends SmoothPagedView
     private ShrinkPosition mWaitingToShrinkPosition;
 
     private boolean mInScrollArea = false;
+    private boolean mInDragMode = false;
 
     private final HolographicOutlineHelper mOutlineHelper = new HolographicOutlineHelper();
     private Bitmap mDragOutline = null;
@@ -213,7 +214,6 @@ public class Workspace extends SmoothPagedView
                 mIsInUnshrinkAnimation = false;
             }
         };
-
         mSnapVelocity = 600;
     }
 
@@ -305,7 +305,6 @@ public class Workspace extends SmoothPagedView
                 }
             }
         }
-
         return folders;
     }
 
@@ -525,9 +524,9 @@ public class Workspace extends SmoothPagedView
     protected void screenScrolled(int screenCenter) {
         final int halfScreenSize = getMeasuredWidth() / 2;
         for (int i = 0; i < getChildCount(); i++) {
-            View v = getChildAt(i);
-            if (v != null) {
-                int totalDistance = v.getMeasuredWidth() + mPageSpacing;
+            CellLayout cl = (CellLayout) getChildAt(i);
+            if (cl != null) {
+                int totalDistance = cl.getMeasuredWidth() + mPageSpacing;
                 int delta = screenCenter - (getChildOffset(i) -
                         getRelativeChildOffset(i) + halfScreenSize);
 
@@ -535,8 +534,11 @@ public class Workspace extends SmoothPagedView
                 scrollProgress = Math.min(scrollProgress, 1.0f);
                 scrollProgress = Math.max(scrollProgress, -1.0f);
 
+                float mult =  mInDragMode ? 1.0f : Math.abs(scrollProgress);
+                cl.setBackgroundAlphaMultiplier(mult);
+
                 float rotation = WORKSPACE_ROTATION * scrollProgress;
-                v.setRotationY(rotation);
+                cl.setRotationY(rotation);
             }
         }
     }
@@ -713,6 +715,9 @@ public class Workspace extends SmoothPagedView
         mTouchState = TOUCH_STATE_REST;
         mActivePointerId = INVALID_POINTER;
 
+        CellLayout currentPage = (CellLayout) getChildAt(mCurrentPage);
+        currentPage.setBackgroundAlphaMultiplier(1.0f);
+
         final Resources res = getResources();
         final int screenWidth = getWidth();
         final int screenHeight = getHeight();
@@ -1172,6 +1177,9 @@ public class Workspace extends SmoothPagedView
             mDragTargetLayout = getCurrentDropLayout();
             mDragTargetLayout.onDragEnter();
             showOutlines();
+            mInDragMode = true;
+            CellLayout cl = (CellLayout) getChildAt(mCurrentPage);
+            cl.setBackgroundAlphaMultiplier(1.0f);
         }
     }
 
@@ -1523,6 +1531,7 @@ public class Workspace extends SmoothPagedView
         }
         if (!mIsPageMoving) {
             hideOutlines();
+            mInDragMode = false;
         }
         clearAllHovers();
     }