summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorDaniel Sandler <dsandler@google.com>2010-10-08 15:13:22 -0400
committerDaniel Sandler <dsandler@google.com>2010-10-13 16:25:43 -0400
commite02d808abf370965c3c4e4d38af11bc69110fde2 (patch)
tree78e681d5f884ee5fd9a75f297b6c0384e6542a2c /policy
parent3f703de0fbc4a626eacc2973926a99bb8e4fe8e2 (diff)
downloadframeworks_base-e02d808abf370965c3c4e4d38af11bc69110fde2.zip
frameworks_base-e02d808abf370965c3c4e4d38af11bc69110fde2.tar.gz
frameworks_base-e02d808abf370965c3c4e4d38af11bc69110fde2.tar.bz2
Dynamically show the menu button on the system bar.
Windows with FLAG_NEEDS_MENU_KEY (or windowNeedsMenuKey=true in their theme) will cause the system bar to show a menu icon. (Note that the phone's status bar currently ignores this, but phones tend to have hardware menu keys anyway.) Additionally, all windows whose package's SDK version is pre-Honeycomb will have FLAG_NEEDS_MENU_KEY set by default. Bug: 3003728 Change-Id: I2d983763a726ea4f32cd1af9b0390e30478b11d1
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindow.java6
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/PhoneWindowManager.java35
2 files changed, 36 insertions, 5 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index 24c9443..db5f6c1 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -21,6 +21,7 @@ import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
+import static android.view.WindowManager.LayoutParams.FLAG_NEEDS_MENU_KEY;
import com.android.internal.view.BaseSurfaceHolder;
import com.android.internal.view.RootViewSurfaceTaker;
@@ -2324,6 +2325,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
setFlags(FLAG_SHOW_WALLPAPER, FLAG_SHOW_WALLPAPER&(~getForcedWindowFlags()));
}
+ if (getContext().getApplicationInfo().targetSdkVersion
+ < android.os.Build.VERSION_CODES.HONEYCOMB) {
+ addFlags(WindowManager.LayoutParams.FLAG_NEEDS_MENU_KEY);
+ }
+
WindowManager.LayoutParams params = getAttributes();
if (!hasSoftInputMode()) {
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 449bd4c..ec5b098 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -287,6 +287,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
Intent mDeskDockIntent;
boolean mSearchKeyPressed;
boolean mConsumeSearchKeyUp;
+ boolean mShowMenuKey = false; // track FLAG_NEEDS_MENU_KEY on frontmost window
// support for activating the lock screen while the screen is on
boolean mAllowLockscreenWhenOn;
@@ -1603,8 +1604,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
/** {@inheritDoc} */
public int finishAnimationLw() {
int changes = 0;
-
boolean topIsFullscreen = false;
+
+ final WindowManager.LayoutParams lp = (mTopFullscreenOpaqueWindowState != null)
+ ? mTopFullscreenOpaqueWindowState.getAttrs()
+ : null;
+
if (mStatusBar != null) {
if (localLOGV) Log.i(TAG, "force=" + mForceStatusBar
+ " top=" + mTopFullscreenOpaqueWindowState);
@@ -1612,7 +1617,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (DEBUG_LAYOUT) Log.v(TAG, "Showing status bar");
if (mStatusBar.showLw(true)) changes |= FINISH_LAYOUT_REDO_LAYOUT;
} else if (mTopFullscreenOpaqueWindowState != null) {
- final WindowManager.LayoutParams lp = mTopFullscreenOpaqueWindowState.getAttrs();
if (localLOGV) {
Log.d(TAG, "frame: " + mTopFullscreenOpaqueWindowState.getFrameLw()
+ " shown frame: " + mTopFullscreenOpaqueWindowState.getShownFrameLw());
@@ -1637,10 +1641,26 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
}
}
-
- if (topIsFullscreen != mTopIsFullscreen) {
+
+ boolean topNeedsMenu = mShowMenuKey;
+ if (lp != null) {
+ topNeedsMenu = (lp.flags & WindowManager.LayoutParams.FLAG_NEEDS_MENU_KEY) != 0;
+ }
+
+ if (DEBUG_LAYOUT) Log.v(TAG, "Top window "
+ + (topNeedsMenu ? "needs" : "does not need")
+ + " the MENU key");
+
+ final boolean changedFullscreen = (mTopIsFullscreen != topIsFullscreen);
+ final boolean changedMenu = (topNeedsMenu != mShowMenuKey);
+
+ if (changedFullscreen || changedMenu) {
final boolean topIsFullscreenF = topIsFullscreen;
+ final boolean topNeedsMenuF = topNeedsMenu;
+
mTopIsFullscreen = topIsFullscreen;
+ mShowMenuKey = topNeedsMenu;
+
mHandler.post(new Runnable() {
public void run() {
if (mStatusBarService == null) {
@@ -1654,7 +1674,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
final IStatusBarService sbs = mStatusBarService;
if (mStatusBarService != null) {
try {
- sbs.setActiveWindowIsFullscreen(topIsFullscreenF);
+ if (changedFullscreen) {
+ sbs.setActiveWindowIsFullscreen(topIsFullscreenF);
+ }
+ if (changedMenu) {
+ sbs.setMenuKeyVisible(topNeedsMenuF);
+ }
} catch (RemoteException e) {
// This should be impossible because we're in the same process.
mStatusBarService = null;