Skip to content

Commit 1a5e105

Browse files
authored
Fix blinking QSTile when QS panel is opening (#4676)
1 parent e0881ca commit 1a5e105

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

V2rayNG/app/src/main/java/com/v2ray/ang/service/QSTileService.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@ class QSTileService : TileService() {
2525
* @param state The state to set.
2626
*/
2727
fun setState(state: Int) {
28+
qsTile?.icon = Icon.createWithResource(applicationContext, R.drawable.ic_stat_name)
2829
if (state == Tile.STATE_INACTIVE) {
2930
qsTile?.state = Tile.STATE_INACTIVE
3031
qsTile?.label = getString(R.string.app_name)
31-
qsTile?.icon = Icon.createWithResource(applicationContext, R.drawable.ic_stat_name)
3232
} else if (state == Tile.STATE_ACTIVE) {
3333
qsTile?.state = Tile.STATE_ACTIVE
3434
qsTile?.label = V2RayServiceManager.getRunningServerName()
35-
qsTile?.icon = Icon.createWithResource(applicationContext, R.drawable.ic_stat_name)
3635
}
3736

3837
qsTile?.updateTile()
@@ -45,7 +44,11 @@ class QSTileService : TileService() {
4544
override fun onStartListening() {
4645
super.onStartListening()
4746

48-
setState(Tile.STATE_INACTIVE)
47+
if (V2RayServiceManager.isRunning()) {
48+
setState(Tile.STATE_ACTIVE)
49+
} else {
50+
setState(Tile.STATE_INACTIVE)
51+
}
4952
mMsgReceive = ReceiveMessageHandler(this)
5053
val mFilter = IntentFilter(AppConfig.BROADCAST_ACTION_ACTIVITY)
5154
ContextCompat.registerReceiver(applicationContext, mMsgReceive, mFilter, Utils.receiverFlags())

0 commit comments

Comments
 (0)