Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b665c8b authored by Christopher Jakob's avatar Christopher Jakob
Browse files

Turn off flashlight when tile is removed

parent a304f4fc
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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