Search in sources :

Example 6 with LauncherApps

use of android.content.pm.LauncherApps in project KISS by Neamar.

the class AppResult method doLaunch.

@Override
public void doLaunch(Context context, View v) {
    try {
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            LauncherApps launcher = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
            launcher.startMainActivity(className, appPojo.userHandle.getRealHandle(), v.getClipBounds(), null);
        } else {
            Intent intent = new Intent(Intent.ACTION_MAIN);
            intent.addCategory(Intent.CATEGORY_LAUNCHER);
            intent.setComponent(className);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
            if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
                intent.setSourceBounds(v.getClipBounds());
            }
            context.startActivity(intent);
        }
    } catch (ActivityNotFoundException e) {
        // Application was just removed?
        Toast.makeText(context, R.string.application_not_found, Toast.LENGTH_LONG).show();
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) LauncherApps(android.content.pm.LauncherApps) Intent(android.content.Intent)

Example 7 with LauncherApps

use of android.content.pm.LauncherApps in project KISS by Neamar.

the class AppResult method buildPopupMenu.

@Override
protected PopupMenu buildPopupMenu(Context context, final RecordAdapter parent, View parentView) {
    PopupMenu menu = inflatePopupMenu(R.menu.menu_item_app, context, parentView);
    if ((context instanceof MainActivity) && (!((MainActivity) context).isOnSearchView())) {
        menu.getMenu().removeItem(R.id.item_remove);
    }
    try {
        // app installed under /system can't be uninstalled
        boolean isSameProfile = true;
        ApplicationInfo ai;
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            LauncherApps launcher = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
            LauncherActivityInfo info = launcher.getActivityList(this.appPojo.packageName, this.appPojo.userHandle.getRealHandle()).get(0);
            ai = info.getApplicationInfo();
            isSameProfile = this.appPojo.userHandle.isCurrentUser();
        } else {
            ai = context.getPackageManager().getApplicationInfo(this.appPojo.packageName, 0);
        }
        // Need to AND the flags with SYSTEM:
        if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) == 0 && isSameProfile) {
            menu.getMenuInflater().inflate(R.menu.menu_item_app_uninstall, menu.getMenu());
        }
    } catch (NameNotFoundException | IndexOutOfBoundsException e) {
    // should not happen
    }
    //append root menu if available
    if (KissApplication.getRootHandler(context).isRootActivated() && KissApplication.getRootHandler(context).isRootAvailable()) {
        menu.getMenuInflater().inflate(R.menu.menu_item_app_root, menu.getMenu());
    }
    return menu;
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ApplicationInfo(android.content.pm.ApplicationInfo) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) LauncherApps(android.content.pm.LauncherApps) MainActivity(fr.neamar.kiss.MainActivity) PopupMenu(android.widget.PopupMenu)

Example 8 with LauncherApps

use of android.content.pm.LauncherApps in project KISS by Neamar.

the class AppResult method launchAppDetails.

/**
     * Open an activity displaying details regarding the current package
     */
private void launchAppDetails(Context context, AppPojo app) {
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        LauncherApps launcher = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
        launcher.startAppDetailsActivity(className, appPojo.userHandle.getRealHandle(), null, null);
    } else {
        Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", app.packageName, null));
        context.startActivity(intent);
    }
}
Also used : LauncherApps(android.content.pm.LauncherApps) Intent(android.content.Intent)

Example 9 with LauncherApps

use of android.content.pm.LauncherApps in project platform_frameworks_base by android.

the class AppWidgetHostView method updateContentDescription.

private void updateContentDescription(AppWidgetProviderInfo info) {
    if (info != null) {
        LauncherApps launcherApps = getContext().getSystemService(LauncherApps.class);
        ApplicationInfo appInfo = launcherApps.getApplicationInfo(info.provider.getPackageName(), 0, info.getProfile());
        if (appInfo != null && (appInfo.flags & ApplicationInfo.FLAG_SUSPENDED) != 0) {
            setContentDescription(Resources.getSystem().getString(com.android.internal.R.string.suspended_widget_accessibility, info.label));
        } else {
            setContentDescription(info.label);
        }
    }
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) LauncherApps(android.content.pm.LauncherApps)

Example 10 with LauncherApps

use of android.content.pm.LauncherApps in project android_frameworks_base by DirtyUnicorns.

the class AppWidgetHostView method updateContentDescription.

private void updateContentDescription(AppWidgetProviderInfo info) {
    if (info != null) {
        LauncherApps launcherApps = getContext().getSystemService(LauncherApps.class);
        ApplicationInfo appInfo = launcherApps.getApplicationInfo(info.provider.getPackageName(), 0, info.getProfile());
        if (appInfo != null && (appInfo.flags & ApplicationInfo.FLAG_SUSPENDED) != 0) {
            setContentDescription(Resources.getSystem().getString(com.android.internal.R.string.suspended_widget_accessibility, info.label));
        } else {
            setContentDescription(info.label);
        }
    }
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) LauncherApps(android.content.pm.LauncherApps)

Aggregations

LauncherApps (android.content.pm.LauncherApps)11 ApplicationInfo (android.content.pm.ApplicationInfo)7 Intent (android.content.Intent)4 LauncherActivityInfo (android.content.pm.LauncherActivityInfo)3 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)2 UserManager (android.os.UserManager)2 UserHandle (fr.neamar.kiss.utils.UserHandle)2 ActivityNotFoundException (android.content.ActivityNotFoundException)1 BroadcastReceiver (android.content.BroadcastReceiver)1 Context (android.content.Context)1 IntentFilter (android.content.IntentFilter)1 PackageManager (android.content.pm.PackageManager)1 ResolveInfo (android.content.pm.ResolveInfo)1 PopupMenu (android.widget.PopupMenu)1 MainActivity (fr.neamar.kiss.MainActivity)1 LoadAppPojos (fr.neamar.kiss.loader.LoadAppPojos)1 AppPojo (fr.neamar.kiss.pojo.AppPojo)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1