Skip to content

Commit e2364b1

Browse files
マシュ・キリエライトMygod
authored andcommitted
support night theme (shadowsocks#1750)
* kotlin version materialdrawer * support dark theme * add night mode settings * revert materialdrawer * revert translucent style * update dark theme color * add night mode changed listener * fix dependency issue * Fix issues with bottom sheet * Use support lib default value * fix stat title color * change default nightmode value * update background color * add night about page * clean style * Fix colors in selection mode in custom rules * Fix weird AboutFragment issues * Misc refinements * Fix cucstom tabs colors * Fix inconsistent color in background_profile * Add EXTRA_NIGHT_MODE to plugin interface * Revert changes to plugin/build.gradle * update toolbar popupTheme
1 parent 2b3524d commit e2364b1

34 files changed

+503
-35
lines changed

mobile/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
android:fullBackupContent="@xml/backup_descriptor"
2727
android:fullBackupOnly="true"
2828
android:label="@string/app_name"
29+
android:theme="@style/Theme.Shadowsocks.App"
2930
android:supportsRtl="true"
3031
android:networkSecurityConfig="@xml/network_security_config"
31-
android:banner="@drawable/ic_service_active">
32+
android:banner="@drawable/ic_service_active"
33+
tools:replace="android:theme">
3234

3335
<meta-data android:name="android.webkit.WebView.EnableSafeBrowsing"
3436
android:value="true" />
Lines changed: 308 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,308 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3+
<head>
4+
<title>MarkdownPad Document</title>
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6+
<style type="text/css">
7+
/* GitHub stylesheet for MarkdownPad (http://markdownpad.com) */
8+
/* Author: Nicolas Hery - http://nicolashery.com */
9+
/* Version: 29d1c5bc36da364ad5aa86946d420b7bbc54a253 */
10+
/* Source: https://github.com/nicolahery/markdownpad-github */
11+
12+
/* RESET
13+
=============================================================================*/
14+
15+
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
16+
margin: 0;
17+
padding: 0;
18+
border: 0;
19+
}
20+
21+
/* BODY
22+
=============================================================================*/
23+
24+
body {
25+
font-family: Helvetica, arial, freesans, clean, sans-serif;
26+
font-size: 14px;
27+
line-height: 1.6;
28+
color: #333;
29+
background-color: #303030;
30+
padding: 20px;
31+
max-width: 960px;
32+
margin: 0 auto;
33+
}
34+
35+
body>*:first-child {
36+
margin-top: 0 !important;
37+
}
38+
39+
body>*:last-child {
40+
margin-bottom: 0 !important;
41+
}
42+
43+
/* BLOCKS
44+
=============================================================================*/
45+
46+
p, blockquote, ul, ol, dl, table, pre {
47+
margin: 15px 0;
48+
color: white;
49+
}
50+
51+
/* HEADERS
52+
=============================================================================*/
53+
54+
h1, h2, h3, h4, h5, h6 {
55+
margin: 20px 0 10px;
56+
padding: 0;
57+
font-weight: bold;
58+
-webkit-font-smoothing: antialiased;
59+
}
60+
61+
h1 tt, h1 code, h2 tt, h2 code, h3 tt, h3 code, h4 tt, h4 code, h5 tt, h5 code, h6 tt, h6 code {
62+
font-size: inherit;
63+
}
64+
65+
h1 {
66+
font-size: 28px;
67+
color: #000;
68+
}
69+
70+
h2 {
71+
font-size: 24px;
72+
border-bottom: 1px solid #ccc;
73+
color: #000;
74+
}
75+
76+
h3 {
77+
font-size: 18px;
78+
color: white;
79+
}
80+
81+
h4 {
82+
font-size: 16px;
83+
}
84+
85+
h5 {
86+
font-size: 14px;
87+
}
88+
89+
h6 {
90+
color: #777;
91+
font-size: 14px;
92+
}
93+
94+
body>h2:first-child, body>h1:first-child, body>h1:first-child+h2, body>h3:first-child, body>h4:first-child, body>h5:first-child, body>h6:first-child {
95+
margin-top: 0;
96+
padding-top: 0;
97+
}
98+
99+
a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
100+
margin-top: 0;
101+
padding-top: 0;
102+
}
103+
104+
h1+p, h2+p, h3+p, h4+p, h5+p, h6+p {
105+
margin-top: 10px;
106+
}
107+
108+
/* LINKS
109+
=============================================================================*/
110+
111+
a {
112+
color: #4183C4;
113+
text-decoration: none;
114+
}
115+
116+
a:hover {
117+
text-decoration: underline;
118+
}
119+
120+
/* LISTS
121+
=============================================================================*/
122+
123+
ul, ol {
124+
padding-left: 30px;
125+
}
126+
127+
ul li > :first-child,
128+
ol li > :first-child,
129+
ul li ul:first-of-type,
130+
ol li ol:first-of-type,
131+
ul li ol:first-of-type,
132+
ol li ul:first-of-type {
133+
margin-top: 0px;
134+
}
135+
136+
ul ul, ul ol, ol ol, ol ul {
137+
margin-bottom: 0;
138+
}
139+
140+
dl {
141+
padding: 0;
142+
}
143+
144+
dl dt {
145+
font-size: 14px;
146+
font-weight: bold;
147+
font-style: italic;
148+
padding: 0;
149+
margin: 15px 0 5px;
150+
}
151+
152+
dl dt:first-child {
153+
padding: 0;
154+
}
155+
156+
dl dt>:first-child {
157+
margin-top: 0px;
158+
}
159+
160+
dl dt>:last-child {
161+
margin-bottom: 0px;
162+
}
163+
164+
dl dd {
165+
margin: 0 0 15px;
166+
padding: 0 15px;
167+
}
168+
169+
dl dd>:first-child {
170+
margin-top: 0px;
171+
}
172+
173+
dl dd>:last-child {
174+
margin-bottom: 0px;
175+
}
176+
177+
/* CODE
178+
=============================================================================*/
179+
180+
pre, code, tt {
181+
font-size: 12px;
182+
font-family: Consolas, "Liberation Mono", Courier, monospace;
183+
}
184+
185+
code, tt {
186+
margin: 0 0px;
187+
padding: 0px 0px;
188+
white-space: nowrap;
189+
border: 1px solid #eaeaea;
190+
background-color: #f8f8f8;
191+
border-radius: 3px;
192+
}
193+
194+
pre>code {
195+
margin: 0;
196+
padding: 0;
197+
white-space: pre;
198+
border: none;
199+
background: transparent;
200+
}
201+
202+
pre {
203+
background-color: #f8f8f8;
204+
border: 1px solid #ccc;
205+
font-size: 13px;
206+
line-height: 19px;
207+
overflow: auto;
208+
padding: 6px 10px;
209+
border-radius: 3px;
210+
}
211+
212+
pre code, pre tt {
213+
background-color: transparent;
214+
border: none;
215+
}
216+
217+
/* QUOTES
218+
=============================================================================*/
219+
220+
blockquote {
221+
border-left: 4px solid #DDD;
222+
padding: 0 15px;
223+
color: #777;
224+
}
225+
226+
blockquote>:first-child {
227+
margin-top: 0px;
228+
}
229+
230+
blockquote>:last-child {
231+
margin-bottom: 0px;
232+
}
233+
234+
/* HORIZONTAL RULES
235+
=============================================================================*/
236+
237+
hr {
238+
clear: both;
239+
margin: 15px 0;
240+
height: 0px;
241+
overflow: hidden;
242+
border: none;
243+
background: transparent;
244+
border-bottom: 4px solid #ddd;
245+
padding: 0;
246+
}
247+
248+
/* TABLES
249+
=============================================================================*/
250+
251+
table th {
252+
font-weight: bold;
253+
}
254+
255+
table th, table td {
256+
border: 1px solid #ccc;
257+
padding: 6px 13px;
258+
}
259+
260+
table tr {
261+
border-top: 1px solid #ccc;
262+
background-color: #303030;
263+
}
264+
265+
table tr:nth-child(2n) {
266+
background-color: #f8f8f8;
267+
}
268+
269+
/* IMAGES
270+
=============================================================================*/
271+
272+
img {
273+
max-width: 100%
274+
}
275+
</style>
276+
</head>
277+
<body>
278+
<p>A <a href="http://shadowsocks.org">Shadowsocks</a> client for Android, written in Kotlin.</p>
279+
<p>Copyright (C) 2017 by Max Lv <a href="&#x6d;&#97;&#x69;&#108;&#116;&#111;&#x3a;&#x6d;&#97;x&#46;&#99;.&#108;&#118;&#x40;&#103;&#109;&#97;&#x69;&#108;&#46;&#x63;&#x6f;&#109;">&#x6d;&#97;&#x78;.&#x63;&#x2e;&#108;v&#64;&#x67;&#109;&#x61;&#x69;&#108;&#x2e;&#99;&#111;&#109;</a></p>
280+
<p>Copyright (C) 2017 by Mygod Studio <a href="mailto:contact-shadowsocks-android@mygod.be">contact-shadowsocks-android@mygod.be</a></p>
281+
<p>This program is free software: you can redistribute it and/or modify
282+
it under the terms of the GNU General Public License as published by
283+
the Free Software Foundation, either version 3 of the License, or
284+
(at your option) any later version.</p>
285+
<p>This program is distributed in the hope that it will be useful,
286+
but WITHOUT ANY WARRANTY; without even the implied warranty of
287+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
288+
GNU General Public License for more details.</p>
289+
<p>You should have received a copy of the GNU General Public License
290+
along with this program. If not, see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>.</p>
291+
292+
<h3>Open Source Licenses</h3>
293+
<ul>
294+
<li>redsocks: <a href="https://github.com/shadowsocks/redsocks/blob/shadowsocks-android/README">APL 2.0</a></li>
295+
<li>mbed TLS: <a href="https://github.com/ARMmbed/mbedtls/blob/development/LICENSE">APL 2.0</a></li>
296+
<li>libevent: <a href="https://github.com/shadowsocks/libevent/blob/master/LICENSE">BSD</a></li>
297+
<li>tun2socks: <a href="https://github.com/shadowsocks/badvpn/blob/shadowsocks-android/COPYING">BSD</a></li>
298+
<li>pcre: <a href="https://android.googlesource.com/platform/external/pcre/+/master/dist2/LICENCE">BSD</a></li>
299+
<li>libancillary: <a href="https://github.com/shadowsocks/libancillary/blob/shadowsocks-android/COPYING">BSD</a></li>
300+
<li>shadowsocks-libev: <a href="https://github.com/shadowsocks/shadowsocks-libev/blob/master/LICENSE">GPLv3</a></li>
301+
<li>overture: <a href="https://github.com/shawn1m/overture/blob/master/LICENSE">MIT</a></li>
302+
<li>libev: <a href="https://github.com/shadowsocks/libev/blob/master/LICENSE">GPLv2</a></li>
303+
<li>libsodium: <a href="https://github.com/jedisct1/libsodium/blob/master/LICENSE">ISC</a></li>
304+
</ul>
305+
306+
</body>
307+
</html>
308+
<!-- This document was created with MarkdownPad, the Markdown editor for Windows (http://markdownpad.com) -->

mobile/src/main/java/com/github/shadowsocks/AboutFragment.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020

2121
package com.github.shadowsocks
2222

23-
import android.annotation.TargetApi
24-
import android.os.Build
2523
import android.os.Bundle
24+
import android.support.v4.content.ContextCompat
2625
import android.view.LayoutInflater
2726
import android.view.View
2827
import android.view.ViewGroup
@@ -31,22 +30,27 @@ import android.webkit.WebView
3130
import android.webkit.WebViewClient
3231

3332
class AboutFragment : ToolbarFragment() {
34-
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =
35-
inflater.inflate(R.layout.layout_about, container, false)
33+
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
34+
// workaround for weird night mode bug
35+
val configuration = resources.configuration
36+
val result = inflater.inflate(R.layout.layout_about, container, false)
37+
if (resources.configuration !== configuration) requireActivity().recreate()
38+
return result
39+
}
3640

3741
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
3842
super.onViewCreated(view, savedInstanceState)
3943
toolbar.title = getString(R.string.about_title, BuildConfig.VERSION_NAME)
4044
val web = view.findViewById<WebView>(R.id.web_view)
41-
web.loadUrl("file:///android_asset/pages/about.html")
45+
web.setBackgroundColor(ContextCompat.getColor(requireActivity(), R.color.background))
46+
web.loadUrl(getString(R.string.about_url))
4247
web.webViewClient = object : WebViewClient() {
4348
@Suppress("OverridingDeprecatedMember")
4449
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
4550
(activity as MainActivity).launchUrl(url)
4651
return true
4752
}
4853

49-
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
5054
override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest): Boolean {
5155
(activity as MainActivity).launchUrl(request.url)
5256
return true

mobile/src/main/java/com/github/shadowsocks/App.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class App : Application() {
160160
}
161161
DataStore.publicStore.putLong(Key.assetUpdateTime, info.lastUpdateTime)
162162
}
163-
163+
AppCompatDelegate.setDefaultNightMode(DataStore.nightMode)
164164
updateNotificationChannels()
165165
}
166166

0 commit comments

Comments
 (0)