diff options
author | Michael Jurka <mikejurka@google.com> | 2010-10-21 16:49:19 -0700 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2011-01-11 20:02:55 -0800 |
commit | 340c5f3a708efa280a120708594247952ca65182 (patch) | |
tree | 15d90e44a0d298cd36d8ba47afb49318cfe44f85 /src/com | |
parent | ecb48385312bc8307cb712b45087abd711fed678 (diff) | |
download | packages_apps_trebuchet-340c5f3a708efa280a120708594247952ca65182.zip packages_apps_trebuchet-340c5f3a708efa280a120708594247952ca65182.tar.gz packages_apps_trebuchet-340c5f3a708efa280a120708594247952ca65182.tar.bz2 |
Restore wallpaper parallax
Gives us a 7-10fps drop
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 12 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 20 |
2 files changed, 19 insertions, 13 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 7faa520..d0f52cb 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -550,12 +550,12 @@ public final class Launcher extends Activity WallpaperManager wpm = (WallpaperManager)getSystemService(WALLPAPER_SERVICE); Display display = getWindowManager().getDefaultDisplay(); - // TODO: Put back when we decide about scrolling the wallpaper - // boolean isPortrait = display.getWidth() < display.getHeight(); - // final int width = isPortrait ? display.getWidth() : display.getHeight(); - // final int height = isPortrait ? display.getHeight() : display.getWidth(); - wpm.suggestDesiredDimensions(Math.max(display.getWidth(), display.getHeight()), - Math.max(display.getWidth(), display.getHeight())); + boolean isPortrait = display.getWidth() < display.getHeight(); + // find width and height when in portrait mode + final int width = isPortrait ? display.getWidth() : display.getHeight(); + final int height = isPortrait ? display.getHeight() : display.getWidth(); + wpm.suggestDesiredDimensions((int) (Math.max(width, height) * 1.5f), + Math.max(width, height)); } // Note: This doesn't do all the client-id magic that BrowserProvider does diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index ff42282..d65f692 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -394,7 +394,7 @@ public class Workspace extends SmoothPagedView @Override void setCurrentPage(int currentPage) { super.setCurrentPage(currentPage); - updateWallpaperOffset(mScrollX); + updateWallpaperOffset(); } /** @@ -558,19 +558,25 @@ public class Workspace extends SmoothPagedView Launcher.setScreen(mCurrentPage); }; - private void updateWallpaperOffset(int scrollRange) { - final boolean isStaticWallpaper = (mWallpaperManager != null) && - (mWallpaperManager.getWallpaperInfo() == null); - if (LauncherApplication.isScreenXLarge() && !isStaticWallpaper) { + private void updateWallpaperOffset() { + if (LauncherApplication.isScreenXLarge()) { IBinder token = getWindowToken(); + int scrollRange = getChildOffset(getChildCount() - 1) - getChildOffset(0); if (token != null) { - mWallpaperManager.setWallpaperOffsetSteps(1.0f / (getChildCount() - 1), 0 ); + mWallpaperManager.setWallpaperOffsetSteps(1.0f / (getChildCount() - 1), 0); + float offset = mScrollX / (float) scrollRange; mWallpaperManager.setWallpaperOffsets(getWindowToken(), - Math.max(0.f, Math.min(mScrollX/(float)scrollRange, 1.f)), 0); + Math.max(0.f, Math.min(offset, 1.0f)), 0); } } } + @Override + public void computeScroll() { + super.computeScroll(); + updateWallpaperOffset(); + } + public void showOutlines() { if (!mIsSmall && !mIsInUnshrinkAnimation) { if (mChildrenOutlineFadeOutAnimation != null) mChildrenOutlineFadeOutAnimation.cancel(); |