Switch to compat methods wherever possible

* Introduce custom compat methods with DEPRECATION suppressed if not present in public library

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2023-10-30 18:33:33 +05:30
parent 0d62abe6eb
commit a0a68d35cf
7 changed files with 41 additions and 28 deletions

View File

@@ -40,3 +40,13 @@ inline fun <reified T : Context> Context.newIntent(flags: Int, extras: Bundle):
intent.putExtras(extras)
return intent
}
fun Intent.applyUninstallActionCompat() {
if (isPAndAbove()) {
action = Intent.ACTION_DELETE
} else {
@Suppress("DEPRECATION")
action = Intent.ACTION_UNINSTALL_PACKAGE
putExtra(Intent.EXTRA_RETURN_RESULT, true)
}
}