diff options
author | Marco Nelissen <marcone@google.com> | 2009-11-09 15:21:13 -0800 |
---|---|---|
committer | Marco Nelissen <marcone@google.com> | 2009-11-09 17:39:33 -0800 |
commit | bf6956b1d95442e9d9c483894d578fe6b7044cbb (patch) | |
tree | dd8e921d31d3182c90eba295bea96848cb221e06 /core/java/android | |
parent | e6ab011b8b8aa6c461e64cabb9b25d890d68edb1 (diff) | |
download | frameworks_base-bf6956b1d95442e9d9c483894d578fe6b7044cbb.zip frameworks_base-bf6956b1d95442e9d9c483894d578fe6b7044cbb.tar.gz frameworks_base-bf6956b1d95442e9d9c483894d578fe6b7044cbb.tar.bz2 |
Add a way for wallpapers to know the delta between virtual screens.
Diffstat (limited to 'core/java/android')
-rw-r--r-- | core/java/android/app/WallpaperManager.java | 21 | ||||
-rw-r--r-- | core/java/android/service/wallpaper/WallpaperService.java | 14 | ||||
-rw-r--r-- | core/java/android/view/IWindow.aidl | 2 | ||||
-rw-r--r-- | core/java/android/view/IWindowSession.aidl | 4 | ||||
-rw-r--r-- | core/java/android/view/ViewRoot.java | 3 |
5 files changed, 36 insertions, 8 deletions
diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java index 66a3396..e98b286 100644 --- a/core/java/android/app/WallpaperManager.java +++ b/core/java/android/app/WallpaperManager.java @@ -53,6 +53,8 @@ import java.io.InputStream; public class WallpaperManager { private static String TAG = "WallpaperManager"; private static boolean DEBUG = false; + private float mWallpaperXStep = -1; + private float mWallpaperYStep = -1; /** * Launch an activity for the user to pick the current global live @@ -575,14 +577,14 @@ public class WallpaperManager { * @param windowToken The window who these offsets should be associated * with, as returned by {@link android.view.View#getWindowToken() * View.getWindowToken()}. - * @param xOffset The offset olong the X dimension, from 0 to 1. + * @param xOffset The offset along the X dimension, from 0 to 1. * @param yOffset The offset along the Y dimension, from 0 to 1. */ public void setWallpaperOffsets(IBinder windowToken, float xOffset, float yOffset) { try { //Log.v(TAG, "Sending new wallpaper offsets from app..."); ViewRoot.getWindowSession(mContext.getMainLooper()).setWallpaperPosition( - windowToken, xOffset, yOffset); + windowToken, xOffset, yOffset, mWallpaperXStep, mWallpaperYStep); //Log.v(TAG, "...app returning after sending offsets!"); } catch (RemoteException e) { // Ignore. @@ -590,6 +592,19 @@ public class WallpaperManager { } /** + * For applications that use multiple virtual screens showing a wallpaper, + * specify the step size between virtual screens. For example, if the + * launcher has 5 virtual screens, it would specify an xStep of 0.5, + * since the X offset for those screens are 0.0, 0.5 and 1.0 + * @param xStep The X offset delta from one screen to the next one + * @param yStep The Y offset delta from one screen to the next one + */ + public void setWallpaperOffsetSteps(float xStep, float yStep) { + mWallpaperXStep = xStep; + mWallpaperYStep = yStep; + } + + /** * Send an arbitrary command to the current active wallpaper. * * @param windowToken The window who these offsets should be associated @@ -627,7 +642,7 @@ public class WallpaperManager { public void clearWallpaperOffsets(IBinder windowToken) { try { ViewRoot.getWindowSession(mContext.getMainLooper()).setWallpaperPosition( - windowToken, -1, -1); + windowToken, -1, -1, -1, -1); } catch (RemoteException e) { // Ignore. } diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index 573be1e..e79832b 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -134,6 +134,8 @@ public abstract class WallpaperService extends Service { boolean mOffsetMessageEnqueued; float mPendingXOffset; float mPendingYOffset; + float mPendingXOffsetStep; + float mPendingYOffsetStep; boolean mPendingSync; MotionEvent mPendingMove; @@ -227,11 +229,14 @@ public abstract class WallpaperService extends Service { } @Override - public void dispatchWallpaperOffsets(float x, float y, boolean sync) { + public void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep, + boolean sync) { synchronized (mLock) { if (DEBUG) Log.v(TAG, "Dispatch wallpaper offsets: " + x + ", " + y); mPendingXOffset = x; mPendingYOffset = y; + mPendingXOffsetStep = xStep; + mPendingYOffsetStep = yStep; if (sync) { mPendingSync = true; } @@ -360,6 +365,7 @@ public abstract class WallpaperService extends Service { * WallpaperManager.setWallpaperOffsets()}. */ public void onOffsetsChanged(float xOffset, float yOffset, + float xOffsetStep, float yOffsetStep, int xPixelOffset, int yPixelOffset) { } @@ -608,10 +614,14 @@ public abstract class WallpaperService extends Service { float xOffset; float yOffset; + float xOffsetStep; + float yOffsetStep; boolean sync; synchronized (mLock) { xOffset = mPendingXOffset; yOffset = mPendingYOffset; + xOffsetStep = mPendingXOffsetStep; + yOffsetStep = mPendingYOffsetStep; sync = mPendingSync; mPendingSync = false; mOffsetMessageEnqueued = false; @@ -622,7 +632,7 @@ public abstract class WallpaperService extends Service { final int xPixels = availw > 0 ? -(int)(availw*xOffset+.5f) : 0; final int availh = mIWallpaperEngine.mReqHeight-mCurHeight; final int yPixels = availh > 0 ? -(int)(availh*yOffset+.5f) : 0; - onOffsetsChanged(xOffset, yOffset, xPixels, yPixels); + onOffsetsChanged(xOffset, yOffset, xOffsetStep, yOffsetStep, xPixels, yPixels); if (sync) { try { diff --git a/core/java/android/view/IWindow.aidl b/core/java/android/view/IWindow.aidl index 6bfc8b5..71302cb 100644 --- a/core/java/android/view/IWindow.aidl +++ b/core/java/android/view/IWindow.aidl @@ -62,7 +62,7 @@ oneway interface IWindow { /** * Called for wallpaper windows when their offsets change. */ - void dispatchWallpaperOffsets(float x, float y, boolean sync); + void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep, boolean sync); void dispatchWallpaperCommand(String action, int x, int y, int z, in Bundle extras, boolean sync); diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl index 7e7a38f..b6b009b 100644 --- a/core/java/android/view/IWindowSession.aidl +++ b/core/java/android/view/IWindowSession.aidl @@ -113,8 +113,10 @@ interface IWindowSession { /** * For windows with the wallpaper behind them, and the wallpaper is * larger than the screen, set the offset within the screen. + * For multi screen launcher type applications, xstep and ystep indicate + * how big the increment is from one screen to another. */ - void setWallpaperPosition(IBinder windowToken, float x, float y); + void setWallpaperPosition(IBinder windowToken, float x, float y, float xstep, float ystep); void wallpaperOffsetsComplete(IBinder window); diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java index f4593f5..bef3e58 100644 --- a/core/java/android/view/ViewRoot.java +++ b/core/java/android/view/ViewRoot.java @@ -2895,7 +2895,8 @@ public final class ViewRoot extends Handler implements ViewParent, } } - public void dispatchWallpaperOffsets(float x, float y, boolean sync) { + public void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep, + boolean sync) { if (sync) { try { sWindowSession.wallpaperOffsetsComplete(asBinder()); |