Skip to content

Commit

Permalink
enh: Change color of dimmer tile according to flash status
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3rko committed Jan 30, 2024
1 parent be47970 commit 6e4a94f
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package com.cyb3rko.flashdim.tiles

import android.content.Context
import android.hardware.camera2.CameraManager
import android.os.Handler
import android.os.Looper
import android.service.quicksettings.Tile
import android.service.quicksettings.TileService
import android.util.Log
Expand Down Expand Up @@ -60,6 +62,17 @@ class DimmerSettingsTile : TileService() {
} else {
qsTile.state = Tile.STATE_INACTIVE
qsTile.updateTile()
val cameraManager = getSystemService(Context.CAMERA_SERVICE) as CameraManager
cameraManager.registerTorchCallback(
object : CameraManager.TorchCallback() {
override fun onTorchModeChanged(cameraId: String, enabled: Boolean) {
if (qsTile == null) return
qsTile.state = if (enabled) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE
qsTile.updateTile()
}
},
Handler(Looper.getMainLooper())
)
}
}

Expand Down

0 comments on commit 6e4a94f

Please sign in to comment.