From 104c45677660586026a7e74ef8c47d396403d50e Mon Sep 17 00:00:00 2001 From: Michael Jurka Date: Mon, 8 Jul 2013 18:03:46 -0700 Subject: Initial implementation of new wallpaper picker. Change-Id: Ib4c5ac4989b4959fa62465d9cde3cac662e24949 --- src/com/android/launcher3/Workspace.java | 61 ++------------------------------ 1 file changed, 3 insertions(+), 58 deletions(-) (limited to 'src/com/android/launcher3/Workspace.java') diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index b2f74330f..2298c5392 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -104,7 +104,6 @@ public class Workspace extends SmoothPagedView private LayoutTransition mLayoutTransition; private final WallpaperManager mWallpaperManager; private IBinder mWindowToken; - private static final float WALLPAPER_SCREENS_SPAN = 2f; private int mDefaultPage; @@ -189,16 +188,11 @@ public class Workspace extends SmoothPagedView public static final int DRAG_BITMAP_PADDING = 2; private boolean mWorkspaceFadeInAdjacentScreens; - enum WallpaperVerticalOffset { TOP, MIDDLE, BOTTOM }; - int mWallpaperWidth; - int mWallpaperHeight; WallpaperOffsetInterpolator mWallpaperOffset; boolean mUpdateWallpaperOffsetImmediately = false; private Runnable mDelayedResizeRunnable; private Runnable mDelayedSnapToPageRunnable; private Point mDisplaySize = new Point(); - private boolean mIsStaticWallpaper; - private int mWallpaperTravelWidth; private int mCameraDistance; // Variables relating to the creation of user folders by hovering shortcuts over shortcuts @@ -397,8 +391,6 @@ public class Workspace extends SmoothPagedView mWallpaperOffset = new WallpaperOffsetInterpolator(); Display display = mLauncher.getWindowManager().getDefaultDisplay(); display.getSize(mDisplaySize); - mWallpaperTravelWidth = (int) (mDisplaySize.x * - wallpaperTravelToScreenWidthRatio(mDisplaySize.x, mDisplaySize.y)); mMaxDistanceForFolderCreation = (0.55f * grid.iconSizePx); mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * mDensity); @@ -529,7 +521,7 @@ public class Workspace extends SmoothPagedView mWorkspaceScreens.remove(EXTRA_EMPTY_SCREEN_ID); mScreenOrder.remove(EXTRA_EMPTY_SCREEN_ID); - long newId = LauncherAppState.getInstance().getLauncherProvider().generateNewScreenId(); + long newId = LauncherAppState.getLauncherProvider().generateNewScreenId(); mWorkspaceScreens.put(newId, cl); mScreenOrder.add(newId); @@ -874,7 +866,6 @@ public class Workspace extends SmoothPagedView // Only show page outlines as we pan if we are on large screen if (LauncherAppState.getInstance().isScreenLarge()) { showOutlines(); - mIsStaticWallpaper = mWallpaperManager.getWallpaperInfo() == null; } // If we are not fading in adjacent screens, we still need to restore the alpha in case the @@ -944,55 +935,9 @@ public class Workspace extends SmoothPagedView Launcher.setScreen(mCurrentPage); }; - // As a ratio of screen height, the total distance we want the parallax effect to span - // horizontally - private float wallpaperTravelToScreenWidthRatio(int width, int height) { - float aspectRatio = width / (float) height; - - // At an aspect ratio of 16/10, the wallpaper parallax effect should span 1.5 * screen width - // At an aspect ratio of 10/16, the wallpaper parallax effect should span 1.2 * screen width - // We will use these two data points to extrapolate how much the wallpaper parallax effect - // to span (ie travel) at any aspect ratio: - - final float ASPECT_RATIO_LANDSCAPE = 16/10f; - final float ASPECT_RATIO_PORTRAIT = 10/16f; - final float WALLPAPER_WIDTH_TO_SCREEN_RATIO_LANDSCAPE = 1.5f; - final float WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT = 1.2f; - - // To find out the desired width at different aspect ratios, we use the following two - // formulas, where the coefficient on x is the aspect ratio (width/height): - // (16/10)x + y = 1.5 - // (10/16)x + y = 1.2 - // We solve for x and y and end up with a final formula: - final float x = - (WALLPAPER_WIDTH_TO_SCREEN_RATIO_LANDSCAPE - WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT) / - (ASPECT_RATIO_LANDSCAPE - ASPECT_RATIO_PORTRAIT); - final float y = WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT - x * ASPECT_RATIO_PORTRAIT; - return x * aspectRatio + y; - } - protected void setWallpaperDimension() { - Point minDims = new Point(); - Point maxDims = new Point(); - mLauncher.getWindowManager().getDefaultDisplay().getCurrentSizeRange(minDims, maxDims); - - final int maxDim = Math.max(maxDims.x, maxDims.y); - final int minDim = Math.min(minDims.x, minDims.y); - - // We need to ensure that there is enough extra space in the wallpaper for the intended - // parallax effects - if (LauncherAppState.getInstance().isScreenLarge()) { - mWallpaperWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim)); - mWallpaperHeight = maxDim; - } else { - mWallpaperWidth = Math.max((int) (minDim * WALLPAPER_SCREENS_SPAN), maxDim); - mWallpaperHeight = maxDim; - } - new Thread("setWallpaperDimension") { - public void run() { - mWallpaperManager.suggestDesiredDimensions(mWallpaperWidth, mWallpaperHeight); - } - }.start(); + WallpaperPickerActivity.suggestWallpaperDimension(mLauncher.getResources(), + mLauncher.getSharedPrefs(), mLauncher.getWindowManager(), mWallpaperManager); } private void syncWallpaperOffsetWithScroll() { -- cgit v1.2.3