Skip to content

Commit

Permalink
fix: Repair buggy settings tile
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3rko committed Feb 12, 2024
1 parent d1eef52 commit 486fa06
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ import com.cyb3rko.flashdim.handleFlashlightException
import com.cyb3rko.flashdim.utils.Safe

class DimmerSettingsTile : TileService() {
private var description = ""

override fun onClick() {
if (qsTile.state == Tile.STATE_UNAVAILABLE) return
Safe.initialize(applicationContext)
val mode = Safe.getInt(Safe.QUICKTILE_DIM_MODE, DIMMER_MIN)
description = mode.description()

val maxLevel = Safe.getInt(Safe.MAX_LEVEL, -1)
val newLevel = when (mode) {
Expand Down Expand Up @@ -67,6 +70,7 @@ class DimmerSettingsTile : TileService() {
object : CameraManager.TorchCallback() {
override fun onTorchModeChanged(cameraId: String, enabled: Boolean) {
if (qsTile == null) return
if (description.isNotEmpty()) qsTile.subtitle = "State: $description"
qsTile.state = if (enabled) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE
qsTile.updateTile()
}
Expand Down

0 comments on commit 486fa06

Please sign in to comment.