Fix blinking QSTile when QS panel is opening (#4676)

This commit is contained in:
Ural Khamitov 2025-06-18 13:17:28 +05:00 committed by GitHub
parent e0881caab4
commit 1a5e105212
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -25,14 +25,13 @@ class QSTileService : TileService() {
* @param state The state to set. * @param state The state to set.
*/ */
fun setState(state: Int) { fun setState(state: Int) {
qsTile?.icon = Icon.createWithResource(applicationContext, R.drawable.ic_stat_name)
if (state == Tile.STATE_INACTIVE) { if (state == Tile.STATE_INACTIVE) {
qsTile?.state = Tile.STATE_INACTIVE qsTile?.state = Tile.STATE_INACTIVE
qsTile?.label = getString(R.string.app_name) qsTile?.label = getString(R.string.app_name)
qsTile?.icon = Icon.createWithResource(applicationContext, R.drawable.ic_stat_name)
} else if (state == Tile.STATE_ACTIVE) { } else if (state == Tile.STATE_ACTIVE) {
qsTile?.state = Tile.STATE_ACTIVE qsTile?.state = Tile.STATE_ACTIVE
qsTile?.label = V2RayServiceManager.getRunningServerName() qsTile?.label = V2RayServiceManager.getRunningServerName()
qsTile?.icon = Icon.createWithResource(applicationContext, R.drawable.ic_stat_name)
} }
qsTile?.updateTile() qsTile?.updateTile()
@ -45,7 +44,11 @@ class QSTileService : TileService() {
override fun onStartListening() { override fun onStartListening() {
super.onStartListening() super.onStartListening()
setState(Tile.STATE_INACTIVE) if (V2RayServiceManager.isRunning()) {
setState(Tile.STATE_ACTIVE)
} else {
setState(Tile.STATE_INACTIVE)
}
mMsgReceive = ReceiveMessageHandler(this) mMsgReceive = ReceiveMessageHandler(this)
val mFilter = IntentFilter(AppConfig.BROADCAST_ACTION_ACTIVITY) val mFilter = IntentFilter(AppConfig.BROADCAST_ACTION_ACTIVITY)
ContextCompat.registerReceiver(applicationContext, mMsgReceive, mFilter, Utils.receiverFlags()) ContextCompat.registerReceiver(applicationContext, mMsgReceive, mFilter, Utils.receiverFlags())