Use app.* instead of ShadowsocksApplication.*
Because typing ShadowsocksApplication is quite troublesome.
This commit is contained in:
@@ -39,11 +39,12 @@
|
||||
|
||||
package com.github.shadowsocks.utils
|
||||
|
||||
import android.content.{SharedPreferences, Context}
|
||||
import com.github.shadowsocks.{R, ShadowsocksApplication}
|
||||
import com.google.android.gms.tagmanager.Container
|
||||
import android.content.{Context, SharedPreferences}
|
||||
import com.github.kevinsawicki.http.HttpRequest
|
||||
import com.github.shadowsocks.R
|
||||
import com.github.shadowsocks.ShadowsocksApplication.app
|
||||
import com.github.shadowsocks.aidl.Config
|
||||
import com.google.android.gms.tagmanager.Container
|
||||
|
||||
object ConfigUtils {
|
||||
val SHADOWSOCKS = "{\"server\": \"%s\", \"server_port\": %d, \"local_port\": %d, \"password\": \"%s\", \"method\":\"%s\", \"timeout\": %d}"
|
||||
@@ -152,14 +153,14 @@ object ConfigUtils {
|
||||
}
|
||||
|
||||
def refresh(context: Context) {
|
||||
val holder = ShadowsocksApplication.containerHolder
|
||||
val holder = app.containerHolder
|
||||
if (holder != null) holder.refresh()
|
||||
}
|
||||
|
||||
def getRejectList(context: Context): String = {
|
||||
val default = context.getString(R.string.reject)
|
||||
try {
|
||||
val container = ShadowsocksApplication.containerHolder.getContainer
|
||||
val container = app.containerHolder.getContainer
|
||||
val update = container.getString("reject")
|
||||
if (update == null || update.isEmpty) default else update
|
||||
} catch {
|
||||
@@ -170,7 +171,7 @@ object ConfigUtils {
|
||||
def getBlackList(context: Context): String = {
|
||||
val default = context.getString(R.string.black_list)
|
||||
try {
|
||||
val container = ShadowsocksApplication.containerHolder.getContainer
|
||||
val container = app.containerHolder.getContainer
|
||||
val update = container.getString("black_list")
|
||||
if (update == null || update.isEmpty) default else update
|
||||
} catch {
|
||||
|
||||
@@ -40,7 +40,8 @@ package com.github.shadowsocks.utils
|
||||
|
||||
import android.content.{Context, Intent}
|
||||
import android.os.Bundle
|
||||
import com.github.shadowsocks.{R, ShadowsocksApplication}
|
||||
import com.github.shadowsocks.R
|
||||
import com.github.shadowsocks.ShadowsocksApplication.app
|
||||
import com.twofortyfouram.locale.api.{Intent => ApiIntent}
|
||||
|
||||
object TaskerSettings {
|
||||
@@ -62,7 +63,7 @@ class TaskerSettings(bundle: Bundle) {
|
||||
if (!switchOn) bundle.putBoolean(KEY_SWITCH_ON, false)
|
||||
if (profileId >= 0) bundle.putInt(KEY_PROFILE_ID, profileId)
|
||||
new Intent().putExtra(ApiIntent.EXTRA_BUNDLE, bundle).putExtra(ApiIntent.EXTRA_STRING_BLURB,
|
||||
ShadowsocksApplication.profileManager.getProfile(profileId) match {
|
||||
app.profileManager.getProfile(profileId) match {
|
||||
case Some(p) => context.getString(if (switchOn) R.string.start_service else R.string.stop_service, p.name)
|
||||
case None => context.getString(if (switchOn) R.string.start_service_default else R.string.stop)
|
||||
})
|
||||
|
||||
@@ -2,7 +2,8 @@ package com.github.shadowsocks.utils
|
||||
|
||||
import java.text.DecimalFormat
|
||||
|
||||
import com.github.shadowsocks.{R, ShadowsocksApplication}
|
||||
import com.github.shadowsocks.R
|
||||
import com.github.shadowsocks.ShadowsocksApplication.app
|
||||
|
||||
object TrafficMonitor {
|
||||
// Bytes per second
|
||||
@@ -28,7 +29,7 @@ object TrafficMonitor {
|
||||
n /= 1024
|
||||
i = i + 1
|
||||
}
|
||||
if (i < 0) size + " " + ShadowsocksApplication.instance.getResources.getQuantityString(R.plurals.bytes, size.toInt)
|
||||
if (i < 0) size + " " + app.getResources.getQuantityString(R.plurals.bytes, size.toInt)
|
||||
else numberFormat.format(n) + ' ' + units(i)
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,8 @@ import android.util.{Base64, DisplayMetrics, Log}
|
||||
import android.view.View.MeasureSpec
|
||||
import android.view.{Gravity, View, Window}
|
||||
import android.widget.Toast
|
||||
import com.github.shadowsocks.{BuildConfig, ShadowsocksApplication, ShadowsocksRunnerService}
|
||||
import com.github.shadowsocks.ShadowsocksApplication.app
|
||||
import com.github.shadowsocks.{BuildConfig, ShadowsocksRunnerService}
|
||||
import org.xbill.DNS._
|
||||
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
@@ -59,7 +60,6 @@ import scala.concurrent.Future
|
||||
import scala.util.{Failure, Try}
|
||||
|
||||
object Utils {
|
||||
|
||||
private val TAG = "Shadowsocks"
|
||||
|
||||
/**
|
||||
@@ -229,7 +229,7 @@ object Utils {
|
||||
}
|
||||
|
||||
def startSsService(context: Context) {
|
||||
val isInstalled: Boolean = ShadowsocksApplication.settings.getBoolean(ShadowsocksApplication.getVersionName, false)
|
||||
val isInstalled: Boolean = app.settings.getBoolean(app.getVersionName, false)
|
||||
if (!isInstalled) return
|
||||
|
||||
val intent = new Intent(context, classOf[ShadowsocksRunnerService])
|
||||
|
||||
Reference in New Issue
Block a user