зеркало из https://github.com/mozilla/gecko-dev.git
Bug 917396: Move the grid to "TopSites" page. [r=lucasr]
--HG-- rename : mobile/android/base/home/PinBookmarkDialog.java => mobile/android/base/home/PinSiteDialog.java rename : mobile/android/base/home/TopBookmarksAdapter.java => mobile/android/base/home/TopSitesGridAdapter.java rename : mobile/android/base/home/TopBookmarkItemView.java => mobile/android/base/home/TopSitesGridItemView.java rename : mobile/android/base/home/TopBookmarksView.java => mobile/android/base/home/TopSitesGridView.java rename : mobile/android/base/home/BookmarkThumbnailView.java => mobile/android/base/home/TopSitesThumbnailView.java rename : mobile/android/base/resources/color/top_bookmark_item_title.xml => mobile/android/base/resources/color/top_sites_grid_item_title.xml rename : mobile/android/base/resources/drawable-hdpi/top_bookmark_add.png => mobile/android/base/resources/drawable-hdpi/top_site_add.png rename : mobile/android/base/resources/drawable-mdpi/top_bookmark_add.png => mobile/android/base/resources/drawable-mdpi/top_site_add.png rename : mobile/android/base/resources/drawable-xhdpi/top_bookmark_add.png => mobile/android/base/resources/drawable-xhdpi/top_site_add.png rename : mobile/android/base/resources/drawable/bookmark_thumbnail_bg.xml => mobile/android/base/resources/drawable/top_sites_thumbnail_bg.xml rename : mobile/android/base/resources/layout/pin_bookmark_dialog.xml => mobile/android/base/resources/layout/pin_site_dialog.xml rename : mobile/android/base/resources/layout/top_bookmark_item_view.xml => mobile/android/base/resources/layout/top_sites_grid_item_view.xml rename : mobile/android/base/resources/menu/top_bookmarks_contextmenu.xml => mobile/android/base/resources/menu/top_sites_contextmenu.xml
This commit is contained in:
Родитель
92f66d6671
Коммит
689741bd5c
|
@ -217,7 +217,6 @@ FENNEC_JAVA_FILES = \
|
|||
home/BookmarksListView.java \
|
||||
home/BookmarksPage.java \
|
||||
home/BookmarkFolderView.java \
|
||||
home/BookmarkThumbnailView.java \
|
||||
home/BrowserSearch.java \
|
||||
home/HistoryPage.java \
|
||||
home/HomeCursorLoaderCallbacks.java \
|
||||
|
@ -231,7 +230,7 @@ FENNEC_JAVA_FILES = \
|
|||
home/LastTabsPage.java \
|
||||
home/MostRecentPage.java \
|
||||
home/MultiTypeCursorAdapter.java \
|
||||
home/PinBookmarkDialog.java \
|
||||
home/PinSiteDialog.java \
|
||||
home/ReadingListPage.java \
|
||||
home/SearchEngine.java \
|
||||
home/SearchEngineRow.java \
|
||||
|
@ -239,10 +238,11 @@ FENNEC_JAVA_FILES = \
|
|||
home/SimpleCursorLoader.java \
|
||||
home/SuggestClient.java \
|
||||
home/TabMenuStrip.java \
|
||||
home/TopBookmarkItemView.java \
|
||||
home/TopBookmarksAdapter.java \
|
||||
home/TopBookmarksView.java \
|
||||
home/TopSitesGridAdapter.java \
|
||||
home/TopSitesGridItemView.java \
|
||||
home/TopSitesGridView.java \
|
||||
home/TopSitesPage.java \
|
||||
home/TopSitesThumbnailView.java \
|
||||
home/TwoLinePageRow.java \
|
||||
menu/GeckoMenu.java \
|
||||
menu/GeckoMenuInflater.java \
|
||||
|
@ -493,7 +493,7 @@ RES_LAYOUT = \
|
|||
res/layout/notification_icon_text.xml \
|
||||
res/layout/notification_progress.xml \
|
||||
res/layout/notification_progress_text.xml \
|
||||
res/layout/pin_bookmark_dialog.xml \
|
||||
res/layout/pin_site_dialog.xml \
|
||||
res/layout/preference_rightalign_icon.xml \
|
||||
res/layout/preference_search_engine.xml \
|
||||
res/layout/preference_search_tip.xml \
|
||||
|
@ -512,7 +512,7 @@ RES_LAYOUT = \
|
|||
res/layout/tabs_item_cell.xml \
|
||||
res/layout/tabs_item_row.xml \
|
||||
res/layout/text_selection_handles.xml \
|
||||
res/layout/top_bookmark_item_view.xml \
|
||||
res/layout/top_sites_grid_item_view.xml \
|
||||
res/layout/two_line_page_row.xml \
|
||||
res/layout/list_item_header.xml \
|
||||
res/layout/select_dialog_list.xml \
|
||||
|
@ -717,7 +717,7 @@ RES_DRAWABLE_MDPI = \
|
|||
res/drawable-mdpi/tabs_normal.png \
|
||||
res/drawable-mdpi/tabs_private.png \
|
||||
res/drawable-mdpi/tabs_synced.png \
|
||||
res/drawable-mdpi/top_bookmark_add.png \
|
||||
res/drawable-mdpi/top_site_add.png \
|
||||
res/drawable-mdpi/urlbar_stop.png \
|
||||
res/drawable-mdpi/reader.png \
|
||||
res/drawable-mdpi/reader_cropped.png \
|
||||
|
@ -826,7 +826,7 @@ RES_DRAWABLE_HDPI = \
|
|||
res/drawable-hdpi/tabs_normal.png \
|
||||
res/drawable-hdpi/tabs_private.png \
|
||||
res/drawable-hdpi/tabs_synced.png \
|
||||
res/drawable-hdpi/top_bookmark_add.png \
|
||||
res/drawable-hdpi/top_site_add.png \
|
||||
res/drawable-hdpi/urlbar_stop.png \
|
||||
res/drawable-hdpi/reader.png \
|
||||
res/drawable-hdpi/reader_cropped.png \
|
||||
|
@ -901,7 +901,7 @@ RES_DRAWABLE_XHDPI = \
|
|||
res/drawable-xhdpi/find_close.png \
|
||||
res/drawable-xhdpi/find_next.png \
|
||||
res/drawable-xhdpi/find_prev.png \
|
||||
res/drawable-xhdpi/top_bookmark_add.png \
|
||||
res/drawable-xhdpi/top_site_add.png \
|
||||
res/drawable-xhdpi/urlbar_stop.png \
|
||||
res/drawable-xhdpi/reader.png \
|
||||
res/drawable-xhdpi/reader_cropped.png \
|
||||
|
@ -1078,7 +1078,7 @@ RES_COLOR = \
|
|||
res/color/select_item_multichoice.xml \
|
||||
res/color/tertiary_text.xml \
|
||||
res/color/tertiary_text_inverse.xml \
|
||||
res/color/top_bookmark_item_title.xml \
|
||||
res/color/top_sites_grid_item_title.xml \
|
||||
res/color/url_bar_title.xml \
|
||||
res/color/url_bar_title_hint.xml \
|
||||
$(NULL)
|
||||
|
@ -1088,7 +1088,7 @@ RES_MENU = \
|
|||
res/menu/gecko_app_menu.xml \
|
||||
res/menu/home_contextmenu.xml \
|
||||
res/menu/titlebar_contextmenu.xml \
|
||||
res/menu/top_bookmarks_contextmenu.xml \
|
||||
res/menu/top_sites_contextmenu.xml \
|
||||
res/menu-large-v11/browser_app_menu.xml \
|
||||
res/menu-v11/browser_app_menu.xml \
|
||||
res/menu-xlarge-v11/browser_app_menu.xml \
|
||||
|
@ -1106,7 +1106,7 @@ RES_DRAWABLE += \
|
|||
$(SYNC_RES_DRAWABLE) \
|
||||
res/drawable/action_bar_button.xml \
|
||||
res/drawable/action_bar_button_inverse.xml \
|
||||
res/drawable/bookmark_thumbnail_bg.xml \
|
||||
res/drawable/top_sites_thumbnail_bg.xml \
|
||||
res/drawable/url_bar_bg.xml \
|
||||
res/drawable/url_bar_entry.xml \
|
||||
res/drawable/url_bar_nav_button.xml \
|
||||
|
|
|
@ -27,12 +27,12 @@ import android.widget.EditText;
|
|||
import android.widget.ListView;
|
||||
|
||||
/**
|
||||
* Dialog fragment that displays frecency search results, for pinning as a bookmark, in a ListView.
|
||||
* Dialog fragment that displays frecency search results, for pinning a site, in a GridView.
|
||||
*/
|
||||
class PinBookmarkDialog extends DialogFragment {
|
||||
class PinSiteDialog extends DialogFragment {
|
||||
// Listener for url selection
|
||||
public static interface OnBookmarkSelectedListener {
|
||||
public void onBookmarkSelected(String url, String title);
|
||||
public static interface OnSiteSelectedListener {
|
||||
public void onSiteSelected(String url, String title);
|
||||
}
|
||||
|
||||
// Cursor loader ID for search query
|
||||
|
@ -57,13 +57,13 @@ class PinBookmarkDialog extends DialogFragment {
|
|||
private CursorLoaderCallbacks mLoaderCallbacks;
|
||||
|
||||
// Bookmark selected listener
|
||||
private OnBookmarkSelectedListener mOnBookmarkSelectedListener;
|
||||
private OnSiteSelectedListener mOnSiteSelectedListener;
|
||||
|
||||
public static PinBookmarkDialog newInstance() {
|
||||
return new PinBookmarkDialog();
|
||||
public static PinSiteDialog newInstance() {
|
||||
return new PinSiteDialog();
|
||||
}
|
||||
|
||||
private PinBookmarkDialog() {
|
||||
private PinSiteDialog() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -77,7 +77,7 @@ class PinBookmarkDialog extends DialogFragment {
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
// All list views are styled to look the same with a global activity theme.
|
||||
// If the style of the list changes, inflate it from an XML.
|
||||
return inflater.inflate(R.layout.pin_bookmark_dialog, container, false);
|
||||
return inflater.inflate(R.layout.pin_site_dialog, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -104,7 +104,7 @@ class PinBookmarkDialog extends DialogFragment {
|
|||
mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (mOnBookmarkSelectedListener != null) {
|
||||
if (mOnSiteSelectedListener != null) {
|
||||
final Cursor c = mAdapter.getCursor();
|
||||
if (c == null || !c.moveToPosition(position)) {
|
||||
return;
|
||||
|
@ -112,7 +112,7 @@ class PinBookmarkDialog extends DialogFragment {
|
|||
|
||||
final String url = c.getString(c.getColumnIndexOrThrow(URLColumns.URL));
|
||||
final String title = c.getString(c.getColumnIndexOrThrow(URLColumns.TITLE));
|
||||
mOnBookmarkSelectedListener.onBookmarkSelected(url, title);
|
||||
mOnSiteSelectedListener.onSiteSelected(url, title);
|
||||
}
|
||||
|
||||
// Dismiss the fragment and the dialog.
|
||||
|
@ -154,8 +154,8 @@ class PinBookmarkDialog extends DialogFragment {
|
|||
SearchLoader.restart(getLoaderManager(), LOADER_ID_SEARCH, mLoaderCallbacks, mSearchTerm);
|
||||
}
|
||||
|
||||
public void setOnBookmarkSelectedListener(OnBookmarkSelectedListener listener) {
|
||||
mOnBookmarkSelectedListener = listener;
|
||||
public void setOnSiteSelectedListener(OnSiteSelectedListener listener) {
|
||||
mOnSiteSelectedListener = listener;
|
||||
}
|
||||
|
||||
private static class SearchAdapter extends CursorAdapter {
|
|
@ -20,9 +20,9 @@ import android.view.ViewGroup;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A cursor adapter holding the pinned and top bookmarks.
|
||||
* A cursor adapter holding the pinned and top sites.
|
||||
*/
|
||||
public class TopBookmarksAdapter extends CursorAdapter {
|
||||
public class TopSitesGridAdapter extends CursorAdapter {
|
||||
// Cache to store the thumbnails.
|
||||
private Map<String, Thumbnail> mThumbnails;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class TopBookmarksAdapter extends CursorAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
public TopBookmarksAdapter(Context context, Cursor cursor) {
|
||||
public TopSitesGridAdapter(Context context, Cursor cursor) {
|
||||
super(context, cursor);
|
||||
}
|
||||
|
||||
|
@ -82,14 +82,14 @@ public class TopBookmarksAdapter extends CursorAdapter {
|
|||
pinned = ((TopSitesCursorWrapper) cursor).isPinned();
|
||||
}
|
||||
|
||||
TopBookmarkItemView view = (TopBookmarkItemView) bindView;
|
||||
TopSitesGridItemView view = (TopSitesGridItemView) bindView;
|
||||
view.setTitle(title);
|
||||
view.setUrl(url);
|
||||
view.setPinned(pinned);
|
||||
|
||||
// If there is no url, then show "add bookmark".
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
view.displayThumbnail(R.drawable.top_bookmark_add);
|
||||
view.displayThumbnail(R.drawable.top_site_add);
|
||||
} else {
|
||||
// Show the thumbnail.
|
||||
Thumbnail thumbnail = (mThumbnails != null ? mThumbnails.get(url) : null);
|
||||
|
@ -108,6 +108,6 @@ public class TopBookmarksAdapter extends CursorAdapter {
|
|||
*/
|
||||
@Override
|
||||
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
||||
return new TopBookmarkItemView(context);
|
||||
return new TopSitesGridItemView(context);
|
||||
}
|
||||
}
|
|
@ -19,13 +19,13 @@ import android.widget.LinearLayout;
|
|||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* A view that displays the thumbnail and the title/url for a bookmark.
|
||||
* A view that displays the thumbnail and the title/url for a top/pinned site.
|
||||
* If the title/url is longer than the width of the view, they are faded out.
|
||||
* If there is no valid url, a default string is shown at 50% opacity.
|
||||
* This is denoted by the empty state.
|
||||
*/
|
||||
public class TopBookmarkItemView extends RelativeLayout {
|
||||
private static final String LOGTAG = "GeckoTopBookmarkItemView";
|
||||
public class TopSitesGridItemView extends LinearLayout {
|
||||
private static final String LOGTAG = "GeckoTopSitesGridItemView";
|
||||
|
||||
// Empty state, to denote there is no valid url.
|
||||
private static final int[] STATE_EMPTY = { android.R.attr.state_empty };
|
||||
|
@ -44,18 +44,18 @@ public class TopBookmarkItemView extends RelativeLayout {
|
|||
// Empty state.
|
||||
private boolean mIsEmpty = true;
|
||||
|
||||
public TopBookmarkItemView(Context context) {
|
||||
public TopSitesGridItemView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public TopBookmarkItemView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, R.attr.topBookmarkItemViewStyle);
|
||||
public TopSitesGridItemView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, R.attr.topSitesGridItemViewStyle);
|
||||
}
|
||||
|
||||
public TopBookmarkItemView(Context context, AttributeSet attrs, int defStyle) {
|
||||
public TopSitesGridItemView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
|
||||
LayoutInflater.from(context).inflate(R.layout.top_bookmark_item_view, this);
|
||||
LayoutInflater.from(context).inflate(R.layout.top_sites_grid_item_view, this);
|
||||
|
||||
mTitleView = (TextView) findViewById(R.id.title);
|
||||
mThumbnailView = (ImageView) findViewById(R.id.thumbnail);
|
|
@ -25,19 +25,19 @@ import android.widget.GridView;
|
|||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
* A grid view of top bookmarks and pinned tabs.
|
||||
* Each cell in the grid is a TopBookmarkItemView.
|
||||
* A grid view of top and pinned sites.
|
||||
* Each cell in the grid is a TopSitesGridItemView.
|
||||
*/
|
||||
public class TopBookmarksView extends GridView {
|
||||
private static final String LOGTAG = "GeckoTopBookmarksView";
|
||||
public class TopSitesGridView extends GridView {
|
||||
private static final String LOGTAG = "GeckoTopSitesGridView";
|
||||
|
||||
// Listener for pinning bookmarks.
|
||||
public static interface OnPinBookmarkListener {
|
||||
public void onPinBookmark(int position);
|
||||
// Listener for pinning sites.
|
||||
public static interface OnPinSiteListener {
|
||||
public void onPinSite(int position);
|
||||
}
|
||||
|
||||
// Max number of bookmarks that needs to be shown.
|
||||
private final int mMaxBookmarks;
|
||||
// Max number of top sites that needs to be shown.
|
||||
private final int mMaxSites;
|
||||
|
||||
// Number of columns to show.
|
||||
private final int mNumColumns;
|
||||
|
@ -57,29 +57,29 @@ public class TopBookmarksView extends GridView {
|
|||
// On URL open listener.
|
||||
private OnUrlOpenListener mUrlOpenListener;
|
||||
|
||||
// Pin bookmark listener.
|
||||
private OnPinBookmarkListener mPinBookmarkListener;
|
||||
// Pin site listener.
|
||||
private OnPinSiteListener mPinSiteListener;
|
||||
|
||||
// Context menu info.
|
||||
private TopBookmarksContextMenuInfo mContextMenuInfo;
|
||||
private TopSitesGridContextMenuInfo mContextMenuInfo;
|
||||
|
||||
public TopBookmarksView(Context context) {
|
||||
public TopSitesGridView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public TopBookmarksView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, R.attr.topBookmarksViewStyle);
|
||||
public TopSitesGridView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, R.attr.topSitesGridViewStyle);
|
||||
}
|
||||
|
||||
public TopBookmarksView(Context context, AttributeSet attrs, int defStyle) {
|
||||
public TopSitesGridView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
mMaxBookmarks = getResources().getInteger(R.integer.number_of_top_sites);
|
||||
mMaxSites = getResources().getInteger(R.integer.number_of_top_sites);
|
||||
mNumColumns = getResources().getInteger(R.integer.number_of_top_sites_cols);
|
||||
setNumColumns(mNumColumns);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TopBookmarksView, defStyle, 0);
|
||||
mHorizontalSpacing = a.getDimensionPixelOffset(R.styleable.TopBookmarksView_android_horizontalSpacing, 0x00);
|
||||
mVerticalSpacing = a.getDimensionPixelOffset(R.styleable.TopBookmarksView_android_verticalSpacing, 0x00);
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TopSitesGridView, defStyle, 0);
|
||||
mHorizontalSpacing = a.getDimensionPixelOffset(R.styleable.TopSitesGridView_android_horizontalSpacing, 0x00);
|
||||
mVerticalSpacing = a.getDimensionPixelOffset(R.styleable.TopSitesGridView_android_verticalSpacing, 0x00);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
|
@ -93,18 +93,18 @@ public class TopBookmarksView extends GridView {
|
|||
setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
TopBookmarkItemView row = (TopBookmarkItemView) view;
|
||||
TopSitesGridItemView row = (TopSitesGridItemView) view;
|
||||
String url = row.getUrl();
|
||||
|
||||
// If the url is empty, the user can pin a bookmark.
|
||||
// If the url is empty, the user can pin a site.
|
||||
// If not, navigate to the page given by the url.
|
||||
if (!TextUtils.isEmpty(url)) {
|
||||
if (mUrlOpenListener != null) {
|
||||
mUrlOpenListener.onUrlOpen(url, EnumSet.noneOf(OnUrlOpenListener.Flags.class));
|
||||
}
|
||||
} else {
|
||||
if (mPinBookmarkListener != null) {
|
||||
mPinBookmarkListener.onPinBookmark(position);
|
||||
if (mPinSiteListener != null) {
|
||||
mPinSiteListener.onPinSite(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,8 +114,8 @@ public class TopBookmarksView extends GridView {
|
|||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Cursor cursor = (Cursor) parent.getItemAtPosition(position);
|
||||
mContextMenuInfo = new TopBookmarksContextMenuInfo(view, position, id, cursor);
|
||||
return showContextMenuForChild(TopBookmarksView.this);
|
||||
mContextMenuInfo = new TopSitesGridContextMenuInfo(view, position, id, cursor);
|
||||
return showContextMenuForChild(TopSitesGridView.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ public class TopBookmarksView extends GridView {
|
|||
super.onDetachedFromWindow();
|
||||
|
||||
mUrlOpenListener = null;
|
||||
mPinBookmarkListener = null;
|
||||
mPinSiteListener = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,7 +160,7 @@ public class TopBookmarksView extends GridView {
|
|||
ThumbnailHelper.getInstance().setThumbnailWidth(childWidth);
|
||||
|
||||
// Get the first child from the adapter.
|
||||
final View child = new TopBookmarkItemView(getContext());
|
||||
final View child = new TopSitesGridItemView(getContext());
|
||||
|
||||
// Set a default LayoutParams on the child, if it doesn't have one on its own.
|
||||
AbsListView.LayoutParams params = (AbsListView.LayoutParams) child.getLayoutParams();
|
||||
|
@ -171,14 +171,14 @@ public class TopBookmarksView extends GridView {
|
|||
}
|
||||
|
||||
// Measure the exact width of the child, and the height based on the width.
|
||||
// Note: the child (and BookmarkThumbnailView) takes care of calculating its height.
|
||||
// Note: the child (and TopSitesThumbnailView) takes care of calculating its height.
|
||||
int childWidthSpec = MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY);
|
||||
int childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
|
||||
child.measure(childWidthSpec, childHeightSpec);
|
||||
final int childHeight = child.getMeasuredHeight();
|
||||
|
||||
// Number of rows required to show these bookmarks.
|
||||
final int rows = (int) Math.ceil((double) mMaxBookmarks / mNumColumns);
|
||||
// Number of rows required to show these top sites.
|
||||
final int rows = (int) Math.ceil((double) mMaxSites / mNumColumns);
|
||||
final int childrenHeight = childHeight * rows;
|
||||
final int totalVerticalSpacing = rows > 0 ? (rows - 1) * mVerticalSpacing : 0;
|
||||
|
||||
|
@ -204,18 +204,18 @@ public class TopBookmarksView extends GridView {
|
|||
}
|
||||
|
||||
/**
|
||||
* Set a pin bookmark listener to be used by this view.
|
||||
* Set a pin site listener to be used by this view.
|
||||
*
|
||||
* @param listener A pin bookmark listener for this view.
|
||||
* @param listener A pin site listener for this view.
|
||||
*/
|
||||
public void setOnPinBookmarkListener(OnPinBookmarkListener listener) {
|
||||
mPinBookmarkListener = listener;
|
||||
public void setOnPinSiteListener(OnPinSiteListener listener) {
|
||||
mPinSiteListener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* A ContextMenuInfo for TopBoomarksView that adds details from the cursor.
|
||||
*/
|
||||
public static class TopBookmarksContextMenuInfo extends AdapterContextMenuInfo {
|
||||
public static class TopSitesGridContextMenuInfo extends AdapterContextMenuInfo {
|
||||
|
||||
// URL to Title replacement regex.
|
||||
private static final String REGEX_URL_TO_TITLE = "^([a-z]+://)?(www\\.)?";
|
||||
|
@ -224,7 +224,7 @@ public class TopBookmarksView extends GridView {
|
|||
public String title;
|
||||
public boolean isPinned;
|
||||
|
||||
public TopBookmarksContextMenuInfo(View targetView, int position, long id, Cursor cursor) {
|
||||
public TopSitesGridContextMenuInfo(View targetView, int position, long id, Cursor cursor) {
|
||||
super(targetView, position, id);
|
||||
|
||||
if (cursor == null) {
|
|
@ -5,24 +5,44 @@
|
|||
|
||||
package org.mozilla.gecko.home;
|
||||
|
||||
import org.mozilla.gecko.favicons.Favicons;
|
||||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.Tabs;
|
||||
import org.mozilla.gecko.animation.PropertyAnimator;
|
||||
import org.mozilla.gecko.animation.PropertyAnimator.Property;
|
||||
import org.mozilla.gecko.animation.ViewHelper;
|
||||
import org.mozilla.gecko.db.BrowserContract.Thumbnails;
|
||||
import org.mozilla.gecko.db.BrowserDB;
|
||||
import org.mozilla.gecko.db.BrowserDB.URLColumns;
|
||||
import org.mozilla.gecko.gfx.BitmapUtils;
|
||||
import org.mozilla.gecko.home.HomeListView.HomeContextMenuInfo;
|
||||
import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
|
||||
import org.mozilla.gecko.home.PinSiteDialog.OnSiteSelectedListener;
|
||||
import org.mozilla.gecko.home.TopSitesGridAdapter.Thumbnail;
|
||||
import org.mozilla.gecko.home.TopSitesGridView.OnPinSiteListener;
|
||||
import org.mozilla.gecko.home.TopSitesGridView.TopSitesGridContextMenuInfo;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
||||
import android.support.v4.content.AsyncTaskLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.support.v4.widget.CursorAdapter;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnTouchListener;
|
||||
|
@ -32,8 +52,12 @@ import android.widget.AdapterView;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Fragment that displays frecency search results in a ListView.
|
||||
|
@ -42,15 +66,30 @@ public class TopSitesPage extends HomeFragment {
|
|||
// Logging tag name
|
||||
private static final String LOGTAG = "GeckoTopSitesPage";
|
||||
|
||||
// Cursor loader ID for search query
|
||||
private static final int LOADER_ID_TOP_SITES = 0;
|
||||
// Cursor loader ID for list of top sites
|
||||
private static final int LOADER_ID_TOP_SITES_LIST = 0;
|
||||
|
||||
// Adapter for the list of search results
|
||||
private VisitedAdapter mAdapter;
|
||||
// Cursor loader ID for grid of top sites
|
||||
private static final int LOADER_ID_TOP_SITES_GRID = 1;
|
||||
|
||||
// The view shown by the fragment.
|
||||
// Loader ID for thumbnails
|
||||
private static final int LOADER_ID_THUMBNAILS = 2;
|
||||
|
||||
// Key for thumbnail urls
|
||||
private static final String THUMBNAILS_URLS_KEY = "urls";
|
||||
|
||||
// Adapter for the list of top sites
|
||||
private VisitedAdapter mListAdapter;
|
||||
|
||||
// Adapter for the grid of top sites
|
||||
private TopSitesGridAdapter mGridAdapter;
|
||||
|
||||
// List of top sites
|
||||
private ListView mList;
|
||||
|
||||
// Grid of top sites
|
||||
private TopSitesGridView mGrid;
|
||||
|
||||
// Reference to the View to display when there are no results.
|
||||
private View mEmptyView;
|
||||
|
||||
|
@ -66,6 +105,12 @@ public class TopSitesPage extends HomeFragment {
|
|||
// Callbacks used for the search and favicon cursor loaders
|
||||
private CursorLoaderCallbacks mCursorLoaderCallbacks;
|
||||
|
||||
// Callback for thumbnail loader
|
||||
private ThumbnailsLoaderCallbacks mThumbnailsLoaderCallbacks;
|
||||
|
||||
// Listener for pinning sites
|
||||
private PinSiteListener mPinSiteListener;
|
||||
|
||||
// On URL open listener
|
||||
private OnUrlOpenListener mUrlOpenListener;
|
||||
|
||||
|
@ -98,18 +143,26 @@ public class TopSitesPage extends HomeFragment {
|
|||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.home_top_sites_page, container, false);
|
||||
final View view = inflater.inflate(R.layout.home_top_sites_page, container, false);
|
||||
|
||||
mList = (HomeListView) view.findViewById(R.id.list);
|
||||
|
||||
mGrid = new TopSitesGridView(getActivity());
|
||||
mList.addHeaderView(mGrid);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
mList = (HomeListView) view.findViewById(R.id.list);
|
||||
mPinSiteListener = new PinSiteListener();
|
||||
|
||||
mList.setTag(HomePager.LIST_TAG_MOST_VISITED);
|
||||
|
||||
mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
final Cursor c = mAdapter.getCursor();
|
||||
final Cursor c = mListAdapter.getCursor();
|
||||
if (c == null || !c.moveToPosition(position)) {
|
||||
return;
|
||||
}
|
||||
|
@ -121,7 +174,11 @@ public class TopSitesPage extends HomeFragment {
|
|||
}
|
||||
});
|
||||
|
||||
mGrid.setOnUrlOpenListener(mUrlOpenListener);
|
||||
mGrid.setOnPinSiteListener(mPinSiteListener);
|
||||
|
||||
registerForContextMenu(mList);
|
||||
registerForContextMenu(mGrid);
|
||||
|
||||
mBanner = (HomeBanner) view.findViewById(R.id.home_banner);
|
||||
mList.setOnTouchListener(new OnTouchListener() {
|
||||
|
@ -137,7 +194,10 @@ public class TopSitesPage extends HomeFragment {
|
|||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
mList = null;
|
||||
mGrid = null;
|
||||
mEmptyView = null;
|
||||
mListAdapter = null;
|
||||
mGridAdapter = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -159,18 +219,163 @@ public class TopSitesPage extends HomeFragment {
|
|||
|
||||
final Activity activity = getActivity();
|
||||
|
||||
// Intialize the search adapter
|
||||
mAdapter = new VisitedAdapter(activity, null);
|
||||
mList.setAdapter(mAdapter);
|
||||
// Setup the top sites grid adapter.
|
||||
mGridAdapter = new TopSitesGridAdapter(activity, null);
|
||||
mGrid.setAdapter(mGridAdapter);
|
||||
|
||||
// Setup the top sites list adapter.
|
||||
mListAdapter = new VisitedAdapter(activity, null);
|
||||
mList.setAdapter(mListAdapter);
|
||||
|
||||
// Create callbacks before the initial loader is started
|
||||
mCursorLoaderCallbacks = new CursorLoaderCallbacks(activity, getLoaderManager());
|
||||
mThumbnailsLoaderCallbacks = new ThumbnailsLoaderCallbacks();
|
||||
loadIfVisible();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
|
||||
if (menuInfo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// HomeFragment will handle the default case.
|
||||
if (menuInfo instanceof HomeContextMenuInfo) {
|
||||
super.onCreateContextMenu(menu, view, menuInfo);
|
||||
}
|
||||
|
||||
if (!(menuInfo instanceof TopSitesGridContextMenuInfo)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MenuInflater inflater = new MenuInflater(view.getContext());
|
||||
inflater.inflate(R.menu.top_sites_contextmenu, menu);
|
||||
|
||||
TopSitesGridContextMenuInfo info = (TopSitesGridContextMenuInfo) menuInfo;
|
||||
|
||||
if (!TextUtils.isEmpty(info.url)) {
|
||||
if (info.isPinned) {
|
||||
menu.findItem(R.id.top_sites_pin).setVisible(false);
|
||||
} else {
|
||||
menu.findItem(R.id.top_sites_unpin).setVisible(false);
|
||||
}
|
||||
} else {
|
||||
menu.findItem(R.id.top_sites_open_new_tab).setVisible(false);
|
||||
menu.findItem(R.id.top_sites_open_private_tab).setVisible(false);
|
||||
menu.findItem(R.id.top_sites_pin).setVisible(false);
|
||||
menu.findItem(R.id.top_sites_unpin).setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
ContextMenuInfo menuInfo = item.getMenuInfo();
|
||||
|
||||
// HomeFragment will handle the default case.
|
||||
if (menuInfo == null || !(menuInfo instanceof TopSitesGridContextMenuInfo)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TopSitesGridContextMenuInfo info = (TopSitesGridContextMenuInfo) menuInfo;
|
||||
final Activity activity = getActivity();
|
||||
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == R.id.top_sites_open_new_tab || itemId == R.id.top_sites_open_private_tab) {
|
||||
if (info.url == null) {
|
||||
Log.e(LOGTAG, "Can't open in new tab because URL is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
int flags = Tabs.LOADURL_NEW_TAB | Tabs.LOADURL_BACKGROUND;
|
||||
if (item.getItemId() == R.id.top_sites_open_private_tab)
|
||||
flags |= Tabs.LOADURL_PRIVATE;
|
||||
|
||||
Tabs.getInstance().loadUrl(info.url, flags);
|
||||
Toast.makeText(activity, R.string.new_tab_opened, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemId == R.id.top_sites_pin) {
|
||||
final String url = info.url;
|
||||
final String title = info.title;
|
||||
final int position = info.position;
|
||||
final Context context = getActivity().getApplicationContext();
|
||||
|
||||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
BrowserDB.pinSite(context.getContentResolver(), url, title, position);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemId == R.id.top_sites_unpin) {
|
||||
final int position = info.position;
|
||||
final Context context = getActivity().getApplicationContext();
|
||||
|
||||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
BrowserDB.unpinSite(context.getContentResolver(), position);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemId == R.id.top_sites_edit) {
|
||||
mPinSiteListener.onPinSite(info.position);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load() {
|
||||
getLoaderManager().initLoader(LOADER_ID_TOP_SITES, null, mCursorLoaderCallbacks);
|
||||
final LoaderManager manager = getLoaderManager();
|
||||
manager.initLoader(LOADER_ID_TOP_SITES_LIST, null, mCursorLoaderCallbacks);
|
||||
manager.initLoader(LOADER_ID_TOP_SITES_GRID, null, mCursorLoaderCallbacks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Listener for pinning sites.
|
||||
*/
|
||||
private class PinSiteListener implements OnPinSiteListener,
|
||||
OnSiteSelectedListener {
|
||||
// Tag for the PinSiteDialog fragment.
|
||||
private static final String TAG_PIN_SITE = "pin_site";
|
||||
|
||||
// Position of the pin.
|
||||
private int mPosition;
|
||||
|
||||
@Override
|
||||
public void onPinSite(int position) {
|
||||
mPosition = position;
|
||||
|
||||
final FragmentManager manager = getActivity().getSupportFragmentManager();
|
||||
PinSiteDialog dialog = (PinSiteDialog) manager.findFragmentByTag(TAG_PIN_SITE);
|
||||
if (dialog == null) {
|
||||
dialog = PinSiteDialog.newInstance();
|
||||
}
|
||||
|
||||
dialog.setOnSiteSelectedListener(this);
|
||||
dialog.show(manager, TAG_PIN_SITE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSiteSelected(final String url, final String title) {
|
||||
final int position = mPosition;
|
||||
final Context context = getActivity().getApplicationContext();
|
||||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
BrowserDB.pinSite(context.getContentResolver(), url, title, position);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void handleListTouchEvent(MotionEvent event) {
|
||||
|
@ -247,11 +452,11 @@ public class TopSitesPage extends HomeFragment {
|
|||
}
|
||||
}
|
||||
|
||||
private static class TopSitesCursorLoader extends SimpleCursorLoader {
|
||||
private static class TopSitesListLoader extends SimpleCursorLoader {
|
||||
// Max number of search results
|
||||
private static final int SEARCH_LIMIT = 50;
|
||||
|
||||
public TopSitesCursorLoader(Context context) {
|
||||
public TopSitesListLoader(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
|
@ -262,6 +467,18 @@ public class TopSitesPage extends HomeFragment {
|
|||
}
|
||||
}
|
||||
|
||||
private static class TopSitesGridLoader extends SimpleCursorLoader {
|
||||
public TopSitesGridLoader(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor loadCursor() {
|
||||
final int max = getContext().getResources().getInteger(R.integer.number_of_top_sites);
|
||||
return BrowserDB.getTopBookmarks(getContext().getContentResolver(), max);
|
||||
}
|
||||
}
|
||||
|
||||
private class VisitedAdapter extends CursorAdapter {
|
||||
public VisitedAdapter(Context context, Cursor cursor) {
|
||||
super(context, cursor);
|
||||
|
@ -286,8 +503,12 @@ public class TopSitesPage extends HomeFragment {
|
|||
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||
if (id == LOADER_ID_TOP_SITES) {
|
||||
return new TopSitesCursorLoader(getActivity());
|
||||
final Activity activity = getActivity();
|
||||
|
||||
if (id == LOADER_ID_TOP_SITES_LIST) {
|
||||
return new TopSitesListLoader(activity);
|
||||
} else if (id == LOADER_ID_TOP_SITES_GRID) {
|
||||
return new TopSitesGridLoader(activity);
|
||||
} else {
|
||||
return super.onCreateLoader(id, args);
|
||||
}
|
||||
|
@ -295,10 +516,29 @@ public class TopSitesPage extends HomeFragment {
|
|||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<Cursor> loader, Cursor c) {
|
||||
if (loader.getId() == LOADER_ID_TOP_SITES) {
|
||||
mAdapter.swapCursor(c);
|
||||
final int id = loader.getId();
|
||||
|
||||
if (id == LOADER_ID_TOP_SITES_LIST) {
|
||||
mListAdapter.swapCursor(c);
|
||||
updateUiFromCursor(c);
|
||||
loadFavicons(c);
|
||||
} else if (id == LOADER_ID_TOP_SITES_GRID) {
|
||||
mGridAdapter.swapCursor(c);
|
||||
|
||||
// Load the thumbnails.
|
||||
if (c.getCount() > 0 && c.moveToFirst()) {
|
||||
final ArrayList<String> urls = new ArrayList<String>();
|
||||
do {
|
||||
final String url = c.getString(c.getColumnIndexOrThrow(URLColumns.URL));
|
||||
urls.add(url);
|
||||
} while (c.moveToNext());
|
||||
|
||||
if (urls.size() > 0) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putStringArrayList(THUMBNAILS_URLS_KEY, urls);
|
||||
getLoaderManager().restartLoader(LOADER_ID_THUMBNAILS, bundle, mThumbnailsLoaderCallbacks);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.onLoadFinished(loader, c);
|
||||
}
|
||||
|
@ -306,8 +546,12 @@ public class TopSitesPage extends HomeFragment {
|
|||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<Cursor> loader) {
|
||||
if (loader.getId() == LOADER_ID_TOP_SITES) {
|
||||
mAdapter.swapCursor(null);
|
||||
final int id = loader.getId();
|
||||
|
||||
if (id == LOADER_ID_TOP_SITES_LIST) {
|
||||
mListAdapter.swapCursor(null);
|
||||
} else if (id == LOADER_ID_TOP_SITES_GRID) {
|
||||
mGridAdapter.swapCursor(null);
|
||||
} else {
|
||||
super.onLoaderReset(loader);
|
||||
}
|
||||
|
@ -315,7 +559,135 @@ public class TopSitesPage extends HomeFragment {
|
|||
|
||||
@Override
|
||||
public void onFaviconsLoaded() {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
mListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An AsyncTaskLoader to load the thumbnails from a cursor.
|
||||
*/
|
||||
private static class ThumbnailsLoader extends AsyncTaskLoader<Map<String, Thumbnail>> {
|
||||
private Map<String, Thumbnail> mThumbnails;
|
||||
private ArrayList<String> mUrls;
|
||||
|
||||
public ThumbnailsLoader(Context context, ArrayList<String> urls) {
|
||||
super(context);
|
||||
mUrls = urls;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Thumbnail> loadInBackground() {
|
||||
if (mUrls == null || mUrls.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Map<String, Thumbnail> thumbnails = new HashMap<String, Thumbnail>();
|
||||
|
||||
// Query the DB for thumbnails.
|
||||
final ContentResolver cr = getContext().getContentResolver();
|
||||
final Cursor cursor = BrowserDB.getThumbnailsForUrls(cr, mUrls);
|
||||
|
||||
try {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
do {
|
||||
// Try to get the thumbnail, if cursor is valid.
|
||||
String url = cursor.getString(cursor.getColumnIndexOrThrow(Thumbnails.URL));
|
||||
final byte[] b = cursor.getBlob(cursor.getColumnIndexOrThrow(Thumbnails.DATA));
|
||||
final Bitmap bitmap = (b == null ? null : BitmapUtils.decodeByteArray(b));
|
||||
|
||||
if (bitmap != null) {
|
||||
thumbnails.put(url, new Thumbnail(bitmap, true));
|
||||
}
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
// Query the DB for favicons for the urls without thumbnails.
|
||||
for (String url : mUrls) {
|
||||
if (!thumbnails.containsKey(url)) {
|
||||
final Bitmap bitmap = BrowserDB.getFaviconForUrl(cr, url);
|
||||
if (bitmap != null) {
|
||||
// Favicons.scaleImage can return several different size favicons,
|
||||
// but will at least prevent this from being too large.
|
||||
thumbnails.put(url, new Thumbnail(Favicons.scaleImage(bitmap), false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return thumbnails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deliverResult(Map<String, Thumbnail> thumbnails) {
|
||||
if (isReset()) {
|
||||
mThumbnails = null;
|
||||
return;
|
||||
}
|
||||
|
||||
mThumbnails = thumbnails;
|
||||
|
||||
if (isStarted()) {
|
||||
super.deliverResult(thumbnails);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartLoading() {
|
||||
if (mThumbnails != null) {
|
||||
deliverResult(mThumbnails);
|
||||
}
|
||||
|
||||
if (takeContentChanged() || mThumbnails == null) {
|
||||
forceLoad();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStopLoading() {
|
||||
cancelLoad();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCanceled(Map<String, Thumbnail> thumbnails) {
|
||||
mThumbnails = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onReset() {
|
||||
super.onReset();
|
||||
|
||||
// Ensure the loader is stopped.
|
||||
onStopLoading();
|
||||
|
||||
mThumbnails = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loader callbacks for the thumbnails on TopSitesGridView.
|
||||
*/
|
||||
private class ThumbnailsLoaderCallbacks implements LoaderCallbacks<Map<String, Thumbnail>> {
|
||||
@Override
|
||||
public Loader<Map<String, Thumbnail>> onCreateLoader(int id, Bundle args) {
|
||||
return new ThumbnailsLoader(getActivity(), args.getStringArrayList(THUMBNAILS_URLS_KEY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<Map<String, Thumbnail>> loader, Map<String, Thumbnail> thumbnails) {
|
||||
if (mGridAdapter != null) {
|
||||
mGridAdapter.updateThumbnails(thumbnails);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<Map<String, Thumbnail>> loader) {
|
||||
if (mGridAdapter != null) {
|
||||
mGridAdapter.updateThumbnails(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,10 +17,10 @@ import android.util.AttributeSet;
|
|||
import android.widget.ImageView;
|
||||
|
||||
/**
|
||||
* A height constrained ImageView to show thumbnails of top bookmarks.
|
||||
* A height constrained ImageView to show thumbnails of top and pinned sites.
|
||||
*/
|
||||
public class BookmarkThumbnailView extends ImageView {
|
||||
private static final String LOGTAG = "GeckoBookmarkThumbnailView";
|
||||
public class TopSitesThumbnailView extends ImageView {
|
||||
private static final String LOGTAG = "GeckoTopSitesThumbnailView";
|
||||
|
||||
// 27.34% opacity filter for the dominant color.
|
||||
private static final int COLOR_FILTER = 0x46FFFFFF;
|
||||
|
@ -41,18 +41,18 @@ public class BookmarkThumbnailView extends ImageView {
|
|||
sBorderPaint.setStyle(Paint.Style.STROKE);
|
||||
}
|
||||
|
||||
public BookmarkThumbnailView(Context context) {
|
||||
public TopSitesThumbnailView(Context context) {
|
||||
this(context, null);
|
||||
|
||||
// A border will be drawn if needed.
|
||||
setWillNotDraw(false);
|
||||
}
|
||||
|
||||
public BookmarkThumbnailView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, R.attr.bookmarkThumbnailViewStyle);
|
||||
public TopSitesThumbnailView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, R.attr.topSitesThumbnailViewStyle);
|
||||
}
|
||||
|
||||
public BookmarkThumbnailView(Context context, AttributeSet attrs, int defStyle) {
|
||||
public TopSitesThumbnailView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class BookmarkThumbnailView extends ImageView {
|
|||
@Override
|
||||
public void setBackgroundColor(int color) {
|
||||
int colorFilter = color == 0 ? DEFAULT_COLOR : color & COLOR_FILTER;
|
||||
Drawable drawable = getResources().getDrawable(R.drawable.bookmark_thumbnail_bg);
|
||||
Drawable drawable = getResources().getDrawable(R.drawable.top_sites_thumbnail_bg);
|
||||
drawable.setColorFilter(colorFilter, Mode.SRC_ATOP);
|
||||
setBackgroundDrawable(drawable);
|
||||
}
|
|
@ -225,9 +225,9 @@ size. -->
|
|||
<!ENTITY contextmenu_edit_bookmark "Edit">
|
||||
<!ENTITY contextmenu_subscribe "Subscribe to Page">
|
||||
<!ENTITY contextmenu_site_settings "Edit Site Settings">
|
||||
<!ENTITY contextmenu_top_bookmarks_edit "Edit">
|
||||
<!ENTITY contextmenu_top_bookmarks_pin "Pin Site">
|
||||
<!ENTITY contextmenu_top_bookmarks_unpin "Unpin Site">
|
||||
<!ENTITY contextmenu_top_sites_edit "Edit">
|
||||
<!ENTITY contextmenu_top_sites_pin "Pin Site">
|
||||
<!ENTITY contextmenu_top_sites_unpin "Unpin Site">
|
||||
|
||||
<!ENTITY pref_titlebar_mode "Title bar">
|
||||
<!ENTITY pref_titlebar_mode_title "Show page title">
|
||||
|
@ -289,7 +289,7 @@ size. -->
|
|||
<!ENTITY home_reading_list_hint_accessible "TIP: Save articles to your reading list by long pressing the reader mode button when it appears in the title bar.">
|
||||
|
||||
<!ENTITY home_most_visited_empty "Websites you visit most frequently show up here.">
|
||||
<!ENTITY pin_bookmark_dialog_hint "Enter a search keyword">
|
||||
<!ENTITY pin_site_dialog_hint "Enter a search keyword">
|
||||
|
||||
<!ENTITY filepicker_title "Choose File">
|
||||
<!ENTITY filepicker_audio_title "Choose or record a sound">
|
||||
|
|
До Ширина: | Высота: | Размер: 151 B После Ширина: | Высота: | Размер: 151 B |
До Ширина: | Высота: | Размер: 137 B После Ширина: | Высота: | Размер: 137 B |
До Ширина: | Высота: | Размер: 156 B После Ширина: | Высота: | Размер: 156 B |
|
@ -19,7 +19,7 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:padding="6dip"
|
||||
android:hint="@string/pin_bookmark_dialog_hint"
|
||||
android:hint="@string/pin_site_dialog_hint"
|
||||
android:background="@drawable/url_bar_entry"
|
||||
android:textColor="@color/url_bar_title"
|
||||
android:textColorHint="@color/url_bar_title_hint"
|
|
@ -6,14 +6,14 @@
|
|||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:gecko="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<org.mozilla.gecko.home.BookmarkThumbnailView
|
||||
<org.mozilla.gecko.home.TopSitesThumbnailView
|
||||
android:id="@+id/thumbnail"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<org.mozilla.gecko.home.FadedTextView
|
||||
android:id="@+id/title"
|
||||
style="@style/Widget.TopBookmarkItemTitle"
|
||||
style="@style/Widget.TopSitesGridItemTitle"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:duplicateParentState="true"
|
|
@ -5,19 +5,19 @@
|
|||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:id="@+id/top_bookmarks_open_new_tab"
|
||||
<item android:id="@+id/top_sites_open_new_tab"
|
||||
android:title="@string/contextmenu_open_new_tab"/>
|
||||
|
||||
<item android:id="@+id/top_bookmarks_open_private_tab"
|
||||
<item android:id="@+id/top_sites_open_private_tab"
|
||||
android:title="@string/contextmenu_open_private_tab"/>
|
||||
|
||||
<item android:id="@+id/top_bookmarks_edit"
|
||||
android:title="@string/contextmenu_top_bookmarks_edit"/>
|
||||
<item android:id="@+id/top_sites_edit"
|
||||
android:title="@string/contextmenu_top_sites_edit"/>
|
||||
|
||||
<item android:id="@+id/top_bookmarks_pin"
|
||||
android:title="@string/contextmenu_top_bookmarks_pin"/>
|
||||
<item android:id="@+id/top_sites_pin"
|
||||
android:title="@string/contextmenu_top_sites_pin"/>
|
||||
|
||||
<item android:id="@+id/top_bookmarks_unpin"
|
||||
android:title="@string/contextmenu_top_bookmarks_unpin"/>
|
||||
<item android:id="@+id/top_sites_unpin"
|
||||
android:title="@string/contextmenu_top_sites_unpin"/>
|
||||
|
||||
</menu>
|
|
@ -26,7 +26,7 @@
|
|||
<item name="android:scrollbarStyle">outsideOverlay</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.TopBookmarksView" parent="Widget.GridView">
|
||||
<style name="Widget.TopSitesGridView" parent="Widget.GridView">
|
||||
<item name="android:paddingLeft">55dp</item>
|
||||
<item name="android:paddingRight">55dp</item>
|
||||
<item name="android:paddingTop">30dp</item>
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
<item name="topDivider">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.TopBookmarksView" parent="Widget.GridView">
|
||||
<style name="Widget.TopSitesGridView" parent="Widget.GridView">
|
||||
<item name="android:paddingLeft">5dp</item>
|
||||
<item name="android:paddingRight">5dp</item>
|
||||
<item name="android:paddingTop">30dp</item>
|
||||
|
|
|
@ -43,9 +43,9 @@
|
|||
<item name="menuItemActionViewStyle">@style/Widget.MenuItemActionView</item>
|
||||
<item name="menuItemDefaultStyle">@style/Widget.MenuItemDefault</item>
|
||||
<item name="bookmarksListViewStyle">@style/Widget.BookmarksListView</item>
|
||||
<item name="bookmarkThumbnailViewStyle">@style/Widget.BookmarkThumbnailView</item>
|
||||
<item name="topBookmarkItemViewStyle">@style/Widget.TopBookmarkItemView</item>
|
||||
<item name="topBookmarksViewStyle">@style/Widget.TopBookmarksView</item>
|
||||
<item name="topSitesGridItemViewStyle">@style/Widget.TopSitesGridItemView</item>
|
||||
<item name="topSitesGridViewStyle">@style/Widget.TopSitesGridView</item>
|
||||
<item name="topSitesThumbnailViewStyle">@style/Widget.TopSitesThumbnailView</item>
|
||||
<item name="homeListViewStyle">@style/Widget.HomeListView</item>
|
||||
</style>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<resources>
|
||||
|
||||
<style name="Widget.TopBookmarksView" parent="Widget.GridView">
|
||||
<style name="Widget.TopSitesGridView" parent="Widget.GridView">
|
||||
<item name="android:paddingLeft">55dp</item>
|
||||
<item name="android:paddingRight">55dp</item>
|
||||
<item name="android:paddingTop">30dp</item>
|
||||
|
|
|
@ -20,14 +20,14 @@
|
|||
<!-- Default style for the BookmarksListView -->
|
||||
<attr name="bookmarksListViewStyle" format="reference" />
|
||||
|
||||
<!-- Default style for the BookmarkThumbnailView -->
|
||||
<attr name="bookmarkThumbnailViewStyle" format="reference" />
|
||||
<!-- Default style for the TopSitesGridItemView -->
|
||||
<attr name="topSitesGridItemViewStyle" format="reference" />
|
||||
|
||||
<!-- Default style for the TopBookmarkItemView -->
|
||||
<attr name="topBookmarkItemViewStyle" format="reference" />
|
||||
<!-- Default style for the TopSitesGridView -->
|
||||
<attr name="topSitesGridViewStyle" format="reference" />
|
||||
|
||||
<!-- Default style for the TopBookmarksView -->
|
||||
<attr name="topBookmarksViewStyle" format="reference" />
|
||||
<!-- Default style for the TopSitesThumbnailView -->
|
||||
<attr name="topSitesThumbnailViewStyle" format="reference" />
|
||||
|
||||
<!-- Default style for the HomeListView -->
|
||||
<attr name="homeListViewStyle" format="reference" />
|
||||
|
@ -212,7 +212,7 @@
|
|||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="TopBookmarksView">
|
||||
<declare-styleable name="TopSitesGridView">
|
||||
<attr name="android:horizontalSpacing"/>
|
||||
<attr name="android:verticalSpacing"/>
|
||||
</declare-styleable>
|
||||
|
|
|
@ -117,13 +117,13 @@
|
|||
<item name="android:drawableLeft">@drawable/bookmark_folder</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.TopBookmarksView" parent="Widget.GridView">
|
||||
<style name="Widget.TopSitesGridView" parent="Widget.GridView">
|
||||
<item name="android:padding">7dp</item>
|
||||
<item name="android:horizontalSpacing">0dp</item>
|
||||
<item name="android:verticalSpacing">7dp</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.TopBookmarkItemView">
|
||||
<style name="Widget.TopSitesGridItemView">
|
||||
<item name="android:layout_width">fill_parent</item>
|
||||
<item name="android:layout_height">fill_parent</item>
|
||||
<item name="android:padding">5dip</item>
|
||||
|
@ -134,19 +134,19 @@
|
|||
|
||||
<style name="Widget.BookmarksListView" parent="Widget.HomeListView"/>
|
||||
|
||||
<style name="Widget.BookmarkThumbnailView">
|
||||
<style name="Widget.TopSitesThumbnailView">
|
||||
<item name="android:padding">0dip</item>
|
||||
<item name="android:scaleType">centerCrop</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.TopBookmarkItemPin">
|
||||
<style name="Widget.TopSitesGridItemPin">
|
||||
<item name="android:minWidth">30dip</item>
|
||||
<item name="android:minHeight">30dip</item>
|
||||
<item name="android:padding">0dip</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.TopBookmarkItemTitle">
|
||||
<item name="android:textColor">@color/top_bookmark_item_title</item>
|
||||
<style name="Widget.TopSitesGridItemTitle">
|
||||
<item name="android:textColor">@color/top_sites_grid_item_title</item>
|
||||
<item name="android:textSize">12sp</item>
|
||||
<item name="android:singleLine">true</item>
|
||||
<item name="android:ellipsize">none</item>
|
||||
|
|
|
@ -78,9 +78,9 @@
|
|||
<item name="android:textViewStyle">@style/Widget.TextView</item>
|
||||
<item name="android:spinnerStyle">@style/Widget.Spinner</item>
|
||||
<item name="bookmarksListViewStyle">@style/Widget.BookmarksListView</item>
|
||||
<item name="bookmarkThumbnailViewStyle">@style/Widget.BookmarkThumbnailView</item>
|
||||
<item name="topBookmarkItemViewStyle">@style/Widget.TopBookmarkItemView</item>
|
||||
<item name="topBookmarksViewStyle">@style/Widget.TopBookmarksView</item>
|
||||
<item name="topSitesGridItemViewStyle">@style/Widget.TopSitesGridItemView</item>
|
||||
<item name="topSitesGridViewStyle">@style/Widget.TopSitesGridView</item>
|
||||
<item name="topSitesThumbnailViewStyle">@style/Widget.TopSitesThumbnailView</item>
|
||||
<item name="homeListViewStyle">@style/Widget.HomeListView</item>
|
||||
</style>
|
||||
|
||||
|
|
|
@ -222,9 +222,9 @@
|
|||
<string name="contextmenu_edit_bookmark">&contextmenu_edit_bookmark;</string>
|
||||
<string name="contextmenu_subscribe">&contextmenu_subscribe;</string>
|
||||
<string name="contextmenu_site_settings">&contextmenu_site_settings;</string>
|
||||
<string name="contextmenu_top_bookmarks_edit">&contextmenu_top_bookmarks_edit;</string>
|
||||
<string name="contextmenu_top_bookmarks_pin">&contextmenu_top_bookmarks_pin;</string>
|
||||
<string name="contextmenu_top_bookmarks_unpin">&contextmenu_top_bookmarks_unpin;</string>
|
||||
<string name="contextmenu_top_sites_edit">&contextmenu_top_sites_edit;</string>
|
||||
<string name="contextmenu_top_sites_pin">&contextmenu_top_sites_pin;</string>
|
||||
<string name="contextmenu_top_sites_unpin">&contextmenu_top_sites_unpin;</string>
|
||||
|
||||
<string name="pref_titlebar_mode">&pref_titlebar_mode;</string>
|
||||
<string name="pref_titlebar_mode_title">&pref_titlebar_mode_title;</string>
|
||||
|
@ -264,7 +264,7 @@
|
|||
<string name="home_reading_list_empty">&home_reading_list_empty;</string>
|
||||
<string name="home_reading_list_hint">&home_reading_list_hint;</string>
|
||||
<string name="home_reading_list_hint_accessible">&home_reading_list_hint_accessible;</string>
|
||||
<string name="pin_bookmark_dialog_hint">&pin_bookmark_dialog_hint;</string>
|
||||
<string name="pin_site_dialog_hint">&pin_site_dialog_hint;</string>
|
||||
|
||||
<string name="filepicker_title">&filepicker_title;</string>
|
||||
<string name="filepicker_audio_title">&filepicker_audio_title;</string>
|
||||
|
|
Загрузка…
Ссылка в новой задаче