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; | |
16 import android.support.annotation.VisibleForTesting; | 15 import android.support.annotation.VisibleForTesting; |
17 import android.support.graphics.drawable.VectorDrawableCompat; | 16 import android.support.graphics.drawable.VectorDrawableCompat; |
18 import android.support.v7.widget.LinearLayoutManager; | 17 import android.support.v7.widget.LinearLayoutManager; |
19 import android.support.v7.widget.RecyclerView; | 18 import android.support.v7.widget.RecyclerView; |
20 import android.support.v7.widget.RecyclerView.OnScrollListener; | 19 import android.support.v7.widget.RecyclerView.OnScrollListener; |
20 import android.support.v7.widget.Toolbar; | |
21 import android.support.v7.widget.Toolbar.OnMenuItemClickListener; | 21 import android.support.v7.widget.Toolbar.OnMenuItemClickListener; |
22 import android.view.LayoutInflater; | 22 import android.view.LayoutInflater; |
23 import android.view.MenuItem; | 23 import android.view.MenuItem; |
24 import android.view.View; | |
25 import android.view.ViewGroup; | 24 import android.view.ViewGroup; |
26 import android.widget.TextView; | 25 import android.widget.TextView; |
27 | 26 |
28 import org.chromium.base.ApiCompatibilityUtils; | 27 import org.chromium.base.ApiCompatibilityUtils; |
29 import org.chromium.base.ContextUtils; | 28 import org.chromium.base.ContextUtils; |
30 import org.chromium.base.metrics.RecordHistogram; | 29 import org.chromium.base.metrics.RecordHistogram; |
31 import org.chromium.base.metrics.RecordUserAction; | 30 import org.chromium.base.metrics.RecordUserAction; |
32 import org.chromium.chrome.R; | 31 import org.chromium.chrome.R; |
33 import org.chromium.chrome.browser.IntentHandler; | 32 import org.chromium.chrome.browser.IntentHandler; |
34 import org.chromium.chrome.browser.NativePage; | |
35 import org.chromium.chrome.browser.document.ChromeLauncherActivity; | 33 import org.chromium.chrome.browser.document.ChromeLauncherActivity; |
36 import org.chromium.chrome.browser.favicon.LargeIconBridge; | 34 import org.chromium.chrome.browser.favicon.LargeIconBridge; |
37 import org.chromium.chrome.browser.preferences.PreferencesLauncher; | 35 import org.chromium.chrome.browser.preferences.PreferencesLauncher; |
38 import org.chromium.chrome.browser.profiles.Profile; | 36 import org.chromium.chrome.browser.profiles.Profile; |
39 import org.chromium.chrome.browser.signin.SigninManager; | 37 import org.chromium.chrome.browser.signin.SigninManager; |
40 import org.chromium.chrome.browser.signin.SigninManager.SignInStateObserver; | 38 import org.chromium.chrome.browser.signin.SigninManager.SignInStateObserver; |
41 import org.chromium.chrome.browser.snackbar.Snackbar; | 39 import org.chromium.chrome.browser.snackbar.Snackbar; |
42 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; | 40 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; |
43 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarManageable; | 41 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarManageable; |
44 import org.chromium.chrome.browser.util.IntentUtils; | 42 import org.chromium.chrome.browser.util.IntentUtils; |
(...skipping 14 matching lines...) Expand all Loading... | |
59 SnackbarController { | 57 SnackbarController { |
60 private static final int FAVICON_MAX_CACHE_SIZE_BYTES = 10 * 1024 * 1024; // 10MB | 58 private static final int FAVICON_MAX_CACHE_SIZE_BYTES = 10 * 1024 * 1024; // 10MB |
61 private static final int MEGABYTES_TO_BYTES = 1024 * 1024; | 59 private static final int MEGABYTES_TO_BYTES = 1024 * 1024; |
62 private static final String METRICS_PREFIX = "Android.HistoryPage."; | 60 private static final String METRICS_PREFIX = "Android.HistoryPage."; |
63 | 61 |
64 private static HistoryProvider sProviderForTests; | 62 private static HistoryProvider sProviderForTests; |
65 | 63 |
66 private final int mListItemLateralShadowSizePx; | 64 private final int mListItemLateralShadowSizePx; |
67 | 65 |
68 private final Activity mActivity; | 66 private final Activity mActivity; |
69 private final boolean mIsDisplayedInNativePage; | 67 private final boolean mIsFullscreenActivity; |
70 private final SelectableListLayout<HistoryItem> mSelectableListLayout; | 68 private final SelectableListLayout<HistoryItem> mSelectableListLayout; |
71 private final HistoryAdapter mHistoryAdapter; | 69 private final HistoryAdapter mHistoryAdapter; |
72 private final SelectionDelegate<HistoryItem> mSelectionDelegate; | 70 private final SelectionDelegate<HistoryItem> mSelectionDelegate; |
73 private final HistoryManagerToolbar mToolbar; | 71 private final HistoryManagerToolbar mToolbar; |
74 private final TextView mEmptyView; | 72 private final TextView mEmptyView; |
75 private final RecyclerView mRecyclerView; | 73 private final RecyclerView mRecyclerView; |
76 private LargeIconBridge mLargeIconBridge; | 74 private LargeIconBridge mLargeIconBridge; |
77 | 75 |
78 private boolean mIsSearching; | 76 private boolean mIsSearching; |
79 | 77 |
80 /** | 78 /** |
81 * Creates a new HistoryManager. | 79 * Creates a new HistoryManager. |
82 * @param activity The Activity associated with the HistoryManager. | 80 * @param activity The Activity associated with the HistoryManager. |
81 * @param isFullscreenActivity Whether the history UI will be shown in a ful lscreen activity. | |
gone
2017/03/15 17:21:15
Ambiguous... Chrome Home is still inside a full sc
Theresa
2017/03/16 18:15:16
Done. Changed this to "separate activity".
| |
83 */ | 82 */ |
84 @SuppressWarnings("unchecked") // mSelectableListLayout | 83 @SuppressWarnings("unchecked") // mSelectableListLayout |
85 public HistoryManager(Activity activity, @Nullable NativePage nativePage) { | 84 public HistoryManager(Activity activity, boolean isFullscreenActivity) { |
86 mActivity = activity; | 85 mActivity = activity; |
87 mIsDisplayedInNativePage = nativePage != null; | 86 mIsFullscreenActivity = isFullscreenActivity; |
88 | 87 |
89 mSelectionDelegate = new SelectionDelegate<>(); | 88 mSelectionDelegate = new SelectionDelegate<>(); |
90 mSelectionDelegate.addObserver(this); | 89 mSelectionDelegate.addObserver(this); |
91 mHistoryAdapter = new HistoryAdapter(mSelectionDelegate, this, | 90 mHistoryAdapter = new HistoryAdapter(mSelectionDelegate, this, |
92 sProviderForTests != null ? sProviderForTests : new BrowsingHist oryBridge()); | 91 sProviderForTests != null ? sProviderForTests : new BrowsingHist oryBridge()); |
93 | 92 |
94 // 1. Create SelectableListLayout. | 93 // 1. Create SelectableListLayout. |
95 mSelectableListLayout = | 94 mSelectableListLayout = |
96 (SelectableListLayout<HistoryItem>) LayoutInflater.from(activity ).inflate( | 95 (SelectableListLayout<HistoryItem>) LayoutInflater.from(activity ).inflate( |
97 R.layout.history_main, null); | 96 R.layout.history_main, null); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 } | 157 } |
159 }}); | 158 }}); |
160 | 159 |
161 // 9. Listen to changes in sign in state. | 160 // 9. Listen to changes in sign in state. |
162 SigninManager.get(mActivity).addSignInStateObserver(this); | 161 SigninManager.get(mActivity).addSignInStateObserver(this); |
163 | 162 |
164 recordUserAction("Show"); | 163 recordUserAction("Show"); |
165 } | 164 } |
166 | 165 |
167 /** | 166 /** |
168 * @return Whether the history manager UI is displayed in a native page. | 167 * @return Whether the history manager UI is displayed in a fullscreen activ ity. |
169 */ | 168 */ |
170 public boolean isDisplayedInNativePage() { | 169 public boolean isDisplayedInFullScreenActivity() { |
171 return mIsDisplayedInNativePage; | 170 return mIsFullscreenActivity; |
172 } | 171 } |
173 | 172 |
174 @Override | 173 @Override |
175 public boolean onMenuItemClick(MenuItem item) { | 174 public boolean onMenuItemClick(MenuItem item) { |
176 mToolbar.hideOverflowMenu(); | 175 mToolbar.hideOverflowMenu(); |
177 | 176 |
178 if (item.getItemId() == R.id.close_menu_id && !isDisplayedInNativePage() ) { | 177 if (item.getItemId() == R.id.close_menu_id && isDisplayedInFullScreenAct ivity()) { |
179 mActivity.finish(); | 178 mActivity.finish(); |
180 return true; | 179 return true; |
181 } else if (item.getItemId() == R.id.selection_mode_open_in_new_tab) { | 180 } else if (item.getItemId() == R.id.selection_mode_open_in_new_tab) { |
182 openItemsInNewTabs(mSelectionDelegate.getSelectedItems(), false); | 181 openItemsInNewTabs(mSelectionDelegate.getSelectedItems(), false); |
183 mSelectionDelegate.clearSelection(); | 182 mSelectionDelegate.clearSelection(); |
184 return true; | 183 return true; |
185 } else if (item.getItemId() == R.id.selection_mode_copy_link) { | 184 } else if (item.getItemId() == R.id.selection_mode_copy_link) { |
186 recordUserActionWithOptionalSearch("CopyLink"); | 185 recordUserActionWithOptionalSearch("CopyLink"); |
187 Clipboard clipboard = new Clipboard(mActivity); | 186 Clipboard clipboard = new Clipboard(mActivity); |
188 clipboard.setText(mSelectionDelegate.getSelectedItems().get(0).getUr l()); | 187 clipboard.setText(mSelectionDelegate.getSelectedItems().get(0).getUr l()); |
(...skipping 28 matching lines...) Expand all Loading... | |
217 } | 216 } |
218 | 217 |
219 /** | 218 /** |
220 * @return The view that shows the main browsing history UI. | 219 * @return The view that shows the main browsing history UI. |
221 */ | 220 */ |
222 public ViewGroup getView() { | 221 public ViewGroup getView() { |
223 return mSelectableListLayout; | 222 return mSelectableListLayout; |
224 } | 223 } |
225 | 224 |
226 /** | 225 /** |
227 * See {@link SelectableListLayout#detachContentView()}. | 226 * See {@link SelectableListLayout#detachToolbarView()}. |
228 */ | 227 */ |
229 public View detachContentView() { | 228 public Toolbar detachToolbarView() { |
230 return mSelectableListLayout.detachContentView(); | 229 return mSelectableListLayout.detachToolbarView(); |
231 } | 230 } |
232 | 231 |
233 /** | 232 /** |
234 * @return The vertical scroll offset of the content view. | 233 * @return The vertical scroll offset of the content view. |
235 */ | 234 */ |
236 public int getVerticalScrollOffset() { | 235 public int getVerticalScrollOffset() { |
237 return mRecyclerView.computeVerticalScrollOffset(); | 236 return mRecyclerView.computeVerticalScrollOffset(); |
238 } | 237 } |
239 | 238 |
240 /** | 239 /** |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 @Override | 430 @Override |
432 public void onAction(Object actionData) { | 431 public void onAction(Object actionData) { |
433 // Handler for the link copied snackbar. Do nothing. | 432 // Handler for the link copied snackbar. Do nothing. |
434 } | 433 } |
435 | 434 |
436 @Override | 435 @Override |
437 public void onDismissNoAction(Object actionData) { | 436 public void onDismissNoAction(Object actionData) { |
438 // Handler for the link copied snackbar. Do nothing. | 437 // Handler for the link copied snackbar. Do nothing. |
439 } | 438 } |
440 } | 439 } |
OLD | NEW |