From 36cf7017848b5a21fdf5fde2eb57785efdcada4b Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Wed, 24 Nov 2010 14:39:49 -0800 Subject: [PATCH] New back behavior The home icon on action bar and the system back key work slightly differently on portrait. home: full-screen message view -> mailbox list + message list back: full-screen message view -> expanded message list -> mailbox list + message list Bug 3228524 Change-Id: I9bb598315ee829c6a8300a35d194a29c7a26291f --- src/com/android/email/activity/MessageListXL.java | 10 +++++----- .../activity/MessageListXLFragmentManager.java | 9 +++++---- .../android/email/activity/ThreePaneLayout.java | 15 +++++++++++++-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/com/android/email/activity/MessageListXL.java b/src/com/android/email/activity/MessageListXL.java index 2879e58b4..82bfbde45 100644 --- a/src/com/android/email/activity/MessageListXL.java +++ b/src/com/android/email/activity/MessageListXL.java @@ -225,14 +225,14 @@ public class MessageListXL extends Activity implements /** * Performs the back action. * - * @param mayCloseActivity if true, the activity will close if it's already on top of the - * internal back state stack. + * @param isSystemBackKey set true if the system back key is pressed, rather than the home + * icon on action bar. */ - private boolean onBackPressed(boolean mayCloseActivity) { - if (mFragmentManager.onBackPressed()) { + private boolean onBackPressed(boolean isSystemBackKey) { + if (mFragmentManager.onBackPressed(isSystemBackKey)) { return true; } - if (mayCloseActivity) { + if (isSystemBackKey) { // Perform the default behavior. super.onBackPressed(); return true; diff --git a/src/com/android/email/activity/MessageListXLFragmentManager.java b/src/com/android/email/activity/MessageListXLFragmentManager.java index efe29663b..72f4f27d0 100644 --- a/src/com/android/email/activity/MessageListXLFragmentManager.java +++ b/src/com/android/email/activity/MessageListXLFragmentManager.java @@ -346,12 +346,13 @@ class MessageListXLFragmentManager { } /** - * Handles back press. + * Handles the back event. * - * @return true "back" is handled. + * @param isSystemBackKey See {@link ThreePaneLayout#onBackPressed} + * @return true if the event is handled. */ - public boolean onBackPressed() { - return mThreePane.onBackPressed(); + public boolean onBackPressed(boolean isSystemBackKey) { + return mThreePane.onBackPressed(isSystemBackKey); } /** diff --git a/src/com/android/email/activity/ThreePaneLayout.java b/src/com/android/email/activity/ThreePaneLayout.java index 98e29630b..a17cafe1d 100644 --- a/src/com/android/email/activity/ThreePaneLayout.java +++ b/src/com/android/email/activity/ThreePaneLayout.java @@ -212,7 +212,14 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene return ret; } - public boolean onBackPressed() { + /** + * Handles the back event. + * + * @param isSystemBackKey set true if the system back key is pressed, rather than the home + * icon on action bar. + * @return true if the event is handled. + */ + public boolean onBackPressed(boolean isSystemBackKey) { if (isLandscape()) { switch (mPaneState) { case STATE_RIGHT_VISIBLE: @@ -222,7 +229,11 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene } else { switch (mPaneState) { case STATE_RIGHT_VISIBLE: - changePaneState(STATE_PORTRAIT_MIDDLE_EXPANDED, true); + if (isSystemBackKey) { + changePaneState(STATE_LEFT_VISIBLE, true); + } else { + changePaneState(STATE_PORTRAIT_MIDDLE_EXPANDED, true); + } return true; case STATE_PORTRAIT_MIDDLE_EXPANDED: changePaneState(STATE_LEFT_VISIBLE, true);