Removed the switch for now
This commit is contained in:
@@ -452,7 +452,6 @@ class Shadowsocks
|
||||
}
|
||||
|
||||
private def setPreferenceEnabled(enabled: Boolean) {
|
||||
preferences.findPreference(Key.notificationTraffic).setEnabled(enabled)
|
||||
preferences.findPreference(Key.isNAT).setEnabled(enabled)
|
||||
for (name <- Shadowsocks.PROXY_PREFS) {
|
||||
val pref = preferences.findPreference(name)
|
||||
|
||||
@@ -76,8 +76,6 @@ object ShadowsocksApplication {
|
||||
.setLabel(getVersionName)
|
||||
.build())
|
||||
|
||||
def notificationTraffic = settings.getBoolean(Key.notificationTraffic, true)
|
||||
|
||||
def profileId = settings.getInt(Key.profileId, -1)
|
||||
def profileId(i: Int) = settings.edit.putInt(Key.profileId, i).apply
|
||||
def currentProfile = profileManager.getProfile(profileId)
|
||||
|
||||
@@ -39,25 +39,21 @@ class ShadowsocksNotification(private val service: BaseService, profileName: Str
|
||||
PendingIntent.getBroadcast(service, 0, new Intent(Action.CLOSE), 0))
|
||||
private lazy val style = new BigTextStyle(builder)
|
||||
private val showOnUnlock = visible && Utils.isLollipopOrAbove
|
||||
if (showOnUnlock || ShadowsocksApplication.notificationTraffic) {
|
||||
update()
|
||||
lockReceiver = (context: Context, intent: Intent) => update(intent.getAction)
|
||||
val screenFilter = new IntentFilter()
|
||||
screenFilter.addAction(Intent.ACTION_SCREEN_ON)
|
||||
screenFilter.addAction(Intent.ACTION_SCREEN_OFF)
|
||||
screenFilter.addAction(Intent.ACTION_USER_PRESENT)
|
||||
service.registerReceiver(lockReceiver, screenFilter)
|
||||
} else setVisible(visible).show()
|
||||
update()
|
||||
lockReceiver = (context: Context, intent: Intent) => update(intent.getAction)
|
||||
val screenFilter = new IntentFilter()
|
||||
screenFilter.addAction(Intent.ACTION_SCREEN_ON)
|
||||
screenFilter.addAction(Intent.ACTION_SCREEN_OFF)
|
||||
if (showOnUnlock) screenFilter.addAction(Intent.ACTION_USER_PRESENT)
|
||||
service.registerReceiver(lockReceiver, screenFilter)
|
||||
|
||||
def update(action: String = Intent.ACTION_SCREEN_ON) = if (service.getState == State.CONNECTED) {
|
||||
if (action == Intent.ACTION_SCREEN_OFF) {
|
||||
if (showOnUnlock) setVisible(false)
|
||||
unregisterCallback // unregister callback to save battery
|
||||
} else if (action == Intent.ACTION_SCREEN_ON) {
|
||||
if (ShadowsocksApplication.notificationTraffic) {
|
||||
service.binder.registerCallback(callback)
|
||||
callbackRegistered = true
|
||||
} else unregisterCallback
|
||||
service.binder.registerCallback(callback)
|
||||
callbackRegistered = true
|
||||
if (!keyGuard.inKeyguardRestrictedInputMode) setVisible(showOnUnlock)
|
||||
} else if (action == Intent.ACTION_USER_PRESENT) setVisible(showOnUnlock)
|
||||
show()
|
||||
|
||||
@@ -68,7 +68,6 @@ object Key {
|
||||
val profiles = "profiles"
|
||||
val isNAT = "isNAT"
|
||||
val route = "route"
|
||||
val notificationTraffic = "notificationTraffic"
|
||||
val stat = "stat"
|
||||
|
||||
val isRunning = "isRunning"
|
||||
|
||||
Reference in New Issue
Block a user