Java Code Examples for android.content.pm.LauncherActivityInfo#getComponentName()

The following examples show how to use android.content.pm.LauncherActivityInfo#getComponentName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IconCache.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds an entry into the DB and the in-memory cache.
 * @param replaceExisting if true, it will recreate the bitmap even if it already exists in
 *                        the memory. This is useful then the previous bitmap was created using
 *                        old data.
 */
@Thunk private synchronized void addIconToDBAndMemCache(LauncherActivityInfo app,
        PackageInfo info, long userSerial, boolean replaceExisting) {
    final ComponentKey key = new ComponentKey(app.getComponentName(), app.getUser());
    CacheEntry entry = null;
    if (!replaceExisting) {
        entry = mCache.get(key);
        // We can't reuse the entry if the high-res icon is not present.
        if (entry == null || entry.isLowResIcon || entry.icon == null) {
            entry = null;
        }
    }
    if (entry == null) {
        entry = new CacheEntry();
        entry.icon = LauncherIcons.createBadgedIconBitmap(getFullResIcon(app), app.getUser(),
                mContext,  app.getApplicationInfo().targetSdkVersion);
    }
    entry.title = app.getLabel();
    entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, app.getUser());
    mCache.put(key, entry);

    Bitmap lowResIcon = generateLowResIcon(entry.icon, mActivityBgColor);
    ContentValues values = newContentValues(entry.icon, lowResIcon, entry.title.toString(),
            app.getApplicationInfo().packageName);
    addIconToDB(values, app.getComponentName(), info, userSerial);
}
 
Example 2
Source File: IconCache.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
public void addCustomInfoToDataBase(Drawable icon, ItemInfo info, CharSequence title) {
    LauncherActivityInfo app = mLauncherApps.resolveActivity(info.getIntent(), info.user);
    final ComponentKey key = new ComponentKey(app.getComponentName(), app.getUser());
    CacheEntry entry = mCache.get(key);
    PackageInfo packageInfo = null;
    try {
        packageInfo = mPackageManager.getPackageInfo(
                app.getComponentName().getPackageName(), 0);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    // We can't reuse the entry if the high-res icon is not present.
    if (entry == null || entry.isLowResIcon || entry.icon == null) {
        entry = new CacheEntry();
    }
    entry.icon = LauncherIcons.createIconBitmap(icon, mContext);

    entry.title = title != null ? title : app.getLabel();

    entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, app.getUser());
    mCache.put(key, entry);

    Bitmap lowResIcon = generateLowResIcon(entry.icon, mActivityBgColor);
    ContentValues values = newContentValues(entry.icon, lowResIcon, entry.title.toString(),
            app.getApplicationInfo().packageName);
    if (packageInfo != null) {
        addIconToDB(values, app.getComponentName(), packageInfo,
                mUserManager.getSerialNumberForUser(app.getUser()));
    }
}
 
Example 3
Source File: AppInfo.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
public AppInfo(LauncherActivityInfo info, UserHandle user, boolean quietModeEnabled) {
    this.componentName = info.getComponentName();
    this.container = ItemInfo.NO_ID;
    this.user = user;
    if (PackageManagerHelper.isAppSuspended(info.getApplicationInfo())) {
        isDisabled |= ShortcutInfo.FLAG_DISABLED_SUSPENDED;
    }
    if (quietModeEnabled) {
        isDisabled |= ShortcutInfo.FLAG_DISABLED_QUIET_USER;
    }

    intent = makeLaunchIntent(info);
}
 
Example 4
Source File: ShortcutConfigActivityInfo.java    From LaunchEnr with GNU General Public License v3.0 4 votes vote down vote up
ShortcutConfigActivityInfoVO(LauncherActivityInfo info) {
    super(info.getComponentName(), info.getUser());
    mInfo = info;
}
 
Example 5
Source File: IconCache.java    From LaunchEnr with GNU General Public License v3.0 4 votes vote down vote up
public CacheEntry getCacheEntry(LauncherActivityInfo app) {
    final ComponentKey key = new ComponentKey(app.getComponentName(), app.getUser());
    return mCache.get(key);
}