Commit ec3933dd authored by Cathy Li's avatar Cathy Li Committed by Commit Bot

[Explore sites]: Remove unneeded files and the title on the explore sites page.

Change-Id: Iee0486cc74130e4b28f60cf9ed9fbddca915e7e3
Reviewed-on: https://chromium-review.googlesource.com/c/1374330
Commit-Queue: Cathy Li <chili@chromium.org>
Reviewed-by: default avatarJustin DeWitt <dewittj@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616091}
parent a6fb79e9
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="@style/BlackHeadline"
android:text="@string/explore_sites_title"
android:paddingBottom="@dimen/explore_sites_category_padding"
android:paddingTop="@dimen/explore_sites_page_padding"/>
...@@ -12,9 +12,8 @@ import android.text.SpannableString; ...@@ -12,9 +12,8 @@ import android.text.SpannableString;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.modelutil.ListObservable; import org.chromium.chrome.browser.modelutil.ForwardingListObservable;
import org.chromium.chrome.browser.modelutil.ListObservable.ListObserver; import org.chromium.chrome.browser.modelutil.ListObservable.ListObserver;
import org.chromium.chrome.browser.modelutil.ListObservableImpl;
import org.chromium.chrome.browser.modelutil.PropertyKey; import org.chromium.chrome.browser.modelutil.PropertyKey;
import org.chromium.chrome.browser.modelutil.PropertyModel; import org.chromium.chrome.browser.modelutil.PropertyModel;
import org.chromium.chrome.browser.modelutil.PropertyObservable; import org.chromium.chrome.browser.modelutil.PropertyObservable;
...@@ -33,17 +32,16 @@ import java.lang.annotation.RetentionPolicy; ...@@ -33,17 +32,16 @@ import java.lang.annotation.RetentionPolicy;
/** /**
* Recycler view adapter delegate for a model containing a list of category cards and an error code. * Recycler view adapter delegate for a model containing a list of category cards and an error code.
*/ */
class CategoryCardAdapter extends ListObservableImpl<Void> class CategoryCardAdapter extends ForwardingListObservable<Void>
implements RecyclerViewAdapter implements RecyclerViewAdapter
.Delegate<CategoryCardViewHolderFactory.CategoryCardViewHolder, Void>, .Delegate<CategoryCardViewHolderFactory.CategoryCardViewHolder, Void>,
PropertyObservable.PropertyObserver<PropertyKey>, ListObserver<Void> { PropertyObservable.PropertyObserver<PropertyKey>, ListObserver<Void> {
@IntDef({ViewType.HEADER, ViewType.CATEGORY, ViewType.LOADING, ViewType.ERROR}) @IntDef({ViewType.CATEGORY, ViewType.LOADING, ViewType.ERROR})
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface ViewType { public @interface ViewType {
int HEADER = 0; int CATEGORY = 0;
int CATEGORY = 1; int LOADING = 1;
int LOADING = 2; int ERROR = 2;
int ERROR = 3;
} }
private final RoundedIconGenerator mIconGenerator; private final RoundedIconGenerator mIconGenerator;
...@@ -89,7 +87,6 @@ class CategoryCardAdapter extends ListObservableImpl<Void> ...@@ -89,7 +87,6 @@ class CategoryCardAdapter extends ListObservableImpl<Void>
case ExploreSitesPage.CatalogLoadingState.LOADING_NET: case ExploreSitesPage.CatalogLoadingState.LOADING_NET:
return ViewType.LOADING; return ViewType.LOADING;
case ExploreSitesPage.CatalogLoadingState.SUCCESS: case ExploreSitesPage.CatalogLoadingState.SUCCESS:
if (position == 0) return ViewType.HEADER;
return ViewType.CATEGORY; return ViewType.CATEGORY;
default: default:
assert(false); assert(false);
...@@ -139,28 +136,8 @@ class CategoryCardAdapter extends ListObservableImpl<Void> ...@@ -139,28 +136,8 @@ class CategoryCardAdapter extends ListObservableImpl<Void>
} }
} }
if (key == ExploreSitesPage.SCROLL_TO_CATEGORY_KEY) { if (key == ExploreSitesPage.SCROLL_TO_CATEGORY_KEY) {
int pos = mCategoryModel.get(ExploreSitesPage.SCROLL_TO_CATEGORY_KEY); mLayoutManager.scrollToPosition(
// Add 1 for title. mCategoryModel.get(ExploreSitesPage.SCROLL_TO_CATEGORY_KEY));
mLayoutManager.scrollToPosition(pos + 1);
} }
} }
@Override
public void onItemRangeInserted(ListObservable source, int index, int count) {
// Add 1 because of title.
notifyItemRangeInserted(index + 1, count);
}
@Override
public void onItemRangeRemoved(ListObservable source, int index, int count) {
// Add 1 because of title.
notifyItemRangeRemoved(index + 1, count);
}
@Override
public void onItemRangeChanged(
ListObservable<Void> source, int index, int count, @Nullable Void payload) {
// Add 1 because of title.
notifyItemRangeChanged(index + 1, count, payload);
}
} }
...@@ -27,11 +27,6 @@ class CategoryCardViewHolderFactory implements RecyclerViewAdapter.ViewHolderFac ...@@ -27,11 +27,6 @@ class CategoryCardViewHolderFactory implements RecyclerViewAdapter.ViewHolderFac
ViewGroup parent, @CategoryCardAdapter.ViewType int viewType) { ViewGroup parent, @CategoryCardAdapter.ViewType int viewType) {
View view; View view;
switch (viewType) { switch (viewType) {
case CategoryCardAdapter.ViewType.HEADER:
view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.explore_sites_title_card, parent,
/* attachToRoot = */ false);
break;
case CategoryCardAdapter.ViewType.CATEGORY: case CategoryCardAdapter.ViewType.CATEGORY:
view = LayoutInflater.from(parent.getContext()) view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.explore_sites_category_card_view, parent, .inflate(R.layout.explore_sites_category_card_view, parent,
......
...@@ -32,7 +32,6 @@ import org.chromium.chrome.browser.profiles.Profile; ...@@ -32,7 +32,6 @@ import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tab.EmptyTabObserver; import org.chromium.chrome.browser.tab.EmptyTabObserver;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabObserver; import org.chromium.chrome.browser.tab.TabObserver;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.widget.RoundedIconGenerator; import org.chromium.chrome.browser.widget.RoundedIconGenerator;
import org.chromium.content_public.browser.NavigationController; import org.chromium.content_public.browser.NavigationController;
import org.chromium.content_public.browser.NavigationEntry; import org.chromium.content_public.browser.NavigationEntry;
...@@ -69,7 +68,6 @@ public class ExploreSitesPage extends BasicNativePage { ...@@ -69,7 +68,6 @@ public class ExploreSitesPage extends BasicNativePage {
int LOADING_NET = 4; // Retrieving catalog resources from internet. int LOADING_NET = 4; // Retrieving catalog resources from internet.
} }
private TabModelSelector mTabModelSelector;
private NativePageHost mHost; private NativePageHost mHost;
private Tab mTab; private Tab mTab;
private TabObserver mTabObserver; private TabObserver mTabObserver;
...@@ -107,7 +105,6 @@ public class ExploreSitesPage extends BasicNativePage { ...@@ -107,7 +105,6 @@ public class ExploreSitesPage extends BasicNativePage {
mTab.addObserver(mTabObserver); mTab.addObserver(mTabObserver);
} }
mTabModelSelector = activity.getTabModelSelector();
mTitle = activity.getString(R.string.explore_sites_title); mTitle = activity.getString(R.string.explore_sites_title);
mView = (ViewGroup) activity.getLayoutInflater().inflate( mView = (ViewGroup) activity.getLayoutInflater().inflate(
R.layout.explore_sites_page_layout, null); R.layout.explore_sites_page_layout, null);
...@@ -128,8 +125,9 @@ public class ExploreSitesPage extends BasicNativePage { ...@@ -128,8 +125,9 @@ public class ExploreSitesPage extends BasicNativePage {
context.getResources(), R.color.default_favicon_background_color), context.getResources(), R.color.default_favicon_background_color),
context.getResources().getDimensionPixelSize(R.dimen.tile_view_icon_text_size)); context.getResources().getDimensionPixelSize(R.dimen.tile_view_icon_text_size));
NativePageNavigationDelegateImpl navDelegate = NativePageNavigationDelegateImpl navDelegate = new NativePageNavigationDelegateImpl(
new NativePageNavigationDelegateImpl(activity, mProfile, host, mTabModelSelector); activity, mProfile, host, activity.getTabModelSelector());
// Don't direct reference activity because it might change if tab is reparented. // Don't direct reference activity because it might change if tab is reparented.
Runnable closeContextMenuCallback = Runnable closeContextMenuCallback =
() -> host.getActiveTab().getActivity().closeContextMenu(); () -> host.getActiveTab().getActivity().closeContextMenu();
...@@ -149,8 +147,6 @@ public class ExploreSitesPage extends BasicNativePage { ...@@ -149,8 +147,6 @@ public class ExploreSitesPage extends BasicNativePage {
ExploreSitesBridge.getEspCatalog(mProfile, this::translateToModel); ExploreSitesBridge.getEspCatalog(mProfile, this::translateToModel);
RecordUserAction.record("Android.ExploreSitesPage.Open"); RecordUserAction.record("Android.ExploreSitesPage.Open");
// TODO(chili): Set layout to be an observer of list model
} }
void translateToModel(@Nullable List<ExploreSitesCategory> categoryList) { void translateToModel(@Nullable List<ExploreSitesCategory> categoryList) {
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.explore_sites;
import android.view.View;
import org.chromium.chrome.browser.profiles.Profile;
/**
* Class to manage layout of explore sites page.
*/
public class ExploreSitesPageLayout {
private View mParent;
private Profile mProfile;
public ExploreSitesPageLayout(View parent, Profile profile) {
mParent = parent;
mProfile = profile;
}
}
...@@ -637,7 +637,6 @@ chrome_java_sources = [ ...@@ -637,7 +637,6 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryTile.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryTile.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryTileView.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryTileView.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesPage.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesPage.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesPageLayout.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesSection.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesSection.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesSite.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesSite.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesTileView.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesTileView.java",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment