Commit 860f3bca authored by Mygod's avatar Mygod

Remove night mode switch

parent 512ca9db
...@@ -136,7 +136,6 @@ class App : Application() { ...@@ -136,7 +136,6 @@ class App : Application() {
} }
DataStore.publicStore.putLong(Key.assetUpdateTime, info.lastUpdateTime) DataStore.publicStore.putLong(Key.assetUpdateTime, info.lastUpdateTime)
} }
if (Build.VERSION.SDK_INT < 28) AppCompatDelegate.setDefaultNightMode(DataStore.nightMode)
updateNotificationChannels() updateNotificationChannels()
} }
......
...@@ -64,7 +64,6 @@ class GlobalSettingsPreferenceFragment : PreferenceFragmentCompat() { ...@@ -64,7 +64,6 @@ class GlobalSettingsPreferenceFragment : PreferenceFragmentCompat() {
tfo.isEnabled = false tfo.isEnabled = false
tfo.summary = getString(R.string.tcp_fastopen_summary_unsupported, System.getProperty("os.version")) tfo.summary = getString(R.string.tcp_fastopen_summary_unsupported, System.getProperty("os.version"))
} }
if (Build.VERSION.SDK_INT >= 28) findPreference(Key.nightMode).remove()
val serviceMode = findPreference(Key.serviceMode) val serviceMode = findPreference(Key.serviceMode)
val portProxy = findPreference(Key.portProxy) val portProxy = findPreference(Key.portProxy)
......
...@@ -22,7 +22,6 @@ package com.github.shadowsocks ...@@ -22,7 +22,6 @@ package com.github.shadowsocks
import android.app.Activity import android.app.Activity
import android.app.PendingIntent import android.app.PendingIntent
import android.app.UiModeManager
import android.app.backup.BackupManager import android.app.backup.BackupManager
import android.content.ActivityNotFoundException import android.content.ActivityNotFoundException
import android.content.Context import android.content.Context
...@@ -30,18 +29,15 @@ import android.content.Intent ...@@ -30,18 +29,15 @@ import android.content.Intent
import android.net.VpnService import android.net.VpnService
import android.nfc.NdefMessage import android.nfc.NdefMessage
import android.nfc.NfcAdapter import android.nfc.NfcAdapter
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.browser.customtabs.CustomTabsIntent import androidx.browser.customtabs.CustomTabsIntent
import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.content.getSystemService
import androidx.core.net.toUri import androidx.core.net.toUri
import androidx.core.view.GravityCompat import androidx.core.view.GravityCompat
import androidx.core.view.updateLayoutParams import androidx.core.view.updateLayoutParams
...@@ -185,11 +181,6 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Interface, OnPre ...@@ -185,11 +181,6 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Interface, OnPre
val intent = this.intent val intent = this.intent
if (intent != null) handleShareIntent(intent) if (intent != null) handleShareIntent(intent)
if (Build.VERSION.SDK_INT < 28 && savedInstanceState != null &&
DataStore.nightMode == AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM &&
AppCompatDelegate.getDefaultNightMode() != AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
}
} }
override fun onNewIntent(intent: Intent) { override fun onNewIntent(intent: Intent) {
...@@ -227,15 +218,6 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Interface, OnPre ...@@ -227,15 +218,6 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Interface, OnPre
connection.disconnect() connection.disconnect()
connection.connect() connection.connect()
} }
Key.nightMode -> if (Build.VERSION.SDK_INT < 28) {
val mode = DataStore.nightMode
AppCompatDelegate.setDefaultNightMode(when (mode) {
AppCompatDelegate.getDefaultNightMode() -> return
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM -> getSystemService<UiModeManager>()!!.nightMode
else -> mode
})
recreate()
}
} }
} }
......
...@@ -157,8 +157,7 @@ class ProfileConfigFragment : PreferenceFragmentCompat(), Toolbar.OnMenuItemClic ...@@ -157,8 +157,7 @@ class ProfileConfigFragment : PreferenceFragmentCompat(), Toolbar.OnMenuItemClic
val intent = PluginManager.buildIntent(pluginConfiguration.selected, PluginContract.ACTION_CONFIGURE) val intent = PluginManager.buildIntent(pluginConfiguration.selected, PluginContract.ACTION_CONFIGURE)
if (intent.resolveActivity(requireContext().packageManager) == null) showPluginEditor() else if (intent.resolveActivity(requireContext().packageManager) == null) showPluginEditor() else
startActivityForResult(intent startActivityForResult(intent
.putExtra(PluginContract.EXTRA_OPTIONS, pluginConfiguration.selectedOptions.toString()) .putExtra(PluginContract.EXTRA_OPTIONS, pluginConfiguration.selectedOptions.toString()),
.putExtra(PluginContract.EXTRA_NIGHT_MODE, DataStore.nightMode),
REQUEST_CODE_PLUGIN_CONFIGURE) REQUEST_CODE_PLUGIN_CONFIGURE)
} else super.onDisplayPreferenceDialog(preference) } else super.onDisplayPreferenceDialog(preference)
} }
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
package com.github.shadowsocks.preference package com.github.shadowsocks.preference
import android.os.Binder import android.os.Binder
import android.os.Build
import androidx.appcompat.app.AppCompatDelegate
import com.github.shadowsocks.App.Companion.app import com.github.shadowsocks.App.Companion.app
import com.github.shadowsocks.database.PrivateDatabase import com.github.shadowsocks.database.PrivateDatabase
import com.github.shadowsocks.database.PublicDatabase import com.github.shadowsocks.database.PublicDatabase
...@@ -55,13 +53,6 @@ object DataStore { ...@@ -55,13 +53,6 @@ object DataStore {
val canToggleLocked: Boolean get() = publicStore.getBoolean(Key.directBootAware) == true val canToggleLocked: Boolean get() = publicStore.getBoolean(Key.directBootAware) == true
val directBootAware: Boolean get() = app.directBootSupported && canToggleLocked val directBootAware: Boolean get() = app.directBootSupported && canToggleLocked
val tcpFastOpen: Boolean get() = TcpFastOpen.sendEnabled && DataStore.publicStore.getBoolean(Key.tfo, true) val tcpFastOpen: Boolean get() = TcpFastOpen.sendEnabled && DataStore.publicStore.getBoolean(Key.tfo, true)
@AppCompatDelegate.NightMode
val nightMode get() = when (if (Build.VERSION.SDK_INT < 28) publicStore.getString(Key.nightMode) else null) {
Key.nightModeAuto -> AppCompatDelegate.MODE_NIGHT_AUTO
Key.nightModeOff -> AppCompatDelegate.MODE_NIGHT_NO
Key.nightModeOn -> AppCompatDelegate.MODE_NIGHT_YES
else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
}
val serviceMode get() = publicStore.getString(Key.serviceMode) ?: Key.modeVpn val serviceMode get() = publicStore.getString(Key.serviceMode) ?: Key.modeVpn
var portProxy: Int var portProxy: Int
get() = getLocalPort(Key.portProxy, 1080) get() = getLocalPort(Key.portProxy, 1080)
......
...@@ -32,12 +32,6 @@ object Key { ...@@ -32,12 +32,6 @@ object Key {
const val individual = "Proxyed" const val individual = "Proxyed"
const val nightMode = "nightMode"
const val nightModeSystem = "system"
const val nightModeAuto = "auto"
const val nightModeOff = "off"
const val nightModeOn = "on"
const val serviceMode = "serviceMode" const val serviceMode = "serviceMode"
const val modeProxy = "proxy" const val modeProxy = "proxy"
const val modeVpn = "vpn" const val modeVpn = "vpn"
......
<vector android:autoMirrored="true" android:height="24dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal">
<path android:fillColor="#FF000000" android:pathData="M9,2c-1.05,0 -2.05,0.16 -3,0.46 4.06,1.27 7,5.06 7,9.54 0,4.48 -2.94,8.27 -7,9.54 0.95,0.3 1.95,0.46 3,0.46 5.52,0 10,-4.48 10,-10S14.52,2 9,2z"/>
</vector>
...@@ -237,16 +237,4 @@ ...@@ -237,16 +237,4 @@
<item>vpn</item> <item>vpn</item>
<item>transproxy</item> <item>transproxy</item>
</string-array> </string-array>
<string-array name="night_modes">
<item>@string/night_mode_system</item>
<item>@string/night_mode_auto</item>
<item>@string/night_mode_off</item>
<item>@string/night_mode_on</item>
</string-array>
<string-array name="night_mode_values" translatable="false">
<item>system</item>
<item>auto</item>
<item>off</item>
<item>on</item>
</string-array>
</resources> </resources>
...@@ -57,11 +57,6 @@ ...@@ -57,11 +57,6 @@
<string name="tcp_fastopen_summary_unsupported">Unsupported kernel version: %s &lt; 3.7.1</string> <string name="tcp_fastopen_summary_unsupported">Unsupported kernel version: %s &lt; 3.7.1</string>
<string name="udp_dns">DNS Forwarding</string> <string name="udp_dns">DNS Forwarding</string>
<string name="udp_dns_summary">Forward all DNS requests to remote</string> <string name="udp_dns_summary">Forward all DNS requests to remote</string>
<string name="night_mode">Night mode</string>
<string name="night_mode_system">Follow system</string>
<string name="night_mode_auto">Auto</string>
<string name="night_mode_on">On</string>
<string name="night_mode_off">Off</string>
<!-- notification category --> <!-- notification category -->
<string name="service_vpn">VPN Service</string> <string name="service_vpn">VPN Service</string>
......
...@@ -15,14 +15,6 @@ ...@@ -15,14 +15,6 @@
android:icon="@drawable/ic_action_offline_bolt" android:icon="@drawable/ic_action_offline_bolt"
android:summary="@string/tcp_fastopen_summary" android:summary="@string/tcp_fastopen_summary"
android:title="TCP Fast Open"/> android:title="TCP Fast Open"/>
<SimpleMenuPreference
android:key="nightMode"
android:icon="@drawable/ic_image_brightness_3"
android:entries="@array/night_modes"
android:entryValues="@array/night_mode_values"
android:defaultValue="system"
android:summary="%s"
android:title="@string/night_mode"/>
<PreferenceCategory <PreferenceCategory
android:title="@string/advanced"> android:title="@string/advanced">
<SimpleMenuPreference <SimpleMenuPreference
......
...@@ -24,7 +24,6 @@ import android.content.Intent ...@@ -24,7 +24,6 @@ import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
/** /**
* Activity that's capable of getting EXTRA_OPTIONS input. * Activity that's capable of getting EXTRA_OPTIONS input.
...@@ -44,13 +43,6 @@ abstract class OptionsCapableActivity : AppCompatActivity() { ...@@ -44,13 +43,6 @@ abstract class OptionsCapableActivity : AppCompatActivity() {
*/ */
protected abstract fun onInitializePluginOptions(options: PluginOptions = pluginOptions()) protected abstract fun onInitializePluginOptions(options: PluginOptions = pluginOptions())
override fun onCreate(savedInstanceState: Bundle?) {
val nightMode = intent.getIntExtra(PluginContract.EXTRA_NIGHT_MODE, -100) // MODE_NIGHT_UNSPECIFIED
if (nightMode >= AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM && nightMode <= AppCompatDelegate.MODE_NIGHT_YES)
AppCompatDelegate.setDefaultNightMode(nightMode)
super.onCreate(savedInstanceState) // applyDayNight is called in AppCompatActivity.onCreate
}
override fun onPostCreate(savedInstanceState: Bundle?) { override fun onPostCreate(savedInstanceState: Bundle?) {
super.onPostCreate(savedInstanceState) super.onPostCreate(savedInstanceState)
if (savedInstanceState == null) onInitializePluginOptions() if (savedInstanceState == null) onInitializePluginOptions()
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
package com.github.shadowsocks.plugin package com.github.shadowsocks.plugin
import androidx.appcompat.app.AppCompatDelegate
/** /**
* The contract between the plugin provider and host. Contains definitions for the supported actions, extras, etc. * The contract between the plugin provider and host. Contains definitions for the supported actions, extras, etc.
* *
...@@ -73,14 +71,6 @@ object PluginContract { ...@@ -73,14 +71,6 @@ object PluginContract {
* Constant Value: "com.github.shadowsocks.plugin.EXTRA_HELP_MESSAGE" * Constant Value: "com.github.shadowsocks.plugin.EXTRA_HELP_MESSAGE"
</host_name> */ </host_name> */
const val EXTRA_HELP_MESSAGE = "com.github.shadowsocks.plugin.EXTRA_HELP_MESSAGE" const val EXTRA_HELP_MESSAGE = "com.github.shadowsocks.plugin.EXTRA_HELP_MESSAGE"
/**
* The lookup key for an @NightMode int that suggests a night mode that is being used in the main app.
*
* Constant Value: "com.github.shadowsocks.plugin.EXTRA_NIGHT_MODE"
*/
@AppCompatDelegate.NightMode
@Deprecated("On Android 9.0+, this will always return system as AOSP has support for night mode since 9.0.")
const val EXTRA_NIGHT_MODE = "com.github.shadowsocks.plugin.EXTRA_NIGHT_MODE"
/** /**
* The metadata key to retrieve plugin id. Required for plugins. * The metadata key to retrieve plugin id. Required for plugins.
......
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