Hide uninstall button for system apps
This commit is contained in:
parent
8d6c839c15
commit
1e4e2571dd
|
@ -584,7 +584,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
menu.findItem(R.id.hide_icon).isVisible = gridItem.type == ITEM_TYPE_ICON && isOnAllAppsFragment
|
menu.findItem(R.id.hide_icon).isVisible = gridItem.type == ITEM_TYPE_ICON && isOnAllAppsFragment
|
||||||
menu.findItem(R.id.resize).isVisible = gridItem.type == ITEM_TYPE_WIDGET
|
menu.findItem(R.id.resize).isVisible = gridItem.type == ITEM_TYPE_WIDGET
|
||||||
menu.findItem(R.id.app_info).isVisible = gridItem.type == ITEM_TYPE_ICON
|
menu.findItem(R.id.app_info).isVisible = gridItem.type == ITEM_TYPE_ICON
|
||||||
menu.findItem(R.id.uninstall).isVisible = gridItem.type == ITEM_TYPE_ICON
|
menu.findItem(R.id.uninstall).isVisible = gridItem.type == ITEM_TYPE_ICON && isUninstallable(gridItem.packageName)
|
||||||
menu.findItem(R.id.remove).isVisible = !isOnAllAppsFragment
|
menu.findItem(R.id.remove).isVisible = !isOnAllAppsFragment
|
||||||
setOnMenuItemClickListener { item ->
|
setOnMenuItemClickListener { item ->
|
||||||
resetFragmentTouches()
|
resetFragmentTouches()
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.simplemobiletools.launcher.extensions
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.pm.ApplicationInfo
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import com.simplemobiletools.commons.extensions.showErrorToast
|
import com.simplemobiletools.commons.extensions.showErrorToast
|
||||||
|
@ -41,6 +42,14 @@ fun Activity.launchAppInfo(packageName: String) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Activity.isUninstallable(packageName: String): Boolean {
|
||||||
|
return try {
|
||||||
|
(packageManager.getApplicationInfo(packageName, 0).flags and ApplicationInfo.FLAG_SYSTEM) == 0
|
||||||
|
} catch (ignored: Exception) {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun Activity.uninstallApp(packageName: String) {
|
fun Activity.uninstallApp(packageName: String) {
|
||||||
Intent(Intent.ACTION_DELETE).apply {
|
Intent(Intent.ACTION_DELETE).apply {
|
||||||
data = Uri.fromParts("package", packageName, null)
|
data = Uri.fromParts("package", packageName, null)
|
||||||
|
|
Loading…
Reference in New Issue