Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/history/HistoryManager.java

Issue 2691373004: [Android History] Even more polish (Closed)
Patch Set: Rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.history; 5 package org.chromium.chrome.browser.history;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.app.ActivityManager; 8 import android.app.ActivityManager;
9 import android.content.ComponentName; 9 import android.content.ComponentName;
10 import android.content.Context; 10 import android.content.Context;
(...skipping 21 matching lines...) Expand all
32 import org.chromium.base.metrics.RecordUserAction; 32 import org.chromium.base.metrics.RecordUserAction;
33 import org.chromium.chrome.R; 33 import org.chromium.chrome.R;
34 import org.chromium.chrome.browser.IntentHandler; 34 import org.chromium.chrome.browser.IntentHandler;
35 import org.chromium.chrome.browser.NativePage; 35 import org.chromium.chrome.browser.NativePage;
36 import org.chromium.chrome.browser.document.ChromeLauncherActivity; 36 import org.chromium.chrome.browser.document.ChromeLauncherActivity;
37 import org.chromium.chrome.browser.favicon.LargeIconBridge; 37 import org.chromium.chrome.browser.favicon.LargeIconBridge;
38 import org.chromium.chrome.browser.preferences.PreferencesLauncher; 38 import org.chromium.chrome.browser.preferences.PreferencesLauncher;
39 import org.chromium.chrome.browser.profiles.Profile; 39 import org.chromium.chrome.browser.profiles.Profile;
40 import org.chromium.chrome.browser.signin.SigninManager; 40 import org.chromium.chrome.browser.signin.SigninManager;
41 import org.chromium.chrome.browser.signin.SigninManager.SignInStateObserver; 41 import org.chromium.chrome.browser.signin.SigninManager.SignInStateObserver;
42 import org.chromium.chrome.browser.snackbar.Snackbar;
43 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController;
44 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarManageable;
42 import org.chromium.chrome.browser.util.IntentUtils; 45 import org.chromium.chrome.browser.util.IntentUtils;
43 import org.chromium.chrome.browser.widget.FadingShadowView; 46 import org.chromium.chrome.browser.widget.FadingShadowView;
44 import org.chromium.chrome.browser.widget.selection.SelectableListLayout; 47 import org.chromium.chrome.browser.widget.selection.SelectableListLayout;
45 import org.chromium.chrome.browser.widget.selection.SelectableListToolbar.Search Delegate; 48 import org.chromium.chrome.browser.widget.selection.SelectableListToolbar.Search Delegate;
46 import org.chromium.chrome.browser.widget.selection.SelectionDelegate; 49 import org.chromium.chrome.browser.widget.selection.SelectionDelegate;
47 import org.chromium.chrome.browser.widget.selection.SelectionDelegate.SelectionO bserver; 50 import org.chromium.chrome.browser.widget.selection.SelectionDelegate.SelectionO bserver;
48 import org.chromium.ui.base.Clipboard; 51 import org.chromium.ui.base.Clipboard;
49 import org.chromium.ui.base.DeviceFormFactor; 52 import org.chromium.ui.base.DeviceFormFactor;
50 53
51 import java.util.List; 54 import java.util.List;
52 55
53 /** 56 /**
54 * Displays and manages the UI for browsing history. 57 * Displays and manages the UI for browsing history.
55 */ 58 */
56 public class HistoryManager implements OnMenuItemClickListener, SignInStateObser ver, 59 public class HistoryManager implements OnMenuItemClickListener, SignInStateObser ver,
57 SelectionObserver<HistoryItem>, SearchDelegate { 60 SelectionObserver<HistoryItem>, SearchDel egate,
61 SnackbarController {
58 private static final int FAVICON_MAX_CACHE_SIZE_BYTES = 10 * 1024 * 1024; // 10MB 62 private static final int FAVICON_MAX_CACHE_SIZE_BYTES = 10 * 1024 * 1024; // 10MB
59 private static final int MEGABYTES_TO_BYTES = 1024 * 1024; 63 private static final int MEGABYTES_TO_BYTES = 1024 * 1024;
60 private static final String METRICS_PREFIX = "Android.HistoryPage."; 64 private static final String METRICS_PREFIX = "Android.HistoryPage.";
61 65
62 private static HistoryProvider sProviderForTests; 66 private static HistoryProvider sProviderForTests;
63 67
64 private final int mListItemLateralShadowSizePx; 68 private final int mListItemLateralShadowSizePx;
65 private final int mDefaultLateralListItemMarginPx; 69 private final int mDefaultLateralListItemMarginPx;
66 70
67 private final Activity mActivity; 71 private final Activity mActivity;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 mToolbarShadow = (FadingShadowView) mSelectableListLayout.findViewById(R .id.shadow); 115 mToolbarShadow = (FadingShadowView) mSelectableListLayout.findViewById(R .id.shadow);
112 mToolbarShadow.setVisibility(View.GONE); 116 mToolbarShadow.setVisibility(View.GONE);
113 117
114 // 4. Configure values for HorizontalDisplayStyle.WIDE and HorizontalDis playStyle.REGULAR. 118 // 4. Configure values for HorizontalDisplayStyle.WIDE and HorizontalDis playStyle.REGULAR.
115 // The list item shadow is part of the drawable nine-patch used as the l ist item background. 119 // The list item shadow is part of the drawable nine-patch used as the l ist item background.
116 // Use the dimensions of the shadow (from the drawable's padding) to cal culate the margins 120 // Use the dimensions of the shadow (from the drawable's padding) to cal culate the margins
117 // to use in the regular and wide display styles. 121 // to use in the regular and wide display styles.
118 Rect listItemShadow = new Rect(); 122 Rect listItemShadow = new Rect();
119 ApiCompatibilityUtils.getDrawable( 123 ApiCompatibilityUtils.getDrawable(
120 mActivity.getResources(), R.drawable.card_middle).getPadding(lis tItemShadow); 124 mActivity.getResources(), R.drawable.card_middle).getPadding(lis tItemShadow);
121 int cardCornerRadius = mActivity.getResources().getDimensionPixelSize( 125 int cardCornerRadius =
122 R.dimen.card_corner_radius); 126 mActivity.getResources().getDimensionPixelSize(R.dimen.list_item _corner_radius);
123 127
124 assert listItemShadow.left == listItemShadow.right; 128 assert listItemShadow.left == listItemShadow.right;
125 // The list item shadow size is used in HorizontalDisplayStyle.WIDE to v isually align other 129 // The list item shadow size is used in HorizontalDisplayStyle.WIDE to v isually align other
126 // elements with the edge of the list items. 130 // elements with the edge of the list items.
127 mListItemLateralShadowSizePx = listItemShadow.left; 131 mListItemLateralShadowSizePx = listItemShadow.left;
128 // A negative margin is used in HorizontalDisplayStyle.REGULAR to hide t he lateral shadow. 132 // A negative margin is used in HorizontalDisplayStyle.REGULAR to hide t he lateral shadow.
129 mDefaultLateralListItemMarginPx = -(listItemShadow.left + cardCornerRadi us); 133 mDefaultLateralListItemMarginPx = -(listItemShadow.left + cardCornerRadi us);
130 134
131 mSelectableListLayout.setHasWideDisplayStyle(mListItemLateralShadowSizeP x); 135 mSelectableListLayout.setHasWideDisplayStyle(mListItemLateralShadowSizeP x);
132 136
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 181
178 /** 182 /**
179 * @return Whether the history manager UI is displayed in a native page. 183 * @return Whether the history manager UI is displayed in a native page.
180 */ 184 */
181 public boolean isDisplayedInNativePage() { 185 public boolean isDisplayedInNativePage() {
182 return mIsDisplayedInNativePage; 186 return mIsDisplayedInNativePage;
183 } 187 }
184 188
185 @Override 189 @Override
186 public boolean onMenuItemClick(MenuItem item) { 190 public boolean onMenuItemClick(MenuItem item) {
191 mToolbar.hideOverflowMenu();
192
187 if (item.getItemId() == R.id.close_menu_id && !isDisplayedInNativePage() ) { 193 if (item.getItemId() == R.id.close_menu_id && !isDisplayedInNativePage() ) {
188 mActivity.finish(); 194 mActivity.finish();
189 return true; 195 return true;
190 } else if (item.getItemId() == R.id.selection_mode_open_in_new_tab) { 196 } else if (item.getItemId() == R.id.selection_mode_open_in_new_tab) {
191 openItemsInNewTabs(mSelectionDelegate.getSelectedItems(), false); 197 openItemsInNewTabs(mSelectionDelegate.getSelectedItems(), false);
192 mSelectionDelegate.clearSelection(); 198 mSelectionDelegate.clearSelection();
193 return true; 199 return true;
194 } else if (item.getItemId() == R.id.selection_mode_copy_link) { 200 } else if (item.getItemId() == R.id.selection_mode_copy_link) {
195 recordUserActionWithOptionalSearch("CopyLink"); 201 recordUserActionWithOptionalSearch("CopyLink");
196 Clipboard clipboard = new Clipboard(mActivity); 202 Clipboard clipboard = new Clipboard(mActivity);
197 clipboard.setText(mSelectionDelegate.getSelectedItems().get(0).getUr l()); 203 clipboard.setText(mSelectionDelegate.getSelectedItems().get(0).getUr l());
204 mSelectionDelegate.clearSelection();
205 Snackbar snackbar = Snackbar.make(mActivity.getString(R.string.copie d), this,
206 Snackbar.TYPE_NOTIFICATION, Snackbar.UMA_HISTORY_LINK_COPIED );
207 ((SnackbarManageable) mActivity).getSnackbarManager().showSnackbar(s nackbar);
gone 2017/02/16 19:29:16 Any reason we're using a snackbar instead of a toa
Theresa 2017/02/16 19:59:10 I asked UX if we could use a toast and they said n
198 return true; 208 return true;
199 } else if (item.getItemId() == R.id.selection_mode_open_in_incognito) { 209 } else if (item.getItemId() == R.id.selection_mode_open_in_incognito) {
200 openItemsInNewTabs(mSelectionDelegate.getSelectedItems(), true); 210 openItemsInNewTabs(mSelectionDelegate.getSelectedItems(), true);
201 mSelectionDelegate.clearSelection(); 211 mSelectionDelegate.clearSelection();
202 return true; 212 return true;
203 } else if (item.getItemId() == R.id.selection_mode_delete_menu_id) { 213 } else if (item.getItemId() == R.id.selection_mode_delete_menu_id) {
204 recordSelectionCountHistorgram("Remove"); 214 recordSelectionCountHistorgram("Remove");
205 recordUserActionWithOptionalSearch("RemoveSelected"); 215 recordUserActionWithOptionalSearch("RemoveSelected");
206 216
207 for (HistoryItem historyItem : mSelectionDelegate.getSelectedItems() ) { 217 for (HistoryItem historyItem : mSelectionDelegate.getSelectedItems() ) {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 mToolbar.onSignInStateChange(); 442 mToolbar.onSignInStateChange();
433 mHistoryAdapter.onSignInStateChange(); 443 mHistoryAdapter.onSignInStateChange();
434 } 444 }
435 445
436 @Override 446 @Override
437 public void onSelectionStateChange(List<HistoryItem> selectedItems) { 447 public void onSelectionStateChange(List<HistoryItem> selectedItems) {
438 mHistoryAdapter.onSelectionStateChange(mSelectionDelegate.isSelectionEna bled()); 448 mHistoryAdapter.onSelectionStateChange(mSelectionDelegate.isSelectionEna bled());
439 setToolbarShadowVisibility(); 449 setToolbarShadowVisibility();
440 } 450 }
441 451
452 @Override
453 public void onAction(Object actionData) {
454 // Handler for the link copied snackbar. Do nothing.
455 }
456
457 @Override
458 public void onDismissNoAction(Object actionData) {
459 // Handler for the link copied snackbar. Do nothing.
460 }
461
442 private void setToolbarShadowVisibility() { 462 private void setToolbarShadowVisibility() {
443 boolean showShadow = mRecyclerView.computeVerticalScrollOffset() != 0 463 boolean showShadow = mRecyclerView.computeVerticalScrollOffset() != 0
444 || mIsSearching || mSelectionDelegate.isSelectionEnabled(); 464 || mIsSearching || mSelectionDelegate.isSelectionEnabled();
445 mToolbarShadow.setVisibility(showShadow ? View.VISIBLE : View.GONE); 465 mToolbarShadow.setVisibility(showShadow ? View.VISIBLE : View.GONE);
446 } 466 }
447 } 467 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698