Bug 717681: The URL bar adds a black line on rotation and screen lock. [r=mfinkle]
authorSriram Ramasubramanian <sriram@mozilla.com>
Mon, 30 Jan 2012 15:10:16 -0800
changeset 86988 cfa6e7eff71f8d0ca66197b0b1c486c1bf27fcc6
parent 86987 27f749dda6fd87d3f20981b8e151f304364011b6
child 86989 6d180635060d2f324fdace497c98bad8fea91a23
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs717681
milestone12.0a1
Bug 717681: The URL bar adds a black line on rotation and screen lock. [r=mfinkle]
mobile/android/base/BrowserToolbar.java
mobile/android/base/GeckoApp.java
mobile/android/base/resources/drawable/address_bar_bg.xml
--- a/mobile/android/base/BrowserToolbar.java
+++ b/mobile/android/base/BrowserToolbar.java
@@ -312,9 +312,21 @@ public class BrowserToolbar extends Line
     public void setSecurityMode(String mode) {
         if (mode.equals("identified"))
             mSiteSecurity.setImageLevel(1);
         else if (mode.equals("verified"))
             mSiteSecurity.setImageLevel(2);
         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());
+        }
+    }
 }
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -1441,16 +1441,30 @@ abstract public class GeckoApp
                 // Hide/show the system notification bar
                 getWindow().setFlags(fullscreen ?
                                      WindowManager.LayoutParams.FLAG_FULLSCREEN : 0,
                                      WindowManager.LayoutParams.FLAG_FULLSCREEN);
             }
         });
     }
 
+    // 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)
     {
         mAppContext = this;
 
         // StrictMode is set by defaults resource flag |enableStrictMode|.
         if (getResources().getBoolean(R.bool.enableStrictMode)) {
@@ -1526,24 +1540,17 @@ abstract public class GeckoApp
 
         super.onCreate(savedInstanceState);
 
         setContentView(R.layout.gecko_app);
 
         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);
         }
 
         mBrowserToolbar.setTitle(mLastTitle);
 
         mFavicons = new Favicons(this);
 
@@ -1894,16 +1901,23 @@ abstract public class GeckoApp
     {
         Log.i(LOGTAG, "resume");
         if (checkLaunchState(LaunchState.GeckoRunning))
             GeckoAppShell.onResume();
         // After an onPause, the activity is back in the foreground.
         // 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());
 
         registerReceiver(mConnectivityReceiver, mConnectivityFilter);
         GeckoNetworkManager.getInstance().start();
 
         if (mOwnActivityDepth > 0)
@@ -2007,33 +2021,17 @@ abstract public class GeckoApp
     {
         Log.i(LOGTAG, "configuration changed");
 
         super.onConfigurationChanged(newConfig);
 
         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();
         }
     }
 
     @Override
     public void onLowMemory()
     {
         Log.e(LOGTAG, "low memory");
         if (checkLaunchState(LaunchState.GeckoRunning))
--- a/mobile/android/base/resources/drawable/address_bar_bg.xml
+++ b/mobile/android/base/resources/drawable/address_bar_bg.xml
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="utf-8"?>
 <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
 
     <item android:right="34dp">
         <bitmap xmlns:android="http://schemas.android.com/apk/res/android"
             android:src="@drawable/address_bar_texture"
-            android:tileMode="mirror"
+            android:tileMode="repeat"
             android:dither="false"/>
      </item>
 
 </layer-list>