diff options
author | Michael Kolb <kolby@google.com> | 2010-12-12 15:27:56 -0800 |
---|---|---|
committer | Michael Kolb <kolby@google.com> | 2010-12-13 10:07:11 -0800 |
commit | a0e2a75fdba703260c02838c96d9d4008e914a1d (patch) | |
tree | 4ada72dc729f04bf7d75858fb469df2b177d624f /src/com/android/browser/TabBar.java | |
parent | 81b6f83b7032f22fdaaa514afda2448f801b73da (diff) | |
download | android_packages_apps_Gello-a0e2a75fdba703260c02838c96d9d4008e914a1d.tar.gz android_packages_apps_Gello-a0e2a75fdba703260c02838c96d9d4008e914a1d.tar.bz2 android_packages_apps_Gello-a0e2a75fdba703260c02838c96d9d4008e914a1d.zip |
Add title bar indicator to tab
Bug: http://b/issue?id=3184567
When the url bar is scrolled off the screen, the current
tab shows an indicator
Change-Id: I5a1f11bac09304c81857496b4bb7662656ef225a
Diffstat (limited to 'src/com/android/browser/TabBar.java')
-rw-r--r-- | src/com/android/browser/TabBar.java | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/src/com/android/browser/TabBar.java b/src/com/android/browser/TabBar.java index 4f179b08..79699559 100644 --- a/src/com/android/browser/TabBar.java +++ b/src/com/android/browser/TabBar.java @@ -73,8 +73,7 @@ public class TabBar extends LinearLayout private Map<Tab, TabViewData> mTabMap; private boolean mUserRequestedUrlbar; - private boolean mTitleVisible; - private boolean mShowUrlMode; + private int mVisibleTitleHeight; private boolean mHasReceivedTitle; private Drawable mGenericFavicon; @@ -121,7 +120,7 @@ public class TabBar extends LinearLayout updateTabs(mUiController.getTabs()); mUserRequestedUrlbar = false; - mTitleVisible = true; + mVisibleTitleHeight = 1; mButtonWidth = -1; // tab dimensions mTabHeight = (int) res.getDimension(R.dimen.tab_height); @@ -204,18 +203,24 @@ public class TabBar extends LinearLayout mUserRequestedUrlbar = true; } - private void setShowUrlMode(boolean showUrl) { - mShowUrlMode = showUrl; + private void showTitleBarIndicator(boolean show) { + Tab tab = mTabControl.getCurrentTab(); + if (tab != null) { + TabViewData tvd = mTabMap.get(tab); + if (tvd != null) { + tvd.mTabView.showIndicator(show); + } + } } // callback after fake titlebar is shown void onShowTitleBar() { - setShowUrlMode(false); + showTitleBarIndicator(false); } // callback after fake titlebar is hidden void onHideTitleBar() { - setShowUrlMode(!mTitleVisible); + showTitleBarIndicator(mVisibleTitleHeight == 0); Tab tab = mTabControl.getCurrentTab(); tab.getWebView().requestFocus(); mUserRequestedUrlbar = false; @@ -224,22 +229,22 @@ public class TabBar extends LinearLayout // webview scroll listener @Override - public void onScroll(boolean titleVisible) { + public void onScroll(int visibleTitleHeight) { // isLoading is using the current tab, which initially might not be set yet if (mTabControl.getCurrentTab() != null) { - mTitleVisible = titleVisible; - if (!mShowUrlMode && !mTitleVisible && !isLoading()) { + if ((mVisibleTitleHeight > 0) && (visibleTitleHeight == 0) + && !isLoading()) { if (mUserRequestedUrlbar) { mUi.hideFakeTitleBar(); } else { - setShowUrlMode(true); - } - } else if (mTitleVisible && !isLoading()) { - if (mShowUrlMode) { - setShowUrlMode(false); + showTitleBarIndicator(true); } + } else if ((mVisibleTitleHeight == 0) && (visibleTitleHeight != 0) + && !isLoading()) { + showTitleBarIndicator(false); } } + mVisibleTitleHeight = visibleTitleHeight; } @Override @@ -277,6 +282,7 @@ public class TabBar extends LinearLayout TabViewData mTabData; View mTabContent; TextView mTitle; + View mIndicator; View mIncognito; ImageView mIconView; ImageView mLock; @@ -297,7 +303,7 @@ public class TabBar extends LinearLayout mTabData = tab; setGravity(Gravity.CENTER_VERTICAL); setOrientation(LinearLayout.HORIZONTAL); - setPadding(0, 0, mTabPadding, 0); + setPadding(mTabPadding, 0, 0, 0); LayoutInflater inflater = LayoutInflater.from(getContext()); mTabContent = inflater.inflate(R.layout.tab_title, this, true); mTitle = (TextView) mTabContent.findViewById(R.id.title); @@ -306,12 +312,17 @@ public class TabBar extends LinearLayout mClose = (ImageView) mTabContent.findViewById(R.id.close); mClose.setOnClickListener(this); mIncognito = mTabContent.findViewById(R.id.incognito); + mIndicator = mTabContent.findViewById(R.id.chevron); mSelected = false; mInLoad = false; // update the status updateFromData(); } + void showIndicator(boolean show) { + mIndicator.setVisibility(show ? View.VISIBLE : View.GONE); + } + @Override public void onClick(View v) { if (v == mClose) { @@ -497,7 +508,7 @@ public class TabBar extends LinearLayout tvd.setProgress(tvd.mProgress); // update the scroll state WebView webview = tab.getWebView(); - onScroll(webview.getVisibleTitleHeight() > 0); + onScroll(webview.getVisibleTitleHeight()); } } |