Skip to content

Commit 67636f3

Browse files
committed
Dark High Contrast: M3 black chrome + visible connected FAB icon
Refine the OLED theme to match the intended high-contrast design and fix two issues seen on-device: - App bar / bottom status bar / status & nav bars now use the black surface instead of the green primary, via a new themable appBarBackgroundColor attr (defaults to colorPrimary, so all other themes are unchanged) wired into the shared appbar/toolbar/tab layouts. This reserves green for actions/selection and lets the blue/green/red status text read against black chrome (previously the cyan/blue detail text was washed out on the green bar). - Fix the connect FAB airplane vanishing when connected: the green connected-icon tint was invisible on the green FAB. Add a dedicated fabConnectedColor attr (defaults to statusConnectedColor for back-compat) and set it to the dark on-primary color for Dark High Contrast so the icon stays visible, matching the stopped state. - Black DHC bottom-bar style, dark ActionBar overlay, green tab selection/indicator on the OLED canvas. Verified on Android across stopped/connected states.
1 parent 3bd3854 commit 67636f3

11 files changed

Lines changed: 68 additions & 14 deletions

File tree

app/src/main/java/io/nekohasekai/sagernet/widget/ServiceButton.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,14 @@ class ServiceButton @JvmOverloads constructor(
141141
}
142142

143143
private fun applyStateTint(state: BaseService.State) {
144-
// Tint the connect FAB icon by state: connected=green, stopped=red. For
145-
// transient states (and on non-Dracula themes) fall back to colorOnPrimary,
146-
// which is the FAB's normal icon color, so those themes look unchanged.
144+
// Tint the connect FAB icon by state. Connected uses fabConnectedColor
145+
// (defaults to the green connected status color, but themes whose FAB
146+
// background is that same green — e.g. Dark High Contrast — override it
147+
// with a contrasting color so the icon stays visible). Stopped uses
148+
// fabStoppedColor. Transient states fall back to colorOnPrimary, the FAB's
149+
// normal icon color, so unaffected themes look unchanged.
147150
val attr = when (state) {
148-
BaseService.State.Connected -> R.attr.statusConnectedColor
151+
BaseService.State.Connected -> R.attr.fabConnectedColor
149152
BaseService.State.Stopped -> R.attr.fabStoppedColor
150153
else -> com.google.android.material.R.attr.colorOnPrimary
151154
}

app/src/main/res/layout/layout_app_list.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
android:id="@+id/appbar"
1212
android:layout_width="match_parent"
1313
android:layout_height="wrap_content"
14-
android:background="?attr/colorPrimary">
14+
android:background="?attr/appBarBackgroundColor">
1515

1616
<com.google.android.material.appbar.CollapsingToolbarLayout
1717
android:layout_width="match_parent"
@@ -23,7 +23,7 @@
2323
android:id="@+id/toolbar"
2424
android:layout_width="match_parent"
2525
android:layout_height="?attr/actionBarSize"
26-
android:background="?attr/colorPrimary"
26+
android:background="?attr/appBarBackgroundColor"
2727
android:elevation="0dp"
2828
android:theme="?actionBarTheme"
2929
android:touchscreenBlocksFocus="false"

app/src/main/res/layout/layout_appbar.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
android:id="@+id/appbar"
55
android:layout_width="match_parent"
66
android:layout_height="?attr/actionBarSize"
7-
android:background="?attr/colorPrimary"
7+
android:background="?attr/appBarBackgroundColor"
88
app:elevation="0dp"
99
app:liftOnScroll="false">
1010

1111
<com.google.android.material.appbar.MaterialToolbar
1212
android:id="@+id/toolbar"
1313
android:layout_width="match_parent"
1414
android:layout_height="match_parent"
15-
android:background="?attr/colorPrimary"
15+
android:background="?attr/appBarBackgroundColor"
1616
android:theme="?actionBarTheme"
1717
android:touchscreenBlocksFocus="false"
1818
app:popupTheme="@style/ThemeOverlay.SagerNet.Toolbar.Popup"

app/src/main/res/layout/layout_apps.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
android:id="@+id/appbar"
1212
android:layout_width="match_parent"
1313
android:layout_height="wrap_content"
14-
android:background="?attr/colorPrimary">
14+
android:background="?attr/appBarBackgroundColor">
1515

1616
<com.google.android.material.appbar.CollapsingToolbarLayout
1717
android:layout_width="match_parent"
@@ -23,7 +23,7 @@
2323
android:id="@+id/toolbar"
2424
android:layout_width="match_parent"
2525
android:layout_height="?attr/actionBarSize"
26-
android:background="?attr/colorPrimary"
26+
android:background="?attr/appBarBackgroundColor"
2727
android:elevation="0dp"
2828
android:theme="?actionBarTheme"
2929
android:touchscreenBlocksFocus="false"

app/src/main/res/layout/layout_group_list.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
android:id="@+id/group_tab"
1717
android:layout_width="match_parent"
1818
android:layout_height="wrap_content"
19-
android:background="?colorPrimary"
19+
android:background="?attr/appBarBackgroundColor"
2020
android:elevation="0dp"
2121
android:visibility="gone"
2222
app:tabIndicatorColor="?tabIndicatorColor"

app/src/main/res/layout/layout_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
android:layout_height="wrap_content"
2626
android:layout_gravity="bottom"
2727
android:nextFocusUp="@+id/fab"
28-
app:backgroundTint="?colorPrimary"
28+
app:backgroundTint="?attr/appBarBackgroundColor"
2929
app:contentInsetStart="0dp"
3030
app:fabAlignmentMode="center"
3131
app:fabAnchorMode="cradle"

app/src/main/res/layout/layout_tools.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
android:id="@+id/tools_tab"
1717
android:layout_width="match_parent"
1818
android:layout_height="wrap_content"
19-
android:background="?colorPrimary"
19+
android:background="?attr/appBarBackgroundColor"
2020
android:elevation="0dp"
2121
app:tabIndicatorColor="?tabIndicatorColor"
2222
app:tabIndicatorFullWidth="false"

app/src/main/res/layout/layout_webdav_settings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
android:id="@+id/toolbar"
1616
android:layout_width="match_parent"
1717
android:layout_height="?attr/actionBarSize"
18-
android:background="?attr/colorPrimary"
18+
android:background="?attr/appBarBackgroundColor"
1919
app:popupTheme="@style/ThemeOverlay.SagerNet.Toolbar.Popup" />
2020

2121
</com.google.android.material.appbar.AppBarLayout>

app/src/main/res/values-night/themes.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@
105105
<item name="android:colorBackground">@color/dhc_background</item>
106106
<item name="colorOnBackground">@color/dhc_on_surface</item>
107107
<item name="android:windowBackground">@color/dhc_background</item>
108+
<item name="appBarBackgroundColor">@color/dhc_background</item>
109+
<item name="bottomAppBarStyle">@style/Widget.SagerNet.BottomAppBar.DarkHighContrast</item>
110+
<item name="android:statusBarColor">@color/dhc_background</item>
111+
<item name="android:navigationBarColor">@color/dhc_background</item>
112+
<item name="actionBarTheme">@style/ThemeOverlay.Material3.Dark.ActionBar</item>
113+
<item name="tabTextColor">@color/dhc_on_surface_variant</item>
114+
<item name="tabSelectedTextColor">@color/dhc_primary</item>
115+
<item name="tabIndicatorColor">@color/dhc_primary</item>
108116
<item name="colorPrimaryContainer">@color/dhc_container</item>
109117
<item name="colorOnPrimaryContainer">@color/dhc_on_surface</item>
110118
<item name="colorSecondary">@color/dhc_accent</item>
@@ -129,6 +137,7 @@
129137
<item name="testFailColor">@color/dhc_red</item>
130138
<item name="speedTextColor">@color/dhc_accent</item>
131139
<item name="fabStoppedColor">@color/dhc_on_primary</item>
140+
<item name="fabConnectedColor">@color/dhc_on_primary</item>
132141
<item name="statusDetailColor">@color/dhc_accent</item>
133142
<item name="statusTestingColor">@color/dhc_yellow</item>
134143
<item name="routeProxyColor">@color/dhc_blue</item>

app/src/main/res/values/attrs.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
(red was invisible on the pink/purple FAB). Separate from the red
3131
statusStoppedColor used for the status text. -->
3232
<attr name="fabStoppedColor" format="color" />
33+
<!-- Connect-FAB icon tint when Connected. Default = statusConnectedColor so
34+
existing themes are unchanged; themes whose FAB background equals the
35+
connected status color (e.g. Dark High Contrast: green icon on a green
36+
FAB) override this with a contrasting color so the airplane icon stays
37+
visible. Separate from statusConnectedColor used for the status text. -->
38+
<attr name="fabConnectedColor" format="color" />
3339
<!-- Secondary status text (the part after "Connected," / "Success:").
3440
Default on-primary; Dracula = cyan. -->
3541
<attr name="statusDetailColor" format="color" />
@@ -43,4 +49,9 @@
4349
<!-- Tonal "elevated surface" color for cards (route / group); each theme
4450
variant tints toward its own primary. -->
4551
<attr name="cardElevatedSurfaceColor" format="color" />
52+
<!-- Background for the top app bar / toolbar and the bottom status bar.
53+
Defaults to colorPrimary (legacy single-accent chrome); full M3 dark
54+
themes (Dark High Contrast) override it with colorSurface so the chrome
55+
is the dark canvas and the accent is reserved for actions/selection. -->
56+
<attr name="appBarBackgroundColor" format="color" />
4657
</resources>

0 commit comments

Comments
 (0)