diff options
-rw-r--r-- | res/raw/favicon_amazon.ico | bin | 0 -> 17542 bytes | |||
-rw-r--r-- | res/raw/favicon_bbc.ico | bin | 0 -> 958 bytes | |||
-rw-r--r-- | res/raw/favicon_cnn.ico | bin | 0 -> 11502 bytes | |||
-rw-r--r-- | res/raw/favicon_ebay.ico | bin | 0 -> 1406 bytes | |||
-rw-r--r-- | res/raw/favicon_espn.ico | bin | 0 -> 2862 bytes | |||
-rw-r--r-- | res/raw/favicon_facebook.ico | bin | 0 -> 318 bytes | |||
-rw-r--r-- | res/raw/favicon_google.ico | bin | 0 -> 1150 bytes | |||
-rw-r--r-- | res/raw/favicon_msn.ico | bin | 0 -> 1150 bytes | |||
-rw-r--r-- | res/raw/favicon_myspace.ico | bin | 0 -> 1406 bytes | |||
-rw-r--r-- | res/raw/favicon_nytimes.ico | bin | 0 -> 1406 bytes | |||
-rw-r--r-- | res/raw/favicon_picasa.ico | bin | 0 -> 1406 bytes | |||
-rw-r--r-- | res/raw/favicon_weatherchannel.ico | bin | 0 -> 1406 bytes | |||
-rw-r--r-- | res/raw/favicon_wikipedia.ico | bin | 0 -> 318 bytes | |||
-rw-r--r-- | res/raw/favicon_yahoo.ico | bin | 0 -> 318 bytes | |||
-rw-r--r-- | res/raw/thumb_amazon.png | bin | 0 -> 2471 bytes | |||
-rw-r--r-- | res/raw/thumb_bbc.png | bin | 0 -> 14406 bytes | |||
-rw-r--r-- | res/raw/thumb_cnn.png | bin | 0 -> 5440 bytes | |||
-rw-r--r-- | res/raw/thumb_ebay.png | bin | 0 -> 2989 bytes | |||
-rw-r--r-- | res/raw/thumb_espn.png | bin | 0 -> 5127 bytes | |||
-rw-r--r-- | res/raw/thumb_facebook.png | bin | 0 -> 936 bytes | |||
-rw-r--r-- | res/raw/thumb_google.png | bin | 0 -> 5905 bytes | |||
-rw-r--r-- | res/raw/thumb_msn.png | bin | 0 -> 5684 bytes | |||
-rw-r--r-- | res/raw/thumb_myspace.png | bin | 0 -> 1601 bytes | |||
-rw-r--r-- | res/raw/thumb_nytimes.png | bin | 0 -> 16333 bytes | |||
-rw-r--r-- | res/raw/thumb_picasa.png | bin | 0 -> 3889 bytes | |||
-rw-r--r-- | res/raw/thumb_weatherchannel.png | bin | 0 -> 1599 bytes | |||
-rw-r--r-- | res/raw/thumb_wikipedia.png | bin | 0 -> 8640 bytes | |||
-rw-r--r-- | res/raw/thumb_yahoo.png | bin | 0 -> 5166 bytes | |||
-rw-r--r-- | res/values/bookmarks_icons.xml | 33 | ||||
-rw-r--r-- | src/com/android/browser/provider/BrowserProvider2.java | 54 |
30 files changed, 83 insertions, 4 deletions
diff --git a/res/raw/favicon_amazon.ico b/res/raw/favicon_amazon.ico Binary files differnew file mode 100644 index 0000000..20a959c --- /dev/null +++ b/res/raw/favicon_amazon.ico diff --git a/res/raw/favicon_bbc.ico b/res/raw/favicon_bbc.ico Binary files differnew file mode 100644 index 0000000..8f62b07 --- /dev/null +++ b/res/raw/favicon_bbc.ico diff --git a/res/raw/favicon_cnn.ico b/res/raw/favicon_cnn.ico Binary files differnew file mode 100644 index 0000000..4a8421d --- /dev/null +++ b/res/raw/favicon_cnn.ico diff --git a/res/raw/favicon_ebay.ico b/res/raw/favicon_ebay.ico Binary files differnew file mode 100644 index 0000000..d7c8a5e --- /dev/null +++ b/res/raw/favicon_ebay.ico diff --git a/res/raw/favicon_espn.ico b/res/raw/favicon_espn.ico Binary files differnew file mode 100644 index 0000000..2dbe28a --- /dev/null +++ b/res/raw/favicon_espn.ico diff --git a/res/raw/favicon_facebook.ico b/res/raw/favicon_facebook.ico Binary files differnew file mode 100644 index 0000000..ea0c6a3 --- /dev/null +++ b/res/raw/favicon_facebook.ico diff --git a/res/raw/favicon_google.ico b/res/raw/favicon_google.ico Binary files differnew file mode 100644 index 0000000..ee7c943 --- /dev/null +++ b/res/raw/favicon_google.ico diff --git a/res/raw/favicon_msn.ico b/res/raw/favicon_msn.ico Binary files differnew file mode 100644 index 0000000..b2279f5 --- /dev/null +++ b/res/raw/favicon_msn.ico diff --git a/res/raw/favicon_myspace.ico b/res/raw/favicon_myspace.ico Binary files differnew file mode 100644 index 0000000..22c46be --- /dev/null +++ b/res/raw/favicon_myspace.ico diff --git a/res/raw/favicon_nytimes.ico b/res/raw/favicon_nytimes.ico Binary files differnew file mode 100644 index 0000000..fb4d000 --- /dev/null +++ b/res/raw/favicon_nytimes.ico diff --git a/res/raw/favicon_picasa.ico b/res/raw/favicon_picasa.ico Binary files differnew file mode 100644 index 0000000..22133b8 --- /dev/null +++ b/res/raw/favicon_picasa.ico diff --git a/res/raw/favicon_weatherchannel.ico b/res/raw/favicon_weatherchannel.ico Binary files differnew file mode 100644 index 0000000..5a56818 --- /dev/null +++ b/res/raw/favicon_weatherchannel.ico diff --git a/res/raw/favicon_wikipedia.ico b/res/raw/favicon_wikipedia.ico Binary files differnew file mode 100644 index 0000000..31b0e38 --- /dev/null +++ b/res/raw/favicon_wikipedia.ico diff --git a/res/raw/favicon_yahoo.ico b/res/raw/favicon_yahoo.ico Binary files differnew file mode 100644 index 0000000..d7761e5 --- /dev/null +++ b/res/raw/favicon_yahoo.ico diff --git a/res/raw/thumb_amazon.png b/res/raw/thumb_amazon.png Binary files differnew file mode 100644 index 0000000..eec1d77 --- /dev/null +++ b/res/raw/thumb_amazon.png diff --git a/res/raw/thumb_bbc.png b/res/raw/thumb_bbc.png Binary files differnew file mode 100644 index 0000000..9cdd902 --- /dev/null +++ b/res/raw/thumb_bbc.png diff --git a/res/raw/thumb_cnn.png b/res/raw/thumb_cnn.png Binary files differnew file mode 100644 index 0000000..70b7ea2 --- /dev/null +++ b/res/raw/thumb_cnn.png diff --git a/res/raw/thumb_ebay.png b/res/raw/thumb_ebay.png Binary files differnew file mode 100644 index 0000000..070fa6c --- /dev/null +++ b/res/raw/thumb_ebay.png diff --git a/res/raw/thumb_espn.png b/res/raw/thumb_espn.png Binary files differnew file mode 100644 index 0000000..94918e2 --- /dev/null +++ b/res/raw/thumb_espn.png diff --git a/res/raw/thumb_facebook.png b/res/raw/thumb_facebook.png Binary files differnew file mode 100644 index 0000000..6e295b1 --- /dev/null +++ b/res/raw/thumb_facebook.png diff --git a/res/raw/thumb_google.png b/res/raw/thumb_google.png Binary files differnew file mode 100644 index 0000000..1753788 --- /dev/null +++ b/res/raw/thumb_google.png diff --git a/res/raw/thumb_msn.png b/res/raw/thumb_msn.png Binary files differnew file mode 100644 index 0000000..2240e12 --- /dev/null +++ b/res/raw/thumb_msn.png diff --git a/res/raw/thumb_myspace.png b/res/raw/thumb_myspace.png Binary files differnew file mode 100644 index 0000000..3f39ac5 --- /dev/null +++ b/res/raw/thumb_myspace.png diff --git a/res/raw/thumb_nytimes.png b/res/raw/thumb_nytimes.png Binary files differnew file mode 100644 index 0000000..d6849c3 --- /dev/null +++ b/res/raw/thumb_nytimes.png diff --git a/res/raw/thumb_picasa.png b/res/raw/thumb_picasa.png Binary files differnew file mode 100644 index 0000000..dca6a7d --- /dev/null +++ b/res/raw/thumb_picasa.png diff --git a/res/raw/thumb_weatherchannel.png b/res/raw/thumb_weatherchannel.png Binary files differnew file mode 100644 index 0000000..c91e54c --- /dev/null +++ b/res/raw/thumb_weatherchannel.png diff --git a/res/raw/thumb_wikipedia.png b/res/raw/thumb_wikipedia.png Binary files differnew file mode 100644 index 0000000..7929468 --- /dev/null +++ b/res/raw/thumb_wikipedia.png diff --git a/res/raw/thumb_yahoo.png b/res/raw/thumb_yahoo.png Binary files differnew file mode 100644 index 0000000..115d8bb --- /dev/null +++ b/res/raw/thumb_yahoo.png diff --git a/res/values/bookmarks_icons.xml b/res/values/bookmarks_icons.xml new file mode 100644 index 0000000..3f1b5d6 --- /dev/null +++ b/res/values/bookmarks_icons.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <array name="bookmark_preloads"> + <item>@raw/favicon_google</item> + <item>@raw/thumb_google</item> + <item>@raw/favicon_picasa</item> + <item>@raw/thumb_picasa</item> + <item>@raw/favicon_yahoo</item> + <item>@raw/thumb_yahoo</item> + <item>@raw/favicon_msn</item> + <item>@raw/thumb_msn</item> + <item>@raw/favicon_myspace</item> + <item>@raw/thumb_myspace</item> + <item>@raw/favicon_facebook</item> + <item>@raw/thumb_facebook</item> + <item>@raw/favicon_wikipedia</item> + <item>@raw/thumb_wikipedia</item> + <item>@raw/favicon_ebay</item> + <item>@raw/thumb_ebay</item> + <item>@raw/favicon_cnn</item> + <item>@raw/thumb_cnn</item> + <item>@raw/favicon_nytimes</item> + <item>@raw/thumb_nytimes</item> + <item>@raw/favicon_espn</item> + <item>@raw/thumb_espn</item> + <item>@raw/favicon_amazon</item> + <item>@raw/thumb_amazon</item> + <item>@raw/favicon_weatherchannel</item> + <item>@raw/thumb_weatherchannel</item> + <item>@raw/favicon_bbc</item> + <item>@raw/thumb_bbc</item> + </array> +</resources> diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java index 03f0557..5b87d0f 100644 --- a/src/com/android/browser/provider/BrowserProvider2.java +++ b/src/com/android/browser/provider/BrowserProvider2.java @@ -25,6 +25,8 @@ import android.content.ContentUris; import android.content.ContentValues; import android.content.Context; import android.content.UriMatcher; +import android.content.res.Resources; +import android.content.res.TypedArray; import android.database.Cursor; import android.database.DatabaseUtils; import android.database.sqlite.SQLiteDatabase; @@ -45,6 +47,9 @@ import android.provider.ContactsContract.RawContacts; import android.provider.SyncStateContract; import android.text.TextUtils; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.util.HashMap; public class BrowserProvider2 extends SQLiteContentProvider { @@ -275,8 +280,6 @@ public class BrowserProvider2 extends SQLiteContentProvider { // TODO indices - createDefaultBookmarks(db); - db.execSQL("CREATE TABLE " + TABLE_HISTORY + "(" + History._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + History.TITLE + " TEXT," + @@ -339,6 +342,8 @@ public class BrowserProvider2 extends SQLiteContentProvider { "FROM bookmarks LEFT OUTER JOIN images ON bookmarks.url = images.url_key WHERE url NOT IN (SELECT url FROM history)"); mSyncHelper.createDatabase(db); + + createDefaultBookmarks(db); } @Override @@ -377,9 +382,11 @@ public class BrowserProvider2 extends SQLiteContentProvider { } private void addDefaultBookmarks(SQLiteDatabase db, long parentId) { - final CharSequence[] bookmarks = getContext().getResources().getTextArray( + Resources res = getContext().getResources(); + final CharSequence[] bookmarks = res.getTextArray( R.array.bookmarks); int size = bookmarks.length; + TypedArray preloads = res.obtainTypedArray(R.array.bookmark_preloads); try { String parent = Long.toString(parentId); String now = Long.toString(System.currentTimeMillis()); @@ -401,11 +408,50 @@ public class BrowserProvider2 extends SQLiteContentProvider { Integer.toString(i) + "," + now + ");"); + + int faviconId = preloads.getResourceId(i, 0); + int thumbId = preloads.getResourceId(i + 1, 0); + byte[] thumb = null, favicon = null; + try { + thumb = readRaw(res, thumbId); + } catch (IOException e) { + } + try { + favicon = readRaw(res, faviconId); + } catch (IOException e) { + } + if (thumb != null || favicon != null) { + ContentValues imageValues = new ContentValues(); + imageValues.put(Images.URL, bookmarkDestination.toString()); + if (favicon != null) { + imageValues.put(Images.FAVICON, favicon); + } + if (thumb != null) { + imageValues.put(Images.THUMBNAIL, thumb); + } + db.insert(TABLE_IMAGES, Images.FAVICON, imageValues); + } } } catch (ArrayIndexOutOfBoundsException e) { } } + private byte[] readRaw(Resources res, int id) throws IOException { + InputStream is = res.openRawResource(id); + try { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + byte[] buf = new byte[4096]; + int read; + while ((read = is.read(buf)) > 0) { + bos.write(buf, 0, read); + } + bos.flush(); + return bos.toByteArray(); + } finally { + is.close(); + } + } + // XXX: This is a major hack to remove our dependency on gsf constants and // its content provider. http://b/issue?id=2425179 private String getClientId(ContentResolver cr) { @@ -844,7 +890,7 @@ public class BrowserProvider2 extends SQLiteContentProvider { insertSettingsInTransaction(db, values); break; } - + default: { throw new UnsupportedOperationException("Unknown insert URI " + uri); } |