OSDN Git Service

Fixing various small bugs with launcher
authorWinson Chung <winsonc@google.com>
Fri, 12 Nov 2010 00:34:41 +0000 (16:34 -0800)
committerWinson Chung <winsonc@google.com>
Fri, 12 Nov 2010 01:20:48 +0000 (17:20 -0800)
- Items added from customization tray add from top left now
- Fixing issue where wallpaper tab was not showing
- Workaround for the extra pixel line showing in homescreen drag icons
- Speeding up animations for tab transitions and clicking

Change-Id: I865531bb4cf896320a9e2ff6cef08bed221a2294

res/anim/paged_view_click_feedback.xml
res/values-xlarge/config.xml
src/com/android/launcher2/AllAppsTabbed.java
src/com/android/launcher2/CellLayout.java
src/com/android/launcher2/CustomizePagedView.java
src/com/android/launcher2/Launcher.java
src/com/android/launcher2/PagedView.java
src/com/android/launcher2/Workspace.java

index 786d974..d1e6e23 100644 (file)
@@ -16,8 +16,8 @@
 
 <alpha xmlns:android="http://schemas.android.com/apk/res/android"
     android:fromAlpha="1.0"
-    android:toAlpha="0.65"
-    android:duration="100"
+    android:toAlpha="0.5"
+    android:duration="75"
     android:fillAfter="true"
     android:repeatCount="1"
     android:repeatMode="reverse" />
index 6a56679..a54528e 100644 (file)
@@ -5,6 +5,10 @@
     <!-- NB: This should be less than the workspaceShrinkTime as they happen together. -->
     <integer name="config_allAppsZoomInTime">350</integer>
 
+    <!-- Duration in milliseconds of the transition between tabs in the all apps/customize
+         tray -->
+    <integer name="config_tabTransitionTime">100</integer>
+
     <!-- Duration in milliseconds of the all apps zoom-out animation -->
     <!-- NB: This should be less than the workspaceUnshrinkTime as they happen together. -->
     <integer name="config_allAppsZoomOutTime">350</integer>
index e0ff1a8..a6e21b9 100644 (file)
@@ -76,7 +76,8 @@ public class AllAppsTabbed extends TabHost implements AllAppsView {
         setOnTabChangedListener(new OnTabChangeListener() {
             public void onTabChanged(String tabId) {
                 // animate the changing of the tab content by fading pages in and out
-                final int duration = 150;
+                final Resources res = getResources();
+                final int duration = res.getInteger(R.integer.config_tabTransitionTime);
                 final float alpha = mAllApps.getAlpha();
                 ValueAnimator alphaAnim = ObjectAnimator.ofFloat(mAllApps, "alpha", alpha, 0.0f).
                         setDuration(duration);
index 63871a7..e340101 100644 (file)
@@ -1038,15 +1038,15 @@ public class CellLayout extends ViewGroup implements Dimmable {
         final int countY = mCountY;
         final boolean[][] occupied = mOccupied;
 
-        for (int x = 0; x < countX - (spanX - 1); x++) {
+        for (int y = 0; y < countY - (spanY - 1); y++) {
             inner:
-            for (int y = 0; y < countY - (spanY - 1); y++) {
+            for (int x = 0; x < countX - (spanX - 1); x++) {
                 for (int i = 0; i < spanX; i++) {
                     for (int j = 0; j < spanY; j++) {
                         if (occupied[x + i][y + j]) {
-                            // small optimization: we can skip to below the row we just found
+                            // small optimization: we can skip to after the column we just found
                             // an occupied cell
-                            y += j;
+                            x += i;
                             continue inner;
                         }
                     }
@@ -1154,15 +1154,15 @@ public class CellLayout extends ViewGroup implements Dimmable {
                 endY = Math.min(endY, intersectY + (spanY - 1) + (spanY == 1 ? 1 : 0));
             }
 
-            for (int x = startX; x < endX; x++) {
+            for (int y = startY; y < endY && !foundCell; y++) {
                 inner:
-                for (int y = startY; y < endY; y++) {
+                for (int x = startX; x < endX; x++) {
                     for (int i = 0; i < spanX; i++) {
                         for (int j = 0; j < spanY; j++) {
                             if (mOccupied[x + i][y + j]) {
-                                // small optimization: we can skip to below the row we just found
+                                // small optimization: we can skip to after the column we just found
                                 // an occupied cell
-                                y += j;
+                                x += i;
                                 continue inner;
                             }
                         }
index 14b2429..1763a00 100644 (file)
@@ -289,6 +289,7 @@ public class CustomizePagedView extends PagedView
     public void setCustomizationFilter(CustomizationType filterType) {
         mCustomizationType = filterType;
         setCurrentPage(0);
+        updateCurrentPageScroll();
         invalidatePageData();
 
         // End the current choice mode so that we don't carry selections across tabs
index 81e1847..37c2b41 100644 (file)
@@ -316,7 +316,8 @@ public final class Launcher extends Activity
             mHomeCustomizationDrawer.setOnTabChangedListener(new OnTabChangeListener() {
                 public void onTabChanged(String tabId) {
                     // animate the changing of the tab content by fading pages in and out
-                    final int duration = 150;
+                    final Resources res = getResources();
+                    final int duration = res.getInteger(R.integer.config_tabTransitionTime);
                     final float alpha = mCustomizePagedView.getAlpha();
                     ValueAnimator alphaAnim = ObjectAnimator.ofFloat(mCustomizePagedView,
                             "alpha", alpha, 0.0f);
index 70746b3..109696c 100644 (file)
@@ -245,6 +245,17 @@ public abstract class PagedView extends ViewGroup {
     }
 
     /**
+     * Updates the scroll of the current page immediately to its final scroll position.  We use this
+     * in CustomizePagedView to allow tabs to share the same PagedView while resetting the scroll of
+     * the previous tab page.
+     */
+    protected void updateCurrentPageScroll() {
+        int newX = getChildOffset(mCurrentPage) - getRelativeChildOffset(mCurrentPage);
+        scrollTo(newX, 0);
+        mScroller.setFinalX(newX);
+    }
+
+    /**
      * Sets the current page.
      */
     void setCurrentPage(int currentPage) {
@@ -256,9 +267,7 @@ public abstract class PagedView extends ViewGroup {
         }
 
         mCurrentPage = Math.max(0, Math.min(currentPage, getPageCount() - 1));
-        int newX = getChildOffset(mCurrentPage) - getRelativeChildOffset(mCurrentPage);
-        scrollTo(newX, 0);
-        mScroller.setFinalX(newX);
+        updateCurrentPageScroll();
 
         invalidate();
         notifyPageSwitchListener();
index e79b8e8..3823cc1 100644 (file)
@@ -1046,8 +1046,8 @@ public class Workspace extends SmoothPagedView
 
         // For a TextView, adjust the clip rect so that we don't include the text label
         if (v instanceof TextView) {
-            final int iconHeight = ((TextView) v).getCompoundPaddingTop()
-            clipRect.bottom = clipRect.top + iconHeight;
+            final TextView tv = (TextView) v;
+            clipRect.bottom = clipRect.top + tv.getCompoundPaddingTop() - 1;
         }
 
         // Draw the View into the bitmap.
@@ -1844,7 +1844,8 @@ public class Workspace extends SmoothPagedView
         if (view == null) {
             cellLayout.onDragExit();
         } else {
-            mTargetCell = findNearestVacantArea(x, y, 1, 1, null, cellLayout, mTargetCell);
+            mTargetCell = new int[]{x, y};
+            cellLayout.findCellForSpan(mTargetCell, 1, 1);
             addInScreen(view, indexOfChild(cellLayout), mTargetCell[0],
                     mTargetCell[1], info.spanX, info.spanY, insertAtFirst);
             cellLayout.onDropChild(view);