allow uninstalling apps

This commit is contained in:
tibbi
2022-09-18 21:12:53 +02:00
parent 155e21188d
commit 1465497601
4 changed files with 17 additions and 3 deletions

View File

@ -28,15 +28,21 @@ fun Activity.launchAppInfo(packageName: String) {
}
}
fun Activity.uninstallApp(packageName: String) {
Intent(Intent.ACTION_DELETE).apply {
data = Uri.fromParts("package", packageName, null)
startActivity(this)
}
}
fun Activity.handleAppIconPopupMenu(anchorView: View, appPackageName: String) {
val contextTheme = ContextThemeWrapper(this, getPopupMenuTheme())
PopupMenu(contextTheme, anchorView, Gravity.TOP or Gravity.END).apply {
inflate(R.menu.menu_app_icon)
setOnMenuItemClickListener { item ->
when (item.itemId) {
R.id.app_info -> {
launchAppInfo(appPackageName)
}
R.id.app_info -> launchAppInfo(appPackageName)
R.id.uninstall -> uninstallApp(appPackageName)
}
true
}