From db22ec4ee014900988062d910bc810172a07df56 Mon Sep 17 00:00:00 2001 From: John Reck Date: Wed, 29 Jun 2011 11:31:24 -0700 Subject: Fix IntentHandler behavior Bug: 4473779 Plus, TESTS! Huzzah! Change-Id: I043e100d99d4653b7fb7885217d7fb305930a137 --- src/com/android/browser/BookmarkUtils.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/com/android/browser/BookmarkUtils.java') diff --git a/src/com/android/browser/BookmarkUtils.java b/src/com/android/browser/BookmarkUtils.java index 491c16c17..23765f4d3 100644 --- a/src/com/android/browser/BookmarkUtils.java +++ b/src/com/android/browser/BookmarkUtils.java @@ -115,10 +115,7 @@ public class BookmarkUtils { static Intent createAddToHomeIntent(Context context, String url, String title, Bitmap touchIcon, Bitmap favicon) { Intent i = new Intent(INSTALL_SHORTCUT); - Intent shortcutIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); - long urlHash = url.hashCode(); - long uniqueId = (urlHash << 32) | shortcutIntent.hashCode(); - shortcutIntent.putExtra(Browser.EXTRA_APPLICATION_ID, Long.toString(uniqueId)); + Intent shortcutIntent = createShortcutIntent(url); i.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); i.putExtra(Intent.EXTRA_SHORTCUT_NAME, title); i.putExtra(Intent.EXTRA_SHORTCUT_ICON, createIcon(context, touchIcon, favicon, @@ -129,6 +126,14 @@ public class BookmarkUtils { return i; } + static Intent createShortcutIntent(String url) { + Intent shortcutIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + long urlHash = url.hashCode(); + long uniqueId = (urlHash << 32) | shortcutIntent.hashCode(); + shortcutIntent.putExtra(Browser.EXTRA_APPLICATION_ID, Long.toString(uniqueId)); + return shortcutIntent; + } + private static Bitmap getIconBackground(Context context, BookmarkIconType type, int density) { if (type == BookmarkIconType.ICON_HOME_SHORTCUT) { // Want to create a shortcut icon on the homescreen, so the icon -- cgit v1.2.3