Commit f01f117f authored by Gang Wu's avatar Gang Wu Committed by Commit Bot

Add Callback/Runnable for feature highlight


Change-Id: I4b585e3498b97709277928dc1b91ede72e7fa61e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1906339Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Gang Wu <gangwu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714637}
parent 8b100f9d
...@@ -104,8 +104,11 @@ public class BrowsingModeBottomToolbarCoordinator { ...@@ -104,8 +104,11 @@ public class BrowsingModeBottomToolbarCoordinator {
public void onActivityTabChanged(Tab tab) { public void onActivityTabChanged(Tab tab) {
if (tab == null) return; if (tab == null) return;
final Tracker tracker = TrackerFactory.getTrackerForProfile(tab.getProfile()); final Tracker tracker = TrackerFactory.getTrackerForProfile(tab.getProfile());
tracker.addOnInitializedCallback((ready) -> mMediator.showIPH(tab.getActivity(), tracker.addOnInitializedCallback(
mSearchAccelerator, tracker)); (ready) -> mMediator.showIPH(tab.getActivity(), mSearchAccelerator, tracker,
() -> {
searchAcceleratorListener.onClick(mSearchAccelerator);
}));
tabProvider.removeObserver(this); tabProvider.removeObserver(this);
} }
}); });
......
...@@ -79,7 +79,8 @@ class BrowsingModeBottomToolbarMediator implements ThemeColorObserver { ...@@ -79,7 +79,8 @@ class BrowsingModeBottomToolbarMediator implements ThemeColorObserver {
* @param anchor The view to anchor the IPH to. * @param anchor The view to anchor the IPH to.
* @param tracker A tracker for IPH. * @param tracker A tracker for IPH.
*/ */
void showIPH(ChromeActivity activity, View anchor, Tracker tracker) { void showIPH(ChromeActivity activity, View anchor, Tracker tracker,
Runnable completeRunnable) {
if (!tracker.shouldTriggerHelpUI(FeatureConstants.CHROME_DUET_FEATURE)) return; if (!tracker.shouldTriggerHelpUI(FeatureConstants.CHROME_DUET_FEATURE)) return;
int baseColor = int baseColor =
ApiCompatibilityUtils.getColor(anchor.getResources(), R.color.modern_blue_600); ApiCompatibilityUtils.getColor(anchor.getResources(), R.color.modern_blue_600);
...@@ -92,7 +93,7 @@ class BrowsingModeBottomToolbarMediator implements ThemeColorObserver { ...@@ -92,7 +93,7 @@ class BrowsingModeBottomToolbarMediator implements ThemeColorObserver {
R.string.iph_duet_title, FeatureHighlightProvider.TextAlignment.CENTER, R.string.iph_duet_title, FeatureHighlightProvider.TextAlignment.CENTER,
R.style.TextAppearance_WhiteTitle1, R.string.iph_duet_description, R.style.TextAppearance_WhiteTitle1, R.string.iph_duet_description,
FeatureHighlightProvider.TextAlignment.CENTER, R.style.TextAppearance_WhiteBody, FeatureHighlightProvider.TextAlignment.CENTER, R.style.TextAppearance_WhiteBody,
finalColor, DUET_IPH_BUBBLE_SHOW_DURATION_MS); finalColor, DUET_IPH_BUBBLE_SHOW_DURATION_MS, completeRunnable);
anchor.postDelayed(() -> tracker.dismissed(FeatureConstants.CHROME_DUET_FEATURE), anchor.postDelayed(() -> tracker.dismissed(FeatureConstants.CHROME_DUET_FEATURE),
DUET_IPH_BUBBLE_SHOW_DURATION_MS); DUET_IPH_BUBBLE_SHOW_DURATION_MS);
......
...@@ -57,4 +57,21 @@ public class FeatureHighlightProvider { ...@@ -57,4 +57,21 @@ public class FeatureHighlightProvider {
@TextAlignment int headAlignment, @StyleRes int headStyle, @StringRes int bodyTextId, @TextAlignment int headAlignment, @StyleRes int headStyle, @StringRes int bodyTextId,
@TextAlignment int bodyAlignment, @StyleRes int bodyStyle, @ColorInt int color, @TextAlignment int bodyAlignment, @StyleRes int bodyStyle, @ColorInt int color,
long timeoutMs) {} long timeoutMs) {}
/**
* Build and show a feature highlight bubble for a particular view.
* @param activity An activity to attach the highlight to.
* @param view The view to focus.
* @param headTextId The text shown in the header section of the bubble.
* @param headAlignment Alignment of the head text.
* @param bodyTextId The text shown in the body section of the bubble.
* @param bodyAlignment Alignment of the body text.
* @param color The color of the bubble.
* @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.
*/
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 color,
long timeoutMs, Runnable completeRunnable) {}
} }
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