summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/browser/BaseUi.java7
-rw-r--r--src/com/android/browser/ComboViewActivity.java1
-rw-r--r--src/com/android/browser/NavScreen.java4
-rw-r--r--src/com/android/browser/PageDialogsHandler.java128
-rw-r--r--src/com/android/browser/PhoneUi.java184
-rw-r--r--src/com/android/browser/Tab.java9
-rw-r--r--src/com/android/browser/preferences/WebsiteSettingsFragment.java6
7 files changed, 203 insertions, 136 deletions
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index a2a51d64f..26f90b669 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -505,8 +505,6 @@ public abstract class BaseUi implements UI {
if (t != null) {
intent.putExtra(ComboViewActivity.EXTRA_CURRENT_URL, t.getUrl());
}
- intent.putExtra(ComboViewActivity.EXTRA_BOOKMARK_PAGE,
- mUiController.createBookmarkCurrentPageIntent(false));
mActivity.startActivityForResult(intent, Controller.COMBO_VIEW);
}
@@ -803,16 +801,19 @@ public abstract class BaseUi implements UI {
mHandler.sendMessageDelayed(msg, duration);
}
- private Handler mHandler = new Handler() {
+ protected Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (msg.what == MSG_HIDE_TITLEBAR) {
suggestHideTitleBar();
}
+ BaseUi.this.handleMessage(msg);
}
};
+ protected void handleMessage(Message msg) {}
+
@Override
public void showWeb(boolean animate) {
mUiController.hideCustomView();
diff --git a/src/com/android/browser/ComboViewActivity.java b/src/com/android/browser/ComboViewActivity.java
index 9bdce185a..ae49898b2 100644
--- a/src/com/android/browser/ComboViewActivity.java
+++ b/src/com/android/browser/ComboViewActivity.java
@@ -41,7 +41,6 @@ public class ComboViewActivity extends Activity implements CombinedBookmarksCall
public static final String EXTRA_OPEN_SNAPSHOT = "snapshot_id";
public static final String EXTRA_OPEN_ALL = "open_all";
public static final String EXTRA_CURRENT_URL = "url";
- public static final String EXTRA_BOOKMARK_PAGE = "create_bookmark";
private ViewPager mViewPager;
private TabsAdapter mTabsAdapter;
diff --git a/src/com/android/browser/NavScreen.java b/src/com/android/browser/NavScreen.java
index 16261836a..45b1dcc03 100644
--- a/src/com/android/browser/NavScreen.java
+++ b/src/com/android/browser/NavScreen.java
@@ -109,6 +109,10 @@ public class NavScreen extends RelativeLayout
}
}
+ public void refreshAdapter() {
+ mAdapter.notifyDataSetChanged();
+ }
+
private void init() {
LayoutInflater.from(mContext).inflate(R.layout.nav_screen, this);
setContentDescription(mContext.getResources().getString(
diff --git a/src/com/android/browser/PageDialogsHandler.java b/src/com/android/browser/PageDialogsHandler.java
index 0c249587a..89c274524 100644
--- a/src/com/android/browser/PageDialogsHandler.java
+++ b/src/com/android/browser/PageDialogsHandler.java
@@ -222,9 +222,7 @@ public class PageDialogsHandler {
} else {
// otherwise, display the top-most certificate from
// the chain
- if (view.getCertificate() != null) {
- showSSLCertificate(tab);
- }
+ showSSLCertificate(tab);
}
}
});
@@ -244,24 +242,11 @@ public class PageDialogsHandler {
if (cert == null) {
return;
}
- final View certificateView = cert.inflateCertificateView(mContext);
-
- LayoutInflater factory = LayoutInflater.from(mContext);
-
- final LinearLayout placeholder =
- (LinearLayout)certificateView.findViewById(com.android.internal.R.id.placeholder);
-
- LinearLayout ll = (LinearLayout) factory.inflate(
- R.layout.ssl_success, placeholder);
- ((TextView)ll.findViewById(R.id.success))
- .setText(com.android.internal.R.string.ssl_certificate_is_valid);
mSSLCertificateView = tab;
- mSSLCertificateDialog =
- new AlertDialog.Builder(mContext)
- .setTitle(com.android.internal.R.string.ssl_certificate).setIcon(
- R.drawable.ic_dialog_browser_certificate_secure)
- .setView(certificateView)
+ // TODO: We should pass the certificate error for the page's main
+ // resource, if present. See http://b/5248376.
+ mSSLCertificateDialog = createSslCertificateDialog(cert, null)
.setPositiveButton(R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
@@ -284,13 +269,6 @@ public class PageDialogsHandler {
.show();
}
- private void addError(LayoutInflater inflater, LinearLayout parent, int error) {
- TextView textView = (TextView) inflater.inflate(R.layout.ssl_warning,
- parent, false);
- textView.setText(error);
- parent.addView(textView);
- }
-
/**
* Displays the SSL error certificate dialog.
* @param view The target web-view.
@@ -306,43 +284,11 @@ public class PageDialogsHandler {
if (cert == null) {
return;
}
- final View certificateView = cert.inflateCertificateView(mContext);
-
- LayoutInflater factory = LayoutInflater.from(mContext);
-
- final LinearLayout placeholder =
- (LinearLayout)certificateView.findViewById(com.android.internal.R.id.placeholder);
-
- if (error.hasError(SslError.SSL_UNTRUSTED)) {
- addError(factory, placeholder, R.string.ssl_untrusted);
- }
- if (error.hasError(SslError.SSL_IDMISMATCH)) {
- addError(factory, placeholder, R.string.ssl_mismatch);
- }
- if (error.hasError(SslError.SSL_EXPIRED)) {
- addError(factory, placeholder, R.string.ssl_expired);
- }
- if (error.hasError(SslError.SSL_NOTYETVALID)) {
- addError(factory, placeholder, R.string.ssl_not_yet_valid);
- }
- if (error.hasError(SslError.SSL_DATE_INVALID)) {
- addError(factory, placeholder, R.string.ssl_date_invalid);
- }
- if (error.hasError(SslError.SSL_INVALID)) {
- addError(factory, placeholder, R.string.ssl_invalid);
- }
- if (placeholder.getChildCount() == 0) {
- addError(factory, placeholder, R.string.ssl_unknown);
- }
mSSLCertificateOnErrorHandler = handler;
mSSLCertificateOnErrorView = view;
mSSLCertificateOnErrorError = error;
- mSSLCertificateOnErrorDialog =
- new AlertDialog.Builder(mContext)
- .setTitle(com.android.internal.R.string.ssl_certificate).setIcon(
- R.drawable.ic_dialog_browser_certificate_partially_secure)
- .setView(certificateView)
+ mSSLCertificateOnErrorDialog = createSslCertificateDialog(cert, error)
.setPositiveButton(R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
@@ -386,4 +332,68 @@ public class PageDialogsHandler {
})
.show();
}
+
+ /*
+ * Creates an AlertDialog to display the given certificate. If error is
+ * null, text is added to state that the certificae is valid and the icon
+ * is set accordingly. If error is non-null, it must relate to the supplied
+ * certificate. In this case, error is used to add text describing the
+ * problems with the certificate and a different icon is used.
+ */
+ private AlertDialog.Builder createSslCertificateDialog(SslCertificate certificate,
+ SslError error) {
+ View certificateView = certificate.inflateCertificateView(mContext);
+ final LinearLayout placeholder =
+ (LinearLayout)certificateView.findViewById(com.android.internal.R.id.placeholder);
+
+ LayoutInflater factory = LayoutInflater.from(mContext);
+ int iconId;
+
+ if (error == null) {
+ iconId = R.drawable.ic_dialog_browser_certificate_secure;
+ LinearLayout table = (LinearLayout)factory.inflate(R.layout.ssl_success, placeholder);
+ TextView successString = (TextView)table.findViewById(R.id.success);
+ successString.setText(com.android.internal.R.string.ssl_certificate_is_valid);
+ } else {
+ iconId = R.drawable.ic_dialog_browser_certificate_partially_secure;
+ if (error.hasError(SslError.SSL_UNTRUSTED)) {
+ addError(factory, placeholder, R.string.ssl_untrusted);
+ }
+ if (error.hasError(SslError.SSL_IDMISMATCH)) {
+ addError(factory, placeholder, R.string.ssl_mismatch);
+ }
+ if (error.hasError(SslError.SSL_EXPIRED)) {
+ addError(factory, placeholder, R.string.ssl_expired);
+ }
+ if (error.hasError(SslError.SSL_NOTYETVALID)) {
+ addError(factory, placeholder, R.string.ssl_not_yet_valid);
+ }
+ if (error.hasError(SslError.SSL_DATE_INVALID)) {
+ addError(factory, placeholder, R.string.ssl_date_invalid);
+ }
+ if (error.hasError(SslError.SSL_INVALID)) {
+ addError(factory, placeholder, R.string.ssl_invalid);
+ }
+ // The SslError should always have at least one type of error and we
+ // should explicitly handle every type of error it supports. We
+ // therefore expect the condition below to never be hit. We use it
+ // as as safety net in case a new error type is added to SslError
+ // without the logic above being updated accordingly.
+ if (placeholder.getChildCount() == 0) {
+ addError(factory, placeholder, R.string.ssl_unknown);
+ }
+ }
+
+ return new AlertDialog.Builder(mContext)
+ .setTitle(com.android.internal.R.string.ssl_certificate)
+ .setIcon(iconId)
+ .setView(certificateView);
+ }
+
+ private void addError(LayoutInflater inflater, LinearLayout parent, int error) {
+ TextView textView = (TextView) inflater.inflate(R.layout.ssl_warning,
+ parent, false);
+ textView.setText(error);
+ parent.addView(textView);
+ }
}
diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java
index 25a7d4a4b..0e2710dee 100644
--- a/src/com/android/browser/PhoneUi.java
+++ b/src/com/android/browser/PhoneUi.java
@@ -25,6 +25,7 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
+import android.os.Message;
import android.util.Log;
import android.util.TypedValue;
import android.view.ActionMode;
@@ -48,9 +49,11 @@ import com.android.browser.UrlInputView.StateListener;
public class PhoneUi extends BaseUi {
private static final String LOGTAG = "PhoneUi";
+ private static final int MSG_INIT_NAVSCREEN = 100;
private PieControlPhone mPieControl;
private NavScreen mNavScreen;
+ private AnimScreen mAnimScreen;
private NavigationBarPhone mNavigationBar;
private int mActionBarHeight;
@@ -88,13 +91,17 @@ public class PhoneUi extends BaseUi {
@Override
public boolean onBackKey() {
- if (mNavScreen != null) {
+ if (showingNavScreen()) {
mNavScreen.close(mUiController.getTabControl().getCurrentPosition());
return true;
}
return super.onBackKey();
}
+ private boolean showingNavScreen() {
+ return mNavScreen != null && mNavScreen.getVisibility() == View.VISIBLE;
+ }
+
@Override
public boolean dispatchKey(int code, KeyEvent event) {
return false;
@@ -122,6 +129,26 @@ public class PhoneUi extends BaseUi {
}
}
}
+ if (mNavScreen == null && getTitleBar().getHeight() > 0) {
+ mHandler.sendEmptyMessage(MSG_INIT_NAVSCREEN);
+ }
+ }
+
+ @Override
+ protected void handleMessage(Message msg) {
+ super.handleMessage(msg);
+ if (msg.what == MSG_INIT_NAVSCREEN) {
+ if (mNavScreen == null) {
+ mNavScreen = new NavScreen(mActivity, mUiController, this);
+ mCustomViewContainer.addView(mNavScreen, COVER_SCREEN_PARAMS);
+ mNavScreen.setVisibility(View.GONE);
+ }
+ if (mAnimScreen == null) {
+ mAnimScreen = new AnimScreen(mActivity);
+ // initialize bitmaps
+ mAnimScreen.set(getTitleBar(), getWebView());
+ }
+ }
}
@Override
@@ -169,17 +196,17 @@ public class PhoneUi extends BaseUi {
public void updateMenuState(Tab tab, Menu menu) {
MenuItem bm = menu.findItem(R.id.bookmarks_menu_id);
if (bm != null) {
- bm.setVisible(mNavScreen == null);
+ bm.setVisible(!showingNavScreen());
}
MenuItem nt = menu.findItem(R.id.new_tab_menu_id);
if (nt != null) {
- nt.setVisible(mNavScreen == null);
+ nt.setVisible(!showingNavScreen());
}
MenuItem abm = menu.findItem(R.id.add_bookmark_menu_id);
if (abm != null) {
- abm.setVisible((tab != null) && !tab.isSnapshot() && mNavScreen == null);
+ abm.setVisible((tab != null) && !tab.isSnapshot() && !showingNavScreen());
}
- if (mNavScreen != null) {
+ if (showingNavScreen()) {
menu.setGroupVisible(R.id.LIVE_MENU, false);
menu.setGroupVisible(R.id.SNAPSHOT_MENU, false);
menu.findItem(R.id.page_info_menu_id).setVisible(false);
@@ -189,7 +216,7 @@ public class PhoneUi extends BaseUi {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- if (mNavScreen != null) {
+ if (showingNavScreen()) {
hideNavScreen(mUiController.getTabControl().getCurrentPosition(), false);
}
return false;
@@ -271,7 +298,7 @@ public class PhoneUi extends BaseUi {
@Override
public boolean isWebShowing() {
- return super.isWebShowing() && mNavScreen == null;
+ return super.isWebShowing() && !showingNavScreen();
}
@Override
@@ -282,12 +309,20 @@ public class PhoneUi extends BaseUi {
void showNavScreen() {
mUiController.setBlockEvents(true);
- mNavScreen = new NavScreen(mActivity, mUiController, this);
+ if (mNavScreen == null) {
+ mNavScreen = new NavScreen(mActivity, mUiController, this);
+ mCustomViewContainer.addView(mNavScreen, COVER_SCREEN_PARAMS);
+ } else {
+ mNavScreen.setVisibility(View.VISIBLE);
+ mNavScreen.setAlpha(1f);
+ mNavScreen.refreshAdapter();
+ }
mActiveTab.capture();
- // Add the custom view to its container
- mCustomViewContainer.addView(mNavScreen, COVER_SCREEN_PARAMS);
- AnimScreen ascreen = new AnimScreen(mActivity, getTitleBar(), getWebView());
- final View animView = ascreen.mMain;
+ if (mAnimScreen == null) {
+ mAnimScreen = new AnimScreen(mActivity);
+ }
+ mAnimScreen.set(getTitleBar(), getWebView());
+ final View animView = mAnimScreen.mMain;
mCustomViewContainer.addView(animView, COVER_SCREEN_PARAMS);
mCustomViewContainer.setVisibility(View.VISIBLE);
mCustomViewContainer.bringToFront();
@@ -307,19 +342,19 @@ public class PhoneUi extends BaseUi {
mContentView.setVisibility(View.GONE);
AnimatorSet set1 = new AnimatorSet();
AnimatorSet inanim = new AnimatorSet();
- ObjectAnimator tx = ObjectAnimator.ofInt(ascreen.mContent, "left",
+ ObjectAnimator tx = ObjectAnimator.ofInt(mAnimScreen.mContent, "left",
fromLeft, toLeft);
- ObjectAnimator ty = ObjectAnimator.ofInt(ascreen.mContent, "top",
+ ObjectAnimator ty = ObjectAnimator.ofInt(mAnimScreen.mContent, "top",
fromTop, toTop);
- ObjectAnimator tr = ObjectAnimator.ofInt(ascreen.mContent, "right",
+ ObjectAnimator tr = ObjectAnimator.ofInt(mAnimScreen.mContent, "right",
fromRight, toRight);
- ObjectAnimator tb = ObjectAnimator.ofInt(ascreen.mContent, "bottom",
+ ObjectAnimator tb = ObjectAnimator.ofInt(mAnimScreen.mContent, "bottom",
fromBottom, toBottom);
- ObjectAnimator title = ObjectAnimator.ofFloat(ascreen.mTitle, "alpha",
+ ObjectAnimator title = ObjectAnimator.ofFloat(mAnimScreen.mTitle, "alpha",
1f, 0f);
- ObjectAnimator sx = ObjectAnimator.ofFloat(ascreen, "scaleFactor",
+ ObjectAnimator sx = ObjectAnimator.ofFloat(mAnimScreen, "scaleFactor",
1f, scaleFactor);
- ObjectAnimator blend1 = ObjectAnimator.ofFloat(ascreen.mMain, "alpha", 1, 0);
+ ObjectAnimator blend1 = ObjectAnimator.ofFloat(mAnimScreen.mMain, "alpha", 1, 0);
blend1.setDuration(100);
inanim.playTogether(tx, ty, tr, tb, sx, title);
@@ -337,7 +372,7 @@ public class PhoneUi extends BaseUi {
}
private void finishAnimationIn() {
- if (mNavScreen != null) {
+ if (showingNavScreen()) {
// notify accessibility manager about the screen change
mNavScreen.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
mTabControl.setOnThumbnailUpdatedListener(mNavScreen);
@@ -345,7 +380,7 @@ public class PhoneUi extends BaseUi {
}
void hideNavScreen(int position, boolean animate) {
- if (mNavScreen == null) return;
+ if (!showingNavScreen()) return;
final Tab tab = mUiController.getTabControl().getTab(position);
if ((tab == null) || !animate) {
if (tab != null) {
@@ -371,9 +406,12 @@ public class PhoneUi extends BaseUi {
mUiController.setBlockEvents(true);
mUiController.setActiveTab(tab);
mContentView.setVisibility(View.VISIBLE);
- final AnimScreen screen = new AnimScreen(mActivity, tab.getScreenshot());
- mCustomViewContainer.addView(screen.mMain, COVER_SCREEN_PARAMS);
- screen.mMain.layout(0, 0, mContentView.getWidth(),
+ if (mAnimScreen == null) {
+ mAnimScreen = new AnimScreen(mActivity);
+ }
+ mAnimScreen.set(tab.getScreenshot());
+ mCustomViewContainer.addView(mAnimScreen.mMain, COVER_SCREEN_PARAMS);
+ mAnimScreen.mMain.layout(0, 0, mContentView.getWidth(),
mContentView.getHeight());
mNavScreen.mScroller.finishScroller();
ImageView target = tabview.mImage;
@@ -388,29 +426,26 @@ public class PhoneUi extends BaseUi {
int fromBottom = fromTop + height;
float scaleFactor = mContentView.getWidth() / (float) width;
int toBottom = toTop + (int) (height * scaleFactor);
- ObjectAnimator l1 = ObjectAnimator.ofInt(screen.mContent, "left",
- fromLeft, fromLeft);
- ObjectAnimator t1 = ObjectAnimator.ofInt(screen.mContent, "top",
- fromTop, fromTop);
- ObjectAnimator r1 = ObjectAnimator.ofInt(screen.mContent, "right",
- fromRight, fromRight);
- ObjectAnimator b1 = ObjectAnimator.ofInt(screen.mContent, "bottom",
- fromBottom, fromBottom);
+ mAnimScreen.mContent.setLeft(fromLeft);
+ mAnimScreen.mContent.setTop(fromTop);
+ mAnimScreen.mContent.setRight(fromRight);
+ mAnimScreen.mContent.setBottom(fromBottom);
+ mAnimScreen.setScaleFactor(1f);
AnimatorSet set1 = new AnimatorSet();
- ObjectAnimator fade2 = ObjectAnimator.ofFloat(screen.mMain, "alpha", 0f, 1f);
+ ObjectAnimator fade2 = ObjectAnimator.ofFloat(mAnimScreen.mMain, "alpha", 0f, 1f);
ObjectAnimator fade1 = ObjectAnimator.ofFloat(mNavScreen, "alpha", 1f, 0f);
- set1.playTogether(l1, t1, r1, b1, fade1, fade2);
+ set1.playTogether(fade1, fade2);
set1.setDuration(100);
AnimatorSet set2 = new AnimatorSet();
- ObjectAnimator l = ObjectAnimator.ofInt(screen.mContent, "left",
+ ObjectAnimator l = ObjectAnimator.ofInt(mAnimScreen.mContent, "left",
fromLeft, toLeft);
- ObjectAnimator t = ObjectAnimator.ofInt(screen.mContent, "top",
+ ObjectAnimator t = ObjectAnimator.ofInt(mAnimScreen.mContent, "top",
fromTop, toTop);
- ObjectAnimator r = ObjectAnimator.ofInt(screen.mContent, "right",
+ ObjectAnimator r = ObjectAnimator.ofInt(mAnimScreen.mContent, "right",
fromRight, toRight);
- ObjectAnimator b = ObjectAnimator.ofInt(screen.mContent, "bottom",
+ ObjectAnimator b = ObjectAnimator.ofInt(mAnimScreen.mContent, "bottom",
fromBottom, toBottom);
- ObjectAnimator scale = ObjectAnimator.ofFloat(screen, "scaleFactor",
+ ObjectAnimator scale = ObjectAnimator.ofFloat(mAnimScreen, "scaleFactor",
1f, scaleFactor);
ObjectAnimator otheralpha = ObjectAnimator.ofFloat(mCustomViewContainer, "alpha", 1f, 0f);
otheralpha.setDuration(100);
@@ -421,7 +456,7 @@ public class PhoneUi extends BaseUi {
combo.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator anim) {
- mCustomViewContainer.removeView(screen.mMain);
+ mCustomViewContainer.removeView(mAnimScreen.mMain);
finishAnimateOut();
mUiController.setBlockEvents(false);
}
@@ -431,9 +466,8 @@ public class PhoneUi extends BaseUi {
private void finishAnimateOut() {
mTabControl.setOnThumbnailUpdatedListener(null);
- mCustomViewContainer.removeView(mNavScreen);
+ mNavScreen.setVisibility(View.GONE);
mCustomViewContainer.setAlpha(1f);
- mNavScreen = null;
mCustomViewContainer.setVisibility(View.GONE);
}
@@ -443,7 +477,7 @@ public class PhoneUi extends BaseUi {
}
public void toggleNavScreen() {
- if (mNavScreen == null) {
+ if (!showingNavScreen()) {
showNavScreen();
} else {
hideNavScreen(mUiController.getTabControl().getCurrentPosition(), false);
@@ -461,55 +495,61 @@ public class PhoneUi extends BaseUi {
private ImageView mTitle;
private ImageView mContent;
private float mScale;
+ private Bitmap mTitleBarBitmap;
+ private Bitmap mContentBitmap;
- public AnimScreen(Context ctx, TitleBar tbar, WebView web) {
+ public AnimScreen(Context ctx) {
mMain = LayoutInflater.from(ctx).inflate(R.layout.anim_screen,
null);
- mContent = (ImageView) mMain.findViewById(R.id.content);
- mContent.setTop(tbar.getHeight());
-
mTitle = (ImageView) mMain.findViewById(R.id.title);
- Bitmap bm1 = Bitmap.createBitmap(tbar.getWidth(), tbar.getHeight(),
- Bitmap.Config.RGB_565);
- Canvas c1 = new Canvas(bm1);
- tbar.draw(c1);
- mTitle.setImageBitmap(bm1);
- int h = web.getHeight() - tbar.getHeight();
- Bitmap bm2 = Bitmap.createBitmap(web.getWidth(), h,
- Bitmap.Config.RGB_565);
- Canvas c2 = new Canvas(bm2);
- int tx = web.getScrollX();
- int ty = web.getScrollY();
- c2.translate(-tx, -ty - tbar.getHeight());
- web.draw(c2);
- mContent.setImageBitmap(bm2);
+ mContent = (ImageView) mMain.findViewById(R.id.content);
mContent.setScaleType(ImageView.ScaleType.MATRIX);
mContent.setImageMatrix(new Matrix());
mScale = 1.0f;
setScaleFactor(getScaleFactor());
}
- public AnimScreen(Context ctx, Bitmap image) {
- mMain = LayoutInflater.from(ctx).inflate(R.layout.anim_screen,
- null);
- mTitle = (ImageView) mMain.findViewById(R.id.title);
+ public void set(TitleBar tbar, WebView web) {
+ if (mTitleBarBitmap == null
+ || mTitleBarBitmap.getWidth() != tbar.getWidth()
+ || mTitleBarBitmap.getHeight() != tbar.getEmbeddedHeight()) {
+ mTitleBarBitmap = Bitmap.createBitmap(tbar.getWidth(),
+ tbar.getEmbeddedHeight(), Bitmap.Config.RGB_565);
+ }
+ Canvas c = new Canvas(mTitleBarBitmap);
+ tbar.draw(c);
+ c.setBitmap(null);
+ mTitle.setImageBitmap(mTitleBarBitmap);
+ mTitle.setVisibility(View.VISIBLE);
+ int h = web.getHeight() - tbar.getEmbeddedHeight();
+ if (mContentBitmap == null
+ || mContentBitmap.getWidth() != web.getWidth()
+ || mContentBitmap.getHeight() != h) {
+ mContentBitmap = Bitmap.createBitmap(web.getWidth(), h,
+ Bitmap.Config.RGB_565);
+ }
+ c.setBitmap(mContentBitmap);
+ int tx = web.getScrollX();
+ int ty = web.getScrollY();
+ c.translate(-tx, -ty - tbar.getEmbeddedHeight());
+ web.draw(c);
+ c.setBitmap(null);
+ mContent.setImageBitmap(mContentBitmap);
+ }
+
+ public void set(Bitmap image) {
mTitle.setVisibility(View.GONE);
- mContent = (ImageView) mMain.findViewById(R.id.content);
mContent.setImageBitmap(image);
- mContent.setScaleType(ImageView.ScaleType.MATRIX);
- mContent.setImageMatrix(new Matrix());
- mScale = 1.0f;
- setScaleFactor(getScaleFactor());
}
- public void setScaleFactor(float sf) {
+ private void setScaleFactor(float sf) {
mScale = sf;
Matrix m = new Matrix();
m.postScale(sf,sf);
mContent.setImageMatrix(m);
}
- public float getScaleFactor() {
+ private float getScaleFactor() {
return mScale;
}
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index f2aa529b1..839280ee5 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -2181,13 +2181,20 @@ class Tab implements PictureListener {
}
}
+ private static final ThreadLocal<ByteBuffer> sBuffer = new ThreadLocal<ByteBuffer>();
+
private byte[] getCaptureBlob() {
synchronized (Tab.this) {
if (mCapture == null) {
return null;
}
- ByteBuffer buffer = ByteBuffer.allocate(mCapture.getByteCount());
+ ByteBuffer buffer = sBuffer.get();
+ if (buffer == null || buffer.limit() < mCapture.getByteCount()) {
+ buffer = ByteBuffer.allocate(mCapture.getByteCount());
+ sBuffer.set(buffer);
+ }
mCapture.copyPixelsToBuffer(buffer);
+ buffer.rewind();
return buffer.array();
}
}
diff --git a/src/com/android/browser/preferences/WebsiteSettingsFragment.java b/src/com/android/browser/preferences/WebsiteSettingsFragment.java
index a2ccca1d1..91c66a0f8 100644
--- a/src/com/android/browser/preferences/WebsiteSettingsFragment.java
+++ b/src/com/android/browser/preferences/WebsiteSettingsFragment.java
@@ -667,6 +667,12 @@ public class WebsiteSettingsFragment extends ListFragment implements OnClickList
getListView().setOnItemClickListener(mAdapter);
}
+ @Override
+ public void onResume() {
+ super.onResume();
+ mAdapter.askForOrigins();
+ }
+
private void finish() {
PreferenceActivity activity = (PreferenceActivity) getActivity();
if (activity != null) {