summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-08-09 16:00:35 -0700
committerJohn Reck <jreck@google.com>2011-08-09 16:17:21 -0700
commit8ee633fd62f94cd66c85c2904232d7c9e204cc9c (patch)
treee451ff70a2367befb1282180d924fa140b8bc2fc /src
parent37d9f2f4c540131453b692d6cb17468637dcef9e (diff)
downloadpackages_apps_Browser-8ee633fd62f94cd66c85c2904232d7c9e204cc9c.zip
packages_apps_Browser-8ee633fd62f94cd66c85c2904232d7c9e204cc9c.tar.gz
packages_apps_Browser-8ee633fd62f94cd66c85c2904232d7c9e204cc9c.tar.bz2
Reduce capture frequency
Bug: 5142655 Only capture while the navscreen is visible Fix Tab.capture to never capture the title bar Fix navscreen not responding to updated thumbnails Change-Id: Id48ad32bb131c398c7d1ce4243e92f04cd421ade
Diffstat (limited to 'src')
-rw-r--r--src/com/android/browser/BrowserWebView.java5
-rw-r--r--src/com/android/browser/NavScreen.java20
-rw-r--r--src/com/android/browser/NavTabView.java2
-rw-r--r--src/com/android/browser/PhoneUi.java8
-rw-r--r--src/com/android/browser/Tab.java30
-rw-r--r--src/com/android/browser/TabControl.java19
6 files changed, 76 insertions, 8 deletions
diff --git a/src/com/android/browser/BrowserWebView.java b/src/com/android/browser/BrowserWebView.java
index 38bbf90..dd93c1f 100644
--- a/src/com/android/browser/BrowserWebView.java
+++ b/src/com/android/browser/BrowserWebView.java
@@ -17,6 +17,7 @@
package com.android.browser;
import android.content.Context;
+import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.View;
import android.webkit.WebView;
@@ -99,4 +100,8 @@ public class BrowserWebView extends WebView {
}
}
+ public void drawContent(Canvas c) {
+ onDraw(c);
+ }
+
}
diff --git a/src/com/android/browser/NavScreen.java b/src/com/android/browser/NavScreen.java
index face39e..0190c1b 100644
--- a/src/com/android/browser/NavScreen.java
+++ b/src/com/android/browser/NavScreen.java
@@ -38,9 +38,12 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import com.android.browser.NavTabGallery.OnRemoveListener;
+import com.android.browser.TabControl.OnThumbnailUpdatedListener;
+
+import java.util.HashMap;
public class NavScreen extends RelativeLayout
- implements OnClickListener, OnMenuItemClickListener {
+ implements OnClickListener, OnMenuItemClickListener, OnThumbnailUpdatedListener {
UiController mUiController;
PhoneUi mUi;
@@ -62,6 +65,7 @@ public class NavScreen extends RelativeLayout
TabAdapter mAdapter;
int mOrientation;
boolean mNeedsMenu;
+ HashMap<Tab, View> mTabViews;
public NavScreen(Activity activity, UiController ctl, PhoneUi ui) {
super(activity);
@@ -119,7 +123,9 @@ public class NavScreen extends RelativeLayout
mNewTab.setOnClickListener(this);
mMore.setOnClickListener(this);
mScroller = (NavTabGallery) findViewById(R.id.scroller);
- mAdapter = new TabAdapter(mContext, mUiController.getTabControl());
+ TabControl tc = mUiController.getTabControl();
+ mTabViews = new HashMap<Tab, View>(tc.getTabCount());
+ mAdapter = new TabAdapter(mContext, tc);
mScroller.setAdapter(mAdapter);
mScroller.setOrientation(mOrientation == Configuration.ORIENTATION_LANDSCAPE
? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL);
@@ -239,6 +245,7 @@ public class NavScreen extends RelativeLayout
final NavTabView tabview = new NavTabView(mActivity);
final Tab tab = getItem(position);
tabview.setWebView(mUi, tab);
+ mTabViews.put(tab, tabview.mImage);
tabview.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
@@ -262,4 +269,13 @@ public class NavScreen extends RelativeLayout
}
+ @Override
+ public void onThumbnailUpdated(Tab t) {
+ View v = mTabViews.get(t);
+ if (v != null) {
+ v.invalidate();
+ mScroller.invalidate();
+ }
+ }
+
}
diff --git a/src/com/android/browser/NavTabView.java b/src/com/android/browser/NavTabView.java
index 23ad2f1..ed6b63d 100644
--- a/src/com/android/browser/NavTabView.java
+++ b/src/com/android/browser/NavTabView.java
@@ -31,7 +31,7 @@ public class NavTabView extends LinearLayout {
private ImageView mClose;
private TextView mTitle;
private View mTitleBar;
- private ImageView mImage;
+ ImageView mImage;
private OnClickListener mClickListener;
private boolean mHighlighted;
diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java
index 32bc092..f33dbef 100644
--- a/src/com/android/browser/PhoneUi.java
+++ b/src/com/android/browser/PhoneUi.java
@@ -17,7 +17,6 @@
package com.android.browser;
import android.app.Activity;
-import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.ActionMode;
@@ -27,7 +26,6 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
-import android.view.accessibility.AccessibilityManager;
import android.webkit.WebView;
import android.widget.FrameLayout;
@@ -112,6 +110,8 @@ public class PhoneUi extends BaseUi {
@Override
public void setActiveTab(final Tab tab) {
+ mTitleBar.cancelTitleBarAnimation(true);
+ mTitleBar.setSkipTitleBarAnimations(true);
super.setActiveTab(tab);
BrowserWebView view = (BrowserWebView) tab.getWebView();
// TabControl.setCurrentTab has been called before this,
@@ -138,6 +138,7 @@ public class PhoneUi extends BaseUi {
mNavigationBar.onStateChanged(StateListener.STATE_NORMAL);
updateLockIconToLatest(tab);
tab.getTopWindow().requestFocus();
+ mTitleBar.setSkipTitleBarAnimations(false);
}
/**
@@ -269,6 +270,7 @@ public class PhoneUi extends BaseUi {
}
void showNavScreen() {
+ mActiveTab.capture();
detachTab(mActiveTab);
mNavScreen = new NavScreen(mActivity, mUiController, this);
// Add the custom view to its container.
@@ -278,10 +280,12 @@ public class PhoneUi extends BaseUi {
mCustomViewContainer.bringToFront();
// notify accessibility manager about the screen change
mNavScreen.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
+ mTabControl.setOnThumbnailUpdatedListener(mNavScreen);
}
void hideNavScreen(boolean animate) {
if (mNavScreen == null) return;
+ mTabControl.setOnThumbnailUpdatedListener(null);
Tab tab = mNavScreen.getSelectedTab();
mCustomViewContainer.removeView(mNavScreen);
mNavScreen = null;
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index 39bf49c..9e4894f 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -68,6 +68,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
+import com.android.browser.TabControl.OnThumbnailUpdatedListener;
import com.android.browser.homepages.HomeProvider;
import com.android.browser.provider.BrowserProvider2.Thumbnails;
import com.android.browser.provider.SnapshotProvider.Snapshots;
@@ -97,7 +98,7 @@ class Tab implements PictureListener {
private static final String CONSOLE_LOGTAG = "browser";
private static final int MSG_CAPTURE = 42;
- private static final int CAPTURE_DELAY = 500;
+ private static final int CAPTURE_DELAY = 100;
private static Bitmap sDefaultFavicon;
@@ -1498,6 +1499,7 @@ class Tab implements PictureListener {
mWebViewController.onSetWebView(this, w);
if (mMainView != null) {
+ mMainView.setPictureListener(null);
if (w != null) {
syncCurrentState(w, null);
} else {
@@ -1516,7 +1518,10 @@ class Tab implements PictureListener {
// switched to another tab while waiting for the download to start.
mMainView.setDownloadListener(mDownloadListener);
mMainView.setWebBackForwardListClient(mWebBackForwardListClient);
- mMainView.setPictureListener(this);
+ TabControl tc = mWebViewController.getTabControl();
+ if (tc != null && tc.getOnThumbnailUpdatedListener() != null) {
+ mMainView.setPictureListener(this);
+ }
if (mSavedState != null) {
mMainView.restoreState(mSavedState);
mSavedState = null;
@@ -1670,6 +1675,9 @@ class Tab implements PictureListener {
}
void putInForeground() {
+ if (mInForeground) {
+ return;
+ }
mInForeground = true;
resume();
Activity activity = mWebViewController.getActivity();
@@ -1685,6 +1693,9 @@ class Tab implements PictureListener {
}
void putInBackground() {
+ if (!mInForeground) {
+ return;
+ }
mInForeground = false;
pause();
mMainView.setOnCreateContextMenuListener(null);
@@ -2024,9 +2035,22 @@ class Tab implements PictureListener {
c.translate(-left, -top);
float scale = mCaptureWidth / (float) mMainView.getWidth();
c.scale(scale, scale, left, top);
- mMainView.draw(c);
+ if (mMainView instanceof BrowserWebView) {
+ ((BrowserWebView)mMainView).drawContent(c);
+ } else {
+ mMainView.draw(c);
+ }
c.setBitmap(null);
+ mHandler.removeMessages(MSG_CAPTURE);
persistThumbnail();
+ TabControl tc = mWebViewController.getTabControl();
+ if (tc != null) {
+ OnThumbnailUpdatedListener updateListener
+ = tc.getOnThumbnailUpdatedListener();
+ if (updateListener != null) {
+ updateListener.onThumbnailUpdated(this);
+ }
+ }
}
@Override
diff --git a/src/com/android/browser/TabControl.java b/src/com/android/browser/TabControl.java
index b708841..38a46a8 100644
--- a/src/com/android/browser/TabControl.java
+++ b/src/com/android/browser/TabControl.java
@@ -36,6 +36,10 @@ class TabControl {
private static final String POSITIONS = "positions";
private static final String CURRENT = "current";
+ public static interface OnThumbnailUpdatedListener {
+ void onThumbnailUpdated(Tab t);
+ }
+
// Maximum number of tabs.
private int mMaxTabs;
// Private array of WebViews that are used as tabs.
@@ -48,6 +52,7 @@ class TabControl {
private final Controller mController;
private final File mThumbnailDir;
+ private OnThumbnailUpdatedListener mOnThumbnailUpdatedListener;
/**
* Construct a new TabControl object
@@ -675,4 +680,18 @@ class TabControl {
return true;
}
+ public void setOnThumbnailUpdatedListener(OnThumbnailUpdatedListener listener) {
+ mOnThumbnailUpdatedListener = listener;
+ for (Tab t : mTabs) {
+ WebView web = t.getWebView();
+ if (web != null) {
+ web.setPictureListener(listener != null ? t : null);
+ }
+ }
+ }
+
+ public OnThumbnailUpdatedListener getOnThumbnailUpdatedListener() {
+ return mOnThumbnailUpdatedListener;
+ }
+
}