Merge change 25349 into eclair
* changes:
Use an "X" on the title bar to allow the user to stop loading.
diff --git a/res/layout/title_bar_bg.xml b/res/layout/title_bar_bg.xml
new file mode 100644
index 0000000..c4213b0
--- /dev/null
+++ b/res/layout/title_bar_bg.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2009, The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:foreground="?android:attr/windowContentOverlay"
+ android:background="@color/white"
+ />
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index d4cd7eb..aa2b2cc 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -881,6 +881,19 @@
private TitleBar mFakeTitleBar;
/**
+ * Holder for the fake title bar. It will have a foreground shadow, as well
+ * as a white background, so the fake title bar looks like the real one.
+ */
+ private ViewGroup mFakeTitleBarHolder;
+
+ /**
+ * Layout parameters for the fake title bar within mFakeTitleBarHolder
+ */
+ private FrameLayout.LayoutParams mFakeTitleBarParams
+ = new FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.FILL_PARENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT);
+ /**
* Keeps track of whether the options menu is open. This is important in
* determining whether to show or hide the title bar overlay.
*/
@@ -967,7 +980,16 @@
Rect rectangle = new Rect();
mBrowserFrameLayout.getGlobalVisibleRect(rectangle);
params.y = rectangle.top;
- manager.addView(mFakeTitleBar, params);
+ // Add a holder for the title bar. It is a FrameLayout, which
+ // allows it to have an overlay shadow. It also has a white
+ // background, which is the same as the background when it is
+ // placed in a WebView.
+ if (mFakeTitleBarHolder == null) {
+ mFakeTitleBarHolder = (ViewGroup) LayoutInflater.from(this)
+ .inflate(R.layout.title_bar_bg, null);
+ }
+ mFakeTitleBarHolder.addView(mFakeTitleBar, mFakeTitleBarParams);
+ manager.addView(mFakeTitleBarHolder, params);
}
}
@@ -987,7 +1009,8 @@
if (mFakeTitleBar == null) return;
WindowManager manager
= (WindowManager) getSystemService(Context.WINDOW_SERVICE);
- manager.removeView(mFakeTitleBar);
+ mFakeTitleBarHolder.removeView(mFakeTitleBar);
+ manager.removeView(mFakeTitleBarHolder);
mFakeTitleBar = null;
}
@@ -1342,10 +1365,10 @@
// we do not need to remove it
removeTabFromContentView(currentTab);
}
- removeTabFromContentView(tab);
mTabControl.setCurrentTab(tab);
attachTabToContentView(tab);
- resetTitle();
+ resetTitleIconAndProgress();
+ updateLockIconToLatest();
return true;
}
@@ -1751,6 +1774,11 @@
ViewGroup.LayoutParams.WRAP_CONTENT));
}
+ if (t == mTabControl.getCurrentTab()) {
+ setLockIconType(t.getLockIconType());
+ setPrevLockType(t.getPrevLockIconType());
+ }
+
WebView view = t.getWebView();
view.setEmbeddedTitleBar(mTitleBar);
// Attach the sub window if necessary
@@ -1788,6 +1816,11 @@
if (t.getSubWebView() != null) {
mContentView.removeView(t.getSubWebViewContainer());
}
+
+ if (t == mTabControl.getCurrentTab()) {
+ t.setLockIconType(getLockIconType());
+ t.setPrevLockIconType(getPrevLockType());
+ }
}
// Remove the sub window if it exists. Also called by TabControl when the
@@ -1827,10 +1860,10 @@
if (currentTab != null) {
removeTabFromContentView(currentTab);
}
- attachTabToContentView(tab);
// We must set the new tab as the current tab to reflect the old
// animation behavior.
mTabControl.setCurrentTab(tab);
+ attachTabToContentView(tab);
if (!urlData.isEmpty()) {
urlData.loadIn(webview);
}
@@ -1897,15 +1930,6 @@
}
/**
- * Resets the browser title-view to whatever it must be (for example, if we
- * load a page from history).
- */
- private void resetTitle() {
- resetLockIcon();
- resetTitleIconAndProgress();
- }
-
- /**
* Resets the browser title-view to whatever it must be
* (for example, if we had a loading error)
* When we have a new page, we call resetTitle, when we
@@ -3428,23 +3452,20 @@
updateLockIconImage(LOCK_ICON_UNSECURE);
}
- /**
- * Resets the lock icon. This method is called when the icon needs to be
- * reset but we do not know whether we are loading a secure or not secure
- * page.
- */
- private void resetLockIcon() {
- // Save the lock-icon state (we revert to it if the load gets cancelled)
- saveLockIcon();
+ /* package */ void setLockIconType(int type) {
+ mLockIconType = type;
+ }
- mLockIconType = LOCK_ICON_UNSECURE;
+ /* package */ int getLockIconType() {
+ return mLockIconType;
+ }
- if (LOGV_ENABLED) {
- Log.v(LOGTAG, "BrowserActivity.resetLockIcon:" +
- " reset lock icon to " + mLockIconType);
- }
+ /* package */ void setPrevLockType(int type) {
+ mPrevLockType = type;
+ }
- updateLockIconImage(LOCK_ICON_UNSECURE);
+ /* package */ int getPrevLockType() {
+ return mPrevLockType;
}
/**
@@ -4150,9 +4171,9 @@
}
- private final static int LOCK_ICON_UNSECURE = 0;
- private final static int LOCK_ICON_SECURE = 1;
- private final static int LOCK_ICON_MIXED = 2;
+ final static int LOCK_ICON_UNSECURE = 0;
+ final static int LOCK_ICON_SECURE = 1;
+ final static int LOCK_ICON_MIXED = 2;
private int mLockIconType = LOCK_ICON_UNSECURE;
private int mPrevLockType = LOCK_ICON_UNSECURE;
diff --git a/src/com/android/browser/TabControl.java b/src/com/android/browser/TabControl.java
index 037a757..4089cac 100644
--- a/src/com/android/browser/TabControl.java
+++ b/src/com/android/browser/TabControl.java
@@ -210,12 +210,17 @@
private String mOriginalUrl;
private ErrorConsoleView mErrorConsole;
+ // the lock icon type and previous lock icon type for the tab
+ private int mSavedLockIconType;
+ private int mSavedPrevLockIconType;
// Construct a new tab
private Tab(WebView w, boolean closeOnExit, String appId, String url, Context context) {
mCloseOnExit = closeOnExit;
mAppId = appId;
mOriginalUrl = url;
+ mSavedLockIconType = BrowserActivity.LOCK_ICON_UNSECURE;
+ mSavedPrevLockIconType = BrowserActivity.LOCK_ICON_UNSECURE;
// The tab consists of a container view, which contains the main
// WebView, as well as any other UI elements associated with the tab.
@@ -413,6 +418,22 @@
mPickerData.mFakeWebView.invalidate();
}
}
+
+ void setLockIconType(int type) {
+ mSavedLockIconType = type;
+ }
+
+ int getLockIconType() {
+ return mSavedLockIconType;
+ }
+
+ void setPrevLockIconType(int type) {
+ mSavedPrevLockIconType = type;
+ }
+
+ int getPrevLockIconType() {
+ return mSavedPrevLockIconType;
+ }
};
// Directory to store thumbnails for each WebView.