Search in sources :

Example 56 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Trebuchet by LineageOS.

the class LoggerUtils method newItemTarget.

public static Target newItemTarget(ItemInfo info, InstantAppResolver instantAppResolver) {
    Target t = newTarget(Target.Type.ITEM);
    switch(info.itemType) {
        case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
            t.itemType = (instantAppResolver != null && info instanceof AppInfo && instantAppResolver.isInstantApp(((AppInfo) info))) ? ItemType.WEB_APP : ItemType.APP_ICON;
            t.predictedRank = DEFAULT_PREDICTED_RANK;
            break;
        case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
            t.itemType = ItemType.SHORTCUT;
            t.predictedRank = DEFAULT_PREDICTED_RANK;
            break;
        case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
            t.itemType = ItemType.FOLDER_ICON;
            break;
        case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
            t.itemType = ItemType.WIDGET;
            break;
        case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT:
            t.itemType = ItemType.DEEPSHORTCUT;
            t.predictedRank = DEFAULT_PREDICTED_RANK;
            break;
    }
    return t;
}
Also used : Target(com.android.launcher3.userevent.nano.LauncherLogProto.Target) ButtonDropTarget(com.android.launcher3.ButtonDropTarget) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 57 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project Neo-Launcher by NeoApplications.

the class IconPreview method applyPreviewIcons.

private void applyPreviewIcons() {
    for (int i = 0; i < 5; i++) {
        BubbleTextView icon = (BubbleTextView) mLauncher.getLayoutInflater().inflate(R.layout.all_apps_icon, this, false);
        LayoutParams lp = (LayoutParams) icon.getLayoutParams();
        lp.height = mLauncher.getDeviceProfile().allAppsCellHeightPx;
        lp.width = 0;
        lp.weight = 1;
        addView(icon);
    }
    for (int i = 0; i < 5; i++) {
        BubbleTextView icon = (BubbleTextView) getChildAt(i);
        icon.reset();
        icon.setVisibility(View.VISIBLE);
        icon.applyFromApplicationInfo((AppInfo) mPreviewApps.get(getRandomApp()));
        icon.setTextColor(mIconTextColor);
    }
    mLauncher.reapplyUi();
}
Also used : BubbleTextView(com.android.launcher3.BubbleTextView)

Example 58 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project Neo-Launcher by NeoApplications.

the class AppSearchProvider method listToCursor.

private Cursor listToCursor(final List<AppInfo> list) {
    final MatrixCursor matrixCursor = new MatrixCursor(AppSearchProvider.eK, list.size());
    final UserManagerCompat instance = UserManagerCompat.getInstance(this.getContext());
    int n = 0;
    for (AppInfo appInfo : list) {
        final String uri = buildUri(appInfo, instance).toString();
        final MatrixCursor.RowBuilder row = matrixCursor.newRow();
        row.add(n++).add(appInfo.title.toString()).add(uri).add("com.google.android.apps.nexuslauncher.search.APP_LAUNCH").add(uri);
    }
    return matrixCursor;
}
Also used : UserManagerCompat(com.android.launcher3.compat.UserManagerCompat) MatrixCursor(android.database.MatrixCursor) AppInfo(com.android.launcher3.AppInfo)

Example 59 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project Neo-Launcher by NeoApplications.

the class PredictionUiStateManager method updateDependencies.

private void updateDependencies(PredictionState state) {
    if (!state.isEnabled || mAppsView == null) {
        return;
    }
    IconCache iconCache = LauncherAppState.getInstance(mContext).getIconCache();
    List<String> instantAppsToLoad = new ArrayList<>();
    List<ShortcutKey> shortcutsToLoad = new ArrayList<>();
    int total = state.apps.size();
    for (int i = 0, count = 0; i < total && count < mMaxIconsPerRow; i++) {
        ComponentKeyMapper mapper = state.apps.get(i);
        // Update instant apps
        if (COMPONENT_CLASS_MARKER.equals(mapper.getComponentClass())) {
            instantAppsToLoad.add(mapper.getPackage());
            count++;
        } else if (mapper.getComponentKey() instanceof ShortcutKey) {
            shortcutsToLoad.add((ShortcutKey) mapper.getComponentKey());
            count++;
        } else {
            // Reload high res icon
            AppInfo info = (AppInfo) mapper.getApp(mAppsView.getAppsStore());
            if (info != null) {
                if (info.usingLowResIcon()) {
                    // TODO: Update icon cache to support null callbacks.
                    iconCache.updateIconInBackground(this, info);
                }
                count++;
            }
        }
    }
    mDynamicItemCache.cacheItems(shortcutsToLoad, instantAppsToLoad);
}
Also used : IconCache(com.android.launcher3.icons.IconCache) ArrayList(java.util.ArrayList) ShortcutKey(com.android.launcher3.shortcuts.ShortcutKey) AppInfo(com.android.launcher3.AppInfo)

Example 60 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project Neo-Launcher by NeoApplications.

the class CacheDataUpdatedTaskTest method testCacheUpdate_update_apps.

@Test
// b/131115553
@Ignore("This test fails with resource errors")
public void testCacheUpdate_update_apps() throws Exception {
    // Clear all icons from apps list so that its easy to check what was updated
    for (AppInfo info : allAppsList.data) {
        info.iconBitmap = null;
    }
    executeTaskForTest(newTask(CacheDataUpdatedTask.OP_CACHE_UPDATE, "app1"));
    // Verify that only the app icons of app1 (id 1 & 2) are updated. Custom shortcut (id 7)
    // is not updated
    verifyUpdate(1, 2);
    // Verify that only app1 var updated in allAppsList
    assertFalse(allAppsList.data.isEmpty());
    for (AppInfo info : allAppsList.data) {
        if (info.componentName.getPackageName().equals("app1")) {
            assertNotNull(info.iconBitmap);
        } else {
            assertNull(info.iconBitmap);
        }
    }
}
Also used : AppInfo(com.android.launcher3.AppInfo) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

AppInfo (com.android.launcher3.model.data.AppInfo)181 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)86 ItemInfo (com.android.launcher3.model.data.ItemInfo)46 ArrayList (java.util.ArrayList)46 ComponentName (android.content.ComponentName)36 AppInfo (com.android.launcher3.AppInfo)33 View (android.view.View)32 LauncherActivityInfo (android.content.pm.LauncherActivityInfo)31 Intent (android.content.Intent)30 FolderInfo (com.android.launcher3.model.data.FolderInfo)30 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)30 UserHandle (android.os.UserHandle)21 PackageItemInfo (com.android.launcher3.model.data.PackageItemInfo)21 PendingAddShortcutInfo (com.android.launcher3.widget.PendingAddShortcutInfo)21 Point (android.graphics.Point)19 BubbleTextView (com.android.launcher3.BubbleTextView)19 LauncherApps (android.content.pm.LauncherApps)17 ItemInfoWithIcon (com.android.launcher3.model.data.ItemInfoWithIcon)17 PendingAddItemInfo (com.android.launcher3.PendingAddItemInfo)15 AppWidgetHostView (android.appwidget.AppWidgetHostView)14