Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Tile/Dimmer): restart cycle if torch was disabled #78

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ import com.cyb3rko.flashdim.utils.Safe

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

override fun onClick() {
if (qsTile.state == Tile.STATE_UNAVAILABLE) return
Safe.initialize(applicationContext)
val mode = Safe.getInt(Safe.QUICKTILE_DIM_MODE, DIMMER_MIN)
var mode = Safe.getInt(Safe.QUICKTILE_DIM_MODE, DIMMER_MIN)
if (!enabled)
// torch was disabled externally, continue again from initial state
mode = DIMMER_MIN
description = mode.description()

val maxLevel = Safe.getInt(Safe.MAX_LEVEL, -1)
Expand Down Expand Up @@ -70,9 +74,12 @@ 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.subtitle =
if (description.isNotEmpty() && enabled) "State: $description"
else "State: ${DIMMER_OFF.description()}"
qsTile.state = if (enabled) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE
qsTile.updateTile()
[email protected] = enabled
}
},
Handler(Looper.getMainLooper())
Expand Down
Loading