mirror of https://github.com/x13a/Wasted.git
disable tile when off
This commit is contained in:
parent
de385837c1
commit
218012b8fc
|
@ -86,6 +86,7 @@
|
|||
android:icon="@android:drawable/ic_lock_lock"
|
||||
android:label="@string/tile_label"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
android:enabled="false"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE" />
|
||||
|
|
|
@ -169,6 +169,7 @@ open class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
prefs.isServiceEnabled = true
|
||||
setCodeReceiverState(prefs.isCodeEnabled)
|
||||
setTileState(true)
|
||||
shortcut.push()
|
||||
}
|
||||
|
||||
|
@ -184,6 +185,7 @@ open class MainActivity : AppCompatActivity() {
|
|||
prefs.isServiceEnabled = false
|
||||
setCodeReceiverState(false)
|
||||
setWipeOnInactivityComponentsState(false)
|
||||
setTileState(false)
|
||||
shortcut.remove()
|
||||
admin.remove()
|
||||
}
|
||||
|
@ -191,11 +193,13 @@ open class MainActivity : AppCompatActivity() {
|
|||
private fun requestAdmin() = requestAdminPolicy.launch(admin.makeRequestIntent())
|
||||
private fun makeCode(): String = UUID.randomUUID().toString()
|
||||
private fun setCodeReceiverState(value: Boolean) =
|
||||
setReceiverState(CodeReceiver::class.java, value)
|
||||
setComponentState(CodeReceiver::class.java, value)
|
||||
private fun setRestartReceiverState(value: Boolean) =
|
||||
setReceiverState(RestartReceiver::class.java, value)
|
||||
setComponentState(RestartReceiver::class.java, value)
|
||||
private fun setTileState(value: Boolean) =
|
||||
setComponentState(QSTileService::class.java, value)
|
||||
|
||||
private fun setReceiverState(cls: Class<*>, value: Boolean) {
|
||||
private fun setComponentState(cls: Class<*>, value: Boolean) {
|
||||
packageManager.setComponentEnabledSetting(
|
||||
ComponentName(this, cls),
|
||||
if (value) PackageManager.COMPONENT_ENABLED_STATE_ENABLED else
|
||||
|
|
Loading…
Reference in New Issue