From 0b665c8b8fc797ad8bde3f05f830bc5bd83acbba Mon Sep 17 00:00:00 2001 From: Christopher Jakob Date: Wed, 22 Nov 2017 21:37:21 +0100 Subject: [PATCH] Turn off flashlight when tile is removed --- .../simplemobiletools/flashlight/helpers/MyTileService.kt | 6 ++++++ 1 file changed, 6 insertions(+) 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 35c24c6..0516804 100644 --- a/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyTileService.kt +++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyTileService.kt @@ -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() + } } \ No newline at end of file