Bug 839855 - Update tabs from last time favicons to match awesomescreen favicons. r=bnicholson

--HG--
rename : mobile/android/base/resources/drawable/awesomebar_row_favicon_bg.xml => mobile/android/base/resources/drawable/favicon_bg.xml
This commit is contained in:
Margaret Leibovic 2013-04-29 17:05:55 -07:00
Родитель ae3029f450
Коммит 87c32cd595
15 изменённых файлов: 99 добавлений и 58 удалений

Просмотреть файл

@ -17,4 +17,4 @@
#
# Modifying this file will now automatically clobber the buildbot machines \o/
#
Bug 856358: Needs a clobber because it renames an IDL file. See also bug 860894.
Bug 839855 - Android resource file changes (only affects Android builds)

Просмотреть файл

@ -7,6 +7,7 @@ package org.mozilla.gecko;
import org.mozilla.gecko.gfx.LayerView;
import org.mozilla.gecko.widget.AboutHomeView;
import org.mozilla.gecko.widget.AddonsSection;
import org.mozilla.gecko.widget.FaviconView;
import org.mozilla.gecko.widget.IconTabWidget;
import org.mozilla.gecko.widget.LastTabsSection;
import org.mozilla.gecko.widget.LinkTextView;
@ -84,6 +85,7 @@ public final class GeckoViewsFactory implements LayoutInflater.Factory {
mFactoryMap.put("RelativeLayout", GeckoRelativeLayout.class.getConstructor(arg1Class, arg2Class));
mFactoryMap.put("TextSwitcher", GeckoTextSwitcher.class.getConstructor(arg1Class, arg2Class));
mFactoryMap.put("TextView", GeckoTextView.class.getConstructor(arg1Class, arg2Class));
mFactoryMap.put("FaviconView", FaviconView.class.getConstructor(arg1Class, arg2Class));
} catch (NoSuchMethodException nsme) {
Log.e(LOGTAG, "Unable to initialize views factory", nsme);
}

Просмотреть файл

@ -221,6 +221,7 @@ FENNEC_JAVA_FILES = \
widget/AboutHomeSection.java \
widget/AddonsSection.java \
widget/DateTimePicker.java \
widget/FaviconView.java \
widget/IconTabWidget.java \
widget/LastTabsSection.java \
widget/LinkTextView.java \
@ -998,10 +999,10 @@ MOZ_ANDROID_DRAWABLES += \
mobile/android/base/resources/drawable/address_bar_url.xml \
mobile/android/base/resources/drawable/awesomebar_listview_divider.xml \
mobile/android/base/resources/drawable/awesomebar_header_row.xml \
mobile/android/base/resources/drawable/awesomebar_row_favicon_bg.xml \
mobile/android/base/resources/drawable/awesomebar_tab_indicator.xml \
mobile/android/base/resources/drawable/awesomebar_tab_selected.xml \
mobile/android/base/resources/drawable/awesomebar_tab_unselected.xml \
mobile/android/base/resources/drawable/favicon_bg.xml \
mobile/android/base/resources/drawable/handle_end_level.xml \
mobile/android/base/resources/drawable/handle_start_level.xml \
mobile/android/base/resources/drawable/ic_menu_back.xml \

Просмотреть файл

@ -15,6 +15,7 @@ import org.mozilla.gecko.util.GeckoEventListener;
import org.mozilla.gecko.util.StringUtils;
import org.mozilla.gecko.util.ThreadUtils;
import org.mozilla.gecko.util.UiAsyncTask;
import org.mozilla.gecko.widget.FaviconView;
import org.json.JSONArray;
import org.json.JSONException;
@ -86,7 +87,7 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
private class SearchEntryViewHolder {
public FlowLayout suggestionView;
public ImageView iconView;
public FaviconView iconView;
public LinearLayout userEnteredView;
public TextView userEnteredTextView;
}
@ -491,7 +492,7 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
viewHolder = new SearchEntryViewHolder();
viewHolder.suggestionView = (FlowLayout) convertView.findViewById(R.id.suggestion_layout);
viewHolder.iconView = (ImageView) convertView.findViewById(R.id.suggestion_icon);
viewHolder.iconView = (FaviconView) convertView.findViewById(R.id.suggestion_icon);
viewHolder.userEnteredView = (LinearLayout) convertView.findViewById(R.id.suggestion_user_entered);
viewHolder.userEnteredTextView = (TextView) convertView.findViewById(R.id.suggestion_text);
@ -510,7 +511,7 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
viewHolder = new AwesomeEntryViewHolder();
viewHolder.titleView = (TextView) convertView.findViewById(R.id.title);
viewHolder.urlView = (TextView) convertView.findViewById(R.id.url);
viewHolder.faviconView = (ImageView) convertView.findViewById(R.id.favicon);
viewHolder.faviconView = (FaviconView) convertView.findViewById(R.id.favicon);
viewHolder.bookmarkIconView = (ImageView) convertView.findViewById(R.id.bookmark_icon);
convertView.setTag(viewHolder);

Просмотреть файл

@ -100,16 +100,7 @@ abstract public class AwesomeBarTab {
}
protected void updateFavicon(ImageView faviconView, Bitmap bitmap) {
if (bitmap == null) {
faviconView.setImageDrawable(null);
} else if (Favicons.getInstance().isLargeFavicon(bitmap)) {
// If the icon is large, hide the background
faviconView.setImageBitmap(bitmap);
faviconView.setBackgroundResource(0);
} else {
faviconView.setImageBitmap(bitmap);
faviconView.setBackgroundResource(R.drawable.awesomebar_row_favicon_bg);
}
faviconView.setImageBitmap(bitmap);
}
protected void updateTitle(TextView titleView, Cursor cursor) {

Просмотреть файл

@ -12,6 +12,7 @@ import org.mozilla.gecko.db.BrowserDB;
import org.mozilla.gecko.db.BrowserDB.URLColumns;
import org.mozilla.gecko.util.GamepadUtils;
import org.mozilla.gecko.util.ThreadUtils;
import org.mozilla.gecko.widget.FaviconView;
import android.app.Activity;
import android.content.Context;
@ -26,7 +27,6 @@ import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
@ -325,7 +325,7 @@ public class BookmarksTab extends AwesomeBarTab {
viewHolder = new AwesomeEntryViewHolder();
viewHolder.titleView = (TextView) convertView.findViewById(R.id.title);
viewHolder.faviconView = (ImageView) convertView.findViewById(R.id.favicon);
viewHolder.faviconView = (FaviconView) convertView.findViewById(R.id.favicon);
if (viewType == VIEW_TYPE_ITEM)
viewHolder.urlView = (TextView) convertView.findViewById(R.id.url);

Просмотреть файл

@ -12,6 +12,7 @@ import org.mozilla.gecko.db.BrowserDB.URLColumns;
import org.mozilla.gecko.gfx.BitmapUtils;
import org.mozilla.gecko.util.GamepadUtils;
import org.mozilla.gecko.util.ThreadUtils;
import org.mozilla.gecko.widget.FaviconView;
import android.app.Activity;
import android.content.ContentResolver;
@ -163,7 +164,7 @@ public class HistoryTab extends AwesomeBarTab {
viewHolder = new AwesomeEntryViewHolder();
viewHolder.titleView = (TextView) convertView.findViewById(R.id.title);
viewHolder.urlView = (TextView) convertView.findViewById(R.id.url);
viewHolder.faviconView = (ImageView) convertView.findViewById(R.id.favicon);
viewHolder.faviconView = (FaviconView) convertView.findViewById(R.id.favicon);
viewHolder.bookmarkIconView = (ImageView) convertView.findViewById(R.id.bookmark_icon);
convertView.setTag(viewHolder);

Просмотреть файл

@ -5,7 +5,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android">
android:shape="rectangle">
<corners android:radius="@dimen/awesomebar_row_favicon_bg_radius"/>
<size android:height="@dimen/awesomebar_row_favicon_bg"/>
<corners android:radius="@dimen/favicon_bg_radius"/>
<size android:height="@dimen/favicon_bg"/>
<solid android:color="#FAFBFC"/>
</shape>

Просмотреть файл

@ -9,12 +9,14 @@
android:gravity="left|center_vertical"
style="@style/AboutHome.RowItem">
<ImageView android:id="@+id/last_tab_favicon"
android:layout_width="32dip"
android:layout_height="32dip"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/abouthome_rowitem_left_padding"
android:src="@drawable/favicon"/>
<Gecko.FaviconView android:id="@+id/last_tab_favicon"
android:layout_width="@dimen/favicon_bg"
android:layout_height="@dimen/favicon_bg"
android:layout_marginLeft="@dimen/abouthome_rowitem_left_padding"
android:layout_centerVertical="true"
android:minWidth="@dimen/favicon_bg"
android:minHeight="@dimen/favicon_bg"
android:background="@drawable/favicon_bg"/>
<Gecko.TextView android:id="@+id/last_tab_title"
android:layout_width="wrap_content"

Просмотреть файл

@ -8,15 +8,14 @@
android:layout_height="@dimen/awesomebar_row_height"
android:padding="6dip">
<ImageView android:id="@+id/favicon"
android:src="@drawable/folder"
android:layout_width="32dip"
android:layout_height="32dip"
android:layout_marginRight="6dip"
android:layout_centerVertical="true"
android:minWidth="32dip"
android:minHeight="32dip"
android:scaleType="fitCenter"/>
<Gecko.FaviconView android:id="@+id/favicon"
android:src="@drawable/folder"
android:layout_width="@dimen/favicon_bg"
android:layout_height="@dimen/favicon_bg"
android:layout_marginRight="6dip"
android:layout_centerVertical="true"
android:minWidth="@dimen/favicon_bg"
android:minHeight="@dimen/favicon_bg"/>
<TextView android:id="@+id/title"
android:layout_width="wrap_content"

Просмотреть файл

@ -8,16 +8,14 @@
android:layout_height="@dimen/awesomebar_row_height"
android:padding="6dip">
<ImageView android:id="@+id/favicon"
android:layout_width="@dimen/awesomebar_row_favicon_bg"
android:layout_height="@dimen/awesomebar_row_favicon_bg"
android:layout_marginLeft="6dip"
android:layout_marginRight="6dip"
android:layout_centerVertical="true"
android:minWidth="@dimen/awesomebar_row_favicon_bg"
android:minHeight="@dimen/awesomebar_row_favicon_bg"
android:scaleType="center"
android:background="@drawable/awesomebar_row_favicon_bg"/>
<Gecko.FaviconView android:id="@+id/favicon"
android:layout_width="@dimen/favicon_bg"
android:layout_height="@dimen/favicon_bg"
android:layout_marginLeft="6dip"
android:layout_marginRight="6dip"
android:layout_centerVertical="true"
android:minWidth="@dimen/favicon_bg"
android:minHeight="@dimen/favicon_bg"/>
<ImageView android:id="@+id/bookmark_icon"
android:layout_width="wrap_content"

Просмотреть файл

@ -9,15 +9,14 @@
android:minHeight="@dimen/awesomebar_row_height"
android:padding="7dip">
<ImageView android:id="@+id/suggestion_icon"
android:layout_width="@dimen/awesomebar_row_favicon_bg"
android:layout_height="@dimen/awesomebar_row_favicon_bg"
android:layout_marginLeft="6dip"
android:layout_marginRight="6dip"
android:minWidth="@dimen/awesomebar_row_favicon_bg"
android:minHeight="@dimen/awesomebar_row_favicon_bg"
android:scaleType="center"
android:background="@drawable/awesomebar_row_favicon_bg"/>
<Gecko.FaviconView android:id="@+id/suggestion_icon"
android:layout_width="@dimen/favicon_bg"
android:layout_height="@dimen/favicon_bg"
android:layout_marginLeft="6dip"
android:layout_marginRight="6dip"
android:layout_centerVertical="true"
android:minWidth="@dimen/favicon_bg"
android:minHeight="@dimen/favicon_bg"/>
<org.mozilla.gecko.FlowLayout android:id="@+id/suggestion_layout"
android:layout_toRightOf="@id/suggestion_icon"

Просмотреть файл

@ -25,14 +25,14 @@
<dimen name="awesomebar_row_height">48dp</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_radius">1dp</dimen>
<dimen name="awesomebar_tab_transparency_height">38dp</dimen>
<dimen name="browser_toolbar_height">48dp</dimen>
<dimen name="browser_toolbar_button_padding">12dp</dimen>
<dimen name="browser_toolbar_icon_width">48dp</dimen>
<dimen name="browser_toolbar_lock_width">20dp</dimen>
<dimen name="browser_toolbar_favicon_size">29.33dip</dimen>
<dimen name="favicon_bg">32dp</dimen>
<dimen name="favicon_bg_radius">1dp</dimen>
<!-- Max width of the doorhanger on tablets -->
<dimen name="doorhanger_width">400dp</dimen>

Просмотреть файл

@ -0,0 +1,44 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.widget;
import org.mozilla.gecko.Favicons;
import org.mozilla.gecko.R;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.widget.ImageView;
/*
* Special version of ImageView for favicons.
* Changes image background depending on favicon size.
*/
public class FaviconView extends ImageView {
public FaviconView(Context context, AttributeSet attrs) {
super(context, attrs);
setScaleType(ImageView.ScaleType.CENTER);
}
@Override
public void setImageBitmap(Bitmap bitmap) {
if (bitmap == null) {
// Call setImageDrawable directly to avoid creating a useless BitmapDrawable.
setImageDrawable(null);
// If the bitmap is null, show a blank background.
setBackgroundResource(R.drawable.favicon_bg);
} else if (Favicons.getInstance().isLargeFavicon(bitmap)) {
super.setImageBitmap(bitmap);
// If the icon is large, hide the background.
setBackgroundResource(0);
} else {
super.setImageBitmap(bitmap);
// XXX Otherwise show a dominant color background.
setBackgroundResource(R.drawable.favicon_bg);
}
}
}

Просмотреть файл

@ -5,6 +5,7 @@
package org.mozilla.gecko.widget;
import org.mozilla.gecko.Favicons;
import org.mozilla.gecko.GeckoProfile;
import org.mozilla.gecko.R;
import org.mozilla.gecko.SessionParser;
@ -13,6 +14,7 @@ import org.mozilla.gecko.db.BrowserDB;
import org.mozilla.gecko.util.GamepadUtils;
import org.mozilla.gecko.util.ThreadUtils;
import org.mozilla.gecko.util.UiAsyncTask;
import org.mozilla.gecko.widget.FaviconView;
import android.content.ContentResolver;
import android.content.Context;
@ -21,7 +23,6 @@ import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
@ -122,7 +123,9 @@ public class LastTabsSection extends AboutHomeSection {
((TextView) tabView.findViewById(R.id.last_tab_title)).setText(tab.title);
((TextView) tabView.findViewById(R.id.last_tab_url)).setText(url);
if (favicon != null) {
((ImageView) tabView.findViewById(R.id.last_tab_favicon)).setImageBitmap(favicon);
FaviconView faviconView = (FaviconView) tabView.findViewById(R.id.last_tab_favicon);
Bitmap bitmap = Favicons.getInstance().scaleImage(favicon);
faviconView.setImageBitmap(favicon);
}
tabView.setOnClickListener(new View.OnClickListener() {