Merge "Fixing workspace scrolling, Bug: 4070816" into honeycomb-mr1
diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml
index 135ec58..ef96d16 100644
--- a/res/values-el/strings.xml
+++ b/res/values-el/strings.xml
@@ -33,7 +33,7 @@
<string name="wallpapers_tab_label" msgid="1617804870364119879">"Ταπετσαρίες"</string>
<string name="applications_tab_label" msgid="2991364240020736760">"Συντομεύσεις εφαρμογών"</string>
<string name="wallpapers_temp_tab_text" msgid="1660218201190495279">"Αυτή θα είναι η καρτέλα ταπετσαριών"</string>
- <string name="all_apps_tab_all" msgid="2942727589595027258">"Κάθε ηλικία"</string>
+ <string name="all_apps_tab_all" msgid="2942727589595027258">"Όλες"</string>
<string name="all_apps_tab_apps" msgid="5468972551904071712">"Εφαρμογές"</string>
<string name="all_apps_tab_games" msgid="1855736784923494918">"Παιχνίδια"</string>
<string name="all_apps_tab_downloaded" msgid="1488049110598641387">"Οι εφαρμογές μου"</string>
diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml
index db21d2b..9a2e511 100644
--- a/res/values-it/strings.xml
+++ b/res/values-it/strings.xml
@@ -58,7 +58,7 @@
<string name="add_clock" msgid="2337943840175865746">"Orologio"</string>
<string name="add_photo_frame" msgid="3154058437359487954">"Cornice immagini"</string>
<string name="out_of_space" msgid="8365249326091984698">"Spazio nella schermata Home esaurito."</string>
- <string name="shortcut_installed" msgid="7071557296331322355">"Scoriciatoia \"<xliff:g id="NAME">%s</xliff:g>\" creata."</string>
+ <string name="shortcut_installed" msgid="7071557296331322355">"Scorciatoia \"<xliff:g id="NAME">%s</xliff:g>\" creata."</string>
<string name="shortcut_uninstalled" msgid="2129499669449749995">"La scorciatoia \"<xliff:g id="NAME">%s</xliff:g>\" è stata rimossa."</string>
<string name="shortcut_duplicate" msgid="4757756326465060694">"Scorciatoia \"<xliff:g id="NAME">%s</xliff:g>\" già presente."</string>
<string name="title_select_shortcut" msgid="2858897527672831763">"Seleziona scorciatoia"</string>
diff --git a/src/com/android/launcher2/AllAppsTabbed.java b/src/com/android/launcher2/AllAppsTabbed.java
index aa828b0..0dd56ac 100644
--- a/src/com/android/launcher2/AllAppsTabbed.java
+++ b/src/com/android/launcher2/AllAppsTabbed.java
@@ -177,8 +177,11 @@
// Turn on hardware layers for performance
setLayerType(LAYER_TYPE_HARDWARE, null);
// Re-enable the rendering of the dimmed background in All Apps for performance reasons
- mLauncher.getWorkspace().disableBackground();
- mBackground.setVisibility(VISIBLE);
+ // if we're fading it in
+ if (mLauncher.getWorkspace().getBackgroundAlpha() == 0f) {
+ mLauncher.getWorkspace().disableBackground();
+ mBackground.setVisibility(VISIBLE);
+ }
// just a sanity check that we don't build a layer before a call to onLayout
if (!mFirstLayout) {
// force building the layer at the beginning of the animation, so you don't get a
@@ -199,8 +202,10 @@
}
// Move the rendering of the dimmed background to workspace after the all apps animation
// is done, so that the background is not rendered *above* the mini workspace screens
- mLauncher.getWorkspace().enableBackground();
- mBackground.setVisibility(GONE);
+ if (mBackground.getVisibility() != GONE) {
+ mLauncher.getWorkspace().enableBackground();
+ mBackground.setVisibility(GONE);
+ }
mAllApps.allowHardwareLayerCreation();
}
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java
index f708e2f..a8db330 100644
--- a/src/com/android/launcher2/BubbleTextView.java
+++ b/src/com/android/launcher2/BubbleTextView.java
@@ -152,8 +152,14 @@
mPressedOrFocusedBackground = null;
}
if (isFocused()) {
- mPressedOrFocusedBackground = createGlowingOutline(
- mTempCanvas, mFocusedGlowColor, mFocusedOutlineColor);
+ if (mLayout == null) {
+ // In some cases, we get focus before we have been layed out. Set the
+ // background to null so that it will get created when the view is drawn.
+ mPressedOrFocusedBackground = null;
+ } else {
+ mPressedOrFocusedBackground = createGlowingOutline(
+ mTempCanvas, mFocusedGlowColor, mFocusedOutlineColor);
+ }
mStayPressed = false;
invalidatePressedOrFocusedBackground();
}
@@ -190,7 +196,7 @@
destCanvas.save();
destCanvas.translate(-getScrollX() + padding / 2, -getScrollY() + padding / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
- draw(destCanvas);
+ drawImpl(destCanvas, true);
destCanvas.restore();
}
@@ -265,8 +271,19 @@
}
invalidatePressedOrFocusedBackground();
}
+
@Override
public void draw(Canvas canvas) {
+ drawImpl(canvas, false);
+ }
+
+ private void drawImpl(Canvas canvas, boolean preventRecursion) {
+ // If the View is focused but the focused background hasn't been created yet, create it now
+ if (!preventRecursion && isFocused() && mPressedOrFocusedBackground == null) {
+ mPressedOrFocusedBackground = createGlowingOutline(
+ mTempCanvas, mFocusedGlowColor, mFocusedOutlineColor);
+ }
+
if (mPressedOrFocusedBackground != null && (isPressed() || isFocused() || mStayPressed)) {
// The blue glow can extend outside of our clip region, so we first temporarily expand
// the canvas's clip region
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index e80eda3..5c61b0b 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -452,6 +452,7 @@
public void onAnimationEnd(Animator animation) {
dragLayer.removeView(view);
mLauncher.addExternalItemToScreen(info, layout);
+ info.dropPos = null;
}
});
anim.start();
diff --git a/src/com/android/launcher2/IconCache.java b/src/com/android/launcher2/IconCache.java
index 2e47adc..0c26bf0 100644
--- a/src/com/android/launcher2/IconCache.java
+++ b/src/com/android/launcher2/IconCache.java
@@ -68,11 +68,13 @@
com.android.internal.R.mipmap.sym_def_app_icon);
}
- public Drawable getFullResIcon(Resources resources, int iconId) {
+ public Drawable getFullResIcon(Resources resources, int iconId)
+ throws Resources.NotFoundException {
return resources.getDrawableForDensity(iconId, mIconDpi);
}
- public Drawable getFullResIcon(ResolveInfo info, PackageManager packageManager) {
+ public Drawable getFullResIcon(ResolveInfo info, PackageManager packageManager)
+ throws Resources.NotFoundException {
Resources resources;
try {
resources = packageManager.getResourcesForApplication(
@@ -174,8 +176,14 @@
if (entry.title == null) {
entry.title = info.activityInfo.name;
}
- entry.icon = Utilities.createIconBitmap(
- getFullResIcon(info, mPackageManager), mContext);
+
+ Drawable icon;
+ try {
+ icon = getFullResIcon(info, mPackageManager);
+ } catch (Resources.NotFoundException e) {
+ icon = getFullResDefaultActivityIcon();
+ }
+ entry.icon = Utilities.createIconBitmap(icon, mContext);
}
return entry;
}
diff --git a/src/com/android/launcher2/ItemInfo.java b/src/com/android/launcher2/ItemInfo.java
index dc45750..b361214 100644
--- a/src/com/android/launcher2/ItemInfo.java
+++ b/src/com/android/launcher2/ItemInfo.java
@@ -81,6 +81,11 @@
*/
boolean isGesture = false;
+ /**
+ * The position of the item in a drag-and-drop operation.
+ */
+ int[] dropPos = null;
+
ItemInfo() {
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index fe40fc1..e7865d2 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -733,11 +733,15 @@
private float wallpaperOffsetForCurrentScroll() {
Display display = mLauncher.getWindowManager().getDefaultDisplay();
+ final boolean isStaticWallpaper = (mWallpaperManager.getWallpaperInfo() == null);
// The wallpaper travel width is how far, from left to right, the wallpaper will move
// at this orientation (for example, in portrait mode we don't move all the way to the
// edges of the wallpaper, or otherwise the parallax effect would be too strong)
int wallpaperTravelWidth = (int) (display.getWidth() *
wallpaperTravelToScreenWidthRatio(display.getWidth(), display.getHeight()));
+ if (!isStaticWallpaper) {
+ wallpaperTravelWidth = mWallpaperWidth;
+ }
// Set wallpaper offset steps (1 / (number of screens - 1))
// We have 3 vertical offset states (centered, and then top/bottom aligned
@@ -751,7 +755,6 @@
// you overscroll as far as you can in landscape mode. Only do this for static wallpapers
// because live wallpapers (and probably 3rd party wallpaper providers) rely on the offset
// being even intervals from 0 to 1 (eg [0, 0.25, 0.5, 0.75, 1])
- final boolean isStaticWallpaper = (mWallpaperManager.getWallpaperInfo() == null);
if (isStaticWallpaper) {
int overscrollOffset = (int) (maxOverScroll() * display.getWidth());
scrollProgressOffset += overscrollOffset / (float) getScrollRange();
@@ -761,7 +764,7 @@
float scrollProgress =
mScrollX / (float) scrollRange + scrollProgressOffset;
float offsetInDips = wallpaperTravelWidth * scrollProgress +
- (mWallpaperWidth - wallpaperTravelWidth) / 2;
+ (mWallpaperWidth - wallpaperTravelWidth) / 2; // center it
float offset = offsetInDips / (float) mWallpaperWidth;
return offset;
}
@@ -1181,8 +1184,9 @@
final int pageCount = getChildCount();
final long drawingTime = getDrawingTime();
for (int i = 0; i < pageCount; i++) {
- final View page = (View) getChildAt(i);
- if (page.getVisibility() == VISIBLE && page.getAlpha() != 0f) {
+ final CellLayout page = (CellLayout) getChildAt(i);
+ if (page.getVisibility() == VISIBLE
+ && (page.getAlpha() != 0f || page.getBackgroundAlpha() != 0f)) {
drawChild(canvas, page, drawingTime);
}
}
@@ -2296,12 +2300,14 @@
}
if (source != this) {
+ final int[] touchXY = new int[] { originX, originY };
if ((mIsSmall || mIsInUnshrinkAnimation) && !mLauncher.isAllAppsVisible()) {
// When the workspace is shrunk and the drop comes from customize, don't actually
// add the item to the screen -- customize will do this itself
+ ((ItemInfo) dragInfo).dropPos = touchXY;
return;
}
- onDropExternal(new int[] { originX, originY }, dragInfo, mDragTargetLayout, false);
+ onDropExternal(touchXY, dragInfo, mDragTargetLayout, false);
} else if (mDragInfo != null) {
final View cell = mDragInfo.cell;
CellLayout dropTargetLayout = mDragTargetLayout;
@@ -2837,7 +2843,7 @@
*/
public boolean addExternalItemToScreen(ItemInfo dragInfo, CellLayout layout) {
if (layout.findCellForSpan(mTempEstimate, dragInfo.spanX, dragInfo.spanY)) {
- onDropExternal(null, (ItemInfo) dragInfo, (CellLayout) layout, false);
+ onDropExternal(dragInfo.dropPos, (ItemInfo) dragInfo, (CellLayout) layout, false);
return true;
}
mLauncher.showOutOfSpaceMessage();