Use app.* instead of ShadowsocksApplication.*
Because typing ShadowsocksApplication is quite troublesome.
This commit is contained in:
@@ -12,6 +12,7 @@ import android.webkit.{WebView, WebViewClient}
|
||||
import com.github.shadowsocks.database.Profile
|
||||
import com.github.shadowsocks.preferences._
|
||||
import com.github.shadowsocks.utils.{Key, Utils}
|
||||
import com.github.shadowsocks.ShadowsocksApplication.app
|
||||
|
||||
object ShadowsocksSettings {
|
||||
// Constants
|
||||
@@ -92,7 +93,7 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
|
||||
switch.setChecked(BootReceiver.getEnabled(activity))
|
||||
|
||||
findPreference("recovery").setOnPreferenceClickListener((preference: Preference) => {
|
||||
ShadowsocksApplication.track(TAG, "reset")
|
||||
app.track(TAG, "reset")
|
||||
activity.recovery()
|
||||
true
|
||||
})
|
||||
@@ -100,13 +101,13 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
|
||||
val flush = findPreference("flush_dnscache")
|
||||
if (Build.VERSION.SDK_INT < 17) flush.setSummary(R.string.flush_dnscache_summary)
|
||||
flush.setOnPreferenceClickListener(_ => {
|
||||
ShadowsocksApplication.track(TAG, "flush_dnscache")
|
||||
app.track(TAG, "flush_dnscache")
|
||||
activity.flushDnsCache()
|
||||
true
|
||||
})
|
||||
|
||||
findPreference("about").setOnPreferenceClickListener((preference: Preference) => {
|
||||
ShadowsocksApplication.track(TAG, "about")
|
||||
app.track(TAG, "about")
|
||||
val web = new WebView(activity)
|
||||
web.loadUrl("file:///android_asset/pages/about.html")
|
||||
web.setWebViewClient(new WebViewClient() {
|
||||
@@ -121,7 +122,7 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
|
||||
})
|
||||
|
||||
new AlertDialog.Builder(activity)
|
||||
.setTitle(getString(R.string.about_title).formatLocal(Locale.ENGLISH, ShadowsocksApplication.getVersionName))
|
||||
.setTitle(getString(R.string.about_title).formatLocal(Locale.ENGLISH, app.getVersionName))
|
||||
.setNegativeButton(getString(android.R.string.ok), null)
|
||||
.setView(web)
|
||||
.create()
|
||||
@@ -132,12 +133,12 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
|
||||
|
||||
override def onResume {
|
||||
super.onResume()
|
||||
isProxyApps.setChecked(ShadowsocksApplication.settings.getBoolean(Key.isProxyApps, false)) // update
|
||||
isProxyApps.setChecked(app.settings.getBoolean(Key.isProxyApps, false)) // update
|
||||
}
|
||||
|
||||
override def onDestroy {
|
||||
super.onDestroy()
|
||||
ShadowsocksApplication.settings.unregisterOnSharedPreferenceChangeListener(this)
|
||||
app.settings.unregisterOnSharedPreferenceChangeListener(this)
|
||||
}
|
||||
|
||||
def onSharedPreferenceChanged(pref: SharedPreferences, key: String) = key match {
|
||||
@@ -155,7 +156,7 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
|
||||
for (name <- Key.isNAT #:: PROXY_PREFS.toStream #::: FEATURE_PREFS.toStream) {
|
||||
val pref = findPreference(name)
|
||||
if (pref != null) pref.setEnabled(enabled &&
|
||||
(name != Key.isProxyApps || Utils.isLollipopOrAbove || !ShadowsocksApplication.isVpnEnabled))
|
||||
(name != Key.isProxyApps || Utils.isLollipopOrAbove || !app.isVpnEnabled))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user