summaryrefslogtreecommitdiff
path: root/src/com/android/browser/BrowserActivity.java
diff options
context:
space:
mode:
authorPatrick Scott <phanna@android.com>2009-08-04 13:22:29 -0400
committerPatrick Scott <phanna@android.com>2009-08-05 10:52:30 -0400
commit3918d4443ff38ef1870e02aa51a8b29f8352bb1a (patch)
tree72751daaca11780acba4f57c73619f4f37f6964c /src/com/android/browser/BrowserActivity.java
parent13feaed9ab1b9a3b8cc5ac1b33e36005802b9fc3 (diff)
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.
Diffstat (limited to 'src/com/android/browser/BrowserActivity.java')
-rw-r--r--src/com/android/browser/BrowserActivity.java45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index c20c5a34..8117961f 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -2926,23 +2926,10 @@ public class BrowserActivity extends Activity
// 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 @@ public class BrowserActivity extends Activity
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 @@ public class BrowserActivity extends Activity
// 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 @@ public class BrowserActivity extends Activity
@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 @@ public class BrowserActivity extends Activity
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);