diff --git a/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyTileService.kt b/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyTileService.kt index 0516804..89f9cf0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyTileService.kt +++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyTileService.kt @@ -10,13 +10,24 @@ class MyTileService : TileService() { override fun onClick() { MyCameraImpl.newInstance(this).toggleFlashlight() - - qsTile.state = if (MyCameraImpl.isFlashlightOn) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE - qsTile.updateTile() + updateTile() } override fun onTileRemoved() { if (MyCameraImpl.isFlashlightOn) MyCameraImpl.newInstance(this).toggleFlashlight() } -} \ No newline at end of file + + override fun onStartListening() { + updateTile() + } + + override fun onTileAdded() { + updateTile() + } + + private fun updateTile() { + qsTile.state = if (MyCameraImpl.isFlashlightOn) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE + qsTile.updateTile() + } +}