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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetContentController.java

Issue 2861453002: [Home] Update util methods to open bookmarks/downloads/history (Closed)
Patch Set: [Home] Update util methods to open bookmarks/downloads/history Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetContentController.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetContentController.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetContentController.java
index f77b0144e7e16582f6d2af16aab567e742013dd8..ef8f6fa0c9b3ec97e1d74b327be34ecfcc1cb852 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetContentController.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetContentController.java
@@ -106,6 +106,16 @@ public class BottomSheetContentController extends BottomNavigationView
// TODO(twellington): determine a policy for destroying the
// SuggestionsBottomSheetContent.
}
+
+ @Override
+ public void onSheetContentChanged(BottomSheetContent newContent) {
+ if (!mShouldOpenSheetOnNextContentChange) return;
+
+ mShouldOpenSheetOnNextContentChange = false;
+ if (!mBottomSheet.isSheetOpen()) {
+ mBottomSheet.setSheetState(BottomSheet.SHEET_STATE_FULL, true);
+ }
+ }
};
private BottomSheet mBottomSheet;
@@ -115,6 +125,7 @@ public class BottomSheetContentController extends BottomNavigationView
private int mSelectedItemId;
private boolean mDefaultContentInitialized;
private ChromeActivity mActivity;
+ private boolean mShouldOpenSheetOnNextContentChange;
public BottomSheetContentController(Context context, AttributeSet atts) {
super(context, atts);
@@ -177,6 +188,19 @@ public class BottomSheetContentController extends BottomNavigationView
mDefaultContentInitialized = true;
}
+ /**
+ * Shows the specified {@link BottomSheetContent} and opens the {@link BottomSheet}.
+ * @param itemId The menu item id of the {@link BottomSheetContent} to show.
+ */
+ public void showContentAndOpenSheet(int itemId) {
+ if (itemId != mSelectedItemId) {
+ mShouldOpenSheetOnNextContentChange = true;
+ selectItem(itemId);
+ } else if (!mBottomSheet.isSheetOpen()) {
+ mBottomSheet.setSheetState(BottomSheet.SHEET_STATE_FULL, true);
+ }
+ }
+
@Override
public boolean onNavigationItemSelected(MenuItem item) {
if (mSelectedItemId == item.getItemId()) return false;
@@ -258,10 +282,18 @@ public class BottomSheetContentController extends BottomNavigationView
* @param itemId The id of the MenuItem to select.
*/
@VisibleForTesting
- public void selectItemForTests(int itemId) {
+ public void selectItem(int itemId) {
// TODO(twellington): A #setSelectedItemId() method was added to the support library
// recently. Replace this custom implementation with that method after
// the support library is rolled.
onNavigationItemSelected(getMenu().findItem(itemId));
}
+
+ @VisibleForTesting
+ public int getSelectedItemIdForTests() {
+ // TODO(twellington): A #getSelectedItemId() method was added to the support library
+ // recently. Replace this custom implementation with that method after
+ // the support library is rolled.
+ return mSelectedItemId;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698