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/AddBookmarkPage.java b/src/com/android/browser/AddBookmarkPage.java
index 191659a..d269546 100644
--- a/src/com/android/browser/AddBookmarkPage.java
+++ b/src/com/android/browser/AddBookmarkPage.java
@@ -20,6 +20,7 @@
import android.content.ContentResolver;
import android.content.Intent;
import android.content.res.Resources;
+import android.database.Cursor;
import android.net.ParseException;
import android.net.WebAddress;
import android.os.Bundle;
@@ -42,6 +43,7 @@
private View mCancelButton;
private boolean mEditingExisting;
private Bundle mMap;
+ private String mTouchIconUrl;
private View.OnClickListener mSaveBookmark = new View.OnClickListener() {
public void onClick(View v) {
@@ -78,6 +80,7 @@
}
title = mMap.getString("title");
url = mMap.getString("url");
+ mTouchIconUrl = mMap.getString("touch_icon_url");
}
mTitle = (EditText) findViewById(R.id.title);
@@ -142,7 +145,15 @@
setResult(RESULT_OK, (new Intent()).setAction(
getIntent().toString()).putExtras(mMap));
} else {
- Bookmarks.addBookmark(null, getContentResolver(), url, title, true);
+ final ContentResolver cr = getContentResolver();
+ Bookmarks.addBookmark(null, cr, url, title, true);
+ if (mTouchIconUrl != null) {
+ final Cursor c =
+ BrowserBookmarksAdapter.queryBookmarksForUrl(
+ cr, null, url);
+ new DownloadTouchIcon(cr, c, url)
+ .execute(mTouchIconUrl);
+ }
setResult(RESULT_OK);
}
} catch (IllegalStateException e) {