OLD | NEW |
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; |
11 import android.content.Intent; | 11 import android.content.Intent; |
12 import android.graphics.Rect; | 12 import android.graphics.Rect; |
13 import android.net.Uri; | 13 import android.net.Uri; |
14 import android.provider.Browser; | 14 import android.provider.Browser; |
15 import android.support.annotation.Nullable; | 15 import android.support.annotation.Nullable; |
16 import android.support.annotation.VisibleForTesting; | 16 import android.support.annotation.VisibleForTesting; |
17 import android.support.graphics.drawable.VectorDrawableCompat; | 17 import android.support.graphics.drawable.VectorDrawableCompat; |
18 import android.support.v7.widget.LinearLayoutManager; | 18 import android.support.v7.widget.LinearLayoutManager; |
19 import android.support.v7.widget.RecyclerView; | 19 import android.support.v7.widget.RecyclerView; |
20 import android.support.v7.widget.RecyclerView.ItemAnimator; | |
21 import android.support.v7.widget.RecyclerView.OnScrollListener; | 20 import android.support.v7.widget.RecyclerView.OnScrollListener; |
22 import android.support.v7.widget.Toolbar.OnMenuItemClickListener; | 21 import android.support.v7.widget.Toolbar.OnMenuItemClickListener; |
23 import android.view.LayoutInflater; | 22 import android.view.LayoutInflater; |
24 import android.view.MenuItem; | 23 import android.view.MenuItem; |
25 import android.view.View; | |
26 import android.view.ViewGroup; | 24 import android.view.ViewGroup; |
27 import android.widget.TextView; | 25 import android.widget.TextView; |
28 | 26 |
29 import org.chromium.base.ApiCompatibilityUtils; | 27 import org.chromium.base.ApiCompatibilityUtils; |
30 import org.chromium.base.ContextUtils; | 28 import org.chromium.base.ContextUtils; |
31 import org.chromium.base.metrics.RecordHistogram; | 29 import org.chromium.base.metrics.RecordHistogram; |
32 import org.chromium.base.metrics.RecordUserAction; | 30 import org.chromium.base.metrics.RecordUserAction; |
33 import org.chromium.chrome.R; | 31 import org.chromium.chrome.R; |
34 import org.chromium.chrome.browser.IntentHandler; | 32 import org.chromium.chrome.browser.IntentHandler; |
35 import org.chromium.chrome.browser.NativePage; | 33 import org.chromium.chrome.browser.NativePage; |
36 import org.chromium.chrome.browser.document.ChromeLauncherActivity; | 34 import org.chromium.chrome.browser.document.ChromeLauncherActivity; |
37 import org.chromium.chrome.browser.favicon.LargeIconBridge; | 35 import org.chromium.chrome.browser.favicon.LargeIconBridge; |
38 import org.chromium.chrome.browser.preferences.PreferencesLauncher; | 36 import org.chromium.chrome.browser.preferences.PreferencesLauncher; |
39 import org.chromium.chrome.browser.profiles.Profile; | 37 import org.chromium.chrome.browser.profiles.Profile; |
40 import org.chromium.chrome.browser.signin.SigninManager; | 38 import org.chromium.chrome.browser.signin.SigninManager; |
41 import org.chromium.chrome.browser.signin.SigninManager.SignInStateObserver; | 39 import org.chromium.chrome.browser.signin.SigninManager.SignInStateObserver; |
42 import org.chromium.chrome.browser.snackbar.Snackbar; | 40 import org.chromium.chrome.browser.snackbar.Snackbar; |
43 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; | 41 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; |
44 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarManageable; | 42 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarManageable; |
45 import org.chromium.chrome.browser.util.IntentUtils; | 43 import org.chromium.chrome.browser.util.IntentUtils; |
46 import org.chromium.chrome.browser.widget.FadingShadowView; | |
47 import org.chromium.chrome.browser.widget.selection.SelectableListLayout; | 44 import org.chromium.chrome.browser.widget.selection.SelectableListLayout; |
48 import org.chromium.chrome.browser.widget.selection.SelectableListToolbar.Search
Delegate; | 45 import org.chromium.chrome.browser.widget.selection.SelectableListToolbar.Search
Delegate; |
49 import org.chromium.chrome.browser.widget.selection.SelectionDelegate; | 46 import org.chromium.chrome.browser.widget.selection.SelectionDelegate; |
50 import org.chromium.chrome.browser.widget.selection.SelectionDelegate.SelectionO
bserver; | 47 import org.chromium.chrome.browser.widget.selection.SelectionDelegate.SelectionO
bserver; |
51 import org.chromium.ui.base.Clipboard; | 48 import org.chromium.ui.base.Clipboard; |
52 import org.chromium.ui.base.DeviceFormFactor; | 49 import org.chromium.ui.base.DeviceFormFactor; |
53 | 50 |
54 import java.util.List; | 51 import java.util.List; |
55 | 52 |
56 /** | 53 /** |
57 * Displays and manages the UI for browsing history. | 54 * Displays and manages the UI for browsing history. |
58 */ | 55 */ |
59 public class HistoryManager implements OnMenuItemClickListener, SignInStateObser
ver, | 56 public class HistoryManager implements OnMenuItemClickListener, SignInStateObser
ver, |
60 SelectionObserver<HistoryItem>, SearchDel
egate, | 57 SelectionObserver<HistoryItem>, SearchDel
egate, |
61 SnackbarController { | 58 SnackbarController { |
62 private static final int FAVICON_MAX_CACHE_SIZE_BYTES = 10 * 1024 * 1024; //
10MB | 59 private static final int FAVICON_MAX_CACHE_SIZE_BYTES = 10 * 1024 * 1024; //
10MB |
63 private static final int MEGABYTES_TO_BYTES = 1024 * 1024; | 60 private static final int MEGABYTES_TO_BYTES = 1024 * 1024; |
64 private static final String METRICS_PREFIX = "Android.HistoryPage."; | 61 private static final String METRICS_PREFIX = "Android.HistoryPage."; |
65 | 62 |
66 private static HistoryProvider sProviderForTests; | 63 private static HistoryProvider sProviderForTests; |
67 | 64 |
68 private final int mListItemLateralShadowSizePx; | 65 private final int mListItemLateralShadowSizePx; |
69 private final int mDefaultLateralListItemMarginPx; | |
70 | 66 |
71 private final Activity mActivity; | 67 private final Activity mActivity; |
72 private final boolean mIsDisplayedInNativePage; | 68 private final boolean mIsDisplayedInNativePage; |
73 private final SelectableListLayout<HistoryItem> mSelectableListLayout; | 69 private final SelectableListLayout<HistoryItem> mSelectableListLayout; |
74 private final HistoryAdapter mHistoryAdapter; | 70 private final HistoryAdapter mHistoryAdapter; |
75 private final SelectionDelegate<HistoryItem> mSelectionDelegate; | 71 private final SelectionDelegate<HistoryItem> mSelectionDelegate; |
76 private final HistoryManagerToolbar mToolbar; | 72 private final HistoryManagerToolbar mToolbar; |
77 private final TextView mEmptyView; | 73 private final TextView mEmptyView; |
78 private final FadingShadowView mToolbarShadow; | |
79 private final RecyclerView mRecyclerView; | 74 private final RecyclerView mRecyclerView; |
80 private final ItemAnimator mItemAnimator; | |
81 private LargeIconBridge mLargeIconBridge; | 75 private LargeIconBridge mLargeIconBridge; |
82 | 76 |
83 private boolean mIsSearching; | 77 private boolean mIsSearching; |
84 | 78 |
85 /** | 79 /** |
86 * Creates a new HistoryManager. | 80 * Creates a new HistoryManager. |
87 * @param activity The Activity associated with the HistoryManager. | 81 * @param activity The Activity associated with the HistoryManager. |
88 */ | 82 */ |
89 @SuppressWarnings("unchecked") // mSelectableListLayout | 83 @SuppressWarnings("unchecked") // mSelectableListLayout |
90 public HistoryManager(Activity activity, @Nullable NativePage nativePage) { | 84 public HistoryManager(Activity activity, @Nullable NativePage nativePage) { |
91 mActivity = activity; | 85 mActivity = activity; |
92 mIsDisplayedInNativePage = nativePage != null; | 86 mIsDisplayedInNativePage = nativePage != null; |
93 | 87 |
94 mSelectionDelegate = new SelectionDelegate<>(); | 88 mSelectionDelegate = new SelectionDelegate<>(); |
95 mSelectionDelegate.addObserver(this); | 89 mSelectionDelegate.addObserver(this); |
96 mHistoryAdapter = new HistoryAdapter(mSelectionDelegate, this, | 90 mHistoryAdapter = new HistoryAdapter(mSelectionDelegate, this, |
97 sProviderForTests != null ? sProviderForTests : new BrowsingHist
oryBridge()); | 91 sProviderForTests != null ? sProviderForTests : new BrowsingHist
oryBridge()); |
98 | 92 |
99 // 1. Create SelectableListLayout. | 93 // 1. Create SelectableListLayout. |
100 mSelectableListLayout = | 94 mSelectableListLayout = |
101 (SelectableListLayout<HistoryItem>) LayoutInflater.from(activity
).inflate( | 95 (SelectableListLayout<HistoryItem>) LayoutInflater.from(activity
).inflate( |
102 R.layout.history_main, null); | 96 R.layout.history_main, null); |
103 | 97 |
104 // 2. Initialize RecyclerView. | 98 // 2. Initialize RecyclerView. |
105 mRecyclerView = mSelectableListLayout.initializeRecyclerView(mHistoryAda
pter); | 99 mRecyclerView = mSelectableListLayout.initializeRecyclerView(mHistoryAda
pter); |
106 mItemAnimator = mRecyclerView.getItemAnimator(); | |
107 | 100 |
108 // 3. Initialize toolbar. | 101 // 3. Initialize toolbar. |
109 mToolbar = (HistoryManagerToolbar) mSelectableListLayout.initializeToolb
ar( | 102 mToolbar = (HistoryManagerToolbar) mSelectableListLayout.initializeToolb
ar( |
110 R.layout.history_toolbar, mSelectionDelegate, R.string.menu_hist
ory, null, | 103 R.layout.history_toolbar, mSelectionDelegate, R.string.menu_hist
ory, null, |
111 R.id.normal_menu_group, R.id.selection_mode_menu_group, | 104 R.id.normal_menu_group, R.id.selection_mode_menu_group, |
112 R.color.default_primary_color, false, this); | 105 R.color.default_primary_color, false, this); |
113 mToolbar.setManager(this); | 106 mToolbar.setManager(this); |
114 mToolbar.initializeSearchView(this, R.string.history_manager_search, R.i
d.search_menu_id); | 107 mToolbar.initializeSearchView(this, R.string.history_manager_search, R.i
d.search_menu_id); |
115 mToolbarShadow = (FadingShadowView) mSelectableListLayout.findViewById(R
.id.shadow); | |
116 mToolbarShadow.setVisibility(View.GONE); | |
117 | 108 |
118 // 4. Configure values for HorizontalDisplayStyle.WIDE and HorizontalDis
playStyle.REGULAR. | 109 // 4. Configure values for HorizontalDisplayStyle.WIDE and HorizontalDis
playStyle.REGULAR. |
119 // The list item shadow is part of the drawable nine-patch used as the l
ist item background. | 110 // The list item shadow is part of the drawable nine-patch used as the l
ist item background. |
120 // Use the dimensions of the shadow (from the drawable's padding) to cal
culate the margins | 111 // Use the dimensions of the shadow (from the drawable's padding) to cal
culate the margins |
121 // to use in the regular and wide display styles. | 112 // to use in the regular and wide display styles. |
122 Rect listItemShadow = new Rect(); | 113 Rect listItemShadow = new Rect(); |
123 ApiCompatibilityUtils.getDrawable( | 114 ApiCompatibilityUtils.getDrawable( |
124 mActivity.getResources(), R.drawable.card_middle).getPadding(lis
tItemShadow); | 115 mActivity.getResources(), R.drawable.card_middle).getPadding(lis
tItemShadow); |
125 int cardCornerRadius = | |
126 mActivity.getResources().getDimensionPixelSize(R.dimen.list_item
_corner_radius); | |
127 | 116 |
128 assert listItemShadow.left == listItemShadow.right; | 117 assert listItemShadow.left == listItemShadow.right; |
129 // The list item shadow size is used in HorizontalDisplayStyle.WIDE to v
isually align other | 118 // The list item shadow size is used in HorizontalDisplayStyle.WIDE to v
isually align other |
130 // elements with the edge of the list items. | 119 // elements with the edge of the list items. |
131 mListItemLateralShadowSizePx = listItemShadow.left; | 120 mListItemLateralShadowSizePx = listItemShadow.left; |
132 // A negative margin is used in HorizontalDisplayStyle.REGULAR to hide t
he lateral shadow. | |
133 mDefaultLateralListItemMarginPx = -(listItemShadow.left + cardCornerRadi
us); | |
134 | 121 |
135 mSelectableListLayout.setHasWideDisplayStyle(mListItemLateralShadowSizeP
x); | 122 mSelectableListLayout.setHasWideDisplayStyle(mListItemLateralShadowSizeP
x); |
136 | 123 |
137 // 5. Initialize empty view. | 124 // 5. Initialize empty view. |
138 mEmptyView = mSelectableListLayout.initializeEmptyView( | 125 mEmptyView = mSelectableListLayout.initializeEmptyView( |
139 VectorDrawableCompat.create( | 126 VectorDrawableCompat.create( |
140 mActivity.getResources(), R.drawable.history_big, | 127 mActivity.getResources(), R.drawable.history_big, mActiv
ity.getTheme()), |
141 mActivity.getTheme()), | 128 R.string.history_manager_empty, R.string.history_manager_no_resu
lts); |
142 R.string.history_manager_empty); | |
143 // TODO(twellington): remove this after unifying bookmarks and downloads
UI with history. | 129 // TODO(twellington): remove this after unifying bookmarks and downloads
UI with history. |
144 mEmptyView.setTextColor(ApiCompatibilityUtils.getColor(mActivity.getReso
urces(), | 130 mEmptyView.setTextColor(ApiCompatibilityUtils.getColor(mActivity.getReso
urces(), |
145 R.color.google_grey_500)); | 131 R.color.google_grey_500)); |
146 | 132 |
147 // 6. Create large icon bridge. | 133 // 6. Create large icon bridge. |
148 mLargeIconBridge = new LargeIconBridge(Profile.getLastUsedProfile().getO
riginalProfile()); | 134 mLargeIconBridge = new LargeIconBridge(Profile.getLastUsedProfile().getO
riginalProfile()); |
149 ActivityManager activityManager = ((ActivityManager) ContextUtils | 135 ActivityManager activityManager = ((ActivityManager) ContextUtils |
150 .getApplicationContext().getSystemService(Context.ACTIVITY_SERVI
CE)); | 136 .getApplicationContext().getSystemService(Context.ACTIVITY_SERVI
CE)); |
151 int maxSize = Math.min((activityManager.getMemoryClass() / 4) * MEGABYTE
S_TO_BYTES, | 137 int maxSize = Math.min((activityManager.getMemoryClass() / 4) * MEGABYTE
S_TO_BYTES, |
152 FAVICON_MAX_CACHE_SIZE_BYTES); | 138 FAVICON_MAX_CACHE_SIZE_BYTES); |
153 mLargeIconBridge.createCache(maxSize); | 139 mLargeIconBridge.createCache(maxSize); |
154 | 140 |
155 // 7. Initialize the adapter to load items. | 141 // 7. Initialize the adapter to load items. |
156 mHistoryAdapter.initialize(); | 142 mHistoryAdapter.initialize(); |
157 | 143 |
158 // 8. Add scroll listener to page in more items when necessary. | 144 // 8. Add scroll listener to page in more items when necessary. |
159 mRecyclerView.addOnScrollListener(new OnScrollListener() { | 145 mRecyclerView.addOnScrollListener(new OnScrollListener() { |
160 @Override | 146 @Override |
161 public void onScrolled(RecyclerView recyclerView, int dx, int dy) { | 147 public void onScrolled(RecyclerView recyclerView, int dx, int dy) { |
162 setToolbarShadowVisibility(); | |
163 | |
164 if (!mHistoryAdapter.canLoadMoreItems()) return; | 148 if (!mHistoryAdapter.canLoadMoreItems()) return; |
165 | 149 |
166 // Load more items if the scroll position is close to the bottom
of the list. | 150 // Load more items if the scroll position is close to the bottom
of the list. |
167 LinearLayoutManager layoutManager = | 151 LinearLayoutManager layoutManager = |
168 (LinearLayoutManager) recyclerView.getLayoutManager(); | 152 (LinearLayoutManager) recyclerView.getLayoutManager(); |
169 if (layoutManager.findLastVisibleItemPosition() | 153 if (layoutManager.findLastVisibleItemPosition() |
170 > (mHistoryAdapter.getItemCount() - 25)) { | 154 > (mHistoryAdapter.getItemCount() - 25)) { |
171 mHistoryAdapter.loadMoreItems(); | 155 mHistoryAdapter.loadMoreItems(); |
172 recordUserActionWithOptionalSearch("LoadMoreOnScroll"); | 156 recordUserActionWithOptionalSearch("LoadMoreOnScroll"); |
173 } | 157 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 recordUserActionWithOptionalSearch("RemoveSelected"); | 199 recordUserActionWithOptionalSearch("RemoveSelected"); |
216 | 200 |
217 for (HistoryItem historyItem : mSelectionDelegate.getSelectedItems()
) { | 201 for (HistoryItem historyItem : mSelectionDelegate.getSelectedItems()
) { |
218 mHistoryAdapter.markItemForRemoval(historyItem); | 202 mHistoryAdapter.markItemForRemoval(historyItem); |
219 } | 203 } |
220 mHistoryAdapter.removeItems(); | 204 mHistoryAdapter.removeItems(); |
221 mSelectionDelegate.clearSelection(); | 205 mSelectionDelegate.clearSelection(); |
222 return true; | 206 return true; |
223 } else if (item.getItemId() == R.id.search_menu_id) { | 207 } else if (item.getItemId() == R.id.search_menu_id) { |
224 mHistoryAdapter.removeHeader(); | 208 mHistoryAdapter.removeHeader(); |
225 | |
226 mRecyclerView.setItemAnimator(null); | |
227 mToolbar.showSearchView(); | 209 mToolbar.showSearchView(); |
228 mToolbarShadow.setVisibility(View.VISIBLE); | 210 mSelectableListLayout.onStartSearch(); |
229 mSelectableListLayout.setEmptyViewText(R.string.history_manager_no_r
esults); | |
230 recordUserAction("Search"); | 211 recordUserAction("Search"); |
231 mIsSearching = true; | 212 mIsSearching = true; |
232 return true; | 213 return true; |
233 } | 214 } |
234 return false; | 215 return false; |
235 } | 216 } |
236 | 217 |
237 /** | 218 /** |
238 * @return The view that shows the main browsing history UI. | 219 * @return The view that shows the main browsing history UI. |
239 */ | 220 */ |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 } | 299 } |
319 | 300 |
320 @Override | 301 @Override |
321 public void onSearchTextChanged(String query) { | 302 public void onSearchTextChanged(String query) { |
322 mHistoryAdapter.search(query); | 303 mHistoryAdapter.search(query); |
323 } | 304 } |
324 | 305 |
325 @Override | 306 @Override |
326 public void onEndSearch() { | 307 public void onEndSearch() { |
327 mHistoryAdapter.onEndSearch(); | 308 mHistoryAdapter.onEndSearch(); |
328 mSelectableListLayout.setEmptyViewText(R.string.history_manager_empty); | 309 mSelectableListLayout.onEndSearch(); |
329 mIsSearching = false; | 310 mIsSearching = false; |
330 setToolbarShadowVisibility(); | |
331 mRecyclerView.setItemAnimator(mItemAnimator); | |
332 } | 311 } |
333 | 312 |
334 /** | 313 /** |
335 * @return The {@link LargeIconBridge} used to fetch large favicons. | 314 * @return The {@link LargeIconBridge} used to fetch large favicons. |
336 */ | 315 */ |
337 public LargeIconBridge getLargeIconBridge() { | 316 public LargeIconBridge getLargeIconBridge() { |
338 return mLargeIconBridge; | 317 return mLargeIconBridge; |
339 } | 318 } |
340 | 319 |
341 /** | 320 /** |
342 * @return The SelectableListLayout that displays HistoryItems. | 321 * @return The SelectableListLayout that displays HistoryItems. |
343 */ | 322 */ |
344 public SelectableListLayout<HistoryItem> getSelectableListLayout() { | 323 public SelectableListLayout<HistoryItem> getSelectableListLayout() { |
345 return mSelectableListLayout; | 324 return mSelectableListLayout; |
346 } | 325 } |
347 | 326 |
348 /** | 327 /** |
349 * @return The px size of the lateral shadow in the 9-patch used for the lis
t item background. | 328 * @return The px size of the lateral shadow in the 9-patch used for the lis
t item background. |
350 * This value should be used in the regular horizontal display style
to visually align | 329 * This value should be used in the regular horizontal display style
to visually align |
351 * elements with the edge of the list items. | 330 * elements with the edge of the list items. |
352 * @see org.chromium.chrome.browser.widget.displaystyle.HorizontalDisplaySty
le#REGULAR | 331 * @see org.chromium.chrome.browser.widget.displaystyle.HorizontalDisplaySty
le#REGULAR |
353 */ | 332 */ |
354 public int getListItemLateralShadowSizePx() { | 333 public int getListItemLateralShadowSizePx() { |
355 return mListItemLateralShadowSizePx; | 334 return mListItemLateralShadowSizePx; |
356 } | 335 } |
357 | 336 |
358 /** | |
359 * @return The start and end margin for list items when in the regular horiz
ontal display style. | |
360 * This value should be used to hide the lateral shadows on list ite
ms. | |
361 * @see org.chromium.chrome.browser.widget.displaystyle.HorizontalDisplaySty
le#REGULAR | |
362 */ | |
363 public int getDefaultLateralListItemMarginPx() { | |
364 return mDefaultLateralListItemMarginPx; | |
365 } | |
366 | |
367 private void openItemsInNewTabs(List<HistoryItem> items, boolean isIncognito
) { | 337 private void openItemsInNewTabs(List<HistoryItem> items, boolean isIncognito
) { |
368 recordSelectionCountHistorgram("Open"); | 338 recordSelectionCountHistorgram("Open"); |
369 recordUserActionWithOptionalSearch("OpenSelected" + (isIncognito ? "Inco
gnito" : "")); | 339 recordUserActionWithOptionalSearch("OpenSelected" + (isIncognito ? "Inco
gnito" : "")); |
370 | 340 |
371 for (HistoryItem item : items) { | 341 for (HistoryItem item : items) { |
372 openUrl(item.getUrl(), isIncognito, true); | 342 openUrl(item.getUrl(), isIncognito, true); |
373 } | 343 } |
374 } | 344 } |
375 | 345 |
376 /** | 346 /** |
(...skipping 17 matching lines...) Expand all Loading... |
394 @VisibleForTesting | 364 @VisibleForTesting |
395 TextView getEmptyViewForTests() { | 365 TextView getEmptyViewForTests() { |
396 return mEmptyView; | 366 return mEmptyView; |
397 } | 367 } |
398 | 368 |
399 @VisibleForTesting | 369 @VisibleForTesting |
400 HistoryAdapter getAdapterForTests() { | 370 HistoryAdapter getAdapterForTests() { |
401 return mHistoryAdapter; | 371 return mHistoryAdapter; |
402 } | 372 } |
403 | 373 |
404 @VisibleForTesting | |
405 View getToolbarShadowForTests() { | |
406 return mToolbarShadow; | |
407 } | |
408 | |
409 /** | 374 /** |
410 * @param action The user action string to record. | 375 * @param action The user action string to record. |
411 */ | 376 */ |
412 static void recordUserAction(String action) { | 377 static void recordUserAction(String action) { |
413 RecordUserAction.record(METRICS_PREFIX + action); | 378 RecordUserAction.record(METRICS_PREFIX + action); |
414 } | 379 } |
415 | 380 |
416 /** | 381 /** |
417 * Records the user action with "Search" prepended if the user is currently
searching. | 382 * Records the user action with "Search" prepended if the user is currently
searching. |
418 * @param action The user action string to record. | 383 * @param action The user action string to record. |
(...skipping 20 matching lines...) Expand all Loading... |
439 | 404 |
440 @Override | 405 @Override |
441 public void onSignedOut() { | 406 public void onSignedOut() { |
442 mToolbar.onSignInStateChange(); | 407 mToolbar.onSignInStateChange(); |
443 mHistoryAdapter.onSignInStateChange(); | 408 mHistoryAdapter.onSignInStateChange(); |
444 } | 409 } |
445 | 410 |
446 @Override | 411 @Override |
447 public void onSelectionStateChange(List<HistoryItem> selectedItems) { | 412 public void onSelectionStateChange(List<HistoryItem> selectedItems) { |
448 mHistoryAdapter.onSelectionStateChange(mSelectionDelegate.isSelectionEna
bled()); | 413 mHistoryAdapter.onSelectionStateChange(mSelectionDelegate.isSelectionEna
bled()); |
449 setToolbarShadowVisibility(); | |
450 } | 414 } |
451 | 415 |
452 @Override | 416 @Override |
453 public void onAction(Object actionData) { | 417 public void onAction(Object actionData) { |
454 // Handler for the link copied snackbar. Do nothing. | 418 // Handler for the link copied snackbar. Do nothing. |
455 } | 419 } |
456 | 420 |
457 @Override | 421 @Override |
458 public void onDismissNoAction(Object actionData) { | 422 public void onDismissNoAction(Object actionData) { |
459 // Handler for the link copied snackbar. Do nothing. | 423 // Handler for the link copied snackbar. Do nothing. |
460 } | 424 } |
461 | |
462 private void setToolbarShadowVisibility() { | |
463 boolean showShadow = mRecyclerView.computeVerticalScrollOffset() != 0 | |
464 || mIsSearching || mSelectionDelegate.isSelectionEnabled(); | |
465 mToolbarShadow.setVisibility(showShadow ? View.VISIBLE : View.GONE); | |
466 } | |
467 } | 425 } |
OLD | NEW |