Turn off flashlight when tile is removed

This commit is contained in:
Christopher Jakob 2017-11-22 21:37:21 +01:00
parent a304f4fc02
commit 0b665c8b8f
1 changed files with 6 additions and 0 deletions

View File

@ -7,10 +7,16 @@ import android.support.annotation.RequiresApi
@RequiresApi(Build.VERSION_CODES.N)
class MyTileService : TileService() {
override fun onClick() {
MyCameraImpl.newInstance(this).toggleFlashlight()
qsTile.state = if (MyCameraImpl.isFlashlightOn) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE
qsTile.updateTile()
}
override fun onTileRemoved() {
if (MyCameraImpl.isFlashlightOn)
MyCameraImpl.newInstance(this).toggleFlashlight()
}
}