Commit c2f986a9 authored by Friedrich Horschig's avatar Friedrich Horschig Committed by Commit Bot

[Mfill Android] Allow entire screen width for IPH bubble alignment

This CL allows the bubble to extend over the whole length of the screen.
The bubble will still be minimal and point to the highlighted item (see
screenshot in the linked bug).

The cause of the previous misalignment was, that we used chip as a
rootview. This results in a very, very restricted area to put the IPH
bubble into (basically the chip's rect instead of the whole activity).

This also fixes the issue of IPH bubbles having multiple line breaks for
small chips.

Bug: 1000041
Change-Id: I21537011a190406b57ddd7a5fe513bfa30d7c56f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1784718
Commit-Queue: Friedrich [CET] <fhorschig@chromium.org>
Reviewed-by: default avatarIoana Pandele <ioanap@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693640}
parent 53fba669
...@@ -51,14 +51,15 @@ class KeyboardAccessoryIPHUtils { ...@@ -51,14 +51,15 @@ class KeyboardAccessoryIPHUtils {
* session or other config restrictions apply. * session or other config restrictions apply.
* @param feature A String identifying the IPH feature and its appropriate help text. * @param feature A String identifying the IPH feature and its appropriate help text.
* @param view The {@link View} providing context and the Rect to which the bubble will point. * @param view The {@link View} providing context and the Rect to which the bubble will point.
* @param rootView The {@link View} used to determine the maximal dimensions for the bubble.
*/ */
static void showHelpBubble(String feature, ChipView view) { static void showHelpBubble(String feature, ChipView view, View rootView) {
final Tracker tracker = TrackerFactory.getTrackerForProfile(Profile.getLastUsedProfile()); final Tracker tracker = TrackerFactory.getTrackerForProfile(Profile.getLastUsedProfile());
if (!tracker.isInitialized()) return; if (!tracker.isInitialized()) return;
if (!tracker.shouldTriggerHelpUI(feature)) return; // This call records the IPH intent. if (!tracker.shouldTriggerHelpUI(feature)) return; // This call records the IPH intent.
@StringRes @StringRes
int helpText = getHelpTextForFeature(feature); int helpText = getHelpTextForFeature(feature);
ImageTextBubble helpBubble = new ImageTextBubble(view.getContext(), view, helpText, ImageTextBubble helpBubble = new ImageTextBubble(view.getContext(), rootView, helpText,
helpText, true, new ViewRectProvider(view), R.drawable.ic_chrome); helpText, true, new ViewRectProvider(view), R.drawable.ic_chrome);
helpBubble.setDismissOnTouchInteraction(true); helpBubble.setDismissOnTouchInteraction(true);
helpBubble.show(); helpBubble.show();
......
...@@ -43,13 +43,18 @@ class KeyboardAccessoryModernViewBinder { ...@@ -43,13 +43,18 @@ class KeyboardAccessoryModernViewBinder {
} }
static class BarItemChipViewHolder extends BarItemViewHolder<AutofillBarItem, ChipView> { static class BarItemChipViewHolder extends BarItemViewHolder<AutofillBarItem, ChipView> {
private final View mRootViewForIPH;
BarItemChipViewHolder(ViewGroup parent) { BarItemChipViewHolder(ViewGroup parent) {
super(parent, R.layout.keyboard_accessory_suggestion); super(parent, R.layout.keyboard_accessory_suggestion);
mRootViewForIPH = parent.getRootView();
} }
@Override @Override
protected void bind(AutofillBarItem item, ChipView chipView) { protected void bind(AutofillBarItem item, ChipView chipView) {
if (item.getFeatureForIPH() != null) showHelpBubble(item.getFeatureForIPH(), chipView); if (item.getFeatureForIPH() != null) {
showHelpBubble(item.getFeatureForIPH(), chipView, mRootViewForIPH);
}
chipView.getPrimaryTextView().setText(item.getSuggestion().getLabel()); chipView.getPrimaryTextView().setText(item.getSuggestion().getLabel());
chipView.getSecondaryTextView().setText(item.getSuggestion().getSublabel()); chipView.getSecondaryTextView().setText(item.getSuggestion().getSublabel());
chipView.getSecondaryTextView().setVisibility( chipView.getSecondaryTextView().setVisibility(
......
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