Fix bug 3240444 - add OnMenuVisibilityListener for action bar.

Fix bug 3180015 - leaking window handles on configuration change for
action bar dropdown menus

Rename ActionBar.NavigationCallback to something more consistent with
the rest of the API.

Change-Id: Ic1fb4c07484c57a72649b30e27d220b18cda6cdf
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index d69a179..6b619fb 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -2362,6 +2362,9 @@
      * @return The default implementation returns true.
      */
     public boolean onMenuOpened(int featureId, Menu menu) {
+        if (featureId == Window.FEATURE_ACTION_BAR) {
+            mActionBar.dispatchMenuVisibilityChanged(true);
+        }
         return true;
     }
 
@@ -2392,7 +2395,7 @@
                     return true;
                 }
                 return mFragments.dispatchContextItemSelected(item);
-                
+
             default:
                 return false;
         }
@@ -2417,6 +2420,10 @@
             case Window.FEATURE_CONTEXT_MENU:
                 onContextMenuClosed(menu);
                 break;
+
+            case Window.FEATURE_ACTION_BAR:
+                mActionBar.dispatchMenuVisibilityChanged(false);
+                break;
         }
     }