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

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

Issue 2754313002: [Home] Record some user actions for the Chrome Home BottomSheet (Closed)
Patch Set: [Home] Record some user actions for the Chrome Home BottomSheet Created 3 years, 9 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/BottomSheet.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java
index 6549ec5fe1feca81f3b860b7d38edc3b3ba23241..a115135d59af7bc65267642ef4961de909061721 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java
@@ -33,6 +33,7 @@ import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.util.MathUtils;
import org.chromium.chrome.browser.widget.FadingBackgroundView;
+import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetContentController.ContentType;
import org.chromium.content_public.browser.LoadUrlParams;
import java.lang.annotation.Retention;
@@ -151,6 +152,9 @@ public class BottomSheet
/** The last non-default toolbar view that was attached to mToolbarHolder. */
private View mLastToolbarView;
+ /** Whether the sheet is currently open. */
+ private boolean mIsSheetOpen;
+
/**
* An interface defining content that can be displayed inside of the bottom sheet for Chrome
* Home.
@@ -182,6 +186,12 @@ public class BottomSheet
* Called to destroy the BottomSheetContent when it is no longer in use.
*/
void destroy();
+
+ /**
+ * @return The {@link BottomSheetContentController.ContentType} for this content.
+ */
+ @ContentType
+ int getType();
}
/**
@@ -271,6 +281,8 @@ public class BottomSheet
mGestureDetector = new GestureDetector(context, new BottomSheetSwipeDetector());
mGestureDetector.setIsLongpressEnabled(false);
+
+ addObserver(new BottomSheetMetrics());
}
@Override
@@ -505,6 +517,10 @@ public class BottomSheet
} else {
mDefaultToolbarView.setVisibility(View.VISIBLE);
}
+
+ for (BottomSheetObserver o : mObservers) {
+ o.onSheetContentChanged(mSheetContent);
+ }
}
/**
@@ -525,6 +541,9 @@ public class BottomSheet
* A notification that the sheet is exiting the peek state into one that shows content.
*/
private void onSheetOpened() {
+ if (mIsSheetOpen) return;
+
+ mIsSheetOpen = true;
for (BottomSheetObserver o : mObservers) o.onSheetOpened();
}
@@ -532,6 +551,9 @@ public class BottomSheet
* A notification that the sheet has returned to the peeking state.
*/
private void onSheetClosed() {
+ if (!mIsSheetOpen) return;
+
+ mIsSheetOpen = false;
for (BottomSheetObserver o : mObservers) o.onSheetClosed();
}
@@ -728,6 +750,7 @@ public class BottomSheet
* move there instantly.
*/
public void setSheetState(@SheetState int state, boolean animate) {
+ boolean stateChanged = state != mCurrentState;
mCurrentState = state;
if (animate) {
@@ -735,6 +758,12 @@ public class BottomSheet
} else {
setSheetOffsetFromBottom(getSheetHeightForState(state));
}
+
+ if (!stateChanged) return;
+
+ for (BottomSheetObserver o : mObservers) {
+ o.onSheetStateChanged(mCurrentState);
+ }
}
/**

Powered by Google App Engine
This is Rietveld 408576698