summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2009-09-21 14:29:20 +0100
committerBen Murdoch <benm@google.com>2009-09-21 14:29:20 +0100
commitdcc2b6f08dd5677bc6ba761a9ba6f1c655113051 (patch)
treefdb8ca6bbe1833fad6e39c489a8fa14253e11bb5 /src/com
parent5942df0c38dff7e4335e352e2d03f100b07b8907 (diff)
downloadpackages_apps_browser-dcc2b6f08dd5677bc6ba761a9ba6f1c655113051.zip
packages_apps_browser-dcc2b6f08dd5677bc6ba761a9ba6f1c655113051.tar.gz
packages_apps_browser-dcc2b6f08dd5677bc6ba761a9ba6f1c655113051.tar.bz2
Put current screenshot under "Add" on bookmark thumbnail page.
Change-Id: Iaf52037f755fea343ef68a23d3740f0f5cdcecb7
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/browser/BrowserActivity.java29
-rw-r--r--src/com/android/browser/BrowserBookmarksAdapter.java14
-rw-r--r--src/com/android/browser/BrowserBookmarksPage.java4
3 files changed, 33 insertions, 14 deletions
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index 15772a5..4a8ddb4 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -1466,6 +1466,7 @@ public class BrowserActivity extends Activity
i.putExtra("url", w.getUrl());
i.putExtra("title", w.getTitle());
i.putExtra("touch_icon_url", w.getTouchIconUrl());
+ i.putExtra("thumbnail", createScreenshot(w));
startActivity(i);
break;
@@ -2316,16 +2317,7 @@ public class BrowserActivity extends Activity
if (values == null) {
final ByteArrayOutputStream os
= new ByteArrayOutputStream();
- Picture thumbnail = view.capturePicture();
- // Keep width and height in sync with BrowserBookmarksPage
- // and bookmark_thumb
- Bitmap bm = Bitmap.createBitmap(100, 80,
- Bitmap.Config.ARGB_4444);
- Canvas canvas = new Canvas(bm);
- // May need to tweak these values to determine what is the
- // best scale factor
- canvas.scale(.5f, .5f);
- thumbnail.draw(canvas);
+ Bitmap bm = createScreenshot(view);
bm.compress(Bitmap.CompressFormat.PNG, 100, os);
values = new ContentValues();
values.put(Browser.BookmarkColumns.THUMBNAIL,
@@ -2339,6 +2331,20 @@ public class BrowserActivity extends Activity
}
}
+ private Bitmap createScreenshot(WebView view) {
+ Picture thumbnail = view.capturePicture();
+ // Keep width and height in sync with BrowserBookmarksPage
+ // and bookmark_thumb
+ Bitmap bm = Bitmap.createBitmap(100, 80,
+ Bitmap.Config.ARGB_4444);
+ Canvas canvas = new Canvas(bm);
+ // May need to tweak these values to determine what is the
+ // best scale factor
+ canvas.scale(.5f, .5f);
+ thumbnail.draw(canvas);
+ return bm;
+ }
+
// -------------------------------------------------------------------------
// WebViewClient implementation.
//-------------------------------------------------------------------------
@@ -4053,6 +4059,8 @@ public class BrowserActivity extends Activity
CombinedBookmarkHistoryActivity.class);
String title = current.getTitle();
String url = current.getUrl();
+ Bitmap thumbnail = createScreenshot(current);
+
// Just in case the user opens bookmarks before a page finishes loading
// so the current history item, and therefore the page, is null.
if (null == url) {
@@ -4068,6 +4076,7 @@ public class BrowserActivity extends Activity
}
intent.putExtra("title", title);
intent.putExtra("url", url);
+ intent.putExtra("thumbnail", thumbnail);
// Disable opening in a new window if we have maxed out the windows
intent.putExtra("disable_new_window", mTabControl.getTabCount()
>= TabControl.MAX_TABS);
diff --git a/src/com/android/browser/BrowserBookmarksAdapter.java b/src/com/android/browser/BrowserBookmarksAdapter.java
index e2c09cf..bd29166 100644
--- a/src/com/android/browser/BrowserBookmarksAdapter.java
+++ b/src/com/android/browser/BrowserBookmarksAdapter.java
@@ -46,6 +46,7 @@ class BrowserBookmarksAdapter extends BaseAdapter {
private String mCurrentPage;
private String mCurrentTitle;
+ private Bitmap mCurrentThumbnail;
private Cursor mCursor;
private int mCount;
private BrowserBookmarksPage mBookmarksPage;
@@ -73,7 +74,8 @@ class BrowserBookmarksAdapter extends BaseAdapter {
* appropriately after a search.
*/
public BrowserBookmarksAdapter(BrowserBookmarksPage b, String curPage,
- String curTitle, boolean createShortcut, boolean mostVisited) {
+ String curTitle, Bitmap curThumbnail, boolean createShortcut,
+ boolean mostVisited) {
mNeedsOffset = !(createShortcut || mostVisited);
mMostVisited = mostVisited;
mExtraOffset = mNeedsOffset ? 1 : 0;
@@ -81,6 +83,7 @@ class BrowserBookmarksAdapter extends BaseAdapter {
mCurrentPage = b.getResources().getString(R.string.current_page)
+ curPage;
mCurrentTitle = curTitle;
+ mCurrentThumbnail = curThumbnail;
mContentResolver = b.getContentResolver();
mViewMode = BookmarkViewMode.LIST;
@@ -427,8 +430,13 @@ class BrowserBookmarksAdapter extends BaseAdapter {
// This is to create a bookmark for the current page.
holder.setVisibility(View.VISIBLE);
tv.setText(mCurrentTitle);
- // FIXME: Want to show the screenshot of the current page
- thumb.setImageResource(R.drawable.blank);
+
+ if (mCurrentThumbnail != null) {
+ thumb.setImageBitmap(mCurrentThumbnail);
+ } else {
+ thumb.setImageResource(
+ R.drawable.ic_launcher_shortcut_browser_bookmark);
+ }
return convertView;
}
holder.setVisibility(View.GONE);
diff --git a/src/com/android/browser/BrowserBookmarksPage.java b/src/com/android/browser/BrowserBookmarksPage.java
index b91e322..f8c80d8 100644
--- a/src/com/android/browser/BrowserBookmarksPage.java
+++ b/src/com/android/browser/BrowserBookmarksPage.java
@@ -241,7 +241,9 @@ public class BrowserBookmarksPage extends Activity implements
}
mBookmarksAdapter = new BrowserBookmarksAdapter(this,
getIntent().getStringExtra("url"),
- getIntent().getStringExtra("title"), mCreateShortcut,
+ getIntent().getStringExtra("title"),
+ (Bitmap) getIntent().getParcelableExtra("thumbnail"),
+ mCreateShortcut,
mMostVisited);
setContentView(R.layout.empty_history);