Merge "Cleanup setToClient calls."
diff --git a/res/anim/all_apps_zoom_in.xml b/res/anim/all_apps_zoom_in.xml
new file mode 100644
index 0000000..644d1cf
--- /dev/null
+++ b/res/anim/all_apps_zoom_in.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/decelerate_interpolator"
+ android:shareInterpolator="true">
+ <translate xmlns:android="http://schemas.android.com/apk/res/android"
+ android:fromXDelta="0%p"
+ android:toXDelta="0%p"
+ android:fromYDelta="-20%p"
+ android:toYDelta="0%p"
+ android:duration="500" />
+ <scale
+ android:fromXScale="5.0"
+ android:toXScale="1.0"
+ android:fromYScale="5.0"
+ android:toYScale="1.0"
+ android:pivotX="50%"
+ android:pivotY="100%"
+ android:duration="500" />
+</set>
diff --git a/res/anim/all_apps_zoom_out.xml b/res/anim/all_apps_zoom_out.xml
new file mode 100644
index 0000000..23a8712
--- /dev/null
+++ b/res/anim/all_apps_zoom_out.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/accelerate_interpolator"
+ android:shareInterpolator="true">
+ <translate xmlns:android="http://schemas.android.com/apk/res/android"
+ android:fromXDelta="0%p"
+ android:toXDelta="0%p"
+ android:fromYDelta="0%p"
+ android:toYDelta="-20%p"
+ android:duration="500" />
+ <scale
+ android:fromXScale="1.0"
+ android:toXScale="5.0"
+ android:fromYScale="1.0"
+ android:toYScale="5.0"
+ android:pivotX="50%"
+ android:pivotY="100%"
+ android:duration="500" />
+</set>
diff --git a/res/layout-land/all_apps_2d.xml b/res/layout-land/all_apps_2d.xml
index a253b93..b7fcd45 100644
--- a/res/layout-land/all_apps_2d.xml
+++ b/res/layout-land/all_apps_2d.xml
@@ -22,7 +22,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="2dip"
- >
+ android:background="#FF000000">
<GridView android:id="@+id/all_apps_2d_grid"
android:tag="all_apps_2d_grid"
diff --git a/res/layout-port/all_apps_2d.xml b/res/layout-port/all_apps_2d.xml
index 0607d62..081cba2 100644
--- a/res/layout-port/all_apps_2d.xml
+++ b/res/layout-port/all_apps_2d.xml
@@ -22,7 +22,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="2dip"
- >
+ android:background="#FF000000">
<GridView android:id="@+id/all_apps_2d_grid"
android:tag="all_apps_2d_grid"
diff --git a/res/layout-xlarge/all_apps_tabbed.xml b/res/layout-xlarge/all_apps_tabbed.xml
new file mode 100644
index 0000000..a5f3d6f
--- /dev/null
+++ b/res/layout-xlarge/all_apps_tabbed.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<com.android.launcher2.AllAppsTabbed xmlns:android="http://schemas.android.com/apk/res/android">
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <TabWidget
+ android:id="@android:id/tabs"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+ <FrameLayout
+ android:id="@android:id/tabcontent"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <com.android.launcher2.AllApps2D
+ android:id="@+id/all_apps_2d"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:padding="2dip">
+ <GridView android:id="@+id/all_apps_2d_grid"
+ android:tag="all_apps_2d_grid"
+ android:scrollbars="none"
+ android:drawSelectorOnTop="false"
+ android:listSelector="@drawable/grid_selector"
+ android:verticalSpacing="10dip"
+ android:numColumns="4"
+ android:fadingEdgeLength="0dip"
+ android:cacheColorHint="#00000000"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_alignParentBottom="true"
+ android:layout_marginBottom="@dimen/button_bar_height"
+ android:layout_marginTop="8dip"
+ android:nextFocusDown="@+id/all_apps_2d_home"
+ android:nextFocusUp="@null"
+ android:nextFocusLeft="@null"
+ android:nextFocusRight="@null" />
+ </com.android.launcher2.AllApps2D>
+ </FrameLayout>
+ </LinearLayout>
+</com.android.launcher2.AllAppsTabbed>
diff --git a/res/layout-xlarge/launcher.xml b/res/layout-xlarge/launcher.xml
index 72cd796..3f56b45 100644
--- a/res/layout-xlarge/launcher.xml
+++ b/res/layout-xlarge/launcher.xml
@@ -22,7 +22,12 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
- <include layout="@layout/all_apps" />
+ <include
+ layout="@layout/all_apps_tabbed"
+ android:id="@+id/all_apps_view"
+ android:layout_width="match_parent"
+ android:layout_height="500dip"
+ android:layout_gravity="top"/>
<!-- The workspace contains 5 screens of cells -->
<com.android.launcher2.Workspace
@@ -39,8 +44,6 @@
<include android:id="@+id/cell5" layout="@layout/workspace_screen" />
</com.android.launcher2.Workspace>
-
-
<RelativeLayout
android:id="@+id/all_apps_button_cluster"
android:layout_width="wrap_content"
@@ -83,40 +86,40 @@
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
- android:layout_height="200dip"
+ android:layout_height="500dip"
android:layout_gravity="bottom"
android:visibility="gone">
- <LinearLayout
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <TabWidget
- android:id="@android:id/tabs"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
- <FrameLayout
- android:id="@android:id/tabcontent"
- android:background="#ff000000"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <com.android.launcher2.WidgetChooser
- android:id="@+id/widget_chooser"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- <com.android.launcher2.FolderChooser
- android:id="@+id/folder_chooser"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- <com.android.launcher2.ShortcutChooser
- android:id="@+id/shortcut_chooser"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- <TextView
- android:id="@+id/wallpaperstab"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:text="@string/wallpapers_temp_tab_text" />
- </FrameLayout>
- </LinearLayout>
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <TabWidget
+ android:id="@android:id/tabs"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+ <FrameLayout
+ android:id="@android:id/tabcontent"
+ android:background="#ff000000"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <com.android.launcher2.WidgetChooser
+ android:id="@+id/widget_chooser"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ <com.android.launcher2.FolderChooser
+ android:id="@+id/folder_chooser"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ <com.android.launcher2.ShortcutChooser
+ android:id="@+id/shortcut_chooser"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ <TextView
+ android:id="@+id/wallpaperstab"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:text="@string/wallpapers_temp_tab_text" />
+ </FrameLayout>
+ </LinearLayout>
</TabHost>
</com.android.launcher2.DragLayer>
diff --git a/res/layout/home_customization_drawer_item.xml b/res/layout/home_customization_drawer_item.xml
index e3d20a1..2ef527d 100644
--- a/res/layout/home_customization_drawer_item.xml
+++ b/res/layout/home_customization_drawer_item.xml
@@ -16,7 +16,7 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:background="?android:attr/galleryItemBackground"
- android:layout_width="200dip"
+ android:layout_width="600dip"
android:layout_height="match_parent"
android:padding="20dip"
android:orientation="vertical"
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 790f835..9bf6cdf 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -37,4 +37,8 @@
<!-- delete_zone_size_full - button_bar_height_portrait -->
<dimen name="delete_zone_padding">14dip</dimen>
+
+ <!-- horizontal spacing between mini screen thumbnails ie. in all
+ apps and in customization mode -->
+ <dimen name="smallScreenSpacing">10dip</dimen>
</resources>
diff --git a/src/com/android/launcher2/AllApps2D.java b/src/com/android/launcher2/AllApps2D.java
index b18fc1a..7d0970b 100644
--- a/src/com/android/launcher2/AllApps2D.java
+++ b/src/com/android/launcher2/AllApps2D.java
@@ -16,15 +16,15 @@
package com.android.launcher2;
-import java.util.ArrayList;
-import java.util.Collections;
+import com.android.launcher.R;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.Resources;
-import android.graphics.drawable.BitmapDrawable;
import android.graphics.Bitmap;
-import android.graphics.Color;
+import android.graphics.PixelFormat;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
@@ -39,7 +39,8 @@
import android.widget.RelativeLayout;
import android.widget.TextView;
-import com.android.launcher.R;
+import java.util.ArrayList;
+import java.util.Collections;
public class AllApps2D
extends RelativeLayout
@@ -125,24 +126,22 @@
@Override
protected void onFinishInflate() {
- setBackgroundColor(Color.BLACK);
-
try {
mGrid = (GridView)findViewWithTag("all_apps_2d_grid");
if (mGrid == null) throw new Resources.NotFoundException();
mGrid.setOnItemClickListener(this);
mGrid.setOnItemLongClickListener(this);
- mGrid.setBackgroundColor(Color.BLACK);
- mGrid.setCacheColorHint(Color.BLACK);
+ // The home button is optional; some layouts might not use it
ImageButton homeButton = (ImageButton) findViewWithTag("all_apps_2d_home");
- if (homeButton == null) throw new Resources.NotFoundException();
- homeButton.setOnClickListener(
- new View.OnClickListener() {
- public void onClick(View v) {
- mLauncher.closeAllApps(true);
- }
- });
+ if (homeButton != null) {
+ homeButton.setOnClickListener(
+ new View.OnClickListener() {
+ public void onClick(View v) {
+ mLauncher.closeAllApps(true);
+ }
+ });
+ }
} catch (Resources.NotFoundException e) {
Log.e(TAG, "Can't find necessary layout elements for AllApps2D");
}
@@ -249,9 +248,8 @@
return mZoom > 0.001f;
}
- @Override
- public boolean isOpaque() {
- return mZoom > 0.999f;
+ public boolean isAnimating() {
+ return (getAnimation() != null);
}
public void setApps(ArrayList<ApplicationInfo> list) {
diff --git a/src/com/android/launcher2/AllApps3D.java b/src/com/android/launcher2/AllApps3D.java
index bb18870..653f355 100644
--- a/src/com/android/launcher2/AllApps3D.java
+++ b/src/com/android/launcher2/AllApps3D.java
@@ -787,8 +787,8 @@
return sRollo != null && mZoom > 0.001f;
}
- public boolean isOpaque() {
- return mZoom > 0.999f;
+ public boolean isAnimating() {
+ return isVisible() && mZoom <= 0.999f;
}
public void setApps(ArrayList<ApplicationInfo> list) {
diff --git a/src/com/android/launcher2/AllAppsList.java b/src/com/android/launcher2/AllAppsList.java
index 3bacd87..e5d8782 100644
--- a/src/com/android/launcher2/AllAppsList.java
+++ b/src/com/android/launcher2/AllAppsList.java
@@ -149,6 +149,17 @@
modified.add(applicationInfo);
}
}
+ } else {
+ // Remove all data for this package.
+ for (int i = data.size() - 1; i >= 0; i--) {
+ final ApplicationInfo applicationInfo = data.get(i);
+ final ComponentName component = applicationInfo.intent.getComponent();
+ if (packageName.equals(component.getPackageName())) {
+ removed.add(applicationInfo);
+ mIconCache.remove(component);
+ data.remove(i);
+ }
+ }
}
}
@@ -160,23 +171,10 @@
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
+ mainIntent.setPackage(packageName);
final List<ResolveInfo> apps = packageManager.queryIntentActivities(mainIntent, 0);
- final List<ResolveInfo> matches = new ArrayList<ResolveInfo>();
-
- if (apps != null) {
- // Find all activities that match the packageName
- int count = apps.size();
- for (int i = 0; i < count; i++) {
- final ResolveInfo info = apps.get(i);
- final ActivityInfo activityInfo = info.activityInfo;
- if (packageName.equals(activityInfo.packageName)) {
- matches.add(info);
- }
- }
- }
-
- return matches;
+ return apps != null ? apps : new ArrayList<ResolveInfo>();
}
/**
diff --git a/src/com/android/launcher2/AllAppsTabbed.java b/src/com/android/launcher2/AllAppsTabbed.java
new file mode 100644
index 0000000..7f6f63f
--- /dev/null
+++ b/src/com/android/launcher2/AllAppsTabbed.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher2;
+
+import com.android.launcher.R;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.View;
+import android.widget.TabHost;
+
+import java.util.ArrayList;
+
+/**
+ * Implements a tabbed version of AllApps2D.
+ */
+public class AllAppsTabbed extends TabHost implements AllAppsView {
+
+ private static final String TAG = "Launcher.AllAppsTabbed";
+
+ private AllAppsView mAllApps2D;
+
+ public AllAppsTabbed(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ try {
+ mAllApps2D = (AllAppsView)findViewById(R.id.all_apps_2d);
+ if (mAllApps2D == null) throw new Resources.NotFoundException();
+ } catch (Resources.NotFoundException e) {
+ Log.e(TAG, "Can't find necessary layout elements for AllAppsTabbed");
+ }
+ setup();
+
+ // This lets us share the same view between all tabs
+ TabContentFactory contentFactory = new TabContentFactory() {
+ public View createTabContent(String tag) {
+ return (View)mAllApps2D;
+ }
+ };
+
+ // TODO: Make these tabs show the appropriate content (they're no-ops for now)
+ addTab(newTabSpec("apps").setIndicator("All").setContent(contentFactory));
+ addTab(newTabSpec("apps").setIndicator("Apps").setContent(contentFactory));
+ addTab(newTabSpec("apps").setIndicator("Games").setContent(contentFactory));
+ addTab(newTabSpec("apps").setIndicator("Downloaded").setContent(contentFactory));
+
+ setCurrentTab(0);
+ setVisibility(GONE);
+ }
+
+ @Override
+ public void setLauncher(Launcher launcher) {
+ mAllApps2D.setLauncher(launcher);
+ }
+
+ @Override
+ public void setDragController(DragController dragger) {
+ mAllApps2D.setDragController(dragger);
+ }
+
+ @Override
+ public void zoom(float zoom, boolean animate) {
+ // NOTE: animate parameter is ignored for the TabHost itself
+ setVisibility((zoom == 0.0f) ? View.GONE : View.VISIBLE);
+ mAllApps2D.zoom(zoom, animate);
+ bringChildToFront((View)mAllApps2D);
+ getParent().bringChildToFront(this);
+ }
+
+ @Override
+ public boolean isVisible() {
+ return mAllApps2D.isVisible();
+ }
+
+ @Override
+ public boolean isAnimating() {
+ return (getAnimation() != null);
+ }
+
+ @Override
+ public void setApps(ArrayList<ApplicationInfo> list) {
+ mAllApps2D.setApps(list);
+ }
+
+ @Override
+ public void addApps(ArrayList<ApplicationInfo> list) {
+ mAllApps2D.addApps(list);
+ }
+
+ @Override
+ public void removeApps(ArrayList<ApplicationInfo> list) {
+ mAllApps2D.removeApps(list);
+ }
+
+ @Override
+ public void updateApps(ArrayList<ApplicationInfo> list) {
+ mAllApps2D.updateApps(list);
+ }
+
+ @Override
+ public void dumpState() {
+ mAllApps2D.dumpState();
+ }
+
+ @Override
+ public void surrender() {
+ mAllApps2D.surrender();
+ }
+
+}
diff --git a/src/com/android/launcher2/AllAppsView.java b/src/com/android/launcher2/AllAppsView.java
index 877c075..007ecf8 100644
--- a/src/com/android/launcher2/AllAppsView.java
+++ b/src/com/android/launcher2/AllAppsView.java
@@ -31,7 +31,7 @@
public boolean isVisible();
- public boolean isOpaque();
+ public boolean isAnimating();
public void setApps(ArrayList<ApplicationInfo> list);
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 7ca549e..16f8135 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -22,7 +22,11 @@
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
+import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Matrix;
+import android.graphics.Paint;
+import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
@@ -32,6 +36,7 @@
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
+import android.view.View.OnTouchListener;
import android.view.animation.Animation;
import android.view.animation.LayoutAnimationController;
@@ -40,6 +45,8 @@
public class CellLayout extends ViewGroup {
static final String TAG = "CellLayout";
+ // we make the dimmed bitmap smaller than the screen itself for memory + perf reasons
+ static final float DIMMED_BITMAP_SCALE = 0.25f;
private boolean mPortrait;
@@ -72,6 +79,18 @@
boolean[][] mOccupied;
+ private OnTouchListener mInterceptTouchListener;
+
+ // this is what the home screen fades to when it shrinks
+ // (ie in all apps and in home screen customize mode)
+ private Bitmap mDimmedBitmap;
+ private Canvas mDimmedBitmapCanvas;
+ private float mDimmedBitmapAlpha;
+ private boolean mDimmedBitmapDirty;
+ private final Paint mDimmedBitmapPaint = new Paint();
+ private final Rect mLayoutRect = new Rect();
+ private final Rect mDimmedBitmapRect = new Rect();
+
private final RectF mDragRect = new RectF();
// When dragging, used to indicate a vacant drop location
@@ -130,6 +149,8 @@
setAlwaysDrawnWithCacheEnabled(false);
mWallpaperManager = WallpaperManager.getInstance(getContext());
+
+ mDimmedBitmapPaint.setFilterBitmap(true);
}
@Override
@@ -147,6 +168,15 @@
(int)mDragRect.bottom);
mDragRectDrawable.draw(canvas);
}
+ if (mDimmedBitmap != null && mDimmedBitmapAlpha > 0.0f) {
+ if (mDimmedBitmapDirty) {
+ updateDimmedBitmap();
+ mDimmedBitmapDirty = false;
+ }
+ mDimmedBitmapPaint.setAlpha((int) (mDimmedBitmapAlpha * 255));
+
+ canvas.drawBitmap(mDimmedBitmap, mDimmedBitmapRect, mLayoutRect, mDimmedBitmapPaint);
+ }
}
@Override
@@ -161,6 +191,10 @@
}
}
+ public void setOnInterceptTouchListener(View.OnTouchListener listener) {
+ mInterceptTouchListener = listener;
+ }
+
int getCountX() {
return mPortrait ? mShortAxisCells : mLongAxisCells;
}
@@ -183,13 +217,26 @@
child.setId(childId);
+ // We might be in the middle or end of shrinking/fading to a dimmed view
+ // Make sure this view's alpha is set the same as all the rest of the views
+ child.setAlpha(1.0f - mDimmedBitmapAlpha);
+
addView(child, index, lp);
+
+ // next time we draw the dimmed bitmap we need to update it
+ mDimmedBitmapDirty = true;
return true;
}
return false;
}
@Override
+ public void removeView(View view) {
+ super.removeView(view);
+ mDimmedBitmapDirty = true;
+ }
+
+ @Override
public void requestChildFocus(View child, View focused) {
super.requestChildFocus(child, focused);
if (child != null) {
@@ -267,6 +314,9 @@
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
+ if (mInterceptTouchListener != null && mInterceptTouchListener.onTouch(this, ev)) {
+ return true;
+ }
final int action = ev.getAction();
final CellInfo cellInfo = mCellInfo;
@@ -654,6 +704,13 @@
}
@Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ super.onSizeChanged(w, h, oldw, oldh);
+ mLayoutRect.set(0, 0, w, h);
+ mDimmedBitmapRect.set(0, 0, (int) (DIMMED_BITMAP_SCALE * w), (int) (DIMMED_BITMAP_SCALE * h));
+ }
+
+ @Override
protected void setChildrenDrawingCacheEnabled(boolean enabled) {
final int count = getChildCount();
for (int i = 0; i < count; i++) {
@@ -669,6 +726,55 @@
super.setChildrenDrawnWithCacheEnabled(enabled);
}
+ public float getDimmedBitmapAlpha() {
+ return mDimmedBitmapAlpha;
+ }
+
+ public void setDimmedBitmapAlpha(float alpha) {
+ // If we're dimming the screen after it was not dimmed, refresh
+ // to allow for updated widgets. We don't continually refresh it
+ // after this point, however, as an optimization
+ if (mDimmedBitmapAlpha == 0.0f && alpha > 0.0f) {
+ updateDimmedBitmap();
+ }
+ mDimmedBitmapAlpha = alpha;
+ setChildrenAlpha(1.0f - mDimmedBitmapAlpha);
+ }
+
+ private void setChildrenAlpha(float alpha) {
+ for (int i = 0; i < getChildCount(); i++) {
+ getChildAt(i).setAlpha(alpha);
+ }
+ }
+
+ public void updateDimmedBitmap() {
+ if (mDimmedBitmap == null) {
+ mDimmedBitmap = Bitmap.createBitmap((int) (getWidth() * DIMMED_BITMAP_SCALE),
+ (int) (getHeight() * DIMMED_BITMAP_SCALE), Bitmap.Config.ARGB_8888);
+ mDimmedBitmapCanvas = new Canvas(mDimmedBitmap);
+ mDimmedBitmapCanvas.scale(DIMMED_BITMAP_SCALE, DIMMED_BITMAP_SCALE);
+ }
+ // clear the canvas
+ mDimmedBitmapCanvas.drawColor(0x00000000, PorterDuff.Mode.CLEAR);
+
+ // draw the screen into the bitmap
+ // just for drawing to the bitmap, make all the items on the screen opaque
+ setChildrenAlpha(1.0f);
+ dispatchDraw(mDimmedBitmapCanvas);
+ setChildrenAlpha(1.0f - mDimmedBitmapAlpha);
+
+ // make the bitmap 'dimmed' ie colored regions are dark grey,
+ // the rest is light grey
+ // We draw grey to the whole bitmap, but filter where we draw based on
+ // what regions are transparent or not (SRC_OUT), causing the intended effect
+
+ // First, draw light grey everywhere in the background (currently transparent) regions
+ // This will leave the regions with the widgets as mostly transparent
+ mDimmedBitmapCanvas.drawColor(0xCCCCCCCC, PorterDuff.Mode.SRC_OUT);
+ // Now, fill the the remaining transparent regions with dark grey
+ mDimmedBitmapCanvas.drawColor(0xCC333333, PorterDuff.Mode.SRC_OUT);
+ }
+
private boolean isVacant(int originX, int originY, int spanX, int spanY) {
for (int i = 0; i < spanY; i++) {
if (!isRowEmpty(originY + i, originX, originX + spanX - 1, mOccupied)) {
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index dd93cbb..be60e98 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -34,8 +34,8 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
-import android.content.IntentFilter;
import android.content.Intent.ShortcutIconResource;
+import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
@@ -68,10 +68,11 @@
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
+import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
-import android.view.View.OnLongClickListener;
import android.view.animation.Animation;
+import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
@@ -217,7 +218,6 @@
private Drawable[] mHotseatIcons = null;
private CharSequence[] mHotseatLabels = null;
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -620,6 +620,8 @@
// Some launcher layouts don't have a previous and next view
if (mPreviousView != null) {
dismissPreview(mPreviousView);
+ }
+ if (mNextView != null) {
dismissPreview(mNextView);
}
mDragController.cancelDrag();
@@ -760,11 +762,6 @@
final Workspace workspace = mWorkspace;
workspace.setHapticFeedbackEnabled(false);
- // We only intercept touch events to dismiss the home customization drawer; if it doesn't
- // exist, then no need to do this
- if (mHomeCustomizationDrawer != null)
- workspace.setOnInterceptTouchListener(this);
-
DeleteZone deleteZone = (DeleteZone) dragLayer.findViewById(R.id.delete_zone);
mDeleteZone = deleteZone;
@@ -1027,10 +1024,14 @@
boolean alreadyOnHome = ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
!= Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
boolean allAppsVisible = isAllAppsVisible();
+
+ // TODO: Figure out the right thing to do in XLarge mode here
if (!mWorkspace.isDefaultScreenShowing()) {
mWorkspace.moveToDefaultScreen(alreadyOnHome && !allAppsVisible);
}
closeAllApps(alreadyOnHome && allAppsVisible);
+ hideCustomizationDrawer();
+ mWorkspace.unshrink();
final View v = getWindow().peekDecorView();
if (v != null && v.getWindowToken() != null) {
@@ -1122,8 +1123,13 @@
getContentResolver().unregisterContentObserver(mWidgetObserver);
- dismissPreview(mPreviousView);
- dismissPreview(mNextView);
+ // Some launcher layouts don't have a previous and next view
+ if (mPreviousView != null) {
+ dismissPreview(mPreviousView);
+ }
+ if (mNextView != null) {
+ dismissPreview(mNextView);
+ }
unregisterReceiver(mCloseSystemDialogsReceiver);
}
@@ -1194,12 +1200,12 @@
// If all apps is animating, don't show the menu, because we don't know
// which one to show.
- if (mAllAppsGrid.isVisible() && !mAllAppsGrid.isOpaque()) {
+ if (mAllAppsGrid.isAnimating()) {
return false;
}
// Only show the add and wallpaper options when we're not in all apps.
- boolean visible = !mAllAppsGrid.isOpaque();
+ boolean visible = !mAllAppsGrid.isVisible();
menu.setGroupVisible(MENU_GROUP_ADD, visible);
menu.setGroupVisible(MENU_GROUP_WALLPAPER, visible);
@@ -1256,7 +1262,15 @@
private void addItems() {
closeAllApps(true);
- showAddDialog(mMenuAddInfo);
+ if (LauncherApplication.isScreenXLarge()) {
+ // Animate the widget chooser up from the bottom of the screen
+ if (!isCustomizationDrawerVisible()) {
+ showCustomizationDrawer();
+ mWorkspace.shrink();
+ }
+ } else {
+ showAddDialog(mMenuAddInfo);
+ }
}
void addAppWidgetFromDrop(ComponentName appWidgetProvider, CellLayout.CellInfo cellInfo) {
@@ -1487,6 +1501,9 @@
public void onBackPressed() {
if (isAllAppsVisible()) {
closeAllApps(true);
+ } else if (isCustomizationDrawerVisible()) {
+ hideCustomizationDrawer();
+ mWorkspace.unshrink();
} else {
closeFolder();
}
@@ -1560,26 +1577,11 @@
}
}
- private final class SlideDownFinishedListener implements Animation.AnimationListener {
- TabHost mHomeCustomizationDrawer;
- SlideDownFinishedListener(TabHost homeCustomizationDrawer) {
- mHomeCustomizationDrawer = homeCustomizationDrawer;
- }
- public void onAnimationEnd(Animation animation) {
- mHomeCustomizationDrawer.setVisibility(View.GONE);
- }
- public void onAnimationRepeat(Animation animation) {}
- public void onAnimationStart(Animation animation) {}
- }
-
public boolean onTouch(View v, MotionEvent event) {
- // this is being forwarded from mWorkspace;
+ // this is an intercepted event being forwarded from mWorkspace;
// clicking anywhere on the workspace causes the drawer to slide down
- if (mHomeCustomizationDrawer != null && mHomeCustomizationDrawer.getVisibility() == View.VISIBLE) {
- Animation slideDownAnimation = AnimationUtils.loadAnimation(this, R.anim.home_customization_drawer_slide_down);
- slideDownAnimation.setAnimationListener(new SlideDownFinishedListener(mHomeCustomizationDrawer));
- mHomeCustomizationDrawer.startAnimation(slideDownAnimation);
- }
+ hideCustomizationDrawer();
+ mWorkspace.unshrink();
return false;
}
@@ -1590,16 +1592,7 @@
* @param v The view that was clicked.
*/
public void onClickAddButton(View v) {
-
- // Animate the widget chooser up from the bottom of the screen
- if (mHomeCustomizationDrawer != null && mHomeCustomizationDrawer.getVisibility() == View.GONE) {
- mHomeCustomizationDrawer.setVisibility(View.VISIBLE);
- mHomeCustomizationDrawer.startAnimation(AnimationUtils.loadAnimation(this, R.anim.home_customization_drawer_slide_up));
- }
- }
-
- public void onClickAllAppsButton(View w) {
- showAllApps(true);
+ addItems();
}
void startActivitySafely(Intent intent, Object tag) {
@@ -2036,7 +2029,16 @@
}
void showAllApps(boolean animated) {
- mAllAppsGrid.zoom(1.0f, animated);
+ hideCustomizationDrawer();
+
+ if (LauncherApplication.isScreenXLarge() && animated) {
+ // Not really a zoom -- this just makes the view visible
+ mAllAppsGrid.zoom(1.0f, false);
+ Animation anim = AnimationUtils.loadAnimation(this, R.anim.all_apps_zoom_in);
+ ((View) mAllAppsGrid).startAnimation(anim);
+ } else {
+ mAllAppsGrid.zoom(1.0f, animated);
+ }
((View) mAllAppsGrid).setFocusable(true);
((View) mAllAppsGrid).requestFocus();
@@ -2087,7 +2089,19 @@
void closeAllApps(boolean animated) {
if (mAllAppsGrid.isVisible()) {
mWorkspace.setVisibility(View.VISIBLE);
- mAllAppsGrid.zoom(0.0f, animated);
+ if (LauncherApplication.isScreenXLarge() && animated) {
+ Animation anim = AnimationUtils.loadAnimation(this, R.anim.all_apps_zoom_out);
+ anim.setAnimationListener(new AnimationListener() {
+ public void onAnimationStart(Animation animation) {}
+ public void onAnimationRepeat(Animation animation) {}
+ public void onAnimationEnd(Animation animation) {
+ mAllAppsGrid.zoom(0.0f, false);
+ }
+ });
+ ((View)mAllAppsGrid).startAnimation(anim);
+ } else {
+ mAllAppsGrid.zoom(0.0f, animated);
+ }
((View)mAllAppsGrid).setFocusable(false);
mWorkspace.getChildAt(mWorkspace.getCurrentScreen()).requestFocus();
}
@@ -2101,6 +2115,33 @@
// TODO
}
+ private boolean isCustomizationDrawerVisible() {
+ return mHomeCustomizationDrawer != null && mHomeCustomizationDrawer.getVisibility() == View.VISIBLE;
+ }
+
+ private void showCustomizationDrawer() {
+ if (isAllAppsVisible()) {
+ // TODO: Make a smoother transition here
+ closeAllApps(false);
+ }
+ mHomeCustomizationDrawer.setVisibility(View.VISIBLE);
+ mHomeCustomizationDrawer.startAnimation(AnimationUtils.loadAnimation(this, R.anim.home_customization_drawer_slide_up));
+ }
+
+ void hideCustomizationDrawer() {
+ if (isCustomizationDrawerVisible()) {
+ Animation slideDownAnimation = AnimationUtils.loadAnimation(this, R.anim.home_customization_drawer_slide_down);
+ slideDownAnimation.setAnimationListener(new Animation.AnimationListener() {
+ public void onAnimationEnd(Animation animation) {
+ mHomeCustomizationDrawer.setVisibility(View.GONE);
+ }
+ public void onAnimationRepeat(Animation animation) {}
+ public void onAnimationStart(Animation animation) {}
+ });
+ mHomeCustomizationDrawer.startAnimation(slideDownAnimation);
+ }
+ }
+
/**
* Displays the shortcut creation dialog and launches, if necessary, the
* appropriate activity.
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 79fb4a9..7fbdd1e 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -17,7 +17,12 @@
package com.android.launcher2;
import com.android.launcher.R;
+import com.android.launcher2.CellLayout.LayoutParams;
+import android.animation.Animatable;
+import android.animation.PropertyAnimator;
+import android.animation.Sequencer;
+import android.animation.Animatable.AnimatableListener;
import android.app.WallpaperManager;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
@@ -41,12 +46,14 @@
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
+import android.view.ViewDebug;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.animation.Animation;
-import android.view.animation.Animation.AnimationListener;
+import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.view.animation.RotateAnimation;
+import android.view.animation.Animation.AnimationListener;
import android.widget.Scroller;
import android.widget.TextView;
import android.widget.Toast;
@@ -59,10 +66,14 @@
* Each screen contains a number of icons, folders or widgets the user can
* interact with. A workspace is meant to be used with a fixed width only.
*/
-public class Workspace extends ViewGroup implements DropTarget, DragSource, DragScroller {
+public class Workspace extends ViewGroup
+ implements DropTarget, DragSource, DragScroller, View.OnTouchListener {
@SuppressWarnings({"UnusedDeclaration"})
private static final String TAG = "Launcher.Workspace";
private static final int INVALID_SCREEN = -1;
+ // This is how much the workspace shrinks when we enter all apps or
+ // customization mode
+ private static final float SHRINK_FACTOR = 0.16f;
/**
* The velocity at which a fling gesture will cause us to snap to the next
@@ -104,7 +115,6 @@
private int mTouchState = TOUCH_STATE_REST;
- private OnTouchListener mInterceptTouchListener;
private OnLongClickListener mLongClickListener;
private Launcher mLauncher;
@@ -144,6 +154,11 @@
private Paint mDropIndicatorPaint;
+ // State variable that indicated whether the screens are small (ie when you're
+ // in all apps or customize mode)
+ private boolean mIsSmall;
+ private AnimatableListener mUnshrinkAnimationListener;
+
private static class WorkspaceOvershootInterpolator implements Interpolator {
private static final float DEFAULT_TENSION = 1.3f;
private float mTension;
@@ -218,6 +233,14 @@
final ViewConfiguration configuration = ViewConfiguration.get(getContext());
mTouchSlop = configuration.getScaledTouchSlop();
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
+ mUnshrinkAnimationListener = new AnimatableListener() {
+ public void onAnimationStart(Animatable animation) {}
+ public void onAnimationEnd(Animatable animation) {
+ mIsSmall = false;
+ }
+ public void onAnimationCancel(Animatable animation) {}
+ public void onAnimationRepeat(Animatable animation) {}
+ };
}
@Override
@@ -278,10 +301,10 @@
}
ArrayList<Folder> getOpenFolders() {
- final int screens = getChildCount();
- ArrayList<Folder> folders = new ArrayList<Folder>(screens);
+ final int screenCount = getChildCount();
+ ArrayList<Folder> folders = new ArrayList<Folder>(screenCount);
- for (int screen = 0; screen < screens; screen++) {
+ for (int screen = 0; screen < screenCount; screen++) {
CellLayout currentScreen = (CellLayout) getChildAt(screen);
int count = currentScreen.getChildCount();
for (int i = 0; i < count; i++) {
@@ -425,7 +448,7 @@
}
public void refreshWorkspaceChildren() {
- final int count = getChildCount();
+ final int screenCount = getChildCount();
View child;
CellLayout.LayoutParams lp;
@@ -436,12 +459,12 @@
clearVacantCache();
- for (int i = 0; i < count; i++) {
+ for (int i = 0; i < screenCount; i++) {
final CellLayout layout = (CellLayout) getChildAt(i);
- int numChildren = layout.getChildCount();
+ final int count = layout.getChildCount();
// save reference to all current children
- for (int j = 0; j < numChildren; j++) {
+ for (int j = 0; j < count; j++) {
child = layout.getChildAt(j);
lp = (CellLayout.LayoutParams) child.getLayoutParams();
@@ -521,8 +544,13 @@
}
}
- public void setOnInterceptTouchListener(View.OnTouchListener listener) {
- mInterceptTouchListener = listener;
+ public boolean onTouch(View v, MotionEvent event) {
+ // this is an intercepted event being forwarded from a cell layout
+ if (mIsSmall) {
+ unshrink((CellLayout)v);
+ mLauncher.hideCustomizationDrawer();
+ }
+ return false;
}
/**
@@ -533,8 +561,8 @@
@Override
public void setOnLongClickListener(OnLongClickListener l) {
mLongClickListener = l;
- final int count = getChildCount();
- for (int i = 0; i < count; i++) {
+ final int screenCount = getChildCount();
+ for (int i = 0; i < screenCount; i++) {
getChildAt(i).setOnLongClickListener(l);
}
}
@@ -602,8 +630,17 @@
// the drawing dispatch by drawing only what we know needs to be drawn.
boolean fastDraw = mTouchState != TOUCH_STATE_SCROLLING && mNextScreen == INVALID_SCREEN;
- // If we are not scrolling or flinging, draw only the current screen
- if (fastDraw) {
+
+ // if the screens are all small, we need to draw all the screens since
+ // they're most likely all visible
+ if (mIsSmall) {
+ final int screenCount = getChildCount();
+ for (int i = 0; i < screenCount; i++) {
+ CellLayout cl = (CellLayout)getChildAt(i);
+ drawChild(canvas, cl, getDrawingTime());
+ }
+ } else if (fastDraw) {
+ // If we are not scrolling or flinging, draw only the current screen
drawChild(canvas, getChildAt(mCurrentScreen), getDrawingTime());
} else {
final long drawingTime = getDrawingTime();
@@ -645,8 +682,8 @@
}
// The children are given the same width and height as the workspace
- final int count = getChildCount();
- for (int i = 0; i < count; i++) {
+ final int screenCount = getChildCount();
+ for (int i = 0; i < screenCount; i++) {
getChildAt(i).measure(widthMeasureSpec, heightMeasureSpec);
}
@@ -655,21 +692,26 @@
scrollTo(mCurrentScreen * width, 0);
setHorizontalScrollBarEnabled(true);
updateWallpaperOffset(width * (getChildCount() - 1));
- mFirstLayout = false;
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- int childLeft = 0;
+ final int screenCount = getChildCount();
+ if (mFirstLayout) {
+ final int width = getWidth();
+ for (int i = 0; i < screenCount; i++) {
+ getChildAt(i).setX(i*width);
+ }
+ mFirstLayout = false;
+ }
- final int count = getChildCount();
- for (int i = 0; i < count; i++) {
+ for (int i = 0; i < screenCount; i++) {
final View child = getChildAt(i);
if (child.getVisibility() != View.GONE) {
- final int childWidth = child.getMeasuredWidth();
- child.layout(childLeft, 0, childLeft + childWidth, child.getMeasuredHeight());
- childLeft += childWidth;
+ final int childX = child.getX();
+ child.layout(
+ childX, 0, childX + child.getMeasuredWidth(), child.getMeasuredHeight());
}
}
@@ -760,9 +802,6 @@
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
- if (mInterceptTouchListener != null && mInterceptTouchListener.onTouch(this, ev)) {
- return true;
- }
final boolean workspaceLocked = mLauncher.isWorkspaceLocked();
final boolean allAppsVisible = mLauncher.isAllAppsVisible();
if (workspaceLocked || allAppsVisible) {
@@ -946,10 +985,10 @@
toScreen = temp;
}
- final int count = getChildCount();
+ final int screenCount = getChildCount();
fromScreen = Math.max(fromScreen, 0);
- toScreen = Math.min(toScreen, count - 1);
+ toScreen = Math.min(toScreen, screenCount - 1);
for (int i = fromScreen; i <= toScreen; i++) {
final CellLayout layout = (CellLayout) getChildAt(i);
@@ -959,8 +998,8 @@
}
void clearChildrenCache() {
- final int count = getChildCount();
- for (int i = 0; i < count; i++) {
+ final int screenCount = getChildCount();
+ for (int i = 0; i < screenCount; i++) {
final CellLayout layout = (CellLayout) getChildAt(i);
layout.setChildrenDrawnWithCacheEnabled(false);
}
@@ -1078,6 +1117,87 @@
return true;
}
+ // we use this to shrink the workspace for the all apps view and the customize view
+ void shrink() {
+ mIsSmall = true;
+ final int screenWidth = getWidth();
+
+ final int scaledWorkspacePageWidth = (int)(SHRINK_FACTOR*screenWidth);
+ final float scaledSpacing = getResources().getDimension(R.dimen.smallScreenSpacing);
+
+ final int screenCount = getChildCount();
+ float totalWidth = screenCount * scaledWorkspacePageWidth + (screenCount - 1) * scaledSpacing;
+
+ // We animate all the screens to the centered position in workspace
+ // At the same time, the screens become greyed/dimmed
+
+ // newX is initialized to the left-most position of the centered screens
+ float newX = (mCurrentScreen + 1) * screenWidth - screenWidth / 2 - totalWidth / 2;
+ Sequencer s = new Sequencer();
+ for (int i = 0; i < screenCount; i++) {
+ CellLayout cl = (CellLayout) getChildAt(i);
+ PropertyAnimator translate = new PropertyAnimator(
+ 500, cl, "x", cl.getX(), (int) newX);
+ PropertyAnimator scaleX = new PropertyAnimator(
+ 500, cl, "scaleX", cl.getScaleX(), SHRINK_FACTOR);
+ PropertyAnimator scaleY = new PropertyAnimator(
+ 500, cl, "scaleY", cl.getScaleY(), SHRINK_FACTOR);
+ PropertyAnimator alpha = new PropertyAnimator(
+ 500, cl, "dimmedBitmapAlpha", cl.getDimmedBitmapAlpha(), 1.0f);
+ Sequencer.Builder b = s.play(translate);
+ b.with(scaleX);
+ b.with(scaleY);
+ b.with(alpha);
+ // increment newX for the next screen
+ newX += scaledWorkspacePageWidth + scaledSpacing;
+ cl.setOnInterceptTouchListener(this);
+ }
+ setChildrenDrawnWithCacheEnabled(true);
+ s.start();
+ }
+
+ // We call this when we trigger an unshrink by clicking on the CellLayout cl
+ private void unshrink(CellLayout clThatWasClicked) {
+ int newCurrentScreen = mCurrentScreen;
+ final int screenCount = getChildCount();
+ for (int i = 0; i < screenCount; i++) {
+ if (getChildAt(i) == clThatWasClicked) {
+ newCurrentScreen = i;
+ }
+ }
+ final int delta = (newCurrentScreen - mCurrentScreen)*getWidth();
+ for (int i = 0; i < screenCount; i++) {
+ CellLayout cl = (CellLayout) getChildAt(i);
+ cl.setX(cl.getX() + delta);
+ }
+ mScrollX = newCurrentScreen * getWidth();
+
+ unshrink();
+ setCurrentScreen(newCurrentScreen);
+ }
+
+ public void unshrink() {
+ final int screenWidth = getWidth();
+ Sequencer s = new Sequencer();
+ final int screenCount = getChildCount();
+ for (int i = 0; i < screenCount; i++) {
+ CellLayout cl = (CellLayout)getChildAt(i);
+ int x = screenWidth * i;
+
+ PropertyAnimator translate = new PropertyAnimator(500, cl, "x", cl.getX(), x);
+ PropertyAnimator scaleX = new PropertyAnimator(500, cl, "scaleX", cl.getScaleX(), 1.0f);
+ PropertyAnimator scaleY = new PropertyAnimator(500, cl, "scaleY", cl.getScaleY(), 1.0f);
+ PropertyAnimator alpha = new PropertyAnimator(
+ 500, cl, "dimmedBitmapAlpha", cl.getDimmedBitmapAlpha(), 0.0f);
+ Sequencer.Builder b = s.play(translate);
+ b.with(scaleX);
+ b.with(scaleY);
+ b.with(alpha);
+ }
+ s.addListener(mUnshrinkAnimationListener);
+ s.start();
+ }
+
void snapToScreen(int whichScreen) {
snapToScreen(whichScreen, 0, false);
}
@@ -1493,8 +1613,8 @@
int result = -1;
if (v != null) {
ViewParent vp = v.getParent();
- int count = getChildCount();
- for (int i = 0; i < count; i++) {
+ final int screenCount = getChildCount();
+ for (int i = 0; i < screenCount; i++) {
if (vp == getChildAt(i)) {
return i;
}
@@ -1504,7 +1624,7 @@
}
public Folder getFolderForTag(Object tag) {
- int screenCount = getChildCount();
+ final int screenCount = getChildCount();
for (int screen = 0; screen < screenCount; screen++) {
CellLayout currentScreen = ((CellLayout) getChildAt(screen));
int count = currentScreen.getChildCount();
@@ -1553,7 +1673,7 @@
}
void removeItems(final ArrayList<ApplicationInfo> apps) {
- final int count = getChildCount();
+ final int screenCount = getChildCount();
final PackageManager manager = getContext().getPackageManager();
final AppWidgetManager widgets = AppWidgetManager.getInstance(getContext());
@@ -1563,7 +1683,7 @@
packageNames.add(apps.get(i).componentName.getPackageName());
}
- for (int i = 0; i < count; i++) {
+ for (int i = 0; i < screenCount; i++) {
final CellLayout layout = (CellLayout) getChildAt(i);
// Avoid ANRs by treating each screen separately
@@ -1674,8 +1794,8 @@
void updateShortcuts(ArrayList<ApplicationInfo> apps) {
final PackageManager pm = mLauncher.getPackageManager();
- final int count = getChildCount();
- for (int i = 0; i < count; i++) {
+ final int screenCount = getChildCount();
+ for (int i = 0; i < screenCount; i++) {
final CellLayout layout = (CellLayout) getChildAt(i);
int childCount = layout.getChildCount();
for (int j = 0; j < childCount; j++) {