diff --git a/mobile/android/base/BrowserToolbar.java b/mobile/android/base/BrowserToolbar.java index efeb983c918..b7577d3a5e3 100644 --- a/mobile/android/base/BrowserToolbar.java +++ b/mobile/android/base/BrowserToolbar.java @@ -317,4 +317,16 @@ public class BrowserToolbar extends LinearLayout { else mSiteSecurity.setImageLevel(0); } + + public void refresh() { + Tab tab = Tabs.getInstance().getSelectedTab(); + if (tab != null) { + setTitle(tab.getDisplayTitle()); + setFavicon(tab.getFavicon()); + setSecurityMode(tab.getSecurityMode()); + setProgressVisibility(tab.isLoading()); + setShadowVisibility(!(tab.getURL().startsWith("about:"))); + updateTabs(Tabs.getInstance().getCount()); + } + } } diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index dc184f9b9aa..db2ae701262 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -1446,6 +1446,20 @@ abstract public class GeckoApp }); } + // The ActionBar needs to be refreshed on rotation as different orientation uses different resources + public void refreshActionBar() { + if (Build.VERSION.SDK_INT >= 11) { + mBrowserToolbar = (BrowserToolbar) getLayoutInflater().inflate(R.layout.browser_toolbar, null); + mBrowserToolbar.refresh(); + GeckoActionBar.setBackgroundDrawable(this, getResources().getDrawable(R.drawable.gecko_actionbar_bg)); + GeckoActionBar.setDisplayOptions(this, ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM | + ActionBar.DISPLAY_SHOW_HOME | + ActionBar.DISPLAY_SHOW_TITLE | + ActionBar.DISPLAY_USE_LOGO); + GeckoActionBar.setCustomView(this, mBrowserToolbar); + } + } + /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) @@ -1531,14 +1545,7 @@ abstract public class GeckoApp mOrientation = getResources().getConfiguration().orientation; if (Build.VERSION.SDK_INT >= 11) { - mBrowserToolbar = (BrowserToolbar) getLayoutInflater().inflate(R.layout.browser_toolbar, null); - - GeckoActionBar.setBackgroundDrawable(this, getResources().getDrawable(R.drawable.gecko_actionbar_bg)); - GeckoActionBar.setDisplayOptions(this, ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM | - ActionBar.DISPLAY_SHOW_HOME | - ActionBar.DISPLAY_SHOW_TITLE | - ActionBar.DISPLAY_USE_LOGO); - GeckoActionBar.setCustomView(this, mBrowserToolbar); + refreshActionBar(); } else { mBrowserToolbar = (BrowserToolbar) findViewById(R.id.browser_toolbar); } @@ -1899,6 +1906,13 @@ abstract public class GeckoApp // Undo whatever we did in onPause. super.onResume(); + int newOrientation = getResources().getConfiguration().orientation; + + if (mOrientation != newOrientation) { + mOrientation = newOrientation; + refreshActionBar(); + } + // Just in case. Normally we start in onNewIntent if (checkLaunchState(LaunchState.Launching)) onNewIntent(getIntent()); @@ -2012,23 +2026,7 @@ abstract public class GeckoApp if (mOrientation != newConfig.orientation) { mOrientation = newConfig.orientation; mAutoCompletePopup.hide(); - - if (Build.VERSION.SDK_INT >= 11) { - mBrowserToolbar = (BrowserToolbar) getLayoutInflater().inflate(R.layout.browser_toolbar, null); - - Tab tab = Tabs.getInstance().getSelectedTab(); - if (tab != null) { - mBrowserToolbar.setTitle(tab.getDisplayTitle()); - mBrowserToolbar.setFavicon(tab.getFavicon()); - mBrowserToolbar.setSecurityMode(tab.getSecurityMode()); - mBrowserToolbar.setProgressVisibility(tab.isLoading()); - mBrowserToolbar.setShadowVisibility(!(tab.getURL().startsWith("about:"))); - mBrowserToolbar.updateTabs(Tabs.getInstance().getCount()); - } - - GeckoActionBar.setBackgroundDrawable(this, getResources().getDrawable(R.drawable.gecko_actionbar_bg)); - GeckoActionBar.setCustomView(mAppContext, mBrowserToolbar); - } + refreshActionBar(); } } diff --git a/mobile/android/base/resources/drawable/address_bar_bg.xml b/mobile/android/base/resources/drawable/address_bar_bg.xml index 5a834f690c5..8ea0341968b 100644 --- a/mobile/android/base/resources/drawable/address_bar_bg.xml +++ b/mobile/android/base/resources/drawable/address_bar_bg.xml @@ -4,7 +4,7 @@