package com.android.browser;
import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.BitmapShader;
+import android.graphics.Paint;
import android.graphics.Picture;
+import android.graphics.Shader;
import android.net.http.SslError;
import android.os.Bundle;
import android.os.Message;
public static class PickerData {
String mUrl;
String mTitle;
+ Bitmap mFavicon;
float mScale;
int mScrollX;
int mScrollY;
- int mWidth;
- Picture mPicture;
- // This can be null. When a new picture comes in, this view should be
- // invalidated to show the new picture.
- FakeWebView mFakeWebView;
}
/**
* Private class for maintaining Tabs with a main WebView and a subwindow.
*/
- public class Tab implements WebView.PictureListener {
+ public class Tab {
// The Geolocation permissions prompt
private GeolocationPermissionsPrompt mGeolocationPermissionsPrompt;
private View mContainer;
return null;
}
- /**
- * Returns the picker data.
- */
- public PickerData getPickerData() {
- return mPickerData;
+ public Bitmap getFavicon() {
+ if (mPickerData != null) {
+ return mPickerData.mFavicon;
+ }
+ return null;
}
private void setParentTab(Tab parent) {
return mCloseOnExit;
}
- public void onNewPicture(WebView view, Picture p) {
- if (mPickerData == null) {
- return;
- }
-
- mPickerData.mPicture = p;
- // Tell the FakeWebView to redraw.
- if (mPickerData.mFakeWebView != null) {
- mPickerData.mFakeWebView.invalidate();
- }
- }
-
void setLockIconType(int type) {
mSavedLockIconType = type;
}
private static final String CURRTAB = "currentTab";
private static final String CURRURL = "currentUrl";
private static final String CURRTITLE = "currentTitle";
- private static final String CURRWIDTH = "currentWidth";
private static final String CURRPICTURE = "currentPicture";
private static final String CLOSEONEXIT = "closeonexit";
private static final String PARENTTAB = "parentTab";
private WebView createNewWebView() {
// Create a new WebView
WebView w = new WebView(mActivity);
+ w.setScrollbarFadingEnabled(true);
+ w.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
w.setMapTrackballToArrowKeys(false); // use trackball directly
// Enable the built-in zoom
w.getSettings().setBuiltInZoomControls(true);
// settings
final BrowserSettings s = BrowserSettings.getInstance();
s.addObserver(w.getSettings()).update(s, null);
+
+ // pick a default
+ if (false) {
+ MeshTracker mt = new MeshTracker(2);
+ Paint paint = new Paint();
+ Bitmap bm = BitmapFactory.decodeResource(mActivity.getResources(),
+ R.drawable.pattern_carbon_fiber_dark);
+ paint.setShader(new BitmapShader(bm, Shader.TileMode.REPEAT,
+ Shader.TileMode.REPEAT));
+ mt.setBGPaint(paint);
+ w.setDragTracker(mt);
+ }
return w;
}
final WebHistoryItem item =
list != null ? list.getCurrentItem() : null;
populatePickerData(t, item);
-
- // This method is only called during the tab picker creation. At this
- // point we need to listen for new pictures since the WebView is still
- // active.
- final WebView w = t.getTopWindow();
- w.setPictureListener(t);
- // Capture the picture here instead of populatePickerData since it can
- // be called when saving the state of a tab.
- t.mPickerData.mPicture = w.capturePicture();
}
// Create the PickerData and populate it using the saved state of the tab.
final Bundle state = t.mSavedState;
data.mUrl = state.getString(CURRURL);
data.mTitle = state.getString(CURRTITLE);
- data.mWidth = state.getInt(CURRWIDTH, 0);
// XXX: These keys are from WebView.savePicture so if they change, this
// will break.
data.mScale = state.getFloat("scale", 1.0f);
data.mScrollX = state.getInt("scrollX", 0);
data.mScrollY = state.getInt("scrollY", 0);
- if (state.containsKey(CURRPICTURE)) {
- final File f = new File(t.mSavedState.getString(CURRPICTURE));
- try {
- final FileInputStream in = new FileInputStream(f);
- data.mPicture = Picture.createFromStream(in);
- in.close();
- } catch (Exception ex) {
- // Ignore any problems with inflating the picture. We just
- // won't draw anything.
- }
- }
-
// Set the tab's picker data.
t.mPickerData = data;
}
if (item != null) {
data.mUrl = item.getUrl();
data.mTitle = item.getTitle();
+ data.mFavicon = item.getFavicon();
if (data.mTitle == null) {
data.mTitle = data.mUrl;
}
// We want to display the top window in the tab picker but use the url
// and title of the main window.
final WebView w = t.getTopWindow();
- data.mWidth = w.getWidth();
data.mScale = w.getScale();
data.mScrollX = w.getScrollX();
data.mScrollY = w.getScrollY();
- // Remember the old picture if possible.
- if (t.mPickerData != null) {
- data.mPicture = t.mPickerData.mPicture;
- }
t.mPickerData = data;
}
if (t != null && t.mSavedState == null) {
t.mPickerData = null;
}
- if (t.mMainView != null) {
- // Clear the picture listeners.
- t.mMainView.setPictureListener(null);
- if (t.mSubView != null) {
- t.mSubView.setPictureListener(null);
- }
- }
}
}
if (data.mTitle != null) {
b.putString(CURRTITLE, data.mTitle);
}
- b.putInt(CURRWIDTH, data.mWidth);
b.putBoolean(CLOSEONEXIT, t.mCloseOnExit);
if (t.mAppId != null) {
b.putString(APPID, t.mAppId);