This commit is contained in:
Max Lv
2016-07-08 11:42:10 +08:00
parent ae1e396a5d
commit a21d099a34
2 changed files with 2 additions and 9 deletions
@@ -117,7 +117,7 @@ trait BaseService extends Service {
}
def checkProfile(profile: Profile) = if (TextUtils.isEmpty(profile.host) || TextUtils.isEmpty(profile.password)) {
changeState(State.STOPPED)
changeState(State.STOPPED, getString(R.string.proxy_empty))
stopRunner(true)
false
} else true
@@ -405,7 +405,7 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext {
fab = findViewById(R.id.fab).asInstanceOf[FloatingActionButton]
fabProgressCircle = findViewById(R.id.fabProgressCircle).asInstanceOf[FABProgressCircle]
fab.setOnClickListener(_ => if (serviceStarted) serviceStop()
else if (checkText(Key.host) && checkText(Key.password) && bgService != null) prepareStartService()
else if (bgService != null) prepareStartService()
else changeSwitch(checked = false))
fab.setOnLongClickListener((v: View) => {
Utils.positionToast(Toast.makeText(this, if (serviceStarted) R.string.stop else R.string.connect,
@@ -568,13 +568,6 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext {
if (bgService != null) bgService.use(-1)
}
def checkText(key: String): Boolean = {
val text = app.settings.getString(key, "")
if (text != null && text.length > 0) return true
Snackbar.make(findViewById(android.R.id.content), R.string.proxy_empty, Snackbar.LENGTH_LONG).show
false
}
/** Called when connect button is clicked. */
def serviceLoad() {
bgService.use(app.profileId)