diff options
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/cyanogenmod/trebuchet/Launcher.java | 13 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/Workspace.java | 72 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java | 4 |
3 files changed, 84 insertions, 5 deletions
diff --git a/src/com/cyanogenmod/trebuchet/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java index 9ef20c6..e5ef20e 100644 --- a/src/com/cyanogenmod/trebuchet/Launcher.java +++ b/src/com/cyanogenmod/trebuchet/Launcher.java @@ -311,6 +311,8 @@ public final class Launcher extends Activity private boolean mHideIconLabels; private boolean mAutoRotate; + private boolean mWallpaperVisible; + private Runnable mBuildLayersRunnable = new Runnable() { public void run() { if (mWorkspace != null) { @@ -772,6 +774,7 @@ public final class Launcher extends Activity // (framework issue). On resuming, we ensure that any widgets are inflated for the current // orientation. getWorkspace().reinflateWidgetsIfNecessary(); + getWorkspace().checkWallpaper(); // Again, as with the above scenario, it's possible that one or more of the global icons // were updated in the wrong orientation. @@ -1251,6 +1254,8 @@ public final class Launcher extends Activity } else if (Intent.ACTION_USER_PRESENT.equals(action)) { mUserPresent = true; updateRunning(); + } else if (Intent.ACTION_SET_WALLPAPER.equals(action)) { + mWorkspace.checkWallpaper(); } } }; @@ -1263,6 +1268,7 @@ public final class Launcher extends Activity final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_USER_PRESENT); + filter.addAction(Intent.ACTION_SET_WALLPAPER); registerReceiver(mReceiver, filter); mAttached = true; @@ -2469,8 +2475,13 @@ public final class Launcher extends Activity } } + void setWallpaperVisibility(boolean visible) { + mWallpaperVisible = visible; + updateWallpaperVisibility(visible); + } + void updateWallpaperVisibility(boolean visible) { - int wpflags = visible ? WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER : 0; + int wpflags = visible && mWallpaperVisible ? WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER : 0; int curflags = getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; if (wpflags != curflags) { diff --git a/src/com/cyanogenmod/trebuchet/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java index e404b5c..bcaaccf 100644 --- a/src/com/cyanogenmod/trebuchet/Workspace.java +++ b/src/com/cyanogenmod/trebuchet/Workspace.java @@ -36,10 +36,12 @@ import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Matrix; +import android.graphics.Paint; import android.graphics.Point; import android.graphics.PointF; import android.graphics.Rect; import android.graphics.Region.Op; +import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.IBinder; @@ -106,8 +108,14 @@ public class Workspace extends SmoothPagedView private int mOriginalPageSpacing; private final WallpaperManager mWallpaperManager; + private boolean mWallpaperHack; + private Bitmap mWallpaperBitmap; + private float mWallpaperScrollX; + private float mWallpaperScrollY; + private int[] mWallpaperOffsets = new int[2]; + private Paint mPaint = new Paint(); private IBinder mWindowToken; - private static final float WALLPAPER_SCREENS_SPAN = 2f; + private static final float DEFAULT_WALLPAPER_SCREENS_SPAN = 2f; /** * CellInfo for the cell that is currently being dragged @@ -349,17 +357,20 @@ public class Workspace extends SmoothPagedView if (mDefaultHomescreen >= mNumberHomescreens) { mDefaultHomescreen = mNumberHomescreens / 2; } + mScreenPaddingVertical = PreferencesProvider.Interface.Homescreen.getScreenPaddingVertical(context); mScreenPaddingHorizontal = PreferencesProvider.Interface.Homescreen.getScreenPaddingHorizontal(context); mShowSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar(context); mResizeAnyWidget = PreferencesProvider.Interface.Homescreen.getResizeAnyWidget(context); mHideIconLabels = PreferencesProvider.Interface.Homescreen.getHideIconLabels(context); mScrollWallpaper = PreferencesProvider.Interface.Homescreen.Scrolling.getScrollWallpaper(context); + mWallpaperHack = PreferencesProvider.Interface.Homescreen.Scrolling.getWallpaperHack(context); mShowScrollingIndicator = PreferencesProvider.Interface.Homescreen.Indicator.getShowScrollingIndicator(context); mFadeScrollingIndicator = PreferencesProvider.Interface.Homescreen.Indicator.getFadeScrollingIndicator(context); mShowDockDivider = PreferencesProvider.Interface.Homescreen.Indicator.getShowDockDivider(context); initWorkspace(); + checkWallpaper(); // Disable multitouch across the workspace/all apps/customize tray setMotionEventSplittingEnabled(true); @@ -503,6 +514,21 @@ public class Workspace extends SmoothPagedView mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * mDensity); } + protected void checkWallpaper() { + if (mWallpaperHack) { + if (mWallpaperBitmap != null) { + mWallpaperBitmap = null; + } + if (mWallpaperManager.getWallpaperInfo() == null) { + Drawable wallpaper = mWallpaperManager.getDrawable(); + if (wallpaper instanceof BitmapDrawable) { + mWallpaperBitmap = ((BitmapDrawable) wallpaper).getBitmap(); + } + } + } + mLauncher.setWallpaperVisibility(mWallpaperBitmap == null); + } + @Override protected int getScrollMode() { return SmoothPagedView.X_LARGE_MODE; @@ -943,7 +969,7 @@ public class Workspace extends SmoothPagedView mWallpaperWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim)); mWallpaperHeight = maxDim; } else { - mWallpaperWidth = Math.max((int) (minDim * WALLPAPER_SCREENS_SPAN), maxDim); + mWallpaperWidth = Math.max((int) (minDim * DEFAULT_WALLPAPER_SCREENS_SPAN), maxDim); mWallpaperHeight = maxDim; } new Thread("setWallpaperDimension") { @@ -995,7 +1021,9 @@ public class Workspace extends SmoothPagedView } private void centerWallpaperOffset() { - if (mWindowToken != null) { + if (mWallpaperHack) { + mWallpaperScrollX = 0.5f; + } else if (mWindowToken != null) { mWallpaperManager.setWallpaperOffsetSteps(0.5f, 0); mWallpaperManager.setWallpaperOffsets(mWindowToken, 0.5f, 0); } @@ -1017,7 +1045,10 @@ public class Workspace extends SmoothPagedView updateNow = keepUpdating = mWallpaperOffset.computeScrollOffset(); } if (updateNow) { - if (mWindowToken != null) { + if (mWallpaperHack) { + mWallpaperScrollX = mWallpaperOffset.getCurrX(); + mWallpaperScrollY = mWallpaperOffset.getCurrY(); + } else if (mWindowToken != null) { mWallpaperManager.setWallpaperOffsets(mWindowToken, mWallpaperOffset.getCurrX(), mWallpaperOffset.getCurrY()); } @@ -1391,12 +1422,45 @@ public class Workspace extends SmoothPagedView super.onLayout(changed, left, top, right, bottom); } + + protected void onSizeChanged (int w, int h, int oldw, int oldh) { + super.onSizeChanged(w, h, oldw, oldh); + + getLocationOnScreen(mWallpaperOffsets); + } + @Override protected void onDraw(Canvas canvas) { if (mScrollWallpaper) { updateWallpaperOffsets(); } + // Draw the wallpaper if necessary + if (mWallpaperHack && mWallpaperBitmap != null) { + float x = getScrollX(); + float y = getScrollY(); + + int width = getWidth(); + int height = getHeight(); + int wallpaperWidth = mWallpaperBitmap.getWidth(); + int wallpaperHeight = mWallpaperBitmap.getHeight(); + + if (width + mWallpaperOffsets[0] > wallpaperWidth) { + // Wallpaper is smaller than screen + x += (width - wallpaperWidth) / 2; + } else { + x -= mWallpaperScrollX * (wallpaperWidth - width) + mWallpaperOffsets[0]; + } + if (height + mWallpaperOffsets[1] > wallpaperHeight) { + // Wallpaper is smaller than screen + y += (height - wallpaperHeight) / 2; + } else { + y -= mWallpaperScrollY * (wallpaperHeight - height) + mWallpaperOffsets[1]; + } + + canvas.drawBitmap(mWallpaperBitmap, x, y, mPaint); + } + // Draw the background gradient if necessary if (mBackground != null && mBackgroundAlpha > 0.0f && mDrawBackground) { int alpha = (int) (mBackgroundAlpha * 255); diff --git a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java index b4228c3..b6c983b 100644 --- a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java +++ b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java @@ -83,6 +83,10 @@ public final class PreferencesProvider { final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0); return preferences.getBoolean("ui_homescreen_scrolling_scroll_wallpaper", true); } + public static boolean getWallpaperHack(Context context) { + final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0); + return preferences.getBoolean("ui_homescreen_scrolling_wallpaper_hack", true); + } } public static class Indicator { public static boolean getShowScrollingIndicator(Context context) { |