mirror of https://github.com/x13a/Wasted.git
add toast when admin disabled from settings and wasted is on
This commit is contained in:
parent
e25b9351de
commit
70d516ed64
|
@ -5,6 +5,7 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.UserHandle
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
class DeviceAdminReceiver : DeviceAdminReceiver() {
|
||||
|
@ -20,6 +21,17 @@ class DeviceAdminReceiver : DeviceAdminReceiver() {
|
|||
onPasswordFailedInternal(context)
|
||||
}
|
||||
|
||||
override fun onDisabled(context: Context, intent: Intent) {
|
||||
super.onDisabled(context, intent)
|
||||
if (Preferences(context).isServiceEnabled) {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.service_unavailable_popup),
|
||||
Toast.LENGTH_SHORT,
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
private fun onPasswordFailedInternal(ctx: Context) {
|
||||
val prefs = Preferences(ctx)
|
||||
if (!prefs.isServiceEnabled || prefs.maxFailedPasswordAttempts == 0) return
|
||||
|
|
|
@ -111,10 +111,10 @@ open class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
private fun setOff() {
|
||||
admin.remove()
|
||||
prefs.isServiceEnabled = false
|
||||
setCodeReceiverState(this, false)
|
||||
shortcut.remove()
|
||||
prefs.isServiceEnabled = false
|
||||
admin.remove()
|
||||
}
|
||||
|
||||
private fun requestAdmin() = requestAdminPolicy.launch(admin.makeRequestIntent())
|
||||
|
|
Loading…
Reference in New Issue