diff options
| author | Leon Scroggins <scroggo@google.com> | 2009-06-18 12:05:28 -0400 |
|---|---|---|
| committer | Leon Scroggins <scroggo@google.com> | 2009-06-18 17:01:59 -0400 |
| commit | b6b7f9ef3b4ed220063f555d8b7c205210a61a04 (patch) | |
| tree | feaa09ad4d5310921189e15cf1307091aa8e34b7 /src/com/android/browser/BrowserActivity.java | |
| parent | 7874657df1a62c8e3b2b9fcc47570333664d6988 (diff) | |
Use a grid view for bookmarks page.
The BrowserProvider now stores another blob
for a screenshot of the page. If the current
page is a bookmark, store a screenshot. When
viewing bookmarks, show a gridview of screenshots
of the bookmarks.
Requires a change to framework to add THUMBNAIL
to Browser.BookmarkColumns and to the HISTORY_PROJECTION
Diffstat (limited to 'src/com/android/browser/BrowserActivity.java')
| -rw-r--r-- | src/com/android/browser/BrowserActivity.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java index 363c6d72..d1d8d15b 100644 --- a/src/com/android/browser/BrowserActivity.java +++ b/src/com/android/browser/BrowserActivity.java @@ -29,6 +29,7 @@ import android.content.ActivityNotFoundException; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; +import android.content.ContentUris; import android.content.ContentValues; import android.content.Context; import android.content.DialogInterface; @@ -130,6 +131,7 @@ import android.widget.TextView; import android.widget.Toast; import java.io.BufferedOutputStream; +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -2989,6 +2991,47 @@ public class BrowserActivity extends Activity // Update the lock icon image only once we are done loading updateLockIconImage(mLockIconType); + // If this is a bookmarked site, add a screenshot to the database. + // FIXME: When should we update? Every time? + if (url != null) { + // copied from BrowserBookmarksAdapter + int query = url.indexOf('?'); + String noQuery = url; + if (query != -1) { + noQuery = url.substring(0, query); + } + String URL = noQuery + '?'; + String[] selArgs = new String[] { noQuery, URL }; + final String where = "(url == ? OR url GLOB ? || '*') AND bookmark == 1"; + final String[] projection = new String[] { Browser.BookmarkColumns._ID }; + ContentResolver cr = getContentResolver(); + final Cursor c = cr.query(Browser.BOOKMARKS_URI, projection, where, selArgs, null); + boolean succeed = c.moveToFirst(); + ContentValues values = null; + while (succeed) { + if (values == null) { + final ByteArrayOutputStream os = new ByteArrayOutputStream(); + Picture thumbnail = view.capturePicture(); + // Height was arbitrarily chosen + Bitmap bm = Bitmap.createBitmap(100, 100, + Bitmap.Config.ARGB_4444); + Canvas canvas = new Canvas(bm); + // Scale chosen to be about one third, since we want + // roughly three rows/columns for bookmark page + canvas.scale(.3f, .3f); + thumbnail.draw(canvas); + bm.compress(Bitmap.CompressFormat.PNG, 100, os); + values = new ContentValues(); + values.put(Browser.BookmarkColumns.THUMBNAIL, + os.toByteArray()); + } + cr.update(ContentUris.withAppendedId(Browser.BOOKMARKS_URI, + c.getInt(0)), values, null, null); + succeed = c.moveToNext(); + } + c.close(); + } + // Performance probe if (false) { long[] sysCpu = new long[7]; |
