修复未激活模块磁贴服务FC

This commit is contained in:
乌堆小透明
2022-03-21 19:45:26 +08:00
parent 8bcb89b04d
commit 14ca833ec1
2 changed files with 45 additions and 34 deletions

View File

@@ -3,32 +3,38 @@ package com.lt2333.simplicitytools.tile
import android.service.quicksettings.Tile
import android.service.quicksettings.TileService
class AllowScreenshots : TileService(){
class AllowScreenshots : TileService() {
val key = "disable_flag_secure"
override fun onClick() {
super.onClick()
val pref = getSharedPreferences("config", MODE_WORLD_READABLE)
val prefEditor = pref.edit()
if (pref.getBoolean(key, false)) {
prefEditor.putBoolean(key, false)
qsTile.state = Tile.STATE_INACTIVE
} else {
prefEditor.putBoolean(key, true)
qsTile.state = Tile.STATE_ACTIVE
try {
val pref = getSharedPreferences("config", MODE_WORLD_READABLE)
val prefEditor = pref.edit()
if (pref.getBoolean(key, false)) {
prefEditor.putBoolean(key, false)
qsTile.state = Tile.STATE_INACTIVE
} else {
prefEditor.putBoolean(key, true)
qsTile.state = Tile.STATE_ACTIVE
}
prefEditor.commit()
qsTile.updateTile()
} catch (e: SecurityException) {
}
prefEditor.commit()
qsTile.updateTile()
}
override fun onStartListening() {
super.onStartListening()
val pref = getSharedPreferences("config", MODE_WORLD_READABLE)
if (pref.getBoolean(key, false)) {
qsTile.state = Tile.STATE_ACTIVE
} else {
qsTile.state = Tile.STATE_INACTIVE
try {
val pref = getSharedPreferences("config", MODE_WORLD_READABLE)
if (pref.getBoolean(key, false)) {
qsTile.state = Tile.STATE_ACTIVE
} else {
qsTile.state = Tile.STATE_INACTIVE
}
qsTile.updateTile()
} catch (e: SecurityException) {
}
qsTile.updateTile()
}
}

View File

@@ -9,28 +9,33 @@ class LockMaxFpsTile : TileService() {
override fun onClick() {
super.onClick()
val pref = getSharedPreferences("config", MODE_WORLD_READABLE)
val prefEditor = pref.edit()
if (pref.getBoolean(key, false)) {
prefEditor.putBoolean(key, false)
qsTile.state = Tile.STATE_INACTIVE
} else {
prefEditor.putBoolean(key, true)
qsTile.state = Tile.STATE_ACTIVE
try {
val pref = getSharedPreferences("config", MODE_WORLD_READABLE)
val prefEditor = pref.edit()
if (pref.getBoolean(key, false)) {
prefEditor.putBoolean(key, false)
qsTile.state = Tile.STATE_INACTIVE
} else {
prefEditor.putBoolean(key, true)
qsTile.state = Tile.STATE_ACTIVE
}
prefEditor.commit()
qsTile.updateTile()
} catch (e: SecurityException) {
}
prefEditor.commit()
qsTile.updateTile()
}
override fun onStartListening() {
super.onStartListening()
val pref = getSharedPreferences("config", MODE_WORLD_READABLE)
if (pref.getBoolean(key, false)) {
qsTile.state = Tile.STATE_ACTIVE
} else {
qsTile.state = Tile.STATE_INACTIVE
try {
val pref = getSharedPreferences("config", MODE_WORLD_READABLE)
if (pref.getBoolean(key, false)) {
qsTile.state = Tile.STATE_ACTIVE
} else {
qsTile.state = Tile.STATE_INACTIVE
}
qsTile.updateTile()
} catch (e: SecurityException) {
}
qsTile.updateTile()
}
}