From 61b18eb2569e3d2cec85a414f83d036c17e9029f Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Wed, 13 Oct 2010 06:10:09 -0700 Subject: Send tap commands when previewing live wallpapers. This enables live wallpapers that rely on tap commands for user interaction to work during live preview. Change-Id: I3dad37702c71ae491bb2fd06edc7544515f6e3fb --- .../wallpaper/livepicker/LiveWallpaperPreview.java | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/com/android') diff --git a/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java b/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java index a8c91be..54b6382 100644 --- a/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java +++ b/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java @@ -196,10 +196,28 @@ public class LiveWallpaperPreview extends Activity { if (ev.getAction() == MotionEvent.ACTION_DOWN) { onUserInteraction(); } - if (getWindow().superDispatchTouchEvent(ev)) { - return true; + boolean handled = getWindow().superDispatchTouchEvent(ev); + if (!handled) { + handled = onTouchEvent(ev); } - return onTouchEvent(ev); + + if (!handled && mWallpaperConnection != null && mWallpaperConnection.mEngine != null) { + int action = ev.getActionMasked(); + try { + if (action == MotionEvent.ACTION_UP) { + mWallpaperConnection.mEngine.dispatchWallpaperCommand( + WallpaperManager.COMMAND_TAP, + (int) ev.getX(), (int) ev.getY(), 0, null); + } else if (action == MotionEvent.ACTION_POINTER_UP) { + int pointerIndex = ev.getActionIndex(); + mWallpaperConnection.mEngine.dispatchWallpaperCommand( + WallpaperManager.COMMAND_SECONDARY_TAP, + (int) ev.getX(pointerIndex), (int) ev.getY(pointerIndex), 0, null); + } + } catch (RemoteException e) { + } + } + return handled; } class WallpaperConnection extends IWallpaperConnection.Stub implements ServiceConnection { -- cgit v1.2.3