Merge branch 'master' into honeycomb-release
diff --git a/res/drawable-mdpi/tab_unselected_holo.9.png b/res/drawable-mdpi/tab_unselected_holo.9.png
new file mode 100644
index 0000000..848f3f1
--- /dev/null
+++ b/res/drawable-mdpi/tab_unselected_holo.9.png
Binary files differ
diff --git a/res/drawable-xlarge/all_apps_bg_gradient.9.png b/res/drawable-xlarge/all_apps_bg_gradient.9.png
new file mode 100644
index 0000000..8d88a7e
--- /dev/null
+++ b/res/drawable-xlarge/all_apps_bg_gradient.9.png
Binary files differ
diff --git a/res/drawable-xlarge/customize_bg_gradient.png b/res/drawable-xlarge/customize_bg_gradient.png
new file mode 100644
index 0000000..fb3ec90
--- /dev/null
+++ b/res/drawable-xlarge/customize_bg_gradient.png
Binary files differ
diff --git a/res/layout-xlarge-land/all_apps_tabbed.xml b/res/layout-xlarge-land/all_apps_tabbed.xml
index fd9d9cb..89a3104 100644
--- a/res/layout-xlarge-land/all_apps_tabbed.xml
+++ b/res/layout-xlarge-land/all_apps_tabbed.xml
@@ -22,9 +22,10 @@
android:layout_height="match_parent">
<TabWidget
android:id="@android:id/tabs"
- android:layout_width="wrap_content"
+ android:layout_width="952dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
+ android:background="@drawable/tab_unselected_holo"
android:tabStripEnabled="false" />
<FrameLayout
android:id="@android:id/tabcontent"
@@ -38,7 +39,7 @@
launcher:cellCountY="5"
launcher:pageLayoutWidthGap="36dp"
launcher:pageLayoutHeightGap="6dp"
- launcher:pageLayoutPaddingTop="0dp"
+ launcher:pageLayoutPaddingTop="15dp"
launcher:pageLayoutPaddingBottom="15dp"
launcher:pageLayoutPaddingLeft="40dp"
launcher:pageLayoutPaddingRight="40dp">
diff --git a/res/layout-xlarge-land/customization_drawer.xml b/res/layout-xlarge-land/customization_drawer.xml
index 8c60e68..9115259 100644
--- a/res/layout-xlarge-land/customization_drawer.xml
+++ b/res/layout-xlarge-land/customization_drawer.xml
@@ -20,9 +20,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
launcher:widgetCellCountX="16"
- launcher:cellCountX="7"
- launcher:cellCountY="4"
- launcher:pageLayoutPaddingTop="10dp"
+ launcher:cellCountX="8"
+ launcher:cellCountY="3"
+ launcher:pageLayoutWidthGap="32dp"
+ launcher:pageLayoutHeightGap="12dp"
+ launcher:pageLayoutPaddingTop="40dp"
launcher:pageLayoutPaddingBottom="25dp"
launcher:pageLayoutPaddingLeft="20dp"
launcher:pageLayoutPaddingRight="20dp" />
\ No newline at end of file
diff --git a/res/layout-xlarge-land/launcher.xml b/res/layout-xlarge-land/launcher.xml
index f42d72b..e5ba393 100644
--- a/res/layout-xlarge-land/launcher.xml
+++ b/res/layout-xlarge-land/launcher.xml
@@ -26,7 +26,7 @@
layout="@layout/all_apps_tabbed"
android:id="@+id/all_apps_view"
android:layout_width="match_parent"
- android:layout_height="600dip"
+ android:layout_height="600dp"
android:layout_gravity="top"/>
<!-- The workspace contains 5 screens of cells -->
@@ -38,7 +38,7 @@
launcher:defaultScreen="2"
launcher:cellCountX="8"
launcher:cellCountY="7"
- launcher:pageSpacing="32dip">
+ launcher:pageSpacing="32dp">
<include android:id="@+id/cell1" layout="@layout/workspace_screen" />
<include android:id="@+id/cell2" layout="@layout/workspace_screen" />
@@ -86,7 +86,7 @@
android:layout_toLeftOf="@id/configure_button"
android:layout_marginLeft="@dimen/toolbar_button_spacing"
android:layout_marginRight="@dimen/toolbar_button_spacing"
- android:textSize="18dip"
+ android:textSize="18dp"
android:onClick="onClickAllAppsButton"
android:focusable="true"
@@ -131,20 +131,19 @@
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
- android:layout_height="500dip"
+ android:layout_height="460dp"
android:layout_gravity="bottom">
<LinearLayout
android:orientation="vertical"
- android:background="#40000000"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TabWidget
android:id="@android:id/tabs"
- android:layout_width="wrap_content"
+ android:layout_width="952dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
- android:tabStripEnabled="false"
- android:paddingBottom="10dp" />
+ android:background="@drawable/tab_unselected_holo"
+ android:tabStripEnabled="false" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
diff --git a/res/layout-xlarge-port/all_apps_tabbed.xml b/res/layout-xlarge-port/all_apps_tabbed.xml
index d61c979..65e3729 100644
--- a/res/layout-xlarge-port/all_apps_tabbed.xml
+++ b/res/layout-xlarge-port/all_apps_tabbed.xml
@@ -15,17 +15,17 @@
-->
<com.android.launcher2.AllAppsTabbed
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
- android:paddingTop="?android:attr/actionBarSize">
+ xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TabWidget
android:id="@android:id/tabs"
- android:layout_width="wrap_content"
+ android:layout_width="700dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
+ android:background="@drawable/tab_unselected_holo"
android:tabStripEnabled="false" />
<FrameLayout
android:id="@android:id/tabcontent"
@@ -39,7 +39,7 @@
launcher:cellCountY="7"
launcher:pageLayoutWidthGap="36dp"
launcher:pageLayoutHeightGap="36dp"
- launcher:pageLayoutPaddingTop="0dp"
+ launcher:pageLayoutPaddingTop="25dp"
launcher:pageLayoutPaddingBottom="10dp"
launcher:pageLayoutPaddingLeft="20dp"
launcher:pageLayoutPaddingRight="20dp">
diff --git a/res/layout-xlarge-port/customization_drawer.xml b/res/layout-xlarge-port/customization_drawer.xml
index d3ca457..28127ea 100644
--- a/res/layout-xlarge-port/customization_drawer.xml
+++ b/res/layout-xlarge-port/customization_drawer.xml
@@ -21,10 +21,10 @@
android:layout_height="match_parent"
launcher:widgetCellCountX="10"
launcher:cellCountX="5"
- launcher:cellCountY="5"
+ launcher:cellCountY="3"
launcher:pageLayoutWidthGap="36dp"
- launcher:pageLayoutHeightGap="36dp"
- launcher:pageLayoutPaddingTop="25dp"
+ launcher:pageLayoutHeightGap="12dp"
+ launcher:pageLayoutPaddingTop="40dp"
launcher:pageLayoutPaddingBottom="25dp"
launcher:pageLayoutPaddingLeft="20dp"
launcher:pageLayoutPaddingRight="20dp" />
diff --git a/res/layout-xlarge-port/launcher.xml b/res/layout-xlarge-port/launcher.xml
index 20debca..13b69fe 100644
--- a/res/layout-xlarge-port/launcher.xml
+++ b/res/layout-xlarge-port/launcher.xml
@@ -26,7 +26,7 @@
layout="@layout/all_apps_tabbed"
android:id="@+id/all_apps_view"
android:layout_width="match_parent"
- android:layout_height="1040dip"
+ android:layout_height="1040dp"
android:layout_gravity="top"/>
<!-- The workspace contains 5 screens of cells -->
@@ -38,7 +38,7 @@
launcher:defaultScreen="2"
launcher:cellCountX="8"
launcher:cellCountY="7"
- launcher:pageSpacing="64dip">
+ launcher:pageSpacing="64dp">
<include android:id="@+id/cell1" layout="@layout/workspace_screen" />
<include android:id="@+id/cell2" layout="@layout/workspace_screen" />
@@ -86,7 +86,7 @@
android:layout_toLeftOf="@id/configure_button"
android:layout_marginLeft="@dimen/toolbar_button_spacing"
android:layout_marginRight="@dimen/toolbar_button_spacing"
- android:textSize="18dip"
+ android:textSize="18dp"
android:onClick="onClickAllAppsButton"
android:focusable="true"
@@ -131,20 +131,19 @@
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
- android:layout_height="800dip"
+ android:layout_height="800dp"
android:layout_gravity="bottom">
<LinearLayout
android:orientation="vertical"
- android:background="#40000000"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TabWidget
android:id="@android:id/tabs"
- android:layout_width="wrap_content"
+ android:layout_width="700dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
- android:tabStripEnabled="false"
- android:paddingBottom="10dp" />
+ android:background="@drawable/tab_unselected_holo"
+ android:tabStripEnabled="false" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
diff --git a/res/layout-xlarge/all_apps_paged_view_application.xml b/res/layout-xlarge/all_apps_paged_view_application.xml
index 48b5712..7458222 100644
--- a/res/layout-xlarge/all_apps_paged_view_application.xml
+++ b/res/layout-xlarge/all_apps_paged_view_application.xml
@@ -27,5 +27,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
+ android:singleLine="false"
+ android:maxLines="1"
style="@style/WorkspaceIcon.Portrait" />
diff --git a/res/layout-xlarge/customize_paged_view_item.xml b/res/layout-xlarge/customize_paged_view_item.xml
index e427345..bbc04d7 100644
--- a/res/layout-xlarge/customize_paged_view_item.xml
+++ b/res/layout-xlarge/customize_paged_view_item.xml
@@ -26,15 +26,7 @@
android:id="@+id/customize_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:gravity="center_horizontal"
- android:paddingTop="2dip"
+ android:singleLine="false"
+ android:maxLines="1"
- android:textColor="#FFFFFFFF"
- android:textSize="14sp"
- android:shadowColor="#FF000000"
- android:shadowDx="0.0"
- android:shadowDy="1.0"
- android:shadowRadius="1.0"
-
- android:maxLines="2"
- android:fadingEdge="horizontal" />
+ style="@style/WorkspaceIcon.Landscape" />
diff --git a/res/layout-xlarge/customize_paged_view_widget.xml b/res/layout-xlarge/customize_paged_view_widget.xml
index cfc0ca0..fab2a9b 100644
--- a/res/layout-xlarge/customize_paged_view_widget.xml
+++ b/res/layout-xlarge/customize_paged_view_widget.xml
@@ -18,7 +18,7 @@
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
android:layout_width="wrap_content"
- android:layout_height="425dp"
+ android:layout_height="365dp"
android:paddingLeft="12.5dp"
android:paddingRight="12.5dp"
android:paddingBottom="50dp"
diff --git a/res/values-xlarge/dimens.xml b/res/values-xlarge/dimens.xml
index aa602be..742b59a 100644
--- a/res/values-xlarge/dimens.xml
+++ b/res/values-xlarge/dimens.xml
@@ -39,7 +39,7 @@
<!-- Vertical spacing between edge of screen and mini cell layouts when they
are minimized to the top when the customization drawer is showing -->
- <dimen name="customizeSmallScreenVerticalMarginLandscape">70dip</dimen>
+ <dimen name="customizeSmallScreenVerticalMarginLandscape">90dip</dimen>
<dimen name="customizeSmallScreenVerticalMarginPortrait">180dip</dimen>
<dimen name="toolbar_padding">10dip</dimen>
diff --git a/res/values-xlarge/styles.xml b/res/values-xlarge/styles.xml
index bf79b4d..83cdbcc 100644
--- a/res/values-xlarge/styles.xml
+++ b/res/values-xlarge/styles.xml
@@ -29,11 +29,11 @@
<style name="WorkspaceIcon.Portrait">
<item name="android:drawablePadding">0dip</item>
- <item name="android:paddingTop">1dip</item>
+ <item name="android:paddingTop">0dip</item>
</style>
<style name="WorkspaceIcon.Landscape">
<item name="android:drawablePadding">0dip</item>
- <item name="android:paddingTop">1dip</item>
+ <item name="android:paddingTop">0dip</item>
</style>
</resources>
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index 4dcdb81..351384f 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -18,14 +18,13 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.ActionMode;
-import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@@ -95,6 +94,12 @@
}
@Override
+ protected void init() {
+ super.init();
+ mCenterPagesVertically = false;
+ }
+
+ @Override
public void setLauncher(Launcher launcher) {
mLauncher = launcher;
mLauncher.setAllAppsPagedView(this);
@@ -294,7 +299,22 @@
}
private void removeAppsWithoutInvalidate(ArrayList<ApplicationInfo> list) {
- // loop through all the apps and remove apps that have the same component
+ // End the choice mode if any of the items in the list that are being removed are
+ // currently selected
+ ArrayList<Checkable> checkedList = getCheckedGrandchildren();
+ HashSet<ApplicationInfo> checkedAppInfos = new HashSet<ApplicationInfo>();
+ for (Checkable checked : checkedList) {
+ PagedViewIcon icon = (PagedViewIcon) checked;
+ checkedAppInfos.add((ApplicationInfo) icon.getTag());
+ }
+ for (ApplicationInfo info : list) {
+ if (checkedAppInfos.contains(info)) {
+ endChoiceMode();
+ break;
+ }
+ }
+
+ // Loop through all the apps and remove apps that have the same component
final int length = list.size();
for (int i = 0; i < length; ++i) {
final ApplicationInfo info = list.get(i);
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index 5cfc38f..156bc20 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -33,6 +33,7 @@
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.Region.Op;
import android.graphics.drawable.Drawable;
@@ -130,6 +131,12 @@
setupWorkspaceLayout();
}
+ @Override
+ protected void init() {
+ super.init();
+ mCenterPagesVertically = false;
+ }
+
public void setLauncher(Launcher launcher) {
Context context = getContext();
mLauncher = launcher;
@@ -144,7 +151,7 @@
Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR);
// Update the widgets/shortcuts to reflect changes in the set of available apps
- update();
+ invalidatePageDataAndIconCache();
}
/**
@@ -170,7 +177,7 @@
addAppsWithoutInvalidate(list);
// Update the widgets/shortcuts to reflect changes in the set of available apps
- update();
+ invalidatePageDataAndIconCache();
}
/**
@@ -197,7 +204,7 @@
removeAppsWithoutInvalidate(list);
// Update the widgets/shortcuts to reflect changes in the set of available apps
- update();
+ invalidatePageDataAndIconCache();
}
/**
@@ -212,7 +219,7 @@
addAppsWithoutInvalidate(list);
// Update the widgets/shortcuts to reflect changes in the set of available apps
- update();
+ invalidatePageDataAndIconCache();
}
/**
@@ -231,8 +238,6 @@
}
public void update() {
- Context context = getContext();
-
// get the list of widgets
mWidgetList = AppWidgetManager.getInstance(mLauncher).getInstalledProviders();
Collections.sort(mWidgetList, new Comparator<AppWidgetProviderInfo>() {
@@ -260,7 +265,11 @@
mWallpaperList = mPackageManager.queryIntentActivities(wallpapersIntent, 0);
Collections.sort(mWallpaperList, resolveInfoComparator);
- // reset the icon cache
+ invalidatePageDataAndIconCache();
+ }
+
+ private void invalidatePageDataAndIconCache() {
+ // Reset the icon cache
mPageViewIconCache.clear();
// Refresh all the tabs
@@ -438,6 +447,17 @@
}
/**
+ * Helper function to draw a drawable to the specified canvas with the specified bounds.
+ */
+ private void renderDrawableToBitmap(Drawable d, Bitmap bitmap, int l, int t, int r, int b) {
+ if (bitmap != null) mCanvas.setBitmap(bitmap);
+ mCanvas.save();
+ d.setBounds(l, t, r, b);
+ d.draw(mCanvas);
+ mCanvas.restore();
+ }
+
+ /**
* This method will extract the preview image specified by the widget developer (if it exists),
* otherwise, it will try to generate a default image preview with the widget's package icon.
* @return the drawable will be used and sized in the ImageView to represent the widget
@@ -451,28 +471,21 @@
if (drawable == null) {
Log.w(TAG, "Can't load icon drawable 0x" + Integer.toHexString(info.icon)
+ " for provider: " + info.provider);
- } else {
- return drawable;
}
}
// If we don't have a preview image, create a default one
+ final int minDim = mWorkspaceWidgetLayout.estimateCellWidth(1);
+ final int maxDim = mWorkspaceWidgetLayout.estimateCellWidth(3);
if (drawable == null) {
Resources resources = mLauncher.getResources();
// Create a new bitmap to hold the widget preview
- final int minDim = mWorkspaceWidgetLayout.estimateCellWidth(1);
- final int maxDim = mWorkspaceWidgetLayout.estimateCellWidth(3);
int width = (int) (Math.max(minDim, Math.min(maxDim, info.minWidth)) * sScaleFactor);
int height = (int) (Math.max(minDim, Math.min(maxDim, info.minHeight)) * sScaleFactor);
- Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
- mCanvas.setBitmap(bitmap);
- // For some reason, we must re-set the clip rect here, otherwise it will be wrong
- mCanvas.clipRect(0, 0, width, height, Op.REPLACE);
-
- Drawable background = resources.getDrawable(R.drawable.default_widget_preview);
- background.setBounds(0, 0, width, height);
- background.draw(mCanvas);
+ final Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
+ final Drawable background = resources.getDrawable(R.drawable.default_widget_preview);
+ renderDrawableToBitmap(background, bitmap, 0, 0, width, height);
// Draw the icon vertically centered, flush left
try {
@@ -488,13 +501,34 @@
final int iconSize = minDim / 2;
final int offset = iconSize / 4;
- icon.setBounds(new Rect(offset, offset, offset + iconSize, offset + iconSize));
- icon.draw(mCanvas);
+ final int offsetIconSize = offset + iconSize;
+ renderDrawableToBitmap(icon, null, offset, offset, offsetIconSize, offsetIconSize);
} catch (Resources.NotFoundException e) {
// if we can't find the icon, then just don't draw it
}
drawable = new FastBitmapDrawable(bitmap);
+ } else {
+ // Scale down the preview if necessary
+ final float aspect = (float) info.minWidth / info.minHeight;
+ final int boundedWidth = (int) Math.max(minDim, Math.min(maxDim, info.minWidth));
+ final int boundedHeight = (int) Math.max(minDim, Math.min(maxDim, info.minHeight));
+ final int scaledWidth = (int) (boundedWidth * sScaleFactor);
+ final int scaledHeight = (int) (boundedHeight * sScaleFactor);
+ int width;
+ int height;
+ if (scaledWidth > scaledHeight) {
+ width = scaledWidth;
+ height = (int) (width / aspect);
+ } else {
+ height = scaledHeight;
+ width = (int) (height * aspect);
+ }
+
+ final Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
+ renderDrawableToBitmap(drawable, bitmap, 0, 0, width, height);
+
+ drawable = new FastBitmapDrawable(bitmap);
}
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
return drawable;
@@ -605,7 +639,7 @@
PagedViewIcon icon = (PagedViewIcon) mInflater.inflate(
R.layout.customize_paged_view_item, layout, false);
- icon.applyFromResolveInfo(info, mPackageManager, mPageViewIconCache);
+ icon.applyFromResolveInfo(info, mPackageManager, mPageViewIconCache, true);
switch (mCustomizationType) {
case WallpaperCustomization:
icon.setOnClickListener(this);
@@ -659,7 +693,7 @@
final ApplicationInfo info = mApps.get(i);
PagedViewIcon icon = (PagedViewIcon) mInflater.inflate(
R.layout.all_apps_paged_view_application, layout, false);
- icon.applyFromApplicationInfo(info, mPageViewIconCache, false);
+ icon.applyFromApplicationInfo(info, mPageViewIconCache, true);
icon.setOnClickListener(this);
icon.setOnLongClickListener(this);
@@ -761,5 +795,4 @@
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return false;
}
-
}
diff --git a/src/com/android/launcher2/HolographicOutlineHelper.java b/src/com/android/launcher2/HolographicOutlineHelper.java
index bca3f71..658490a 100644
--- a/src/com/android/launcher2/HolographicOutlineHelper.java
+++ b/src/com/android/launcher2/HolographicOutlineHelper.java
@@ -183,4 +183,4 @@
thickOuterBlur.recycle();
thickInnerBlur.recycle();
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index c14c22c..6b1290d 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -991,9 +991,13 @@
View createShortcut(int layoutResId, ViewGroup parent, ShortcutInfo info) {
TextView favorite = (TextView) mInflater.inflate(layoutResId, parent, false);
- // Temporarily, we are scaling up all shortcuts on the workspace
- int scaledSize = parent.getResources().getDimensionPixelSize(R.dimen.temp_scaled_icon_size);
- Bitmap b = Bitmap.createScaledBitmap(info.getIcon(mIconCache), scaledSize, scaledSize, true);
+ Bitmap b = info.getIcon(mIconCache);
+
+ if (LauncherApplication.isScreenXLarge()) {
+ // Temporarily, we are scaling up all shortcuts on the workspace
+ int scaledSize = getResources().getDimensionPixelSize(R.dimen.temp_scaled_icon_size);
+ b = Bitmap.createScaledBitmap(b, scaledSize, scaledSize, true);
+ }
favorite.setCompoundDrawablesWithIntrinsicBounds(null,
new FastBitmapDrawable(b),
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 9739b15..e9829fb 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -102,6 +102,7 @@
protected int mPageLayoutHeightGap;
protected int mCellCountX;
protected int mCellCountY;
+ protected boolean mCenterPagesVertically;
protected static final int INVALID_POINTER = -1;
@@ -207,6 +208,7 @@
mPageViewIconCache = new PagedViewIconCache();
mScroller = new Scroller(getContext());
mCurrentPage = 0;
+ mCenterPagesVertically = true;
final ViewConfiguration configuration = ViewConfiguration.get(getContext());
mTouchSlop = configuration.getScaledTouchSlop();
@@ -394,7 +396,8 @@
final View child = getChildAt(i);
if (child.getVisibility() != View.GONE) {
final int childWidth = child.getMeasuredWidth();
- final int childHeight = (getMeasuredHeight() - child.getMeasuredHeight()) / 2;
+ final int childHeight = (mCenterPagesVertically ?
+ (getMeasuredHeight() - child.getMeasuredHeight()) / 2 : 0);
child.layout(childLeft, childHeight,
childLeft + childWidth, childHeight + child.getMeasuredHeight());
childLeft += childWidth + mPageSpacing;
@@ -755,7 +758,9 @@
// by a distant descendant, so use the mAllowLongPress flag to block
// everything
final View currentPage = getPageAt(mCurrentPage);
- currentPage.cancelLongPress();
+ if (currentPage != null) {
+ currentPage.cancelLongPress();
+ }
}
}
}
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index c59ef80..6c6c4dc 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -156,12 +156,16 @@
}
public void applyFromResolveInfo(ResolveInfo info, PackageManager packageManager,
- PagedViewIconCache cache) {
+ PagedViewIconCache cache, boolean scaleUp) {
mIconCache = cache;
mIconCacheKey = info;
mHolographicOutline = mIconCache.getOutline(mIconCacheKey);
mIcon = Utilities.createIconBitmap(info.loadIcon(packageManager), mContext);
+ if (scaleUp) {
+ mIcon = Bitmap.createScaledBitmap(mIcon, mScaledIconSize,
+ mScaledIconSize, true);
+ }
setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null);
setText(info.loadLabel(packageManager));
setTag(info);
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 2ddd044..263c3a6 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -164,6 +164,9 @@
// Paint used to draw external drop outline
private final Paint mExternalDragOutlinePaint = new Paint();
+ /** Used to trigger an animation as soon as the workspace stops scrolling. */
+ private Animator mAnimOnPageEndMoving = null;
+
/**
* Used to inflate the Workspace from XML.
*
@@ -462,6 +465,12 @@
if (!mDragController.dragging()) {
hideOutlines();
}
+ // Check for an animation that's waiting to be started
+ if (mAnimOnPageEndMoving != null) {
+ mAnimOnPageEndMoving.start();
+ mAnimOnPageEndMoving = null;
+ }
+
mPageMoving = false;
}
@@ -594,6 +603,8 @@
super.dispatchDraw(canvas);
if (mDropView != null) {
+ // We are animating an item that was just dropped on the home screen.
+ // Render its View in the current animation position.
canvas.save(Canvas.MATRIX_SAVE_FLAG);
final int xPos = mDropViewPos[0] - mDropView.getScrollX();
final int yPos = mDropViewPos[1] - mDropView.getScrollY();
@@ -767,8 +778,7 @@
// We shrink and disappear to nothing in the case of all apps
// (which is when we shrink to the bottom)
newY = screenHeight - newY - scaledPageHeight;
- finalAlpha = 0.0f;
- extraShrinkFactor = 0.1f;
+ finalAlpha = 0.25f;
} else if (shrinkPosition == ShrinkPosition.SHRINK_TO_MIDDLE) {
newY = screenHeight / 2 - scaledPageHeight / 2;
finalAlpha = 1.0f;
@@ -899,6 +909,9 @@
// never dragged over
public void onDragStopped() {
updateWhichPagesAcceptDrops(mShrunkenState);
+ if (mShrunkenState == ShrinkPosition.SHRINK_TO_BOTTOM_VISIBLE) {
+ shrink(ShrinkPosition.SHRINK_TO_BOTTOM_HIDDEN, true);
+ }
}
// We call this when we trigger an unshrink by clicking on the CellLayout cl
@@ -1143,8 +1156,6 @@
final CellLayout parent = (CellLayout) view.getParent();
final CellLayout.LayoutParams lp = (CellLayout.LayoutParams) view.getLayoutParams();
- mDropView = view;
-
// Convert the animation params to be relative to the Workspace, not the CellLayout
final int fromX = lp.oldX + parent.getLeft();
final int fromY = lp.oldY + parent.getTop();
@@ -1156,18 +1167,21 @@
final float dist = (float) Math.sqrt(dx*dx + dy*dy);
final Resources res = getResources();
final float maxDist = (float) res.getInteger(R.integer.config_dropAnimMaxDist);
- final int duration = (int) (res.getInteger(R.integer.config_dropAnimMaxDuration)
- * mQuintEaseOutInterpolator.getInterpolation(dist / maxDist));
+ int duration = res.getInteger(R.integer.config_dropAnimMaxDuration);
+ if (dist < maxDist) {
+ duration *= mQuintEaseOutInterpolator.getInterpolation(dist / maxDist);
+ }
// Lazy initialize the animation
if (mDropAnim == null) {
mDropAnim = new ValueAnimator();
mDropAnim.setInterpolator(mQuintEaseOutInterpolator);
- // Make the view invisible during the animation; we'll render it manually.
+ // The view is invisible during the animation; we render it manually.
mDropAnim.addListener(new AnimatorListenerAdapter() {
public void onAnimationStart(Animator animation) {
- mDropView.setVisibility(View.INVISIBLE);
+ // Set this here so that we don't render it until the animation begins
+ mDropView = view;
}
public void onAnimationEnd(Animator animation) {
@@ -1180,6 +1194,7 @@
} else {
mDropAnim.end(); // Make sure it's not already running
}
+
mDropAnim.setDuration(duration);
mDropAnim.setFloatValues(0.0f, 1.0f);
mDropAnim.removeAllUpdateListeners();
@@ -1196,7 +1211,15 @@
mDropViewPos[0] + view.getWidth(), mDropViewPos[1] + view.getHeight());
}
});
- mDropAnim.start();
+
+
+ view.setVisibility(View.INVISIBLE);
+
+ if (!mScroller.isFinished()) {
+ mAnimOnPageEndMoving = mDropAnim;
+ } else {
+ mDropAnim.start();
+ }
}
/**
@@ -1253,7 +1276,7 @@
mTargetCell);
if (mTargetCell == null) {
- mLauncher.showOutOfSpaceMessage();
+ snapToPage(mDragInfo.screen);
} else {
int screen = indexOfChild(mDragTargetLayout);
if (screen != mDragInfo.screen) {