From d3c9704d3efee8a64de321aa96bc49013f2db7f3 Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Mon, 28 Feb 2011 21:25:37 -0800 Subject: Fix bug 3497307 - Fix issues with FEATURE_ACTION_MODE_OVERLAY Properly close down overlay windows when decor is detached. Delay opening popup overlays to prevent issues when restoring instance state. Change-Id: I7ff44ce65e78c0172a12a9ddfe11460c885593ca --- .../com/android/internal/policy/impl/PhoneWindow.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'policy') diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java index b746c37..d342d66 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java @@ -1601,6 +1601,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { private ActionMode mActionMode; private ActionBarContextView mActionModeView; private PopupWindow mActionModePopup; + private Runnable mShowActionModePopup; public DecorView(Context context, int featureId) { super(context); @@ -1976,6 +1977,12 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { final int height = TypedValue.complexToDimensionPixelSize(heightValue.data, mContext.getResources().getDisplayMetrics()); mActionModePopup.setHeight(height); + mShowActionModePopup = new Runnable() { + public void run() { + mActionModePopup.showAtLocation(PhoneWindow.DecorView.this, + Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0); + } + }; } else { ViewStub stub = (ViewStub) findViewById( com.android.internal.R.id.action_mode_bar_stub); @@ -1994,8 +2001,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { mActionModeView.setVisibility(View.VISIBLE); mActionMode = mode; if (mActionModePopup != null) { - mActionModePopup.showAtLocation(this, - Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0); + post(mShowActionModePopup); } } else { mActionMode = null; @@ -2183,6 +2189,14 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } mActionButtonPopup = null; } + + if (mActionModePopup != null) { + removeCallbacks(mShowActionModePopup); + if (mActionModePopup.isShowing()) { + mActionModePopup.dismiss(); + } + mActionModePopup = null; + } } @Override @@ -2246,6 +2260,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { public void onDestroyActionMode(ActionMode mode) { mWrapped.onDestroyActionMode(mode); if (mActionModePopup != null) { + removeCallbacks(mShowActionModePopup); mActionModePopup.dismiss(); } else if (mActionModeView != null) { mActionModeView.setVisibility(GONE); -- cgit v1.1