Commit bd2bd105 authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

Move Duet IPH to the bottom toolbar

This patch moves the IPH bubble for duet from pointing at the top
toolbar to pointing at the bottom. As a result, the special case
for the NTP has been removed.

Change-Id: Icbe86c1c19dde17de069d1514f9833243be5e32d
Reviewed-on: https://chromium-review.googlesource.com/1249816
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595893}
parent 900770bf
......@@ -13,12 +13,16 @@ import android.view.ViewStub;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ActivityTabProvider;
import org.chromium.chrome.browser.ActivityTabProvider.HintlessActivityTabObserver;
import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper;
import org.chromium.chrome.browser.compositor.layouts.LayoutManager;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior;
import org.chromium.chrome.browser.compositor.layouts.ToolbarSwipeLayout;
import org.chromium.chrome.browser.feature_engagement.TrackerFactory;
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
import org.chromium.chrome.browser.modelutil.PropertyModelChangeProcessor;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.toolbar.BottomToolbarViewBinder.ViewHolder;
import org.chromium.chrome.browser.toolbar.ToolbarButtonSlotData.ToolbarButtonData;
......@@ -62,7 +66,8 @@ public class BottomToolbarCoordinator {
* @param secondSlotData The data required to fill in the second bottom toolbar button slot.
*/
public BottomToolbarCoordinator(ChromeFullscreenManager fullscreenManager, ViewGroup root,
ToolbarButtonSlotData firstSlotData, ToolbarButtonSlotData secondSlotData) {
ToolbarButtonSlotData firstSlotData, ToolbarButtonSlotData secondSlotData,
final ActivityTabProvider tabProvider) {
BottomToolbarModel model = new BottomToolbarModel();
int shadowHeight =
......@@ -92,6 +97,16 @@ public class BottomToolbarCoordinator {
mMediator = new BottomToolbarMediator(model, fullscreenManager, root.getResources(),
firstSlotData, secondSlotData, mNormalPrimaryColor);
final View iphAnchor = toolbarRoot.findViewById(R.id.bottom_toolbar_container);
tabProvider.addObserverAndTrigger(new HintlessActivityTabObserver() {
@Override
public void onActivityTabChanged(Tab tab) {
if (tab == null) return;
mMediator.showIPH(iphAnchor, TrackerFactory.getTrackerForProfile(tab.getProfile()));
tabProvider.removeObserver(this);
}
});
}
/**
......
......@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.toolbar;
import android.content.res.Resources;
import android.view.View;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanelManager.OverlayPanelManagerObserver;
......@@ -18,9 +19,13 @@ import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandl
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager.FullscreenListener;
import org.chromium.chrome.browser.toolbar.ToolbarButtonSlotData.ToolbarButtonData;
import org.chromium.chrome.browser.widget.textbubble.TextBubble;
import org.chromium.components.feature_engagement.FeatureConstants;
import org.chromium.components.feature_engagement.Tracker;
import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.base.WindowAndroid.KeyboardVisibilityListener;
import org.chromium.ui.resources.ResourceManager;
import org.chromium.ui.widget.ViewRectProvider;
/**
* This class is responsible for reacting to events from the outside world, interacting with other
......@@ -30,6 +35,9 @@ import org.chromium.ui.resources.ResourceManager;
class BottomToolbarMediator implements FullscreenListener, KeyboardVisibilityListener,
OverlayPanelManagerObserver, OverviewModeObserver,
SceneChangeObserver {
/** The amount of time to show the Duet help bubble for. */
private static final int DUET_IPH_BUBBLE_SHOW_DURATION_MS = 6000;
/** The model for the bottom toolbar that holds all of its state. */
private BottomToolbarModel mModel;
......@@ -240,4 +248,21 @@ class BottomToolbarMediator implements FullscreenListener, KeyboardVisibilityLis
void setPrimaryColor(int color) {
mModel.set(BottomToolbarModel.PRIMARY_COLOR, color);
}
/**
* Maybe show the IPH bubble for Chrome Duet.
* @param anchor The view to anchor the IPH to.
* @param tracker A tracker for IPH.
*/
void showIPH(View anchor, Tracker tracker) {
if (tracker.shouldTriggerHelpUI(FeatureConstants.CHROME_DUET_FEATURE)) {
TextBubble bubble =
new TextBubble(anchor.getContext(), anchor, R.string.iph_duet_icons_moved,
R.string.iph_duet_icons_moved, true, new ViewRectProvider(anchor));
bubble.setAutoDismissTimeout(DUET_IPH_BUBBLE_SHOW_DURATION_MS);
bubble.addOnDismissListener(
() -> tracker.dismissed(FeatureConstants.CHROME_DUET_FEATURE));
bubble.show();
}
}
}
......@@ -5,7 +5,6 @@
package org.chromium.chrome.browser.toolbar;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
......@@ -148,9 +147,6 @@ public class ToolbarManager implements ToolbarTabController, UrlFocusChangeListe
private static final ActionEvent ACCELERATOR_BUTTON_TAP_ACTION =
new ActionEvent("MobileToolbarOmniboxAcceleratorTap");
/** The amount of time to show the Duet help bubble for. */
private static final int DUET_IPH_BUBBLE_SHOW_DURATION_MS = 6000;
/**
* The number of ms to wait before reporting to UMA omnibox interaction metrics.
*/
......@@ -692,7 +688,7 @@ public class ToolbarManager implements ToolbarTabController, UrlFocusChangeListe
new ToolbarButtonSlotData(createSearchAccelerator());
mBottomToolbarCoordinator = new BottomToolbarCoordinator(
mActivity.getFullscreenManager(), mActivity.findViewById(R.id.coordinator),
firstButtonSlot, secondButtonSlot);
firstButtonSlot, secondButtonSlot, mActivity.getActivityTabProvider());
if (mAppMenuButtonHelper != null) mAppMenuButtonHelper.setMenuShowsFromBottom(true);
}
}
......@@ -923,9 +919,6 @@ public class ToolbarManager implements ToolbarTabController, UrlFocusChangeListe
wrapBottomToolbarClickListenerForIPH(newTabClickHandler)),
tabModelSelector.getCurrentModel().isIncognito());
Tab currentTab = tabModelSelector.getCurrentTab();
maybeShowDuetHelpBubble(currentTab);
// Allow the bottom toolbar to be focused in accessibility after the top toolbar.
ApiCompatibilityUtils.setAccessibilityTraversalBefore(
mLocationBar.getContainerView(), R.id.bottom_toolbar);
......@@ -936,34 +929,6 @@ public class ToolbarManager implements ToolbarTabController, UrlFocusChangeListe
});
}
/**
* Maybe show the IPH bubble for Chrome Duet.
* @param tab The active tab.
*/
private void maybeShowDuetHelpBubble(Tab tab) {
if (tab == null) return;
assert mToolbar != null;
final Tracker tracker = TrackerFactory.getTrackerForProfile(tab.getProfile());
if (tracker.shouldTriggerHelpUI(FeatureConstants.CHROME_DUET_FEATURE)) {
TextBubble bubble;
// If on the NTP, there is no toolbar. Place the bubble in the space where the toolbar
// would be.
if (NewTabPage.isNTPUrl(tab.getUrl())) {
bubble = new TextBubble(mToolbar.getContext(), mToolbar,
R.string.iph_duet_icons_moved, R.string.iph_duet_icons_moved, false,
new Rect(0, 0, mToolbar.getWidth(), 0));
} else {
bubble = new TextBubble(mToolbar.getContext(), mToolbar,
R.string.iph_duet_icons_moved, R.string.iph_duet_icons_moved, true,
new ViewRectProvider(mToolbar));
}
bubble.setAutoDismissTimeout(DUET_IPH_BUBBLE_SHOW_DURATION_MS);
bubble.addOnDismissListener(
() -> tracker.dismissed(FeatureConstants.CHROME_DUET_FEATURE));
bubble.show();
}
}
/**
* Show the update badge in both the top and bottom toolbar.
* TODO(amaralp): Only the top or bottom menu should be visible.
......
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