am 11cff8cd: Merge change Ie211adae into eclair
Merge commit '11cff8cd30f03b5adb137e985532543da5e960c4' into eclair-mr2 * commit '11cff8cd30f03b5adb137e985532543da5e960c4': Add a way for wallpapers to know the delta between virtual screens.
This commit is contained in:
@@ -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,20 +577,33 @@ 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.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@@ -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.
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -2896,7 +2896,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());
|
||||
|
||||
@@ -102,6 +102,7 @@ public class ImageWallpaper extends WallpaperService {
|
||||
|
||||
@Override
|
||||
public void onOffsetsChanged(float xOffset, float yOffset,
|
||||
float xOffsetStep, float yOffsetStep,
|
||||
int xPixels, int yPixels) {
|
||||
mXOffset = xOffset;
|
||||
mYOffset = yOffset;
|
||||
|
||||
@@ -94,7 +94,7 @@ public class BaseIWindow extends IWindow.Stub {
|
||||
public void closeSystemDialogs(String reason) {
|
||||
}
|
||||
|
||||
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 {
|
||||
mSession.wallpaperOffsetsComplete(asBinder());
|
||||
|
||||
Reference in New Issue
Block a user