Commit 2e7bc22b authored by Henry Jian's avatar Henry Jian Committed by Commit Bot

[Android] Remove use of callback for feature highlight

This CL removes the use of callback for feature highlight.

Because the callback is no longer needed, we're removing
its use now.

Bug: 1057234
Change-Id: I5ce9ba270851397da926f8c33a4e8c3cbc5d8fbd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2122619Reviewed-by: default avatarGang Wu <gangwu@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Henry Jian <hzjian@google.com>
Cr-Commit-Position: refs/heads/master@{#756394}
parent 7aee0288
......@@ -96,7 +96,7 @@ public class BrowsingModeBottomToolbarCoordinator {
mHomeButton = mToolbarRoot.findViewById(R.id.bottom_home_button);
mHomeButton.setOnClickListener(homeButtonListener);
mHomeButton.setActivityTabProvider(mTabProvider);
setupIPH(FeatureConstants.CHROME_DUET_HOME_BUTTON_FEATURE, mHomeButton, homeButtonListener);
setupIPH(FeatureConstants.CHROME_DUET_HOME_BUTTON_FEATURE, mHomeButton);
mNewTabButton = mToolbarRoot.findViewById(R.id.bottom_new_tab_button);
......@@ -104,8 +104,7 @@ public class BrowsingModeBottomToolbarCoordinator {
mSearchAccelerator = mToolbarRoot.findViewById(R.id.search_accelerator);
mSearchAccelerator.setOnClickListener(searchAcceleratorListener);
setupIPH(FeatureConstants.CHROME_DUET_SEARCH_FEATURE, mSearchAccelerator,
searchAcceleratorListener);
setupIPH(FeatureConstants.CHROME_DUET_SEARCH_FEATURE, mSearchAccelerator);
// TODO(amaralp): Make this adhere to MVC framework.
mTabSwitcherButtonView = mToolbarRoot.findViewById(R.id.bottom_tab_switcher_button);
......@@ -137,25 +136,16 @@ public class BrowsingModeBottomToolbarCoordinator {
* Setup and show the IPH bubble for Chrome Duet if needed.
* @param feature A String identifying the feature.
* @param anchor The view to anchor the IPH to.
* @param listener An {@link OnClickListener} that is triggered when IPH is clicked. {@link
* HomeButton} and {@link SearchAccelerator} need to pass this parameter, {@link
* TabSwitcherButtonView} just passes null.
*/
void setupIPH(@FeatureConstants String feature, View anchor, OnClickListener listener) {
void setupIPH(@FeatureConstants String feature, View anchor) {
mTabProvider.addObserverAndTrigger(new HintlessActivityTabObserver() {
@Override
public void onActivityTabChanged(Tab tab) {
if (tab == null) return;
Profile profile = Profile.fromWebContents(tab.getWebContents());
final Tracker tracker = TrackerFactory.getTrackerForProfile(profile);
final Runnable completeRunnable = () -> {
if (listener != null) {
listener.onClick(anchor);
}
};
tracker.addOnInitializedCallback((ready) -> {
mMediator.showIPH(feature, ((TabImpl) tab).getActivity(), anchor, tracker,
completeRunnable);
mMediator.showIPH(feature, ((TabImpl) tab).getActivity(), anchor, tracker);
});
mTabProvider.removeObserver(this);
}
......@@ -214,11 +204,7 @@ public class BrowsingModeBottomToolbarCoordinator {
mTabSwitcherButtonCoordinator.setTabSwitcherListener(tabSwitcherListener);
mTabSwitcherButtonCoordinator.setThemeColorProvider(themeColorProvider);
mTabSwitcherButtonCoordinator.setTabCountProvider(tabCountProvider);
// Send null to IPH here to avoid tabSwitcherListener to be called twince, since
// mTabSwitcherButtonView has it own OnClickListener, but other buttons set
// OnClickListener to their wrappers.
setupIPH(FeatureConstants.CHROME_DUET_TAB_SWITCHER_FEATURE, mTabSwitcherButtonView,
null);
setupIPH(FeatureConstants.CHROME_DUET_TAB_SWITCHER_FEATURE, mTabSwitcherButtonView);
}
// If StartSurface is HomePage, BrowsingModeBottomToolbar is shown in browsing mode and in
......
......@@ -70,10 +70,9 @@ class BrowsingModeBottomToolbarMediator implements ThemeColorObserver {
* @param activity An activity to attach the IPH to.
* @param anchor The view to anchor the IPH to.
* @param tracker A tracker for IPH.
* @param completeRunnable The Runnable to be called if the user tab on the view.
*/
void showIPH(@FeatureConstants String feature, ChromeActivity activity, View anchor,
Tracker tracker, Runnable completeRunnable) {
Tracker tracker) {
if (!tracker.shouldTriggerHelpUI(feature) || !anchor.isShown() || !anchor.isEnabled()) {
return;
}
......@@ -126,8 +125,8 @@ class BrowsingModeBottomToolbarMediator implements ThemeColorObserver {
R.style.TextAppearance_TextLarge_Primary_Light, descId,
FeatureHighlightProvider.TextAlignment.CENTER,
R.style.TextAppearance_TextMedium_Primary_Light, innerBackgroundColor,
finalOuterColor, finalScrimColor, FeatureHighlightProvider.NO_TIMEOUT, tapToDismiss,
completeRunnable);
finalOuterColor, finalScrimColor, FeatureHighlightProvider.NO_TIMEOUT,
tapToDismiss);
}
/**
......
......@@ -48,13 +48,13 @@ public class FeatureHighlightProvider {
* @param outerColor The outer color of the bubble.
* @param scrimColor The color of the out side of feature highlight.
* @param timeoutMs The amount of time in ms before the bubble disappears.
* @param completeRunnable The Runnable to be called if the user tab on the view.
* @param tapToDismiss The feature highlight bubble can be dismissiable.
*/
public void buildForView(AppCompatActivity activity, View view, @StringRes int headTextId,
@TextAlignment int headAlignment, @StyleRes int headStyle, @StringRes int bodyTextId,
@TextAlignment int bodyAlignment, @StyleRes int bodyStyle, @ColorInt int pulseColor,
@ColorInt int outerColor, @ColorInt int scrimColor, long timeoutMs,
Runnable completeRunnable) {}
Boolean tapToDismiss) {}
/**
* Build and show a feature highlight bubble for a particular view.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment