Commit 8de0daef authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

Hide history page info icon toast when in VR.

It should be impossible for this toast to show up while in VR as we
intentionally never send long presses for exactly this reason.
However, the toast is still showing up whenever the icon is clicked or
scrolled over, but only on Android N. I've gone through the support
library code, and overridden the long-press handler that shows the toast
and the toast still shows up. I have no idea what's creating the toast
or how to even find that out.

The simplest solution seems to be just clearing the title when we're in
VR, as the toast will never show up then.

Bug: 829151
Change-Id: I9353ffa41ee44e488cc79d44ad6869961e11561f
Reviewed-on: https://chromium-review.googlesource.com/998658Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548782}
parent 201c8e48
...@@ -122,6 +122,8 @@ public class SelectableListToolbar<E> ...@@ -122,6 +122,8 @@ public class SelectableListToolbar<E>
private int mModernToolbarSearchIconOffsetPx; private int mModernToolbarSearchIconOffsetPx;
private boolean mIsDestroyed; private boolean mIsDestroyed;
private boolean mShowInfoItem;
private boolean mInfoShowing;
/** /**
* Constructor for inflating from XML. * Constructor for inflating from XML.
...@@ -200,6 +202,9 @@ public class SelectableListToolbar<E> ...@@ -200,6 +202,9 @@ public class SelectableListToolbar<E>
if (!FeatureUtilities.isChromeModernDesignEnabled()) { if (!FeatureUtilities.isChromeModernDesignEnabled()) {
setTitleTextAppearance(getContext(), R.style.BlackHeadline2); setTitleTextAppearance(getContext(), R.style.BlackHeadline2);
} }
VrShellDelegate.registerVrModeObserver(this);
if (VrShellDelegate.isInVr()) onEnterVr();
} }
@Override @Override
...@@ -208,12 +213,14 @@ public class SelectableListToolbar<E> ...@@ -208,12 +213,14 @@ public class SelectableListToolbar<E>
// searching. // searching.
mIsVrEnabled = true; mIsVrEnabled = true;
if (mHasSearchView) updateSearchMenuItem(); if (mHasSearchView) updateSearchMenuItem();
updateInfoMenuItem(mShowInfoItem, mInfoShowing);
} }
@Override @Override
public void onExitVr() { public void onExitVr() {
mIsVrEnabled = false; mIsVrEnabled = false;
if (mHasSearchView) updateSearchMenuItem(); if (mHasSearchView) updateSearchMenuItem();
updateInfoMenuItem(mShowInfoItem, mInfoShowing);
} }
/** /**
...@@ -268,9 +275,6 @@ public class SelectableListToolbar<E> ...@@ -268,9 +275,6 @@ public class SelectableListToolbar<E>
getResources().getDimensionPixelSize(R.dimen.clear_text_button_end_padding), getResources().getDimensionPixelSize(R.dimen.clear_text_button_end_padding),
mClearTextButton.getPaddingBottom()); mClearTextButton.getPaddingBottom());
} }
VrShellDelegate.registerVrModeObserver(this);
if (VrShellDelegate.isInVr()) onEnterVr();
} }
@Override @Override
...@@ -637,6 +641,8 @@ public class SelectableListToolbar<E> ...@@ -637,6 +641,8 @@ public class SelectableListToolbar<E>
* @param infoShowing Whether or not info header is currently showing. * @param infoShowing Whether or not info header is currently showing.
*/ */
public void updateInfoMenuItem(boolean showItem, boolean infoShowing) { public void updateInfoMenuItem(boolean showItem, boolean infoShowing) {
mShowInfoItem = showItem;
mInfoShowing = infoShowing;
MenuItem infoMenuItem = getMenu().findItem(mInfoMenuItemId); MenuItem infoMenuItem = getMenu().findItem(mInfoMenuItemId);
if (infoMenuItem != null) { if (infoMenuItem != null) {
Drawable iconDrawable = Drawable iconDrawable =
...@@ -644,7 +650,16 @@ public class SelectableListToolbar<E> ...@@ -644,7 +650,16 @@ public class SelectableListToolbar<E>
infoShowing ? R.color.light_active_color : R.color.light_normal_color); infoShowing ? R.color.light_active_color : R.color.light_normal_color);
infoMenuItem.setIcon(iconDrawable); infoMenuItem.setIcon(iconDrawable);
infoMenuItem.setTitle(infoShowing ? R.string.hide_info : R.string.show_info); if (VrShellDelegate.isInVr()) {
// There seems to be a bug with the support library, only on Android N, where the
// toast showing the title shows up every time the info menu item is clicked or
// scrolled on, even if its long press handler is overridden. VR on N doesn't
// support toasts, which render monocularly over top of VR content, so we need to
// disable it.
infoMenuItem.setTitle("");
} else {
infoMenuItem.setTitle(infoShowing ? R.string.hide_info : R.string.show_info);
}
infoMenuItem.setVisible(showItem); infoMenuItem.setVisible(showItem);
} }
} }
......
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