Hide stop action in notification if the quick settings tile is present

This commit is contained in:
Mygod
2016-06-17 14:40:33 +08:00
parent e1364c012b
commit 89df2bc715
2 changed files with 17 additions and 3 deletions
@@ -10,8 +10,14 @@ import com.github.shadowsocks.ShadowsocksApplication.app
/**
* @author Mygod
*/
object ShadowsocksTileService {
var running: Boolean = _
}
@TargetApi(24)
final class ShadowsocksTileService extends TileService with ServiceBoundContext {
import ShadowsocksTileService._
private lazy val iconIdle = Icon.createWithResource(this, R.drawable.ic_start_idle).setTint(0x80ffffff)
private lazy val iconBusy = Icon.createWithResource(this, R.drawable.ic_start_busy)
private lazy val iconConnected = Icon.createWithResource(this, R.drawable.ic_start_connected)
@@ -42,11 +48,19 @@ final class ShadowsocksTileService extends TileService with ServiceBoundContext
override def onServiceConnected = callback.stateChanged(bgService.getState, null)
override def onCreate {
super.onCreate
running = true
}
override def onDestroy {
super.onDestroy
running = false
}
override def onStartListening {
super.onStartListening
attachService(callback)
}
override def onStopListening {
super.onStopListening
detachService // just in case the user switches to NAT mode, also saves battery