mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 897772 - Actually get a favicon when creating a homescreen shortcut from the about:home context menu. r=wesj
This commit is contained in:
parent
a3d6f033bf
commit
dfe4267f13
@ -6,6 +6,7 @@
|
||||
package org.mozilla.gecko.home;
|
||||
|
||||
import org.mozilla.gecko.EditBookmarkDialog;
|
||||
import org.mozilla.gecko.Favicons;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.GeckoEvent;
|
||||
import org.mozilla.gecko.R;
|
||||
@ -132,14 +133,8 @@ abstract class HomeFragment extends Fragment {
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIXME: bug 897772
|
||||
Bitmap bitmap = null;
|
||||
if (info.favicon != null) {
|
||||
bitmap = BitmapUtils.decodeByteArray(info.favicon);
|
||||
}
|
||||
|
||||
String shortcutTitle = TextUtils.isEmpty(info.title) ? info.url.replaceAll(REGEX_URL_TO_TITLE, "") : info.title;
|
||||
GeckoAppShell.createShortcut(shortcutTitle, info.url, bitmap, "");
|
||||
new AddToLauncherTask(info.url, shortcutTitle).execute();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -225,6 +220,35 @@ abstract class HomeFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
private static class AddToLauncherTask extends UiAsyncTask<Void, Void, String> {
|
||||
private final String mUrl;
|
||||
private final String mTitle;
|
||||
|
||||
public AddToLauncherTask(String url, String title) {
|
||||
super(ThreadUtils.getBackgroundHandler());
|
||||
|
||||
mUrl = url;
|
||||
mTitle = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String doInBackground(Void... params) {
|
||||
return Favicons.getInstance().getFaviconUrlForPageUrl(mUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostExecute(String faviconUrl) {
|
||||
Favicons.OnFaviconLoadedListener listener = new Favicons.OnFaviconLoadedListener() {
|
||||
@Override
|
||||
public void onFaviconLoaded(String url, Bitmap favicon) {
|
||||
GeckoAppShell.createShortcut(mTitle, mUrl, favicon, "");
|
||||
}
|
||||
};
|
||||
|
||||
Favicons.getInstance().loadFavicon(mUrl, faviconUrl, 0, listener);
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveBookmarkTask extends UiAsyncTask<Void, Void, Void> {
|
||||
private final Context mContext;
|
||||
private final int mId;
|
||||
|
@ -113,7 +113,6 @@ public class HomeListView extends ListView
|
||||
public int bookmarkId;
|
||||
public int historyId;
|
||||
public String url;
|
||||
public byte[] favicon;
|
||||
public String title;
|
||||
public int display;
|
||||
public boolean isFolder;
|
||||
@ -165,13 +164,6 @@ public class HomeListView extends ListView
|
||||
historyId = -1;
|
||||
}
|
||||
|
||||
final int faviconCol = cursor.getColumnIndex(Combined.FAVICON);
|
||||
if (faviconCol != -1) {
|
||||
favicon = cursor.getBlob(faviconCol);
|
||||
} else {
|
||||
favicon = null;
|
||||
}
|
||||
|
||||
// We only have the parent column in cursors from getBookmarksInFolder.
|
||||
final int parentCol = cursor.getColumnIndex(Bookmarks.PARENT);
|
||||
if (parentCol != -1) {
|
||||
|
Loading…
Reference in New Issue
Block a user