зеркало из https://github.com/mozilla/gecko-dev.git
Bug 808663 - Use large favicons in awesomebar if they're provided. r=bnicholson
This commit is contained in:
Родитель
b0a473bc33
Коммит
19acca1828
|
@ -576,8 +576,13 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Bitmap getBitmapFromDataURI(String dataURI) {
|
private Bitmap getBitmapFromDataURI(String dataURI) {
|
||||||
|
try {
|
||||||
byte[] raw = Base64.decode(dataURI.substring(22), Base64.DEFAULT);
|
byte[] raw = Base64.decode(dataURI.substring(22), Base64.DEFAULT);
|
||||||
return BitmapFactory.decodeByteArray(raw, 0, raw.length);
|
return BitmapFactory.decodeByteArray(raw, 0, raw.length);
|
||||||
|
} catch(Exception ex) {
|
||||||
|
Log.i(LOGTAG, "exception while decoding bitmap: " + dataURI, ex);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showSuggestionsOptIn() {
|
private void showSuggestionsOptIn() {
|
||||||
|
|
|
@ -41,12 +41,16 @@ abstract public class AwesomeBarTab {
|
||||||
// FIXME: This value should probably come from a prefs key
|
// FIXME: This value should probably come from a prefs key
|
||||||
public static final int MAX_RESULTS = 100;
|
public static final int MAX_RESULTS = 100;
|
||||||
protected Context mContext = null;
|
protected Context mContext = null;
|
||||||
private static int sFaviconSize = -1;
|
private static int sFaviconSmallSize = -1;
|
||||||
|
private static int sFaviconLargeSize = -1;
|
||||||
|
|
||||||
public AwesomeBarTab(Context context) {
|
public AwesomeBarTab(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
if (sFaviconSize < 0) {
|
if (sFaviconSmallSize < 0) {
|
||||||
sFaviconSize = Math.round(mContext.getResources().getDimension(R.dimen.awesomebar_row_favicon_size));
|
sFaviconSmallSize = Math.round(mContext.getResources().getDimension(R.dimen.awesomebar_row_favicon_size_small));
|
||||||
|
}
|
||||||
|
if (sFaviconLargeSize < 0) {
|
||||||
|
sFaviconLargeSize = Math.round(mContext.getResources().getDimension(R.dimen.awesomebar_row_favicon_size_large));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,9 +109,16 @@ abstract public class AwesomeBarTab {
|
||||||
protected void updateFavicon(ImageView faviconView, Bitmap bitmap) {
|
protected void updateFavicon(ImageView faviconView, Bitmap bitmap) {
|
||||||
if (bitmap == null) {
|
if (bitmap == null) {
|
||||||
faviconView.setImageDrawable(null);
|
faviconView.setImageDrawable(null);
|
||||||
} else {
|
} else if (bitmap.getWidth() > 16 || bitmap.getHeight() > 16) {
|
||||||
bitmap = Bitmap.createScaledBitmap(bitmap, sFaviconSize, sFaviconSize, false);
|
// If the icon is larger than 16px, scale it to sFaviconLargeSize and hide the background
|
||||||
|
bitmap = Bitmap.createScaledBitmap(bitmap, sFaviconLargeSize, sFaviconLargeSize, false);
|
||||||
faviconView.setImageBitmap(bitmap);
|
faviconView.setImageBitmap(bitmap);
|
||||||
|
faviconView.setBackgroundResource(0);
|
||||||
|
} else {
|
||||||
|
// If the icon is 16px or smaller, don't scale it up to full size
|
||||||
|
bitmap = Bitmap.createScaledBitmap(bitmap, sFaviconSmallSize, sFaviconSmallSize, false);
|
||||||
|
faviconView.setImageBitmap(bitmap);
|
||||||
|
faviconView.setBackgroundResource(R.drawable.awesomebar_row_favicon_bg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
<dimen name="autocomplete_row_height">32dp</dimen>
|
<dimen name="autocomplete_row_height">32dp</dimen>
|
||||||
<dimen name="awesomebar_header_row_height">20dp</dimen>
|
<dimen name="awesomebar_header_row_height">20dp</dimen>
|
||||||
<dimen name="awesomebar_row_height">48dp</dimen>
|
<dimen name="awesomebar_row_height">48dp</dimen>
|
||||||
<dimen name="awesomebar_row_favicon_size">16dp</dimen>
|
<dimen name="awesomebar_row_favicon_size_small">16dp</dimen>
|
||||||
|
<dimen name="awesomebar_row_favicon_size_large">32dp</dimen>
|
||||||
<dimen name="awesomebar_row_favicon_bg">32dp</dimen>
|
<dimen name="awesomebar_row_favicon_bg">32dp</dimen>
|
||||||
<dimen name="awesomebar_row_favicon_bg_radius">1dp</dimen>
|
<dimen name="awesomebar_row_favicon_bg_radius">1dp</dimen>
|
||||||
<dimen name="awesomebar_tab_transparency_height">38dp</dimen>
|
<dimen name="awesomebar_tab_transparency_height">38dp</dimen>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче