@@ -4,41 +4,36 @@ import android.service.quicksettings.Tile
44import android.widget.Toast
55import com.wstxda.toolkit.R
66import com.wstxda.toolkit.base.BaseTileService
7- import com.wstxda.toolkit.manager.tools.SosManager
7+ import com.wstxda.toolkit.manager.tools.SosModule
88import com.wstxda.toolkit.ui.icon.SosIconProvider
99import com.wstxda.toolkit.ui.label.SosLabelProvider
1010import kotlinx.coroutines.flow.Flow
1111
1212class SosTileService : BaseTileService () {
1313
14- private val sosManager by lazy { SosManager (applicationContext) }
14+ private val sosModule by lazy { SosModule .getInstance (applicationContext) }
1515 private val sosLabelProvider by lazy { SosLabelProvider (applicationContext) }
1616 private val sosIconProvider by lazy { SosIconProvider (applicationContext) }
1717
18- override fun onDestroy () {
19- super .onDestroy()
20- sosManager.cleanup()
21- }
22-
2318 override fun onClick () {
24- if (! sosManager .hasFlashHardware()) {
19+ if (! sosModule .hasFlashHardware()) {
2520 Toast .makeText(this , getString(R .string.not_supported), Toast .LENGTH_SHORT ).show()
2621 return
2722 }
2823
2924 if (qsTile?.state == Tile .STATE_UNAVAILABLE ) return
3025
31- sosManager .toggle()
26+ sosModule .toggle()
3227 }
3328
3429 override fun flowsToCollect (): List <Flow <* >> {
35- return listOf (sosManager .isActive, sosManager .isFlashAvailable)
30+ return listOf (sosModule .isActive, sosModule .isFlashAvailable)
3631 }
3732
3833 override fun updateTile () {
39- val active = sosManager .isActive.value
40- val isHardwareAvailable = sosManager .hasFlashHardware()
41- val isSystemAvailable = sosManager .isFlashAvailable.value
34+ val active = sosModule .isActive.value
35+ val isHardwareAvailable = sosModule .hasFlashHardware()
36+ val isSystemAvailable = sosModule .isFlashAvailable.value
4237 val isFullyAvailable = isHardwareAvailable && isSystemAvailable
4338
4439 setTileState(
0 commit comments