diff options
| author | Adam Powell <adamp@google.com> | 2011-07-15 21:33:11 -0700 | 
|---|---|---|
| committer | Adam Powell <adamp@google.com> | 2011-07-17 13:04:37 -0700 | 
| commit | b80d332e7421e0b8cff12569c2f1b450d769e782 (patch) | |
| tree | 1960934ceb8d3bf1b67503a2846e644cad4b4743 /policy | |
| parent | 8eb89cc7789314ea28f899def3fa34529724f80f (diff) | |
| download | frameworks_base-b80d332e7421e0b8cff12569c2f1b450d769e782.zip frameworks_base-b80d332e7421e0b8cff12569c2f1b450d769e782.tar.gz frameworks_base-b80d332e7421e0b8cff12569c2f1b450d769e782.tar.bz2  | |
Fix bug 5037642 - Refine back button behavior for action bar modes.
Action modes for the action bar used to aggressively hijack the back
button before the view hierarchy got a chance to respond to it. Loosen
this. New ordering is: view hierarchy => window feature-level modes
(action bar modes e.g. CAB/search) => Activity/window callback
behavior.
Change-Id: Iac1b22997713be968a94f77f9fa6cebaf6f923f0
Diffstat (limited to 'policy')
| -rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindow.java | 36 | 
1 files changed, 27 insertions, 9 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java index 4be00c5..b963b13 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java @@ -1668,14 +1668,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {                  }              } -            // Back cancels action modes first. -            if (mActionMode != null && keyCode == KeyEvent.KEYCODE_BACK) { -                if (action == KeyEvent.ACTION_UP) { -                    mActionMode.finish(); -                } -                return true; -            } -              if (!isDestroyed()) {                  final Callback cb = getCallback();                  final boolean handled = cb != null && mFeatureId < 0 ? cb.dispatchKeyEvent(event) @@ -1684,6 +1676,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {                      return true;                  }              } +              return isDown ? PhoneWindow.this.onKeyDown(mFeatureId, event.getKeyCode(), event)                      : PhoneWindow.this.onKeyUp(mFeatureId, event.getKeyCode(), event);          } @@ -1730,7 +1723,32 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {          }          public boolean superDispatchKeyEvent(KeyEvent event) { -            return super.dispatchKeyEvent(event); +            if (super.dispatchKeyEvent(event)) { +                return true; +            } + +            // Not handled by the view hierarchy, does the action bar want it +            // to cancel out of something special? +            if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { +                final int action = event.getAction(); +                // Back cancels action modes first. +                if (mActionMode != null) { +                    if (action == KeyEvent.ACTION_UP) { +                        mActionMode.finish(); +                    } +                    return true; +                } + +                // Next collapse any expanded action views. +                if (mActionBar != null && mActionBar.hasExpandedActionView()) { +                    if (action == KeyEvent.ACTION_UP) { +                        mActionBar.collapseActionView(); +                    } +                    return true; +                } +            } + +            return false;          }          public boolean superDispatchKeyShortcutEvent(KeyEvent event) {  | 
