From 8506afff2848d1e9b8c36dc9e1012ceedcc2f921 Mon Sep 17 00:00:00 2001 From: Ben Komalo Date: Wed, 21 Sep 2011 13:06:40 -0700 Subject: [PATCH] Avoid building/rebuilding the action tabs. Doing this on a tab callback confuses the action bar rendering. Bug: 5288508 Change-Id: Ifbba2c2a30f5def04ec36ea2395c0d6da2bdf00d --- .../email/activity/MessageCompose.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/com/android/email/activity/MessageCompose.java b/src/com/android/email/activity/MessageCompose.java index 8ee574f44..a3d6d721e 100644 --- a/src/com/android/email/activity/MessageCompose.java +++ b/src/com/android/email/activity/MessageCompose.java @@ -1801,11 +1801,12 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus if (shouldUseActionTabs()) { // Tab-based mode switching. if (actionBar.getTabCount() > 0) { - actionBar.removeAllTabs(); + selectActionTab(mAction); + } else { + createAndAddTab(R.string.reply_action, ACTION_REPLY); + createAndAddTab(R.string.reply_all_action, ACTION_REPLY_ALL); + createAndAddTab(R.string.forward_action, ACTION_FORWARD); } - createAndAddTab(R.string.reply_action, ACTION_REPLY); - createAndAddTab(R.string.reply_all_action, ACTION_REPLY_ALL); - createAndAddTab(R.string.forward_action, ACTION_FORWARD); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); } else { @@ -1912,6 +1913,17 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus return tab; } + private void selectActionTab(final String action) { + final ActionBar actionBar = getActionBar(); + for (int i = 0, n = actionBar.getTabCount(); i < n; i++) { + ActionBar.Tab tab = actionBar.getTabAt(i); + if (action.equals(tab.getTag())) { + actionBar.selectTab(tab); + return; + } + } + } + private boolean shouldUseActionTabs() { return getResources().getBoolean(R.bool.message_compose_action_tabs); }