summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/TabBar.java
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2010-12-16 17:30:34 -0800
committerJohn Reck <jreck@google.com>2010-12-17 14:19:05 -0800
commit30c714c853a4239e72ab1e238ce2a92472d06ab0 (patch)
tree397e4e02aa9404f008d65d24fa1d3e6ae039ccd9 /src/com/android/browser/TabBar.java
parent39772c83f8e210eed1186b66f5f4841aa41776ee (diff)
downloadpackages_apps_browser-30c714c853a4239e72ab1e238ce2a92472d06ab0.zip
packages_apps_browser-30c714c853a4239e72ab1e238ce2a92472d06ab0.tar.gz
packages_apps_browser-30c714c853a4239e72ab1e238ce2a92472d06ab0.tar.bz2
Overhaul handling tab data updates
Bug: 2127502, 3191165 Pushed some state tracking to the tab for URL, title, favicon, and lock status. This allowed me to remove many duplicate methods of updating that data, preventing the UI from getting out of sync with the web view. Change-Id: I995caa98068ad03ca37710207b5ab57bb9d801ab
Diffstat (limited to 'src/com/android/browser/TabBar.java')
-rw-r--r--src/com/android/browser/TabBar.java45
1 files changed, 6 insertions, 39 deletions
diff --git a/src/com/android/browser/TabBar.java b/src/com/android/browser/TabBar.java
index ea734a6..88209fe 100644
--- a/src/com/android/browser/TabBar.java
+++ b/src/com/android/browser/TabBar.java
@@ -73,10 +73,8 @@ public class TabBar extends LinearLayout
private boolean mUserRequestedUrlbar;
private int mVisibleTitleHeight;
- private boolean mHasReceivedTitle;
private Drawable mGenericFavicon;
- private String mLoadingText;
private Drawable mActiveDrawable;
private Drawable mInactiveDrawable;
@@ -111,7 +109,6 @@ public class TabBar extends LinearLayout
mNewTab = (ImageButton) findViewById(R.id.newtab);
mNewTab.setOnClickListener(this);
mGenericFavicon = res.getDrawable(R.drawable.app_web_browser_sm);
- mLoadingText = res.getString(R.string.title_bar_loading);
setChildrenDrawingOrderEnabled(true);
// TODO: Change enabled states based on whether you can go
@@ -346,19 +343,16 @@ public class TabBar extends LinearLayout
private void updateFromData() {
mTabData.mTabView = this;
- if (mTabData.mUrl != null) {
- setDisplayTitle(mTabData.mUrl);
- }
- if (mTabData.mTitle != null) {
- setDisplayTitle(mTabData.mTitle);
+ Tab tab = mTabData.mTab;
+ String displayTitle = tab.getTitle();
+ if (displayTitle == null) {
+ displayTitle = tab.getUrl();
}
+ setDisplayTitle(displayTitle);
setProgress(mTabData.mProgress);
if (mTabData.mIcon != null) {
setFavicon(mTabData.mIcon);
}
- if (mTabData.mLock != null) {
- setLock(mTabData.mLock);
- }
if (mTabData.mTab != null) {
mIncognito.setVisibility(
mTabData.mTab.isPrivateBrowsingEnabled() ?
@@ -463,21 +457,13 @@ public class TabBar extends LinearLayout
TabView mTabView;
int mProgress;
Drawable mIcon;
- Drawable mLock;
- String mTitle;
- String mUrl;
TabViewData(Tab tab) {
mTab = tab;
- WebView web = tab.getWebView();
- if (web != null) {
- setUrlAndTitle(web.getUrl(), web.getTitle());
- }
+ setUrlAndTitle(mTab.getUrl(), mTab.getTitle());
}
void setUrlAndTitle(String url, String title) {
- mUrl = url;
- mTitle = title;
if (mTabView != null) {
if (title != null) {
mTabView.setDisplayTitle(title);
@@ -562,31 +548,12 @@ public class TabBar extends LinearLayout
}
public void onUrlAndTitle(Tab tab, String url, String title) {
- mHasReceivedTitle = true;
TabViewData tvd = mTabMap.get(tab);
if (tvd != null) {
tvd.setUrlAndTitle(url, title);
}
}
- public void onPageFinished(Tab tab) {
- if (!mHasReceivedTitle) {
- TabViewData tvd = mTabMap.get(tab);
- if (tvd != null) {
- tvd.setUrlAndTitle(tvd.mUrl, null);
- }
- }
- }
-
- public void onPageStarted(Tab tab, String url, Bitmap favicon) {
- mHasReceivedTitle = false;
- TabViewData tvd = mTabMap.get(tab);
- if (tvd != null) {
- tvd.setFavicon(favicon);
- tvd.setUrlAndTitle(url, mLoadingText);
- }
- }
-
private boolean isLoading() {
TabViewData tvd = mTabMap.get(mTabControl.getCurrentTab());
if ((tvd != null) && (tvd.mTabView != null)) {