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;
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,
}
}
+ 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.
//-------------------------------------------------------------------------
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) {
}
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);
private String mCurrentPage;
private String mCurrentTitle;
+ private Bitmap mCurrentThumbnail;
private Cursor mCursor;
private int mCount;
private BrowserBookmarksPage mBookmarksPage;
* 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;
mCurrentPage = b.getResources().getString(R.string.current_page)
+ curPage;
mCurrentTitle = curTitle;
+ mCurrentThumbnail = curThumbnail;
mContentResolver = b.getContentResolver();
mViewMode = BookmarkViewMode.LIST;
// 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);