OSDN Git Service

Set a title for pages with no title.
authorLeon Scroggins <scroggo@google.com>
Mon, 20 Jul 2009 17:38:47 +0000 (13:38 -0400)
committerLeon Scroggins <scroggo@google.com>
Mon, 20 Jul 2009 17:38:47 +0000 (13:38 -0400)
In the title bar, we were showing "Loading..." as the
title for a page that finished loading but still has no
title.  Now, display the url where the title is displayed
and display nothing for the url.

src/com/android/browser/TitleBar.java

index b818dd2..f534a03 100644 (file)
@@ -39,6 +39,7 @@ public class TitleBar extends LinearLayout {
     private ImageView       mFavicon;
     private ImageView       mLockIcon;
     private boolean         mInLoad;
+    private boolean         mTitleSet;
 
     public TitleBar(Context context) {
         this(context, null);
@@ -112,6 +113,11 @@ public class TitleBar extends LinearLayout {
             mRtButton.setVisibility(View.VISIBLE);
             mLftButton.setImageDrawable(mBookmarkDrawable);
             mInLoad = false;
+            if (!mTitleSet) {
+                mTitle.setText(mUrl.getText());
+                mUrl.setText(null);
+                mTitleSet = true;
+            }
         } else {
             mCircularProgress.setProgress(newProgress);
             mHorizontalProgress.setProgress(newProgress);
@@ -132,13 +138,24 @@ public class TitleBar extends LinearLayout {
     }
 
     /* package */ void setTitleAndUrl(CharSequence title, CharSequence url) {
+        if (url != null) {
+            url = BrowserActivity.buildTitleUrl(url.toString());
+        }
         if (null == title) {
-            mTitle.setText(R.string.title_bar_loading);
+            if (mInLoad) {
+                mTitleSet = false;
+                mTitle.setText(R.string.title_bar_loading);
+            } else {
+                // If the page has no title, put the url in the title space
+                // and leave the url blank.
+                mTitle.setText(url);
+                mUrl.setText(null);
+                mTitleSet = true;
+                return;
+            }
         } else {
             mTitle.setText(title);
-        }
-        if (url != null) {
-            url = BrowserActivity.buildTitleUrl(url.toString());
+            mTitleSet = true;
         }
         mUrl.setText(url);
     }