Recently Written · git

ink-dim

Ink Dim: tap to set the frontlight of a Viwoods AiPaper reader below the lowest system level. Tap again to go back.

git clone https://github.com/equwal/ink-dim

Log | Files | Refs


app/src/main/java/dev/equwal/inkdim/DimTileService.kt (865 bytes)

1 // SPDX-License-Identifier: GPL-3.0-or-later
2 // Copyright (c) 2026 equwal
3 package dev.equwal.inkdim
4 
5 import android.service.quicksettings.Tile
6 import android.service.quicksettings.TileService
7 
8 /** A tile in the quick settings panel. It does the same as the icon. */
9 class DimTileService : TileService() {
10 
11     override fun onStartListening() {
12         super.onStartListening()
13         paint(Toggle.remembered(this))
14         Shell.connect(this)
15         if (Shell.ready) Toggle.live(this) { paint(it) }
16     }
17 
18     override fun onClick() {
19         super.onClick()
20         Shell.connect(this)
21         Toggle.run(this, Dim.Action.TOGGLE) { state -> if (state != null) paint(state) }
22     }
23 
24     private fun paint(on: Boolean) {
25         qsTile?.apply {
26             this.state = if (on) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE
27             updateTile()
28         }
29     }
30 }