blob: 23a333475541d9e995960f7f5f06b09b2e724665 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
package moe.yuuta.workmode.suspend
import android.content.Intent
import android.service.quicksettings.Tile
import android.service.quicksettings.TileService
import moe.yuuta.workmode.suspend.data.Status
import moe.yuuta.workmode.suspend.data.SuspendedStorage
class SuspendTile : TileService() {
override fun onClick() {
val storage = SuspendedStorage.get(this)
storage.setStatus(
when (storage.getStatus()) {
Status.ON -> Status.OFF
Status.OFF -> Status.ON
}
)
sendBroadcast(Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS))
Suspender(this).applyFromSettings()
}
override fun onStartListening() {
val tile = qsTile
tile.state = when (SuspendedStorage.get(this@SuspendTile).getStatus()) {
Status.ON -> Tile.STATE_ACTIVE
Status.OFF -> Tile.STATE_INACTIVE
}
tile.updateTile()
}
}
|