Implement onReceivedTouchIconUrl.
Add DownloadTouchIcon, an AsyncTask that downloads the apple-touch-icon for urls
that are marked as bookmarks. The touch icon is stored in the bookmark database
similar to favicons and thumbnails. If a shortcut is created for a bookmark
containing a touch icon, the touch icon is used (with rounded corners).
Refactor the bookmarks query to be a static function. The function uses the
original url and new url to look for matching bookmarks. This takes care of
redirects as well as bookmarks containing queries.
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index c20c5a3..8117961 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -2926,23 +2926,10 @@
// FIXME: Would like to make sure there is actually something to
// draw, but the API for that (WebViewCore.pictureReady()) is not
// currently accessible here.
- String original = view.getOriginalUrl();
- if (original != null) {
- // copied from BrowserBookmarksAdapter
- int query = original.indexOf('?');
- String noQuery = original;
- if (query != -1) {
- noQuery = original.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);
+ ContentResolver cr = getContentResolver();
+ final Cursor c = BrowserBookmarksAdapter.queryBookmarksForUrl(
+ cr, view.getOriginalUrl(), view.getUrl());
+ if (c != null) {
boolean succeed = c.moveToFirst();
ContentValues values = null;
while (succeed) {
@@ -2986,10 +2973,10 @@
return mWebViewClient;
}
- private void updateIcon(String url, Bitmap icon) {
+ private void updateIcon(WebView view, Bitmap icon) {
if (icon != null) {
BrowserBookmarksAdapter.updateBookmarkFavicon(mResolver,
- url, icon);
+ view, icon);
}
setFavicon(icon);
}
@@ -3010,7 +2997,7 @@
// Call updateIcon instead of setFavicon so the bookmark
// database can be updated.
- updateIcon(url, favicon);
+ updateIcon(view, favicon);
if (mSettings.isTracing() == true) {
// FIXME: we should save the trace file somewhere other than data.
@@ -3794,7 +3781,22 @@
@Override
public void onReceivedIcon(WebView view, Bitmap icon) {
- updateIcon(view.getUrl(), icon);
+ updateIcon(view, icon);
+ }
+
+ @Override
+ public void onReceivedTouchIconUrl(WebView view, String url) {
+ final ContentResolver cr = getContentResolver();
+ final Cursor c =
+ BrowserBookmarksAdapter.queryBookmarksForUrl(cr,
+ view.getOriginalUrl(), view.getUrl());
+ if (c != null) {
+ if (c.getCount() > 0) {
+ new DownloadTouchIcon(cr, c, view).execute(url);
+ } else {
+ c.close();
+ }
+ }
}
@Override
@@ -4830,6 +4832,7 @@
intent.putExtra("url", url);
intent.putExtra("maxTabsOpen",
mTabControl.getTabCount() >= TabControl.MAX_TABS);
+ intent.putExtra("touch_icon_url", current.getTouchIconUrl());
if (startWithHistory) {
intent.putExtra(CombinedBookmarkHistoryActivity.STARTING_TAB,
CombinedBookmarkHistoryActivity.HISTORY_TAB);