merge in ics-release history after reset to master
diff --git a/res/values-land/config.xml b/res/values-land/config.xml
index 2fee8cf..07eac4f 100644
--- a/res/values-land/config.xml
+++ b/res/values-land/config.xml
@@ -20,4 +20,8 @@
<bool name="config_useDropTargetDownTransition">false</bool>
<!-- Whether or not to fade the side pages -->
<bool name="config_workspaceFadeAdjacentScreens">true</bool>
+
+ <!-- Padding applied to AppWidgets -->
+ <dimen name="app_widget_padding_top">8dp</dimen>
+ <dimen name="app_widget_padding_bottom">8dp</dimen>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 722fb0d..a5b394d 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -96,10 +96,10 @@
<dimen name="dragViewOffsetY">-8dp</dimen>
<!-- Padding applied to AppWidgets -->
- <dimen name="app_widget_padding_left">4dp</dimen>
- <dimen name="app_widget_padding_right">4dp</dimen>
- <dimen name="app_widget_padding_top">4dp</dimen>
- <dimen name="app_widget_padding_bottom">4dp</dimen>
+ <dimen name="app_widget_padding_left">16dp</dimen>
+ <dimen name="app_widget_padding_right">16dp</dimen>
+ <dimen name="app_widget_padding_top">16dp</dimen>
+ <dimen name="app_widget_padding_bottom">16dp</dimen>
<!-- Folders -->
<!-- The size of the image which sits behind the preview of the folder contents -->
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index df98c89..d3e0963 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -492,8 +492,7 @@
int h = preview.getIntrinsicHeight();
if (createItemInfo instanceof PendingAddWidgetInfo) {
PendingAddWidgetInfo createWidgetInfo = (PendingAddWidgetInfo) createItemInfo;
- int[] spanXY = CellLayout.rectToCell(getResources(),
- createWidgetInfo.minWidth, createWidgetInfo.minHeight, null);
+ int[] spanXY = mLauncher.getSpanForWidget(createWidgetInfo, null);
createItemInfo.spanX = spanXY[0];
createItemInfo.spanY = spanXY[1];
@@ -986,8 +985,7 @@
Object rawInfo = items.get(i);
if (rawInfo instanceof AppWidgetProviderInfo) {
AppWidgetProviderInfo info = (AppWidgetProviderInfo) rawInfo;
- int[] cellSpans = CellLayout.rectToCell(getResources(),
- info.minWidth, info.minHeight, null);
+ int[] cellSpans = mLauncher.getSpanForWidget(info, null);
images.add(getWidgetPreview(info, cellSpans[0],cellSpans[1],
cellWidth, cellHeight));
} else if (rawInfo instanceof ResolveInfo) {
@@ -1017,8 +1015,7 @@
// Fill in the widget information
AppWidgetProviderInfo info = (AppWidgetProviderInfo) rawInfo;
createItemInfo = new PendingAddWidgetInfo(info, null, null, "13");
- int[] cellSpans = CellLayout.rectToCell(getResources(),
- info.minWidth, info.minHeight, null);
+ int[] cellSpans = mLauncher.getSpanForWidget(info, null);
FastBitmapDrawable preview = new FastBitmapDrawable(data.generatedImages.get(i));
widget.applyFromAppWidgetProviderInfo(info, preview, -1, cellSpans,
mHolographicOutlineHelper);
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 80f0261..637d956 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -90,7 +90,6 @@
import com.android.common.Search;
import com.android.launcher.R;
import com.android.launcher2.DropTarget.DragObject;
-import com.android.launcher2.Workspace.State;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -853,14 +852,13 @@
int bottom = 0;
}
- Padding getPaddingForWidget(AppWidgetProviderInfo widgetInfo) {
+ Padding getPaddingForWidget(ComponentName component) {
PackageManager packageManager = getPackageManager();
Padding p = new Padding();
android.content.pm.ApplicationInfo appInfo;
try {
- appInfo = packageManager.getApplicationInfo(
- widgetInfo.provider.getPackageName(), 0);
+ appInfo = packageManager.getApplicationInfo(component.getPackageName(), 0);
} catch (Exception e) {
// if we can't find the package, return 0 padding
return p;
@@ -879,6 +877,27 @@
return p;
}
+ int[] getSpanForWidget(ComponentName component, int minWidth, int minHeight, int[] spanXY) {
+ if (spanXY == null) {
+ spanXY = new int[2];
+ }
+
+ Padding padding = getPaddingForWidget(component);
+ // We want to account for the extra amount of padding that we are adding to the widget
+ // to ensure that it gets the full amount of space that it has requested
+ int requiredWidth = minWidth + padding.left + padding.right;
+ int requiredHeight = minHeight + padding.top + padding.bottom;
+ return CellLayout.rectToCell(getResources(), requiredWidth, requiredHeight, null);
+ }
+
+ int[] getSpanForWidget(AppWidgetProviderInfo info, int[] spanXY) {
+ return getSpanForWidget(info.provider, info.minWidth, info.minHeight, spanXY);
+ }
+
+ int[] getSpanForWidget(PendingAddWidgetInfo info, int[] spanXY) {
+ return getSpanForWidget(info.componentName, info.minWidth, info.minHeight, spanXY);
+ }
+
/**
* Add a widget to the workspace.
*
@@ -891,12 +910,7 @@
// Calculate the grid spans needed to fit this widget
CellLayout layout = getCellLayout(container, screen);
- Padding padding = getPaddingForWidget(appWidgetInfo);
- // We want to account for the extra amount of padding that we are adding to the widget
- // to ensure that it gets the full amount of space that it has requested
- int requiredWidth = appWidgetInfo.minWidth + padding.left + padding.right;
- int requiredHeight = appWidgetInfo.minHeight + padding.top + padding.bottom;
- int[] spanXY = layout.rectToCell(requiredWidth, requiredHeight, null);
+ int[] spanXY = getSpanForWidget(appWidgetInfo, null);
// Try finding open space on Launcher screen
// We have saved the position to which the widget was dragged-- this really only matters
@@ -1737,6 +1751,16 @@
private void handleFolderClick(FolderIcon folderIcon) {
final FolderInfo info = folderIcon.mInfo;
+ Folder openFolder = mWorkspace.getFolderForTag(info);
+
+ // If the folder info reports that the associated folder is open, then verify that
+ // it is actually opened. There have been a few instances where this gets out of sync.
+ if (info.opened && openFolder == null) {
+ Log.d(TAG, "Folder info marked as open, but associated folder is not open. Screen: "
+ + info.screen + " (" + info.cellX + ", " + info.cellY + ")");
+ info.opened = false;
+ }
+
if (!info.opened) {
// Close any open folder
closeFolder();
@@ -1744,7 +1768,6 @@
openFolder(folderIcon);
} else {
// Find the open folder...
- Folder openFolder = mWorkspace.getFolderForTag(info);
int folderScreen;
if (openFolder != null) {
folderScreen = mWorkspace.getPageForView(openFolder);
@@ -2144,7 +2167,6 @@
// Hide the workspace scrollbar
mWorkspace.hideScrollingIndicator(true);
mWorkspace.hideDockDivider(true);
- mWorkspace.showAllAppsAnimationComplete();
}
updateWallpaperVisibility(false);
}
diff --git a/src/com/android/launcher2/LauncherAppWidgetHostView.java b/src/com/android/launcher2/LauncherAppWidgetHostView.java
index a84ced6..7118c49 100644
--- a/src/com/android/launcher2/LauncherAppWidgetHostView.java
+++ b/src/com/android/launcher2/LauncherAppWidgetHostView.java
@@ -119,7 +119,7 @@
public void setAppWidget(int appWidgetId, AppWidgetProviderInfo info) {
super.setAppWidget(appWidgetId, info);
// We add necessary padding to the AppWidgetHostView
- Launcher.Padding padding = mLauncher.getPaddingForWidget(info);
+ Launcher.Padding padding = mLauncher.getPaddingForWidget(info.provider);
setPadding(padding.left, padding.top, padding.right, padding.bottom);
}
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index ea51d01..239970e 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -465,7 +465,7 @@
item.onAddToDatabase(values);
item.updateValuesWithCoordinates(values, item.cellX, item.cellY);
- sWorker.post(new Runnable() {
+ Runnable r = new Runnable() {
public void run() {
cr.update(LauncherSettings.Favorites.getContentUri(item.id, false),
values, null, null);
@@ -481,7 +481,12 @@
throw new RuntimeException(msg);
}
}
- });
+ };
+ if (sWorkerThread.getThreadId() == Process.myTid()) {
+ r.run();
+ } else {
+ sWorker.post(r);
+ }
}
/**
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 6f94c93..29da4bf 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -113,6 +113,8 @@
private int mOverScrollPageIndex = -1;
private AnimatorSet mDividerAnimator;
+ private float mWallpaperScrollRatio = 1.0f;
+
private final WallpaperManager mWallpaperManager;
private IBinder mWindowToken;
@@ -159,7 +161,6 @@
enum State { NORMAL, SPRING_LOADED, SMALL };
private State mState = State.NORMAL;
private boolean mIsSwitchingState = false;
- boolean mEnableSyncWallpaper = false;
private boolean mSwitchStateAfterFirstLayout = false;
private State mStateAfterFirstLayout;
@@ -192,7 +193,6 @@
int mWallpaperHeight;
WallpaperOffsetInterpolator mWallpaperOffset;
boolean mUpdateWallpaperOffsetImmediately = false;
- boolean mSyncWallpaperOffsetWithScroll = true;
private Runnable mDelayedResizeRunnable;
// Variables relating to the creation of user folders by hovering shortcuts over shortcuts
@@ -754,6 +754,11 @@
// for all apps/customize)
mWallpaperManager.setWallpaperOffsetSteps(1.0f / (getChildCount() - 1), 1.0f / (3 - 1));
+ // For the purposes of computing the scrollRange and overScrollOffset, we ignore
+ // assume that mLayoutScale is 1. This means that when we're in spring-loaded mode,
+ // there's no discrepancy between the wallpaper offset for a given page.
+ float layoutScale = mLayoutScale;
+ mLayoutScale = 1f;
int scrollRange = getScrollRange();
float scrollProgressOffset = 0;
@@ -767,8 +772,12 @@
scrollRange += 2 * overscrollOffset;
}
+ // Again, we adjust the wallpaper offset to be consistent between values of mLayoutScale
+ float adjustedScrollX = mWallpaperScrollRatio * mScrollX;
+ mLayoutScale = layoutScale;
+
float scrollProgress =
- mScrollX / (float) scrollRange + scrollProgressOffset;
+ adjustedScrollX / (float) scrollRange + scrollProgressOffset;
float offsetInDips = wallpaperTravelWidth * scrollProgress +
(mWallpaperWidth - wallpaperTravelWidth) / 2; // center it
float offset = offsetInDips / (float) mWallpaperWidth;
@@ -807,6 +816,34 @@
}
}
+ @Override
+ protected void updateCurrentPageScroll() {
+ super.updateCurrentPageScroll();
+ computeWallpaperScrollRatio(mCurrentPage);
+ }
+
+ @Override
+ protected void snapToPage(int whichPage) {
+ super.snapToPage(whichPage);
+ computeWallpaperScrollRatio(whichPage);
+ }
+
+ private void computeWallpaperScrollRatio(int page) {
+ // Here, we determine what the desired scroll would be with and without a layout scale,
+ // and compute a ratio between the two. This allows us to adjust the wallpaper offset
+ // as though there is no layout scale.
+ float layoutScale = mLayoutScale;
+ int scaled = getChildOffset(page) - getRelativeChildOffset(page);
+ mLayoutScale = 1.0f;
+ float unscaled = getChildOffset(page) - getRelativeChildOffset(page);
+ mLayoutScale = layoutScale;
+ if (scaled > 0) {
+ mWallpaperScrollRatio = (1.0f * unscaled) / scaled;
+ } else {
+ mWallpaperScrollRatio = 1f;
+ }
+ }
+
class WallpaperOffsetInterpolator {
float mFinalHorizontalWallpaperOffset = 0.0f;
float mFinalVerticalWallpaperOffset = 0.5f;
@@ -920,9 +957,7 @@
@Override
public void computeScroll() {
super.computeScroll();
- if (mSyncWallpaperOffsetWithScroll) {
- syncWallpaperOffsetWithScroll();
- }
+ syncWallpaperOffsetWithScroll();
}
void showOutlines() {
@@ -1411,13 +1446,6 @@
changeState(shrinkState, true);
}
- void showAllAppsAnimationComplete() {
- if (mEnableSyncWallpaper) {
- mSyncWallpaperOffsetWithScroll = true;
- mEnableSyncWallpaper = true;
- }
- }
-
void changeState(final State state, boolean animated) {
if (mFirstLayout) {
// (mFirstLayout == "first layout has not happened yet")
@@ -1440,14 +1468,13 @@
State oldState = mState;
mState = state;
boolean zoomIn = true;
+
if (state != State.NORMAL) {
finalScaleFactor = mSpringLoadedShrinkFactor - (state == State.SMALL ? 0.1f : 0);
finalBackgroundAlpha = 1.0f;
if (oldState == State.NORMAL && state == State.SMALL) {
zoomIn = false;
if (animated) {
- mEnableSyncWallpaper = true;
- mSyncWallpaperOffsetWithScroll = false;
hideScrollingIndicator(true);
}
setLayoutScale(finalScaleFactor);