Commit 54cd2ba3 authored by Yue Zhang's avatar Yue Zhang Committed by Commit Bot

Make TabGridDialog scrim affect navigation bar

Bug: 1119632
Change-Id: I8814e259146b50144ec422b89732f15a6f677129
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2381053
Commit-Queue: Yue Zhang <yuezhanggg@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803653}
parent 97c7f71a
......@@ -652,12 +652,13 @@ public class TabGridDialogView extends FrameLayout
* @param scrimClickRunnable The {@link Runnable} that runs when scrim view is clicked.
*/
void setScrimClickRunnable(Runnable scrimClickRunnable) {
mScrimPropertyModel = new PropertyModel.Builder(ScrimProperties.REQUIRED_KEYS)
mScrimPropertyModel = new PropertyModel.Builder(ScrimProperties.ALL_KEYS)
.with(ScrimProperties.ANCHOR_VIEW, mDialogContainerView)
.with(ScrimProperties.SHOW_IN_FRONT_OF_ANCHOR_VIEW, false)
.with(ScrimProperties.AFFECTS_STATUS_BAR, true)
.with(ScrimProperties.TOP_MARGIN, 0)
.with(ScrimProperties.CLICK_DELEGATE, scrimClickRunnable)
.with(ScrimProperties.AFFECTS_NAVIGATION_BAR, true)
.build();
}
......
......@@ -31,6 +31,7 @@ import static org.hamcrest.Matchers.not;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.chromium.chrome.browser.flags.ChromeFeatureList.TAB_GRID_LAYOUT_ANDROID;
......@@ -58,13 +59,16 @@ import static org.chromium.chrome.test.util.ViewUtils.waitForView;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Rect;
import android.os.Build;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.recyclerview.widget.RecyclerView;
import androidx.test.espresso.Espresso;
import androidx.test.espresso.contrib.RecyclerViewActions;
......@@ -80,6 +84,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.test.params.ParameterAnnotations;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.util.CommandLineFlags;
......@@ -106,6 +111,7 @@ import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.ui.test.util.NightModeTestUtils;
import org.chromium.ui.test.util.UiRestriction;
import org.chromium.ui.util.ColorUtils;
import java.util.concurrent.ExecutionException;
......@@ -928,6 +934,26 @@ public class TabGridDialogTest {
onView(allOf(withParent(withId(R.id.dialog_parent_view)),
withId(R.id.dialog_animation_card_view)))
.check((v, e) -> assertEquals(0f, v.getAlpha(), 0.0));
// For devices with version higher or equal to O_MR1 and use light color navigation bar,
// make sure that the color of navigation bar is changed by dialog scrim.
Resources resources = cta.getResources();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O_MR1
|| !resources.getBoolean(R.bool.window_light_navigation_bar)) {
return;
}
@ColorInt
int scrimDefaultColor = ApiCompatibilityUtils.getColor(resources, R.color.black_alpha_65);
@ColorInt
int navigationBarColor =
ApiCompatibilityUtils.getColor(resources, R.color.bottom_system_nav_color);
float scrimColorAlpha = (scrimDefaultColor >>> 24) / 255f;
int scrimColorOpaque = scrimDefaultColor & 0xFF000000;
int navigationBarColorWithScrimOverlay = ColorUtils.getColorWithOverlay(
navigationBarColor, scrimColorOpaque, scrimColorAlpha, true);
assertEquals(cta.getWindow().getNavigationBarColor(), navigationBarColorWithScrimOverlay);
assertNotEquals(navigationBarColor, navigationBarColorWithScrimOverlay);
}
private boolean isDialogShowing(ChromeTabbedActivity cta) {
......
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