diff options
50 files changed, 185 insertions, 773 deletions
diff --git a/chrome/android/java/res/drawable-hdpi/eb_grid_icon.png b/chrome/android/java/res/drawable-hdpi/eb_grid_icon.png Binary files differdeleted file mode 100644 index b4ad0f3..0000000 --- a/chrome/android/java/res/drawable-hdpi/eb_grid_icon.png +++ /dev/null diff --git a/chrome/android/java/res/drawable-hdpi/eb_item_tile.9.png b/chrome/android/java/res/drawable-hdpi/eb_large_tablet_list_background.9.png Binary files differindex 788f670..788f670 100644 --- a/chrome/android/java/res/drawable-hdpi/eb_item_tile.9.png +++ b/chrome/android/java/res/drawable-hdpi/eb_large_tablet_list_background.9.png diff --git a/chrome/android/java/res/drawable-hdpi/eb_list_icon.png b/chrome/android/java/res/drawable-hdpi/eb_list_icon.png Binary files differdeleted file mode 100644 index 55d6243..0000000 --- a/chrome/android/java/res/drawable-hdpi/eb_list_icon.png +++ /dev/null diff --git a/chrome/android/java/res/drawable-mdpi/eb_grid_icon.png b/chrome/android/java/res/drawable-mdpi/eb_grid_icon.png Binary files differdeleted file mode 100644 index d2a20fb..0000000 --- a/chrome/android/java/res/drawable-mdpi/eb_grid_icon.png +++ /dev/null diff --git a/chrome/android/java/res/drawable-mdpi/eb_item_tile.9.png b/chrome/android/java/res/drawable-mdpi/eb_large_tablet_list_background.9.png Binary files differindex 2133eaa..2133eaa 100644 --- a/chrome/android/java/res/drawable-mdpi/eb_item_tile.9.png +++ b/chrome/android/java/res/drawable-mdpi/eb_large_tablet_list_background.9.png diff --git a/chrome/android/java/res/drawable-mdpi/eb_list_icon.png b/chrome/android/java/res/drawable-mdpi/eb_list_icon.png Binary files differdeleted file mode 100644 index 1d03e69..0000000 --- a/chrome/android/java/res/drawable-mdpi/eb_list_icon.png +++ /dev/null diff --git a/chrome/android/java/res/drawable-xhdpi/eb_grid_icon.png b/chrome/android/java/res/drawable-xhdpi/eb_grid_icon.png Binary files differdeleted file mode 100644 index 0d105f0..0000000 --- a/chrome/android/java/res/drawable-xhdpi/eb_grid_icon.png +++ /dev/null diff --git a/chrome/android/java/res/drawable-xhdpi/eb_item_tile.9.png b/chrome/android/java/res/drawable-xhdpi/eb_large_tablet_list_background.9.png Binary files differindex eb5a8f7..eb5a8f7 100644 --- a/chrome/android/java/res/drawable-xhdpi/eb_item_tile.9.png +++ b/chrome/android/java/res/drawable-xhdpi/eb_large_tablet_list_background.9.png diff --git a/chrome/android/java/res/drawable-xhdpi/eb_list_icon.png b/chrome/android/java/res/drawable-xhdpi/eb_list_icon.png Binary files differdeleted file mode 100644 index e0dcb48..0000000 --- a/chrome/android/java/res/drawable-xhdpi/eb_list_icon.png +++ /dev/null diff --git a/chrome/android/java/res/drawable-xxhdpi/eb_grid_icon.png b/chrome/android/java/res/drawable-xxhdpi/eb_grid_icon.png Binary files differdeleted file mode 100644 index 434884f..0000000 --- a/chrome/android/java/res/drawable-xxhdpi/eb_grid_icon.png +++ /dev/null diff --git a/chrome/android/java/res/drawable-xxhdpi/eb_item_tile.9.png b/chrome/android/java/res/drawable-xxhdpi/eb_large_tablet_list_background.9.png Binary files differindex de5c22d..de5c22d 100644 --- a/chrome/android/java/res/drawable-xxhdpi/eb_item_tile.9.png +++ b/chrome/android/java/res/drawable-xxhdpi/eb_large_tablet_list_background.9.png diff --git a/chrome/android/java/res/drawable-xxhdpi/eb_list_icon.png b/chrome/android/java/res/drawable-xxhdpi/eb_list_icon.png Binary files differdeleted file mode 100644 index 95581b8..0000000 --- a/chrome/android/java/res/drawable-xxhdpi/eb_list_icon.png +++ /dev/null diff --git a/chrome/android/java/res/drawable-xxxhdpi/eb_grid_icon.png b/chrome/android/java/res/drawable-xxxhdpi/eb_grid_icon.png Binary files differdeleted file mode 100644 index 6589301..0000000 --- a/chrome/android/java/res/drawable-xxxhdpi/eb_grid_icon.png +++ /dev/null diff --git a/chrome/android/java/res/drawable-xxxhdpi/eb_item_tile.9.png b/chrome/android/java/res/drawable-xxxhdpi/eb_large_tablet_list_background.9.png Binary files differindex 2e78ed4..2e78ed4 100644 --- a/chrome/android/java/res/drawable-xxxhdpi/eb_item_tile.9.png +++ b/chrome/android/java/res/drawable-xxxhdpi/eb_large_tablet_list_background.9.png diff --git a/chrome/android/java/res/drawable-xxxhdpi/eb_list_icon.png b/chrome/android/java/res/drawable-xxxhdpi/eb_list_icon.png Binary files differdeleted file mode 100644 index e7c96de..0000000 --- a/chrome/android/java/res/drawable-xxxhdpi/eb_list_icon.png +++ /dev/null diff --git a/chrome/android/java/res/drawable/eb_item_highlight.xml b/chrome/android/java/res/drawable/eb_item_highlight.xml index cb0bb89..5c71610 100644 --- a/chrome/android/java/res/drawable/eb_item_highlight.xml +++ b/chrome/android/java/res/drawable/eb_item_highlight.xml @@ -4,10 +4,6 @@ found in the LICENSE file. --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_checked="true"> - <shape> - <solid android:color="#804281f4" /> - <corners android:radius="2dp" /> - </shape> - </item> + <item android:state_checked="true" + android:drawable="@color/enhanced_bookmark_list_item_highlight_color" /> </selector>
\ No newline at end of file diff --git a/chrome/android/java/res/drawable/eb_list_toggle.xml b/chrome/android/java/res/drawable/eb_list_toggle.xml deleted file mode 100644 index 40761c2..0000000 --- a/chrome/android/java/res/drawable/eb_list_toggle.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright 2015 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. --> - -<level-list xmlns:android="http://schemas.android.com/apk/res/android" > - - <item - android:drawable="@drawable/eb_list_icon" - android:maxLevel="0"/> - <item - android:drawable="@drawable/eb_grid_icon" - android:maxLevel="1"/> - -</level-list>
\ No newline at end of file diff --git a/chrome/android/java/res/layout/eb_list_divider.xml b/chrome/android/java/res/layout/eb_divider.xml index 9c23fe4..9c23fe4 100644 --- a/chrome/android/java/res/layout/eb_list_divider.xml +++ b/chrome/android/java/res/layout/eb_divider.xml diff --git a/chrome/android/java/res/layout/eb_list_folder.xml b/chrome/android/java/res/layout/eb_folder.xml index 51aab19..51aab19 100644 --- a/chrome/android/java/res/layout/eb_list_folder.xml +++ b/chrome/android/java/res/layout/eb_folder.xml diff --git a/chrome/android/java/res/layout/eb_grid_folder.xml b/chrome/android/java/res/layout/eb_grid_folder.xml deleted file mode 100644 index 9488c50..0000000 --- a/chrome/android/java/res/layout/eb_grid_folder.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright 2015 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. --> - -<view class="org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkFolder" - xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:background="@drawable/eb_item_tile" > - - <TextView - android:id="@+id/title" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_gravity="start|top" - android:layout_margin="12dp" - android:drawablePadding="12dp" - android:ellipsize="end" - android:gravity="center_vertical" - android:singleLine="true" - android:textColor="#DF000000" - android:textSize="14sp" /> - - <org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkItemHighlightView - android:id="@+id/highlight" - android:layout_width="match_parent" - android:layout_height="match_parent" /> - -</view>
\ No newline at end of file diff --git a/chrome/android/java/res/layout/eb_grid_item.xml b/chrome/android/java/res/layout/eb_grid_item.xml deleted file mode 100644 index b7290f5..0000000 --- a/chrome/android/java/res/layout/eb_grid_item.xml +++ /dev/null @@ -1,90 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright 2015 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. --> - -<view class="org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkItem$EnhancedBookmarkGridItem" - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:chrome="http://schemas.android.com/apk/res-auto" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:background="@drawable/eb_item_tile" > - - <!-- TODO(kkimlabs): Add content descrption to the ImageViews --> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical" > - - <FrameLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" > - - <org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkSalientImageView - android:id="@+id/bookamrk_image" - android:layout_width="match_parent" - android:layout_height="75dp" - android:contentDescription="@null" /> - - <org.chromium.chrome.browser.widget.TintedImageButton - android:id="@+id/more" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="end|top" - android:background="@null" - android:contentDescription="@string/accessibility_enhanced_bookmark_more_info" - android:paddingTop="5dp" - android:paddingEnd="1dp" - android:paddingStart="20dp" - android:paddingBottom="20dp" - android:src="@drawable/eb_item_more" - chrome:tint="@color/light_mode_tint" /> - - <TextView - android:id="@+id/folder_title" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="start|bottom" - android:background="#CC000000" - android:ellipsize="end" - android:paddingEnd="5dp" - android:paddingStart="5dp" - android:singleLine="true" - android:textColor="@android:color/white" - android:textSize="12sp" /> - </FrameLayout> - - <TextView - android:id="@+id/title" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ellipsize="end" - android:paddingStart="12dp" - android:paddingEnd="12dp" - android:paddingTop="8dp" - android:paddingBottom="1dp" - android:lines="2" - android:textColor="#DE000000" - android:textSize="16sp" /> - - <TextView - android:id="@+id/url" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingStart="12dp" - android:paddingEnd="12dp" - android:paddingBottom="12dp" - android:ellipsize="end" - android:singleLine="true" - android:textColor="#8A000000" - android:textSize="12sp" /> - - </LinearLayout> - - <org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkItemHighlightView - android:id="@+id/highlight" - android:layout_width="match_parent" - android:layout_height="match_parent" /> - -</view>
\ No newline at end of file diff --git a/chrome/android/java/res/layout/eb_list_item.xml b/chrome/android/java/res/layout/eb_item.xml index fc98436..5fb9b13 100644 --- a/chrome/android/java/res/layout/eb_list_item.xml +++ b/chrome/android/java/res/layout/eb_item.xml @@ -3,7 +3,7 @@ Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. --> -<view class="org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkItem$EnhancedBookmarkListItem" +<view class="org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkItem" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:chrome="http://schemas.android.com/apk/res-auto" android:layout_width="wrap_content" diff --git a/chrome/android/java/res/layout/eb_main_content.xml b/chrome/android/java/res/layout/eb_main_content.xml index 5b05c62..7bbc3d5 100644 --- a/chrome/android/java/res/layout/eb_main_content.xml +++ b/chrome/android/java/res/layout/eb_main_content.xml @@ -15,7 +15,6 @@ android:layout_height="match_parent" android:layout_alignParentBottom="true" android:layout_below="@+id/eb_action_bar" - android:clipToPadding="false" android:scrollbars="vertical" android:scrollbarStyle="outsideOverlay" /> diff --git a/chrome/android/java/res/layout/eb_promo_header.xml b/chrome/android/java/res/layout/eb_promo_header.xml index ba2120d..c0d0d1b 100644 --- a/chrome/android/java/res/layout/eb_promo_header.xml +++ b/chrome/android/java/res/layout/eb_promo_header.xml @@ -9,7 +9,6 @@ xmlns:chrome="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@drawable/eb_item_tile" android:orientation="vertical" android:padding="16dp" > diff --git a/chrome/android/java/res/menu/eb_action_bar_menu.xml b/chrome/android/java/res/menu/eb_action_bar_menu.xml index 4848984..a9b4f2f 100644 --- a/chrome/android/java/res/menu/eb_action_bar_menu.xml +++ b/chrome/android/java/res/menu/eb_action_bar_menu.xml @@ -14,11 +14,6 @@ android:visible="false" chrome:showAsAction="ifRoom"/> <item - android:id="@+id/list_toggle_menu_id" - android:icon="@drawable/eb_list_toggle" - android:title="@string/enhanced_bookmark_action_bar_list_toggle" - chrome:showAsAction="ifRoom"/> - <item android:id="@+id/close_menu_id" android:icon="@drawable/btn_close" android:title="@string/enhanced_bookmark_action_bar_close" diff --git a/chrome/android/java/res/values/colors.xml b/chrome/android/java/res/values/colors.xml index 7a07cdc..feaba16 100644 --- a/chrome/android/java/res/values/colors.xml +++ b/chrome/android/java/res/values/colors.xml @@ -141,6 +141,7 @@ <color name="enhanced_bookmark_detail_dialog_shadow_color">#30000000</color> <color name="enhanced_bookmark_selection_action_bar_background">#4F82F4</color> <color name="enhanced_bookmark_drawer_selected_color">#4281F4</color> + <color name="enhanced_bookmark_list_item_highlight_color">#804281f4</color> <!-- Opt out promo --> <color name="opt_out_text_color">#646464</color> diff --git a/chrome/android/java/res/values/dimens.xml b/chrome/android/java/res/values/dimens.xml index b66a953..5f729df 100644 --- a/chrome/android/java/res/values/dimens.xml +++ b/chrome/android/java/res/values/dimens.xml @@ -270,10 +270,8 @@ <dimen name="reader_mode_text_size">14sp</dimen> <!-- Enhanced bookmarks dimensions --> - <dimen name="enhanced_bookmark_min_grid_width">135dp</dimen> <dimen name="enhanced_bookmark_item_corner_radius">3dp</dimen> <dimen name="enhanced_bookmark_item_popup_width">140dp</dimen> - <dimen name="enhanced_bookmark_item_half_space">4dp</dimen> <dimen name="enhanced_bookmark_folder_item_left">16dp</dimen> <dimen name="enhanced_bookmark_folder_item_icon_size">40dp</dimen> <dimen name="enhanced_bookmark_detail_image_height">232dp</dimen> diff --git a/chrome/android/java/src/org/chromium/chrome/browser/enhanced_bookmarks/EnhancedBookmarksBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/enhanced_bookmarks/EnhancedBookmarksBridge.java index 86817f6..1163834 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/enhanced_bookmarks/EnhancedBookmarksBridge.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/enhanced_bookmarks/EnhancedBookmarksBridge.java @@ -136,13 +136,6 @@ public final class EnhancedBookmarksBridge { } /** - * @see |enhanced_bookmarks::GetDefaultViewMode()| - */ - public static int getDefaultViewMode() { - return nativeGetDefaultViewMode(); - } - - /** * @return Return the cache if it is stored in the static weak reference, or create a new empty * one if the reference is empty. */ @@ -176,5 +169,4 @@ public final class EnhancedBookmarksBridge { String url, SalientImageCallback callback); private native void nativeFetchImageForTab(long nativeEnhancedBookmarksBridge, WebContents webContents); - private static native int nativeGetDefaultViewMode(); } diff --git a/chrome/android/java/strings/android_chrome_strings.grd b/chrome/android/java/strings/android_chrome_strings.grd index 55b41d5..b3456b9 100644 --- a/chrome/android/java/strings/android_chrome_strings.grd +++ b/chrome/android/java/strings/android_chrome_strings.grd @@ -1785,9 +1785,6 @@ Just open Chrome on your computer, go to the menu, and select “Sign in to Chro <message name="IDS_ENHANCED_BOOKMARK_ACTION_BAR_EDIT_FOLDER" desc="Button text for editing current folder action on the enhanced bookmark action bar [CHAR-LIMIT=32]"> Edit folder </message> - <message name="IDS_ENHANCED_BOOKMARK_ACTION_BAR_LIST_TOGGLE" desc="Button text for switching between list mode and grid mode [CHAR-LIMIT=32]"> - Toggle between list and grid mode - </message> <message name="IDS_ENHANCED_BOOKMARK_ACTION_BAR_MOVE" desc="Button text for bookmark move action on the enhanced bookmark action bar [CHAR-LIMIT=32]"> Move bookmarks </message> diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkActionBar.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkActionBar.java index 51f6347..063e911 100644 --- a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkActionBar.java +++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkActionBar.java @@ -83,9 +83,6 @@ public class EnhancedBookmarkActionBar extends Toolbar implements EnhancedBookma if (menuItem.getItemId() == R.id.edit_menu_id) { EnhancedBookmarkAddEditFolderActivity.startEditFolderActivity(getContext(), mCurrentFolder.getId()); - } else if (menuItem.getItemId() == R.id.list_toggle_menu_id) { - mDelegate.setListModeEnabled(!mDelegate.isListModeEnabled()); - return true; } else if (menuItem.getItemId() == R.id.close_menu_id) { mDelegate.finishActivityOnPhone(); return true; @@ -185,7 +182,6 @@ public class EnhancedBookmarkActionBar extends Toolbar implements EnhancedBookma setTitle(null); setNavigationButton(NAVIGATION_BUTTON_NONE); getMenu().findItem(R.id.edit_menu_id).setVisible(false); - getMenu().findItem(R.id.list_toggle_menu_id).setVisible(false); } // EnhancedBookmarkUIObserver implementations. @@ -195,7 +191,6 @@ public class EnhancedBookmarkActionBar extends Toolbar implements EnhancedBookma mDelegate = delegate; mDelegate.addUIObserver(this); delegate.getModel().addModelObserver(mBookmarkModelObserver); - getMenu().findItem(R.id.list_toggle_menu_id).setVisible(true); } @Override @@ -272,10 +267,4 @@ public class EnhancedBookmarkActionBar extends Toolbar implements EnhancedBookma mDelegate.notifyStateChange(this); } } - - @Override - public void onListModeChange(boolean isListModeEnabled) { - MenuItem menuItem = getMenu().findItem(R.id.list_toggle_menu_id); - menuItem.getIcon().setLevel(isListModeEnabled ? 1 : 0); - } } diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkContentView.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkContentView.java index 3603dba..9c115a5 100644 --- a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkContentView.java +++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkContentView.java @@ -4,55 +4,28 @@ package org.chromium.chrome.browser.enhancedbookmarks; -import android.animation.ObjectAnimator; import android.content.Context; -import android.support.v7.widget.RecyclerView; import android.util.AttributeSet; import android.view.View; -import android.view.ViewTreeObserver.OnScrollChangedListener; import android.widget.RelativeLayout; import org.chromium.chrome.R; import org.chromium.chrome.browser.widget.FadingShadow; import org.chromium.chrome.browser.widget.FadingShadowView; import org.chromium.components.bookmarks.BookmarkId; -import org.chromium.ui.interpolators.BakedBezierInterpolator; import java.util.List; /** * A ViewGroup that holds an {@link EnhancedBookmarkActionBar}, a {@link FadingShadowView}, a - * {@link EnhancedBookmarkRecyclerView} and a {@link EnhancedBookmarkLoadingView}. On large - * tablet, it can be replaced by a {@link EnhancedBookmarkSearchView} with the same size, located at - * the right of the window. + * {@link EnhancedBookmarkRecyclerView} and a {@link EnhancedBookmarkLoadingView}. */ public class EnhancedBookmarkContentView extends RelativeLayout implements EnhancedBookmarkUIObserver { - private static final int SHADOW_ANIMATION_DURATION_MS = 500; private EnhancedBookmarkDelegate mDelegate; private EnhancedBookmarkRecyclerView mItemsContainer; private EnhancedBookmarkActionBar mActionBar; - private FadingShadowView mShadow; private EnhancedBookmarkLoadingView mLoadingView; - private ObjectAnimator mShadowInAnim; - - private OnScrollChangedListener mScrollListener = new OnScrollChangedListener() { - @Override - public void onScrollChanged() { - if (mShadow == null || mDelegate == null || mDelegate.isSelectionEnabled() - || mDelegate.isListModeEnabled()) return; - int firstPosition = mItemsContainer.getLayoutManager() - .findFirstCompletelyVisibleItemPosition(); - if (firstPosition == 0 || firstPosition == RecyclerView.NO_POSITION) { - if (mShadowInAnim.isStarted()) mShadowInAnim.cancel(); - mShadow.setStrength(0); - } else { - if (!mShadowInAnim.isStarted() && mShadow.getStrength() < 1.0f) { - mShadowInAnim.start(); - } - } - } - }; /** * Creates an instance of {@link EnhancedBookmarkContentView}. This constructor should be used @@ -65,18 +38,18 @@ public class EnhancedBookmarkContentView extends RelativeLayout implements @Override protected void onFinishInflate() { super.onFinishInflate(); - mItemsContainer = (EnhancedBookmarkRecyclerView) findViewById( - R.id.eb_items_container); + mItemsContainer = (EnhancedBookmarkRecyclerView) findViewById(R.id.eb_items_container); mItemsContainer.setEmptyView(findViewById(R.id.eb_empty_view)); - mItemsContainer.getViewTreeObserver().addOnScrollChangedListener(mScrollListener); mActionBar = (EnhancedBookmarkActionBar) findViewById(R.id.eb_action_bar); mLoadingView = (EnhancedBookmarkLoadingView) findViewById(R.id.eb_initial_loading_view); - mShadow = (FadingShadowView) findViewById(R.id.shadow); - mShadow.init(getResources().getColor(R.color.enhanced_bookmark_app_bar_shadow_color), - FadingShadow.POSITION_TOP); - mShadowInAnim = ObjectAnimator.ofFloat(mShadow, "Strength", 1.0f) - .setDuration(SHADOW_ANIMATION_DURATION_MS); - mShadowInAnim.setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE); + FadingShadowView shadow = (FadingShadowView) findViewById(R.id.shadow); + if (EnhancedBookmarkRecyclerView.isLargeTablet(getContext())) { + shadow.setVisibility(View.GONE); + } else { + shadow.init(getResources().getColor(R.color.enhanced_bookmark_app_bar_shadow_color), + FadingShadow.POSITION_TOP); + shadow.setStrength(1.0f); + } } /** @@ -84,7 +57,7 @@ public class EnhancedBookmarkContentView extends RelativeLayout implements * @return True if there are selected bookmarks, and the back button is processed by this * method. False otherwise. */ - public boolean onBackPressed() { + boolean onBackPressed() { if (mDelegate != null && mDelegate.isSelectionEnabled()) { mDelegate.clearSelection(); return true; @@ -97,7 +70,7 @@ public class EnhancedBookmarkContentView extends RelativeLayout implements mLoadingView.showLoadingUI(); } - // EnhancedBookmarkDelegate implementations. + // EnhancedBookmarkUIObserver implementations. @Override public void onEnhancedBookmarkDelegateInitialized(EnhancedBookmarkDelegate delegate) { @@ -108,6 +81,11 @@ public class EnhancedBookmarkContentView extends RelativeLayout implements } @Override + public void onDestroy() { + mDelegate.removeUIObserver(this); + } + + @Override public void onAllBookmarksStateSet() { mLoadingView.hideLoadingUI(); } @@ -119,21 +97,5 @@ public class EnhancedBookmarkContentView extends RelativeLayout implements @Override public void onSelectionStateChange(List<BookmarkId> selectedBookmarks) { - if (!selectedBookmarks.isEmpty()) mShadow.setStrength(1.0f); - else mScrollListener.onScrollChanged(); - } - - @Override - public void onDestroy() { - mDelegate.removeUIObserver(this); - } - - @Override - public void onListModeChange(boolean isListModeEnabled) { - if (EnhancedBookmarkRecyclerView.isLargeTablet(getContext())) { - if (isListModeEnabled) mShadow.setVisibility(View.GONE); - else mShadow.setVisibility(View.VISIBLE); - } - mShadow.setStrength(mDelegate.isListModeEnabled() ? 1.0f : 0.0f); } } diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDelegate.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDelegate.java index cbe3805..60b1f68 100644 --- a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDelegate.java +++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDelegate.java @@ -69,17 +69,6 @@ interface EnhancedBookmarkDelegate { List<BookmarkId> getSelectedBookmarks(); /** - * Sets list mode. If the mode is toggles, - * {@link EnhancedBookmarkUIObserver#onListModeChange(boolean)} will be called. - */ - void setListModeEnabled(boolean isListModeEnabled); - - /** - * @return True is list mode is enabled. False otherwise. - */ - boolean isListModeEnabled(); - - /** * Notifies the current mode set event to the given observer. For example, if the current mode * is MODE_ALL_BOOKMARKS, it calls onAllBookmarksModeSet. */ diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDrawerListView.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDrawerListView.java index 979b2cd..16bc4eb 100644 --- a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDrawerListView.java +++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDrawerListView.java @@ -100,7 +100,4 @@ class EnhancedBookmarkDrawerListView extends ListView implements EnhancedBookmar @Override public void onSelectionStateChange(List<BookmarkId> selectedBookmarks) { } - - @Override - public void onListModeChange(boolean isListModeEnabled) {} } diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDrawerListViewAdapter.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDrawerListViewAdapter.java index b2e8a79..0a105df 100644 --- a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDrawerListViewAdapter.java +++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDrawerListViewAdapter.java @@ -280,7 +280,7 @@ class EnhancedBookmarkDrawerListViewAdapter extends BaseAdapter { R.layout.eb_drawer_item, parent, false); } else if (itemViewType == VIEW_TYPE_DIVIDER) { convertView = LayoutInflater.from(parent.getContext()).inflate( - R.layout.eb_list_divider, parent, false); + R.layout.eb_divider, parent, false); } else if (itemViewType == VIEW_TYPE_TITLE) { convertView = LayoutInflater.from(parent.getContext()).inflate( R.layout.eb_drawer_title, parent, false); diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkFolderSelectActivity.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkFolderSelectActivity.java index 9afcea3..b386960 100644 --- a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkFolderSelectActivity.java +++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkFolderSelectActivity.java @@ -298,7 +298,7 @@ public class EnhancedBookmarkFolderSelectActivity extends EnhancedBookmarkActivi if (convertView == null) { if (entry.mType == FolderListEntry.TYPE_DIVIDER) { return LayoutInflater.from(parent.getContext()).inflate( - R.layout.eb_list_divider, parent, false); + R.layout.eb_divider, parent, false); } else { convertView = LayoutInflater.from(parent.getContext()).inflate( R.layout.eb_folder_select_item, parent, false); diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkItem.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkItem.java index 1c10406..6e2adaa 100644 --- a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkItem.java +++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkItem.java @@ -4,11 +4,8 @@ package org.chromium.chrome.browser.enhancedbookmarks; -import android.annotation.SuppressLint; import android.content.Context; -import android.graphics.Bitmap; import android.graphics.PorterDuff; -import android.graphics.drawable.Drawable; import android.net.Uri; import android.util.AttributeSet; import android.view.View; @@ -25,9 +22,6 @@ import org.chromium.chrome.browser.BookmarksBridge.BookmarkItem; import org.chromium.chrome.browser.enhanced_bookmarks.LaunchLocation; import org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkItemsAdapter.BookmarkGrid; import org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkManager.UIState; -import org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkSalientImageView.SalientImageDrawableFactory; -import org.chromium.chrome.browser.widget.CustomShapeDrawable.CircularDrawable; -import org.chromium.chrome.browser.widget.CustomShapeDrawable.TopRoundedCornerDrawable; import org.chromium.chrome.browser.widget.TintedImageButton; import org.chromium.components.bookmarks.BookmarkId; import org.chromium.components.bookmarks.BookmarkType; @@ -37,49 +31,8 @@ import java.util.List; /** * A view that shows a bookmark's title, screenshot, URL, etc, shown in the enhanced bookmarks UI. */ -abstract class EnhancedBookmarkItem extends FrameLayout implements EnhancedBookmarkUIObserver, - SalientImageDrawableFactory, BookmarkGrid { - /** - * The item to show in list view mode. - */ - @SuppressLint("Instantiatable") - static class EnhancedBookmarkListItem extends EnhancedBookmarkItem { - public EnhancedBookmarkListItem(Context context, AttributeSet attrs) { - super(context, attrs); - } - - @Override - public Drawable getSalientDrawable(int color) { - return new CircularDrawable(color); - } - - @Override - public Drawable getSalientDrawable(Bitmap bitmap) { - return new CircularDrawable(bitmap); - } - } - - /** - * The item to show in grid mode. - */ - @SuppressLint("Instantiatable") - static class EnhancedBookmarkGridItem extends EnhancedBookmarkItem { - public EnhancedBookmarkGridItem(Context context, AttributeSet attrs) { - super(context, attrs); - } - - @Override - public Drawable getSalientDrawable(int color) { - return new TopRoundedCornerDrawable(color, getResources().getDimensionPixelSize( - R.dimen.enhanced_bookmark_item_corner_radius)); - } - - @Override - public Drawable getSalientDrawable(Bitmap bitmap) { - return new TopRoundedCornerDrawable(bitmap, getResources().getDimensionPixelSize( - R.dimen.enhanced_bookmark_item_corner_radius)); - } - } +public class EnhancedBookmarkItem extends FrameLayout implements EnhancedBookmarkUIObserver, + BookmarkGrid { private EnhancedBookmarkSalientImageView mSalientImageView; private TintedImageButton mMoreIcon; @@ -234,7 +187,7 @@ abstract class EnhancedBookmarkItem extends FrameLayout implements EnhancedBookm } mSalientImageView.load(mDelegate.getModel(), bookmarkItem.getUrl(), - EnhancedBookmarkUtils.generateBackgroundColor(bookmarkItem), this); + EnhancedBookmarkUtils.generateBackgroundColor(bookmarkItem)); } @Override @@ -319,7 +272,4 @@ abstract class EnhancedBookmarkItem extends FrameLayout implements EnhancedBookm public void onSelectionStateChange(List<BookmarkId> selectedBookmarks) { updateSelectionState(); } - - @Override - public void onListModeChange(boolean isListModeEnabled) {} } diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkItemsAdapter.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkItemsAdapter.java index a7079e6..bd7fcc4 100644 --- a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkItemsAdapter.java +++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkItemsAdapter.java @@ -19,7 +19,6 @@ import org.chromium.chrome.R; import org.chromium.chrome.browser.BookmarksBridge.BookmarkItem; import org.chromium.chrome.browser.BookmarksBridge.BookmarkModelObserver; import org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkPromoHeader.PromoHeaderShowingChangeListener; -import org.chromium.chrome.browser.util.MathUtils; import org.chromium.components.bookmarks.BookmarkId; import java.util.ArrayList; @@ -35,42 +34,33 @@ class EnhancedBookmarkItemsAdapter extends RecyclerView.Adapter<RecyclerView.Vie * An abstraction for the common functionalities for {@link EnhancedBookmarkFolder} and * {@link EnhancedBookmarkItem} */ - public interface BookmarkGrid extends OnClickListener, Checkable { + interface BookmarkGrid extends OnClickListener, Checkable { /** * Sets the bookmarkId the object is holding. Corresponding UI changes might occur. */ - public void setBookmarkId(BookmarkId id); + void setBookmarkId(BookmarkId id); /** * @return The bookmark that the object is holding. */ - public BookmarkId getBookmarkId(); + BookmarkId getBookmarkId(); } - public static final int PROMO_HEADER_GRID = 0; - public static final int FOLDER_VIEW_GRID = 1; - public static final int PADDING_VIEW = 2; - public static final int BOOKMARK_VIEW_GRID = 3; - - // Have different view types for list and grid modes, in order to force the recycler not reuse - // the same tiles across the two modes. - public static final int PROMO_HEADER_LIST = 4; - public static final int FOLDER_VIEW_LIST = 5; - public static final int DIVIDER_LIST = 6; - public static final int BOOKMARK_VIEW_LIST = 7; + private static final int PROMO_HEADER_VIEW = 0; + private static final int FOLDER_VIEW = 1; + private static final int DIVIDER_VIEW = 2; + private static final int BOOKMARK_VIEW = 3; private EnhancedBookmarkDelegate mDelegate; private Context mContext; private EnhancedBookmarkPromoHeader mPromoHeaderManager; - private ItemFactory mItemFactory; - private List<BookmarkId> mFolders = new ArrayList<BookmarkId>(); - private List<BookmarkId> mBookmarks = new ArrayList<BookmarkId>(); - // These are used to track placeholder invisible view between folder items and bookmark items, - // to align the beginning of the bookmark items to be the first column. - // In list mode, this variable represents the presence of the divider, either 1 or 0. - private int mEmptyViewCount; - private int mColumnCount = 1; + private List<List<? extends Object>> mSections; + private List<Object> mPromoHeaderSection = new ArrayList<>(); + private List<Object> mFolderDividerSection = new ArrayList<>(); + private List<BookmarkId> mFolderSection = new ArrayList<>(); + private List<Object> mBookmarkDividerSection = new ArrayList<>(); + private List<BookmarkId> mBookmarkSection = new ArrayList<>(); private BookmarkModelObserver mBookmarkModelObserver = new BookmarkModelObserver() { @Override @@ -100,74 +90,43 @@ class EnhancedBookmarkItemsAdapter extends RecyclerView.Adapter<RecyclerView.Vie EnhancedBookmarkItemsAdapter(Context context) { mContext = context; - } - - /** - * @return Whether the first item is header. - */ - boolean isHeader(int position) { - int type = getItemViewType(position); - return type == PROMO_HEADER_GRID || type == PROMO_HEADER_LIST; - } - - /** - * Set folders and bookmarks to show. - * @param folders This can be null if there is no folders to show. - */ - void setBookmarks(List<BookmarkId> folders, List<BookmarkId> bookmarks) { - if (folders == null) folders = new ArrayList<BookmarkId>(); - mFolders = folders; - mBookmarks = bookmarks; - // TODO(kkimlabs): Animation is disabled due to a performance issue on bookmark undo. - // http://crbug.com/484174 - updateDataset(); - } - - /** - * Set number of columns. This information will be used to align the starting position of - * bookmarks to be the beginning of the row. - * - * This is a hacky responsibility violation, since adapter shouldn't care about the way items - * are presented in the UI. However, there is no other easy way to do this correctly with - * GridView. - */ - void setNumColumns(int columnNumber) { - if (mColumnCount == columnNumber) return; - mColumnCount = columnNumber; - updateDataset(); + mSections = new ArrayList<>(); + mSections.add(mPromoHeaderSection); + mSections.add(mFolderDividerSection); + mSections.add(mFolderSection); + mSections.add(mBookmarkDividerSection); + mSections.add(mBookmarkSection); } - /** - * If called, recycler view will be brutally reset and no animation will be shown. - */ - void updateDataset() { - updateEmptyViewCount(); - notifyDataSetChanged(); - } - - private void updateEmptyViewCount() { - if (mDelegate.isListModeEnabled()) mEmptyViewCount = mFolders.size() > 0 ? 1 : 0; - else mEmptyViewCount = MathUtils.positiveModulo(-mFolders.size(), mColumnCount); + BookmarkId getItem(int position) { + return (BookmarkId) getSection(position).get(toSectionPosition(position)); } - private int getHeaderItemsCount() { - // In listview a promo header carries a divider below it. - if (mPromoHeaderManager.isShowing()) { - return mDelegate.isListModeEnabled() ? 2 : 1; + private int toSectionPosition(int globalPosition) { + int sectionPosition = globalPosition; + for (List section : mSections) { + if (sectionPosition < section.size()) break; + sectionPosition -= section.size(); } - return 0; + return sectionPosition; } - @Override - public int getItemCount() { - return getHeaderItemsCount() + mFolders.size() + mEmptyViewCount + mBookmarks.size(); + private List<Object> getSection(int position) { + int i = position; + for (List section : mSections) { + if (i < section.size()) { + return section; + } + i -= section.size(); + } + return null; } /** * @return The position of the given bookmark in adapter. Will return -1 if not found. */ - int getPositionForBookmark(BookmarkId bookmark) { + private int getPositionForBookmark(BookmarkId bookmark) { assert bookmark != null; int position = -1; for (int i = 0; i < getItemCount(); i++) { @@ -179,83 +138,68 @@ class EnhancedBookmarkItemsAdapter extends RecyclerView.Adapter<RecyclerView.Vie return position; } - BookmarkId getItem(int position) { - switch(getItemViewType(position)) { - case PROMO_HEADER_GRID: - case PROMO_HEADER_LIST: - return null; - case FOLDER_VIEW_GRID: - case FOLDER_VIEW_LIST: - return mFolders.get(position - getHeaderItemsCount()); - case PADDING_VIEW: - case DIVIDER_LIST: - return null; - case BOOKMARK_VIEW_GRID: - case BOOKMARK_VIEW_LIST: - return mBookmarks.get( - position - getHeaderItemsCount() - mFolders.size() - mEmptyViewCount); - default: - assert false; - return null; - } + /** + * Set folders and bookmarks to show. + * @param folders This can be null if there is no folders to show. + */ + private void setBookmarks(List<BookmarkId> folders, List<BookmarkId> bookmarks) { + if (folders == null) folders = new ArrayList<BookmarkId>(); + + mFolderSection.clear(); + mFolderSection.addAll(folders); + mBookmarkSection.clear(); + mBookmarkSection.addAll(bookmarks); + + updateDividerSections(); + + // TODO(kkimlabs): Animation is disabled due to a performance issue on bookmark undo. + // http://crbug.com/484174 + notifyDataSetChanged(); } - void removeItem(int position) { - switch(getItemViewType(position)) { - case PROMO_HEADER_GRID: - case PROMO_HEADER_LIST: - assert false : "Promo header remove should be handled in PromoHeaderManager."; - break; - case FOLDER_VIEW_GRID: - case FOLDER_VIEW_LIST: - mFolders.remove(position - getHeaderItemsCount()); - notifyItemRemoved(position); - break; - case PADDING_VIEW: - case DIVIDER_LIST: - assert false : "Cannot remove a padding view or a divider"; - break; - case BOOKMARK_VIEW_GRID: - case BOOKMARK_VIEW_LIST: - mBookmarks.remove( - position - - getHeaderItemsCount() - - mFolders.size() - - mEmptyViewCount); - notifyItemRemoved(position); - break; - default: - assert false; + private void updateDividerSections() { + mFolderDividerSection.clear(); + mBookmarkDividerSection.clear(); + if (!mPromoHeaderSection.isEmpty() && !mFolderSection.isEmpty()) { + mFolderDividerSection.add(null); + } + if ((!mPromoHeaderSection.isEmpty() || !mFolderSection.isEmpty()) + && !mBookmarkSection.isEmpty()) { + mBookmarkDividerSection.add(null); } } - @Override - public int getItemViewType(int position) { - int i = position; - - if (mPromoHeaderManager.isShowing()) { - if (mDelegate.isListModeEnabled()) { - if (i == 0) return PROMO_HEADER_LIST; - if (i == 1) return DIVIDER_LIST; - } else { - if (i == 0) return PROMO_HEADER_GRID; - } - } - i -= getHeaderItemsCount(); + private void removeItem(int position) { + List section = getSection(position); + assert section == mFolderSection || section == mBookmarkSection; + section.remove(toSectionPosition(position)); + notifyItemRemoved(position); + } - if (i < mFolders.size()) { - return mDelegate.isListModeEnabled() ? FOLDER_VIEW_LIST : FOLDER_VIEW_GRID; - } - i -= mFolders.size(); + // RecyclerView.Adapter implementation. - if (i < mEmptyViewCount) { - if (mDelegate.isListModeEnabled()) return DIVIDER_LIST; - else return PADDING_VIEW; + @Override + public int getItemCount() { + int count = 0; + for (List section : mSections) { + count += section.size(); } - i -= mEmptyViewCount; + return count; + } - if (i < mBookmarks.size()) { - return mDelegate.isListModeEnabled() ? BOOKMARK_VIEW_LIST : BOOKMARK_VIEW_GRID; + @Override + public int getItemViewType(int position) { + List section = getSection(position); + + if (section == mPromoHeaderSection) { + return PROMO_HEADER_VIEW; + } else if (section == mFolderDividerSection + || section == mBookmarkDividerSection) { + return DIVIDER_VIEW; + } else if (section == mFolderSection) { + return FOLDER_VIEW; + } else if (section == mBookmarkSection) { + return BOOKMARK_VIEW; } assert false : "Invalid position requested"; @@ -265,23 +209,19 @@ class EnhancedBookmarkItemsAdapter extends RecyclerView.Adapter<RecyclerView.Vie @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { switch (viewType) { - case PROMO_HEADER_GRID: - case PROMO_HEADER_LIST: - return mPromoHeaderManager.createHolder(parent, mDelegate.isListModeEnabled()); - case FOLDER_VIEW_GRID: - case FOLDER_VIEW_LIST: - EnhancedBookmarkFolder folder = mItemFactory.createBookmarkFolder(parent); + case PROMO_HEADER_VIEW: + return mPromoHeaderManager.createHolder(parent); + case FOLDER_VIEW: + EnhancedBookmarkFolder folder = (EnhancedBookmarkFolder) LayoutInflater.from( + parent.getContext()).inflate(R.layout.eb_folder, parent, false); folder.setDelegate(mDelegate); return new ItemViewHolder(folder, mDelegate); - case PADDING_VIEW: - // Padding views are empty place holders that will be set invisible. - return new ViewHolder(new View(parent.getContext())) {}; - case DIVIDER_LIST: + case DIVIDER_VIEW: return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate( - R.layout.eb_list_divider, parent, false)) {}; - case BOOKMARK_VIEW_GRID: - case BOOKMARK_VIEW_LIST: - EnhancedBookmarkItem item = mItemFactory.createBookmarkItem(parent); + R.layout.eb_divider, parent, false)) {}; + case BOOKMARK_VIEW: + EnhancedBookmarkItem item = (EnhancedBookmarkItem) LayoutInflater.from( + parent.getContext()).inflate(R.layout.eb_item, parent, false); item.onEnhancedBookmarkDelegateInitialized(mDelegate); return new ItemViewHolder(item, mDelegate); default: @@ -295,18 +235,14 @@ class EnhancedBookmarkItemsAdapter extends RecyclerView.Adapter<RecyclerView.Vie public void onBindViewHolder(ViewHolder holder, int position) { BookmarkId id = getItem(position); switch (getItemViewType(position)) { - case PROMO_HEADER_GRID: - case PROMO_HEADER_LIST: + case PROMO_HEADER_VIEW: break; - case FOLDER_VIEW_GRID: - case FOLDER_VIEW_LIST: + case FOLDER_VIEW: ((ItemViewHolder) holder).setBookmarkId(id); break; - case PADDING_VIEW: - case DIVIDER_LIST: + case DIVIDER_VIEW: break; - case BOOKMARK_VIEW_GRID: - case BOOKMARK_VIEW_LIST: + case BOOKMARK_VIEW: ((ItemViewHolder) holder).setBookmarkId(id); break; default: @@ -318,13 +254,11 @@ class EnhancedBookmarkItemsAdapter extends RecyclerView.Adapter<RecyclerView.Vie @Override public void onPromoHeaderShowingChanged(boolean isShowing) { - if (isShowing) { - notifyItemInserted(0); - } else { - // TODO(kkimlabs): Ideally we want to animate by |notifyItemRemoved| but the default - // animation looks broken for this promo header for some reason. - notifyDataSetChanged(); - } + mPromoHeaderSection.clear(); + if (isShowing) mPromoHeaderSection.add(null); + + updateDividerSections(); + notifyDataSetChanged(); } // EnhancedBookmarkUIObserver implementations. @@ -334,18 +268,16 @@ class EnhancedBookmarkItemsAdapter extends RecyclerView.Adapter<RecyclerView.Vie mDelegate = delegate; mDelegate.addUIObserver(this); mDelegate.getModel().addModelObserver(mBookmarkModelObserver); - - mItemFactory = mDelegate.isListModeEnabled() - ? new ListItemFactory() : new GridItemFactory(); - mPromoHeaderManager = new EnhancedBookmarkPromoHeader(mContext, this); + if (mPromoHeaderManager.isShowing()) mPromoHeaderSection.add(null); + + updateDividerSections(); } @Override public void onDestroy() { mDelegate.removeUIObserver(this); mDelegate.getModel().removeModelObserver(mBookmarkModelObserver); - mPromoHeaderManager.destroy(); } @@ -363,17 +295,6 @@ class EnhancedBookmarkItemsAdapter extends RecyclerView.Adapter<RecyclerView.Vie @Override public void onSelectionStateChange(List<BookmarkId> selectedBookmarks) {} - @Override - public void onListModeChange(boolean isListModeEnabled) { - if (isListModeEnabled) { - setNumColumns(1); - mItemFactory = new EnhancedBookmarkItemsAdapter.ListItemFactory(); - } else { - mItemFactory = new EnhancedBookmarkItemsAdapter.GridItemFactory(); - } - updateDataset(); - } - private static class ItemViewHolder extends RecyclerView.ViewHolder implements OnClickListener, OnLongClickListener { private EnhancedBookmarkDelegate mDelegate; @@ -405,39 +326,4 @@ class EnhancedBookmarkItemsAdapter extends RecyclerView.Adapter<RecyclerView.Vie } } - /** - * Factory interface to get the correct views to show. - */ - private interface ItemFactory { - EnhancedBookmarkItem createBookmarkItem(ViewGroup parent); - EnhancedBookmarkFolder createBookmarkFolder(ViewGroup parent); - } - - private static class GridItemFactory implements ItemFactory { - @Override - public EnhancedBookmarkItem createBookmarkItem(ViewGroup parent) { - return (EnhancedBookmarkItem) LayoutInflater.from(parent.getContext()).inflate( - R.layout.eb_grid_item, parent, false); - } - - @Override - public EnhancedBookmarkFolder createBookmarkFolder(ViewGroup parent) { - return (EnhancedBookmarkFolder) LayoutInflater.from( - parent.getContext()).inflate(R.layout.eb_grid_folder, parent, false); - } - } - - private static class ListItemFactory implements ItemFactory { - @Override - public EnhancedBookmarkItem createBookmarkItem(ViewGroup parent) { - return (EnhancedBookmarkItem) LayoutInflater.from(parent.getContext()).inflate( - R.layout.eb_list_item, parent, false); - } - - @Override - public EnhancedBookmarkFolder createBookmarkFolder(ViewGroup parent) { - return (EnhancedBookmarkFolder) LayoutInflater.from( - parent.getContext()).inflate(R.layout.eb_list_folder, parent, false); - } - } } diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkManager.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkManager.java index 76aa99a..97b46d9 100644 --- a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkManager.java +++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkManager.java @@ -18,10 +18,8 @@ import org.chromium.chrome.R; import org.chromium.chrome.browser.BookmarksBridge.BookmarkItem; import org.chromium.chrome.browser.BookmarksBridge.BookmarkModelObserver; import org.chromium.chrome.browser.UrlConstants; -import org.chromium.chrome.browser.enhanced_bookmarks.EnhancedBookmarksBridge; import org.chromium.chrome.browser.enhanced_bookmarks.EnhancedBookmarksModel; import org.chromium.chrome.browser.enhanced_bookmarks.LaunchLocation; -import org.chromium.chrome.browser.enhanced_bookmarks.ViewMode; import org.chromium.chrome.browser.ntp.NewTabPageUma; import org.chromium.chrome.browser.partnerbookmarks.PartnerBookmarksShim; import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarManageable; @@ -43,7 +41,6 @@ import java.util.Stack; */ public class EnhancedBookmarkManager implements EnhancedBookmarkDelegate { private static final String PREF_LAST_USED_URL = "enhanced_bookmark_last_used_url"; - static final String PREF_WAS_IN_LIST_MODE = "enhanced_bookmark_list_mode_choice"; private Activity mActivity; private ViewGroup mMainView; @@ -52,7 +49,6 @@ public class EnhancedBookmarkManager implements EnhancedBookmarkDelegate { private final ObserverList<EnhancedBookmarkUIObserver> mUIObservers = new ObserverList<EnhancedBookmarkUIObserver>(); private Set<BookmarkId> mSelectedBookmarks = new HashSet<>(); - private boolean mListModeEnabled; private EnhancedBookmarkStateChangeListener mUrlChangeListener; private EnhancedBookmarkContentView mContentView; private DrawerLayout mDrawer; @@ -222,8 +218,6 @@ public class EnhancedBookmarkManager implements EnhancedBookmarkDelegate { String url = mStateStack.pop().mUrl; setState(UIState.createStateFromUrl(url, mEnhancedBookmarksModel)); } - // Restore the previous view mode selection saved in preference. - initListModeOptionTo(getListModePreference()); } else { mContentView.showLoadingUi(); mDrawerListView.showLoadingUi(); @@ -258,34 +252,6 @@ public class EnhancedBookmarkManager implements EnhancedBookmarkDelegate { PREF_LAST_USED_URL, UrlConstants.BOOKMARKS_URL); } - private void saveListModePreference() { - PreferenceManager.getDefaultSharedPreferences(mActivity).edit() - .putInt(PREF_WAS_IN_LIST_MODE, mListModeEnabled ? ViewMode.LIST : ViewMode.GRID) - .apply(); - } - - private boolean getListModePreference() { - int mode = PreferenceManager.getDefaultSharedPreferences(mActivity).getInt( - PREF_WAS_IN_LIST_MODE, ViewMode.DEFAULT); - - if (mode == ViewMode.DEFAULT) mode = EnhancedBookmarksBridge.getDefaultViewMode(); - - return mode == ViewMode.LIST ? true : false; - } - - private void initListModeOptionTo(boolean isListModeEnabled) { - mListModeEnabled = isListModeEnabled; - for (EnhancedBookmarkUIObserver observer: mUIObservers) { - observer.onListModeChange(isListModeEnabled); - } - // Every time the enhanced bookmark manager launches or the user clicks the list-mode - // toggle, we record the list view state. - int listViewstate = PreferenceManager.getDefaultSharedPreferences(getView().getContext()) - .getInt(EnhancedBookmarkManager.PREF_WAS_IN_LIST_MODE, - ViewMode.DEFAULT); - RecordHistogram.recordEnumeratedHistogram("EnhancedBookmarks.ViewMode", listViewstate, 3); - } - /** * This is the ultimate internal method that updates UI and controls backstack. And it is the * only method that pushes states to {@link #mStateStack}. @@ -373,17 +339,6 @@ public class EnhancedBookmarkManager implements EnhancedBookmarkDelegate { } @Override - public void setListModeEnabled(boolean isListModeEnabled) { - initListModeOptionTo(isListModeEnabled); - saveListModePreference(); - } - - @Override - public boolean isListModeEnabled() { - return mListModeEnabled; - } - - @Override public void notifyStateChange(EnhancedBookmarkUIObserver observer) { int state = getCurrentState(); switch (state) { diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkPromoHeader.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkPromoHeader.java index 2e3a7e8..e0d4826 100644 --- a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkPromoHeader.java +++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkPromoHeader.java @@ -83,14 +83,12 @@ class EnhancedBookmarkPromoHeader implements AndroidSyncSettingsObserver, } /** - * @param isListMode Whether listview is showing. * @return Signin promo header {@link ViewHolder} instance that can be used with * {@link RecyclerView}. */ - ViewHolder createHolder(ViewGroup parent, boolean isListMode) { + ViewHolder createHolder(ViewGroup parent) { ViewGroup promoHeader = (ViewGroup) LayoutInflater.from(mContext) .inflate(R.layout.eb_promo_header, parent, false); - if (isListMode) promoHeader.setBackground(null); promoHeader.findViewById(R.id.no_thanks).setOnClickListener(new OnClickListener() { @Override diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkRecyclerView.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkRecyclerView.java index 2c744a6..e4352d7 100644 --- a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkRecyclerView.java +++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkRecyclerView.java @@ -5,15 +5,13 @@ package org.chromium.chrome.browser.enhancedbookmarks; import android.content.Context; -import android.graphics.Rect; -import android.support.v7.widget.GridLayoutManager; -import android.support.v7.widget.GridLayoutManager.SpanSizeLookup; +import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.AttributeSet; import android.view.View; import android.widget.Checkable; -import android.widget.RelativeLayout; +import org.chromium.base.VisibleForTesting; import org.chromium.chrome.R; import org.chromium.components.bookmarks.BookmarkId; @@ -29,14 +27,11 @@ public class EnhancedBookmarkRecyclerView extends RecyclerView implements private EnhancedBookmarkDelegate mDelegate; private View mEmptyView; - private int mGridMinWidthPx; - private int mItemHalfSpacePx; - private ItemDecoration mItemDecoration; /** * @return True if the current device's minimum dimension is larger than 720dp. */ - public static boolean isLargeTablet(Context context) { + static boolean isLargeTablet(Context context) { // TODO(ianwen): move this function to DeviceFormFactor.java in upstream. if (sIsLargeTablet == null) { int minimumScreenWidthDp = context.getResources().getConfiguration() @@ -51,41 +46,43 @@ public class EnhancedBookmarkRecyclerView extends RecyclerView implements */ public EnhancedBookmarkRecyclerView(Context context, AttributeSet attrs) { super(context, attrs); - // Span count will be dynamically computed in onMeasure(). - setLayoutManager(new GridLayoutManager(context, 1)); - mGridMinWidthPx = getResources().getDimensionPixelSize( - R.dimen.enhanced_bookmark_min_grid_width); - mItemHalfSpacePx = getResources().getDimensionPixelSize( - R.dimen.enhanced_bookmark_item_half_space); - mItemDecoration = new ItemDecoration() { - @Override - public void getItemOffsets(Rect outRect, View view, RecyclerView parent, State state) { - outRect.set(mItemHalfSpacePx, mItemHalfSpacePx, mItemHalfSpacePx, mItemHalfSpacePx); - } - }; - setHasFixedSize(true); - } - @Override - protected void onMeasure(int widthSpec, int heightSpec) { - super.onMeasure(widthSpec, heightSpec); - int width = MeasureSpec.getSize(widthSpec); - if (width != 0 && mDelegate != null && !mDelegate.isListModeEnabled()) { - int spans = width / mGridMinWidthPx; - if (spans > 0) { - getLayoutManager().setSpanCount(spans); - if (getAdapter() != null) getAdapter().setNumColumns(spans); - } - } + setLayoutManager(new LinearLayoutManager(context)); + setHasFixedSize(true); } /** * Sets the view to be shown if there are no items in adapter. */ - public void setEmptyView(View emptyView) { + void setEmptyView(View emptyView) { mEmptyView = emptyView; } + // RecyclerView implementation + + @Override + public void setLayoutParams(android.view.ViewGroup.LayoutParams params) { + if (isLargeTablet(getContext())) { + int marginPx = getContext().getResources().getDimensionPixelSize( + R.dimen.enhanced_bookmark_list_mode_background_margin); + assert params instanceof MarginLayoutParams; + ((MarginLayoutParams) params).setMargins(marginPx, marginPx, marginPx, marginPx); + } + + super.setLayoutParams(params); + } + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + + if (isLargeTablet(getContext())) { + setBackgroundResource(R.drawable.eb_large_tablet_list_background); + } else { + setBackgroundColor(getContext().getResources().getColor(android.R.color.white)); + } + } + @Override public void setAdapter(final Adapter adapter) { super.setAdapter(adapter); @@ -111,16 +108,12 @@ public class EnhancedBookmarkRecyclerView extends RecyclerView implements updateEmptyViewVisibility(adapter); } + @VisibleForTesting @Override public EnhancedBookmarkItemsAdapter getAdapter() { return (EnhancedBookmarkItemsAdapter) super.getAdapter(); } - @Override - public GridLayoutManager getLayoutManager() { - return (GridLayoutManager) super.getLayoutManager(); - } - /** * Unlike ListView or GridView, RecyclerView does not provide default empty * view implementation. We need to check it ourselves. @@ -129,12 +122,6 @@ public class EnhancedBookmarkRecyclerView extends RecyclerView implements mEmptyView.setVisibility(adapter.getItemCount() == 0 ? View.VISIBLE : View.GONE); } - private void setMargin(int marginInPx) { - RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) getLayoutParams(); - lp.setMargins(marginInPx, marginInPx, marginInPx, marginInPx); - setLayoutParams(lp); - } - // EnhancedBookmarkUIObserver implementations @Override @@ -145,13 +132,6 @@ public class EnhancedBookmarkRecyclerView extends RecyclerView implements EnhancedBookmarkItemsAdapter adapter = new EnhancedBookmarkItemsAdapter(getContext()); adapter.onEnhancedBookmarkDelegateInitialized(mDelegate); setAdapter(adapter); - - getLayoutManager().setSpanSizeLookup(new SpanSizeLookup() { - @Override - public int getSpanSize(int position) { - return getAdapter().isHeader(position) ? getLayoutManager().getSpanCount() : 1; - } - }); } @Override @@ -178,38 +158,4 @@ public class EnhancedBookmarkRecyclerView extends RecyclerView implements } } } - - @Override - public void onListModeChange(final boolean isListModeEnabled) { - if (isListModeEnabled) { - removeItemDecoration(mItemDecoration); - setPadding(0, 0, 0, 0); - getLayoutManager().setSpanCount(1); - - if (isLargeTablet(getContext())) { - setClipToPadding(true); - setBackgroundResource(R.drawable.eb_item_tile); - setMargin(getContext().getResources().getDimensionPixelSize( - R.dimen.enhanced_bookmark_list_mode_background_margin)); - } else { - setBackgroundColor(getContext().getResources().getColor(android.R.color.white)); - } - } else { - addItemDecoration(mItemDecoration); - setPadding(mItemHalfSpacePx, mItemHalfSpacePx, mItemHalfSpacePx, mItemHalfSpacePx); - - if (isLargeTablet(getContext())) { - setClipToPadding(false); - setBackgroundResource(0); - setMargin(0); - } else { - setBackgroundColor( - getContext().getResources().getColor(R.color.default_primary_color)); - } - requestLayout(); - } - - // TODO(ianwen): remember scroll position and scroll back after mode switching. - mDelegate.notifyStateChange(this); - } } diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkSalientImageView.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkSalientImageView.java index ae00e09..e684e29 100644 --- a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkSalientImageView.java +++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkSalientImageView.java @@ -13,7 +13,6 @@ import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.PixelFormat; import android.graphics.Rect; -import android.graphics.RectF; import android.graphics.Shader; import android.graphics.drawable.Drawable; import android.util.AttributeSet; @@ -23,6 +22,7 @@ import android.widget.ImageView; import org.chromium.chrome.browser.enhanced_bookmarks.EnhancedBookmarksBridge.SalientImageCallback; import org.chromium.chrome.browser.enhanced_bookmarks.EnhancedBookmarksModel; +import org.chromium.chrome.browser.widget.CustomShapeDrawable.CircularDrawable; import org.chromium.ui.interpolators.BakedBezierInterpolator; /** @@ -36,26 +36,9 @@ import org.chromium.ui.interpolators.BakedBezierInterpolator; public class EnhancedBookmarkSalientImageView extends FrameLayout { /** - * Factory for getting drawable for Salient Image View, because in various scenarios, shapes of - * images might vary. This factory should be responsible for providing drawables for both color - * place holder as well as salient bitmap image. - */ - public interface SalientImageDrawableFactory { - /** - * @return The drawable containing pure color. - */ - Drawable getSalientDrawable(int color); - /** - * @return The drawable containing bitmap as background. - */ - Drawable getSalientDrawable(Bitmap bitmap); - } - - /** * Base class for different kinds of drawables to be used to define shapes of salient images. */ public abstract static class BaseSalientDrawable extends Drawable { - protected RectF mRect = new RectF(); protected Paint mPaint = new Paint(); private int mBitmapWidth; private int mBitmapHeight; @@ -147,10 +130,8 @@ public class EnhancedBookmarkSalientImageView extends FrameLayout { * @param model Enhanced bookmark model from which to get image. * @param url Url for representing bookmark. * @param color Color of place holder. - * @param drawableFactory Factory providing drawables that defines shape of the ImageView. */ - public void load(EnhancedBookmarksModel model, String url, int color, - final SalientImageDrawableFactory drawableFactory) { + public void load(EnhancedBookmarksModel model, String url, int color) { // Reset conditions. clearAnimation(); mSolidColorImage.setImageDrawable(null); @@ -178,12 +159,12 @@ public class EnhancedBookmarkSalientImageView extends FrameLayout { mSolidColorImage.setAlpha(1.0f); } }); - mSalientImage.setImageDrawable(drawableFactory.getSalientDrawable(image)); + mSalientImage.setImageDrawable(new CircularDrawable(image)); mSalientImage.setAlpha(0.0f); mSalientImage.animate().alpha(1.0f).setDuration(SALIENT_IMAGE_ANIMATION_MS) .setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE); } else { - mSalientImage.setImageDrawable(drawableFactory.getSalientDrawable(image)); + mSalientImage.setImageDrawable(new CircularDrawable(image)); mSolidColorImage.setVisibility(View.INVISIBLE); } } @@ -193,7 +174,7 @@ public class EnhancedBookmarkSalientImageView extends FrameLayout { // If there is no image or the image is still loading asynchronously, show pure color. if (!isSalientImageLoaded) { - mSolidColorImage.setImageDrawable(drawableFactory.getSalientDrawable(color)); + mSolidColorImage.setImageDrawable(new CircularDrawable(color)); } } } diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkUIObserver.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkUIObserver.java index a08a2bb..9d4b26c 100644 --- a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkUIObserver.java +++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkUIObserver.java @@ -38,9 +38,4 @@ interface EnhancedBookmarkUIObserver { * {@link EnhancedBookmarkDelegate#getSelectedBookmarks()} */ void onSelectionStateChange(List<BookmarkId> selectedBookmarks); - - /** - * @see EnhancedBookmarkDelegate#setListModeEnabled(boolean) - */ - void onListModeChange(boolean isListModeEnabled); } diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/widget/CustomShapeDrawable.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/widget/CustomShapeDrawable.java index 2dbbfcd..af8a50f 100644 --- a/chrome/android/java_staging/src/org/chromium/chrome/browser/widget/CustomShapeDrawable.java +++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/widget/CustomShapeDrawable.java @@ -16,8 +16,6 @@ import android.graphics.RectF; import android.graphics.Shader; import android.graphics.drawable.Drawable; -import org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkSalientImageView.BaseSalientDrawable; - /** * Base class for drawables that are to control what shape they take. */ @@ -53,41 +51,6 @@ public abstract class CustomShapeDrawable extends Drawable { } } - /** - * Drawable that has rounded top corners, with image or pure color as content. - */ - public static class TopRoundedCornerDrawable extends BaseSalientDrawable { - private final float mRadius; - - /** - * Create a drawable based on bitmap of salient image as well as radius. - */ - public TopRoundedCornerDrawable(Bitmap bitmap, float radius) { - super(bitmap); - mRadius = radius; - } - - /** - * Create a drawable based on the pure color as well as radius. - */ - public TopRoundedCornerDrawable(int color, float radius) { - super(color); - mRadius = radius; - } - - @Override - protected void onBoundsChange(Rect bounds) { - // We avoid drawing bottom corners just by making it taller by the radius. - mRect.set(0, 0, bounds.width(), bounds.height() + mRadius); - super.onBoundsChange(bounds); - } - - @Override - public void draw(Canvas canvas) { - canvas.drawRoundRect(mRect, mRadius, mRadius, mPaint); - } - } - protected RectF mRect = new RectF(); protected Paint mPaint = new Paint(); private int mBitmapWidth; diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkTest.java index c5af84b..318cd95 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkTest.java @@ -111,10 +111,10 @@ public class EnhancedBookmarkTest extends ChromeActivityTestCaseBase<ChromeActiv @Override public Boolean call() throws Exception { for (int i = 0; i < mItemsContainer.getAdapter().getItemCount(); i++) { - if (mItemsContainer.getAdapter().isHeader(i)) continue; + BookmarkId item = mItemsContainer.getAdapter().getItem(i); + if (item == null) continue; - String actualTitle = mBookmarkModel.getBookmarkTitle( - mItemsContainer.getAdapter().getItem(i)); + String actualTitle = mBookmarkModel.getBookmarkTitle(item); if (TextUtils.equals(actualTitle, expectedTitle)) { return true; } diff --git a/chrome/browser/bookmarks/enhanced_bookmarks_features.cc b/chrome/browser/bookmarks/enhanced_bookmarks_features.cc index 84e840c..97f6ccb 100644 --- a/chrome/browser/bookmarks/enhanced_bookmarks_features.cc +++ b/chrome/browser/bookmarks/enhanced_bookmarks_features.cc @@ -7,7 +7,6 @@ #include "base/command_line.h" #include "base/prefs/pref_service.h" #include "chrome/common/chrome_switches.h" -#include "components/enhanced_bookmarks/enhanced_bookmark_utils.h" #include "components/variations/variations_associated_data.h" #if !defined(OS_ANDROID) && !defined(OS_IOS) @@ -17,9 +16,11 @@ namespace { +const char kFieldTrialName[] = "EnhancedBookmarks"; + bool GetBookmarksExperimentExtensionID(std::string* extension_id) { *extension_id = variations::GetVariationParamValue( - enhanced_bookmarks::kFieldTrialName, "id"); + kFieldTrialName, "id"); if (extension_id->empty()) return false; @@ -46,7 +47,7 @@ bool IsEnhancedBookmarkImageFetchingEnabled(const PrefService* user_prefs) { // experience is not a big list of flat colors. However as a precautionary // measure it is possible to disable this collection of images from finch. std::string disable_fetching = variations::GetVariationParamValue( - enhanced_bookmarks::kFieldTrialName, "DisableImagesFetching"); + kFieldTrialName, "DisableImagesFetching"); return disable_fetching.empty(); } #endif // defined(OS_ANDROID) @@ -83,7 +84,7 @@ bool IsEnableDomDistillerSet() { switches::kEnableDomDistiller)) { return true; } - if (variations::GetVariationParamValue(enhanced_bookmarks::kFieldTrialName, + if (variations::GetVariationParamValue(kFieldTrialName, "enable-dom-distiller") == "1") return true; @@ -95,7 +96,7 @@ bool IsEnableSyncArticlesSet() { switches::kEnableSyncArticles)) { return true; } - if (variations::GetVariationParamValue(enhanced_bookmarks::kFieldTrialName, + if (variations::GetVariationParamValue(kFieldTrialName, "enable-sync-articles") == "1") return true; diff --git a/chrome/browser/enhanced_bookmarks/android/enhanced_bookmarks_bridge.cc b/chrome/browser/enhanced_bookmarks/android/enhanced_bookmarks_bridge.cc index 04634fb..446f172 100644 --- a/chrome/browser/enhanced_bookmarks/android/enhanced_bookmarks_bridge.cc +++ b/chrome/browser/enhanced_bookmarks/android/enhanced_bookmarks_bridge.cc @@ -16,7 +16,6 @@ #include "components/bookmarks/browser/bookmark_utils.h" #include "components/bookmarks/common/android/bookmark_id.h" #include "components/bookmarks/common/android/bookmark_type.h" -#include "components/enhanced_bookmarks/enhanced_bookmark_utils.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" #include "jni/EnhancedBookmarksBridge_jni.h" @@ -176,10 +175,6 @@ bool EnhancedBookmarksBridge::IsEditable(const BookmarkNode* node) const { bookmarks::prefs::kEditBookmarksEnabled); } -static jint GetDefaultViewMode(JNIEnv* env, jclass jcaller) { - return enhanced_bookmarks::GetDefaultViewMode(); -} - static jlong Init(JNIEnv* env, jobject obj, jobject j_profile) { return reinterpret_cast<jlong>(new EnhancedBookmarksBridge( env, obj, ProfileAndroid::FromProfileAndroid(j_profile))); diff --git a/components/enhanced_bookmarks/BUILD.gn b/components/enhanced_bookmarks/BUILD.gn index d4fcc2a..7702fbd 100644 --- a/components/enhanced_bookmarks/BUILD.gn +++ b/components/enhanced_bookmarks/BUILD.gn @@ -64,7 +64,6 @@ if (is_android) { ] outputs = [ "org/chromium/chrome/browser/enhanced_bookmarks/LaunchLocation.java", - "org/chromium/chrome/browser/enhanced_bookmarks/ViewMode.java", ] } } diff --git a/components/enhanced_bookmarks/DEPS b/components/enhanced_bookmarks/DEPS index 1a3fa5a..114b12c 100644 --- a/components/enhanced_bookmarks/DEPS +++ b/components/enhanced_bookmarks/DEPS @@ -4,7 +4,6 @@ include_rules = [ "+components/pref_registry", "+components/signin", "+components/sync_driver", - "+components/variations", "+google_apis/gaia", "+jni", "+net", diff --git a/components/enhanced_bookmarks/enhanced_bookmark_utils.cc b/components/enhanced_bookmarks/enhanced_bookmark_utils.cc index 7108d98..1ca96ca 100644 --- a/components/enhanced_bookmarks/enhanced_bookmark_utils.cc +++ b/components/enhanced_bookmarks/enhanced_bookmark_utils.cc @@ -5,15 +5,12 @@ #include "components/enhanced_bookmarks/enhanced_bookmark_utils.h" #include "components/bookmarks/browser/bookmark_model.h" -#include "components/variations/variations_associated_data.h" using bookmarks::BookmarkModel; using bookmarks::BookmarkNode; namespace enhanced_bookmarks { -const char kFieldTrialName[] = "EnhancedBookmarks"; - std::vector<const BookmarkNode*> PrimaryPermanentNodes(BookmarkModel* model) { DCHECK(model->loaded()); std::vector<const BookmarkNode*> nodes; @@ -66,19 +63,4 @@ const BookmarkNode* RootLevelFolderForNode(const BookmarkNode* node, return top; } -ViewMode GetDefaultViewMode() { - std::string default_view_mode = variations::GetVariationParamValue( - enhanced_bookmarks::kFieldTrialName, "DefaultViewMode"); - - if (default_view_mode == "List") { - return ViewMode::LIST; - } else if (default_view_mode == "Grid") { - return ViewMode::GRID; - } - - // If finch data is not available or has an invalid value, we fall back to - // ViewMode::GRID. - return ViewMode::GRID; -} - } // namespace enhanced_bookmarks diff --git a/components/enhanced_bookmarks/enhanced_bookmark_utils.h b/components/enhanced_bookmarks/enhanced_bookmark_utils.h index 81476eb..c66fa9a 100644 --- a/components/enhanced_bookmarks/enhanced_bookmark_utils.h +++ b/components/enhanced_bookmarks/enhanced_bookmark_utils.h @@ -16,8 +16,6 @@ class BookmarkNode; namespace enhanced_bookmarks { -extern const char kFieldTrialName[]; - // Possible locations where a bookmark can be opened from. // Please sync with the corresponding histograms.xml. // @@ -33,16 +31,6 @@ enum LaunchLocation { COUNT = 6, }; -// View modes of enhanced bookmarks' main items UI. -// -// A Java counterpart will be generated for this enum. -// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.enhanced_bookmarks -enum ViewMode { - DEFAULT = 0, - LIST = 1, - GRID = 2, -}; - // Returns the permanent nodes whose url children are considered uncategorized // and whose folder children should be shown in the bookmark menu. // |model| must be loaded. @@ -66,11 +54,6 @@ const bookmarks::BookmarkNode* RootLevelFolderForNode( const bookmarks::BookmarkNode* node, bookmarks::BookmarkModel* model); -// Returns the default view mode for main items UI. -// The default is controlled by a finch experiment. If finch is not available or -// has an invalid value, it returns a hard coded default view mode. -ViewMode GetDefaultViewMode(); - } // namespace enhanced_bookmarks #endif // COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_UTILS_H_ |