diff --git a/src/main/scala/com/github/shadowsocks/BaseService.scala b/src/main/scala/com/github/shadowsocks/BaseService.scala index 12c61eb4..e8db2fdf 100644 --- a/src/main/scala/com/github/shadowsocks/BaseService.scala +++ b/src/main/scala/com/github/shadowsocks/BaseService.scala @@ -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 diff --git a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala index 63907dba..6f6d1f39 100644 --- a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala +++ b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala @@ -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)