Skip to content

Commit

Permalink
[WL] Fix Switches in WebLayer Settings UI
Browse files Browse the repository at this point in the history
This CL applies the ColorOverlay style to the WebLayer Settings UI,
which fixes missing switch colors.

Bug: 1241132
Change-Id: I7598018d54c5b2c1c4671531a07770a27bc4c9e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3101399
Reviewed-by: Bo <boliu@chromium.org>
Reviewed-by: Sky Malice <skym@chromium.org>
Commit-Queue: Robbie McElrath <rmcelrath@chromium.org>
Cr-Commit-Position: refs/heads/main@{#913675}
  • Loading branch information
robbiemc authored and Chromium LUCI CQ committed Aug 20, 2021
1 parent b70376f commit da37134
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions weblayer/browser/java/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ android_resources("weblayer_resources") {
"res/layout/settings_layout.xml",
"res/layout/weblayer_infobar_translate_compact_content.xml",
"res/layout/weblayer_url_bar.xml",
"res/values-night/styles.xml",
"res/values/colors.xml",
"res/values/dimens.xml",
"res/values/styles.xml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import androidx.annotation.Nullable;

import org.chromium.base.metrics.RecordHistogram;
import org.chromium.components.browser_ui.styles.R;
import org.chromium.components.embedder_support.application.ClassLoaderContextWrapperFactory;
import org.chromium.weblayer_private.interfaces.BrowserFragmentArgs;
import org.chromium.weblayer_private.interfaces.IBrowser;
Expand Down Expand Up @@ -186,7 +185,9 @@ public IBrowser getBrowser() {
protected FragmentHostingRemoteFragmentImpl.RemoteFragmentContext createRemoteFragmentContext(
Context embedderContext) {
Context wrappedContext = ClassLoaderContextWrapperFactory.get(embedderContext);
Context themedContext = new ContextThemeWrapper(wrappedContext, R.style.Theme_BrowserUI);
Context themedContext =
new ContextThemeWrapper(wrappedContext, R.style.Theme_WebLayer_Settings);
themedContext.getTheme().applyStyle(R.style.ColorOverlay_WebLayer, /*force=*/true);
return new FragmentHostingRemoteFragmentImpl.RemoteFragmentContext(themedContext);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public MediaRouteDialogContext(Context embedderContext) {
// TODO(estade): this is necessary because MediaRouter dialogs crash if the theme has an
// action bar. It's unclear why this is necessary when it's not in Chrome, and why
// ContextThemeWrapper doesn't work.
getTheme().applyStyle(R.style.Theme_BrowserUI, true);
getTheme().applyStyle(R.style.Theme_BrowserUI, /*force=*/true);
getTheme().applyStyle(R.style.ColorOverlay_WebLayer, /*force=*/true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ private static class SettingsContext
public SettingsContext(SettingsFragmentImpl fragmentImpl, Context embedderContext) {
super(new ContextThemeWrapper(ClassLoaderContextWrapperFactory.get(embedderContext),
R.style.Theme_WebLayer_Settings));
getTheme().applyStyle(R.style.ColorOverlay_WebLayer, /*force=*/true);
mEmbedderContext = embedderContext;
mFragmentImpl = fragmentImpl;
}
Expand Down
8 changes: 8 additions & 0 deletions weblayer/browser/java/res/values-night/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2021 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->

<resources xmlns:tools="http://schemas.android.com/tools">
<style name="ColorOverlay.WebLayer" parent="ColorOverlay.WebLayer.DayNight" />
</resources>
7 changes: 6 additions & 1 deletion weblayer/browser/java/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
found in the LICENSE file. -->

<resources xmlns:tools="http://schemas.android.com/tools">
<style name="Theme.WebLayer.Settings" parent="Theme.BrowserUI">
<style name="Theme.WebLayer" parent="Theme.BrowserUI" />

<style name="Theme.WebLayer.Settings" parent="Theme.WebLayer">
<item name="preferenceTheme">@style/PreferenceTheme</item>
<item name="alertDialogTheme">@style/Theme.Chromium.AlertDialog</item>

<!-- Text style attributes used by the preference_material.xml layout. -->
<item name="android:textAppearanceListItem">@style/TextAppearance.TextLarge.Primary</item>
<item name="android:textColorSecondary">@color/default_text_color_secondary_list</item>
</style>

<style name="ColorOverlay.WebLayer" parent="ColorOverlay.WebLayer.DayNight" />
<style name="ColorOverlay.WebLayer.DayNight" parent="ColorOverlay.BrowserUi" />
</resources>

0 comments on commit da37134

Please sign in to comment.