diff options
| author | Dianne Hackborn <hackbod@google.com> | 2011-01-18 21:56:45 -0800 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2011-01-18 21:56:45 -0800 |
| commit | 7fc5d4b8e7145413411da3320495388f09fab536 (patch) | |
| tree | f48771a1c24f02454388dd383285f80104342998 /core/java/android/view/Window.java | |
| parent | 7cca7e0b28679cf09ce6b56687c3a9679a6c7296 (diff) | |
| parent | 2ec5a7160b3d32887b2428edef7a751ee3700809 (diff) | |
am 2ec5a716: am 36c84403: Merge "Fix issue #3362484: Can\'t dismiss activity picker by tapping outside dialog" into honeycomb
* commit '2ec5a7160b3d32887b2428edef7a751ee3700809':
Fix issue #3362484: Can't dismiss activity picker by tapping outside dialog
Diffstat (limited to 'core/java/android/view/Window.java')
| -rw-r--r-- | core/java/android/view/Window.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java index 5cbaf2a69e9d..04dff8b3c895 100644 --- a/core/java/android/view/Window.java +++ b/core/java/android/view/Window.java @@ -116,6 +116,8 @@ public abstract class Window { private Window mActiveChild; private boolean mIsActive = false; private boolean mHasChildren = false; + private boolean mCloseOnTouchOutside = false; + private boolean mSetCloseOnTouchOutside = false; private int mForcedWindowFlags = 0; private int mFeatures = DEFAULT_FEATURES; @@ -798,6 +800,39 @@ public abstract class Window { return mHasSoftInputMode; } + /** @hide */ + public void setCloseOnTouchOutside(boolean close) { + mCloseOnTouchOutside = close; + mSetCloseOnTouchOutside = true; + } + + /** @hide */ + public boolean hasSetCloseOnTouchOutside() { + return mSetCloseOnTouchOutside; + } + + /** @hide */ + public abstract void alwaysReadCloseOnTouchAttr(); + + /** @hide */ + public boolean shouldCloseOnTouch(Context context, MotionEvent event) { + if (mCloseOnTouchOutside && event.getAction() == MotionEvent.ACTION_DOWN + && isOutOfBounds(context, event) && peekDecorView() != null) { + return true; + } + return false; + } + + private boolean isOutOfBounds(Context context, MotionEvent event) { + final int x = (int) event.getX(); + final int y = (int) event.getY(); + final int slop = ViewConfiguration.get(context).getScaledWindowTouchSlop(); + final View decorView = getDecorView(); + return (x < -slop) || (y < -slop) + || (x > (decorView.getWidth()+slop)) + || (y > (decorView.getHeight()+slop)); + } + /** * Enable extended screen features. This must be called before * setContentView(). May be called as many times as desired as long as it |
