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

@ -8,6 +8,8 @@
android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission
android:name="android.permission.USE_FINGERPRINT"
tools:node="remove" />

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
}

View file

@ -6,4 +6,9 @@
android:icon="@drawable/ic_info_vector"
android:title="@string/app_info"
app:showAsAction="always" />
<item
android:id="@+id/uninstall"
android:icon="@drawable/ic_delete_vector"
android:title="@string/uninstall"
app:showAsAction="always" />
</menu>

View file

@ -3,6 +3,7 @@
<string name="app_launcher_name">Launcher</string>
<string name="app_info">App info</string>
<string name="touch_hold_widget">Long press the widget and drag it on your home screen</string>
<string name="uninstall">Uninstall</string>
<!--
Haven't found some strings? There's more at
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res