diff options
author | Michael Kolb <kolby@google.com> | 2011-04-05 10:39:10 -0700 |
---|---|---|
committer | Michael Kolb <kolby@google.com> | 2011-04-06 16:43:03 -0700 |
commit | 46f987eca738a36e2c8382aaec6c7ef2ae2482ae (patch) | |
tree | 06f3000c84f436670e9062c134b786438f22c98e /src/com/android/browser/BaseUi.java | |
parent | 181aac7e29bdf4b9946101100620d4c358ac91aa (diff) | |
download | packages_apps_Browser-46f987eca738a36e2c8382aaec6c7ef2ae2482ae.zip packages_apps_Browser-46f987eca738a36e2c8382aaec6c7ef2ae2482ae.tar.gz packages_apps_Browser-46f987eca738a36e2c8382aaec6c7ef2ae2482ae.tar.bz2 |
refactor titlebar code
Change-Id: I45db5f19af142ba78d3e3833fa428e8f9a14b889
Diffstat (limited to 'src/com/android/browser/BaseUi.java')
-rw-r--r-- | src/com/android/browser/BaseUi.java | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java index 2a03893..5daf17a 100644 --- a/src/com/android/browser/BaseUi.java +++ b/src/com/android/browser/BaseUi.java @@ -87,8 +87,6 @@ public abstract class BaseUi implements UI, WebViewFactory { private Toast mStopToast; - private boolean mTitleShowing; - // the default <video> poster private Bitmap mDefaultVideoPoster; // the video progress view @@ -117,7 +115,6 @@ public abstract class BaseUi implements UI, WebViewFactory { mCustomViewContainer = (FrameLayout) mBrowserFrameLayout .findViewById(R.id.fullscreen_custom_content); frameLayout.addView(mBrowserFrameLayout, COVER_SCREEN_PARAMS); - mTitleShowing = false; } @Override @@ -183,8 +180,6 @@ public abstract class BaseUi implements UI, WebViewFactory { public void onConfigurationChanged(Configuration config) { } - public abstract void editUrl(boolean clearInput); - // key handling @Override @@ -413,39 +408,50 @@ public abstract class BaseUi implements UI, WebViewFactory { } protected void refreshWebView() { - Tab tab = getActiveTab(); - if ((tab != null) && (tab.getWebView() != null)) { - tab.getWebView().invalidate(); + WebView web = getWebView(); + if (web != null) { + web.invalidate(); + } + } + + public void editUrl(boolean clearInput) { + if (mUiController.isInCustomActionMode()) { + mUiController.endActionMode(); } + showTitleBar(); + getTitleBar().startEditingUrl(clearInput); } boolean canShowTitleBar() { return !isTitleBarShowing() && !isActivityPaused() && (getActiveTab() != null) - && (getActiveTab().getWebView() != null) + && (getWebView() != null) && !mUiController.isInCustomActionMode(); } void showTitleBar() { - mTitleShowing = true; + if (canShowTitleBar()) { + getTitleBar().show(); + } } protected void hideTitleBar() { - mTitleShowing = false; + if (getTitleBar().isShowing()) { + getTitleBar().hide(); + } } protected boolean isTitleBarShowing() { - return mTitleShowing; + return getTitleBar().isShowing(); } protected abstract TitleBarBase getTitleBar(); protected void setTitleGravity(int gravity) { - getTitleBar().setTitleGravity(gravity); - Tab tab = getActiveTab(); - if ((tab != null) && (tab.getWebView() != null)) { - tab.getWebView().setTitleBarGravity(gravity); + WebView web = getWebView(); + if (web != null) { + web.setTitleBarGravity(gravity); } } @@ -759,9 +765,12 @@ public abstract class BaseUi implements UI, WebViewFactory { tab.setScreenshot(sshot); } - void showTitleBarAndEdit() { - showTitleBar(); - getTitleBar().startEditingUrl(false); + protected WebView getWebView() { + if (mActiveTab != null) { + return mActiveTab.getWebView(); + } else { + return null; + } } } |