Commit 122f12d7 authored by Brandon Wylie's avatar Brandon Wylie Committed by Commit Bot

Reset StatusView's alpha when mFirstVisibleFocusedView is swapped

Bug: 1049829
Change-Id: Ia262b370239816d02c58f2066e20c907169865f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2080818
Commit-Queue: Brandon Wylie <wylieb@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarPatrick Noland <pnoland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746628}
parent 18e86964
......@@ -12,6 +12,7 @@ import androidx.annotation.VisibleForTesting;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.offlinepages.OfflinePageUtils;
import org.chromium.chrome.browser.omnibox.SearchEngineLogoUtils;
import org.chromium.chrome.browser.omnibox.UrlBar.UrlTextChangeListener;
import org.chromium.chrome.browser.omnibox.UrlBarEditingTextStateProvider;
import org.chromium.chrome.browser.page_info.PageInfoController;
......@@ -221,6 +222,7 @@ public class StatusViewCoordinator implements View.OnClickListener, UrlTextChang
*/
public void setShowIconsWhenUrlFocused(boolean showIconsWithUrlFocused) {
mMediator.setShowIconsWhenUrlFocused(showIconsWithUrlFocused);
reconcileVisualState(showIconsWithUrlFocused);
}
/**
......@@ -239,6 +241,37 @@ public class StatusViewCoordinator implements View.OnClickListener, UrlTextChang
shouldShowSearchEngineLogo, isSearchEngineGoogle, searchEngineUrl);
}
/**
* Temporary workaround for the divergent logic for status icon visibility changes for the dse
* icon experiment. Should be removed when the dse icon launches (crbug.com/1019488).
*
* When transitioning to incognito, the first visible view when focused will be assigned to
* UrlBar. When the UrlBar is the first visible view when focused, the StatusView's alpha
* will be set to 0 in LocationBarPhone#populateFadeAnimations. When transitioning back from
* incognito, StatusView's state needs to be reset to match the current state of the status view
* {@link org.chromium.chrome.browser.omnibox.LocationBarPhone#updateVisualsForState}.
* property model.
**/
private void reconcileVisualState(boolean showStatusIconWhenFocused) {
// State requirements:
// - The ToolbarDataProvider and views are not null.
// - The status icon will be shown when focused.
// - Incognito isn't active.
// - The search engine logo should be shown.
if (mToolbarDataProvider == null || mStatusView == null || getSecurityIconView() == null
|| !showStatusIconWhenFocused || mToolbarDataProvider.isIncognito()
|| !SearchEngineLogoUtils.shouldShowSearchEngineLogo(
mToolbarDataProvider.isIncognito())) {
return;
}
View securityIconView = getSecurityIconView();
mStatusView.setAlpha(1f);
securityIconView.setAlpha(mModel.get(StatusProperties.STATUS_ICON_ALPHA));
securityIconView.setVisibility(
mModel.get(StatusProperties.SHOW_STATUS_ICON) ? View.VISIBLE : View.GONE);
}
/**
* @return Width of the status icon including start/end margins.
*/
......
......@@ -252,6 +252,26 @@ public class LocationBarLayoutTest {
.check((view, e) -> Assert.assertEquals(iconView.getVisibility(), GONE));
}
@Test
@SmallTest
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE)
@EnableFeatures(ChromeFeatureList.OMNIBOX_SEARCH_ENGINE_LOGO)
@Feature({"OmniboxSearchEngineLogo"})
public void testOmniboxSearchEngineLogo_backAndForthFromIncognito() {
final LocationBarLayout locationBar = getLocationBar();
final View iconView = locationBar.getSecurityIconView();
updateSearchEngineLogoWithGoogle(locationBar);
loadUrlInNewTabAndUpdateModels(UrlConstants.NTP_URL, true);
TestThreadUtils.runOnUiThreadBlocking(() -> { locationBar.updateVisualsForState(); });
loadUrlInNewTabAndUpdateModels(UrlConstants.ABOUT_URL, false);
TestThreadUtils.runOnUiThreadBlocking(() -> { locationBar.updateVisualsForState(); });
onView(withId(R.id.location_bar_status)).check((view, e) -> {
Assert.assertEquals(1.0f, view.getAlpha(), 0f);
});
}
@Test
@SmallTest
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE)
......
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