mirror of
https://github.com/SimpleMobileTools/Simple-Launcher.git
synced 2025-06-05 21:59:15 +02:00
handle long pressing icons at the desktop too
This commit is contained in:
@ -1,7 +1,16 @@
|
||||
package com.simplemobiletools.launcher.extensions
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.provider.Settings
|
||||
import android.view.ContextThemeWrapper
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.PopupMenu
|
||||
import com.simplemobiletools.commons.extensions.getPopupMenuTheme
|
||||
import com.simplemobiletools.commons.extensions.showErrorToast
|
||||
import com.simplemobiletools.launcher.R
|
||||
|
||||
fun Activity.launchApp(packageName: String) {
|
||||
val launchIntent = packageManager.getLaunchIntentForPackage(packageName)
|
||||
@ -11,3 +20,26 @@ fun Activity.launchApp(packageName: String) {
|
||||
showErrorToast(e)
|
||||
}
|
||||
}
|
||||
|
||||
fun Activity.launchAppInfo(packageName: String) {
|
||||
Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).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)
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
show()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user