Search in sources :

Example 16 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class WidgetsListTableViewHolderBinderTest method generateSampleAppWithWidgets.

private WidgetsListContentEntry generateSampleAppWithWidgets(String appName, String packageName, int numOfWidgets) {
    PackageItemInfo appInfo = new PackageItemInfo(packageName);
    appInfo.title = appName;
    appInfo.bitmap = BitmapInfo.of(Bitmap.createBitmap(10, 10, Bitmap.Config.ALPHA_8), 0);
    return new WidgetsListContentEntry(appInfo, /* titleSectionName= */
    "", generateWidgetItems(packageName, numOfWidgets));
}
Also used : PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry)

Example 17 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class LauncherModelHelper method initializeData.

/**
 * Initializes mock data for the test.
 */
public void initializeData(String resourceName) throws Exception {
    Context targetContext = RuntimeEnvironment.application;
    BgDataModel bgDataModel = getBgDataModel();
    AllAppsList allAppsList = getAllAppsList();
    MODEL_EXECUTOR.submit(() -> {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream(resourceName)))) {
            String line;
            HashMap<String, Class> classMap = new HashMap<>();
            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (line.startsWith("#") || line.isEmpty()) {
                    continue;
                }
                String[] commands = line.split(" ");
                switch(commands[0]) {
                    case "classMap":
                        classMap.put(commands[1], Class.forName(commands[2]));
                        break;
                    case "bgItem":
                        bgDataModel.addItem(targetContext, (ItemInfo) initItem(classMap.get(commands[1]), commands, 2), false);
                        break;
                    case "allApps":
                        allAppsList.add((AppInfo) initItem(AppInfo.class, commands, 1), null);
                        break;
                }
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }).get();
}
Also used : Context(android.content.Context) InputStreamReader(java.io.InputStreamReader) HashMap(java.util.HashMap) ItemInfo(com.android.launcher3.model.data.ItemInfo) BgDataModel(com.android.launcher3.model.BgDataModel) AllAppsList(com.android.launcher3.model.AllAppsList) BufferedReader(java.io.BufferedReader) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ExecutionException(java.util.concurrent.ExecutionException) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 18 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class ItemClickHandler method startAppShortcutOrInfoActivity.

private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher) {
    TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: startAppShortcutOrInfoActivity");
    Intent intent;
    if (item instanceof ItemInfoWithIcon && (((ItemInfoWithIcon) item).runtimeStatusFlags & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
        ItemInfoWithIcon appInfo = (ItemInfoWithIcon) item;
        intent = new PackageManagerHelper(launcher).getMarketIntent(appInfo.getTargetComponent().getPackageName());
    } else {
        intent = item.getIntent();
    }
    if (intent == null) {
        throw new IllegalArgumentException("Input must have a valid intent");
    }
    if (item instanceof WorkspaceItemInfo) {
        WorkspaceItemInfo si = (WorkspaceItemInfo) item;
        if (si.hasStatusFlag(WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI) && Intent.ACTION_VIEW.equals(intent.getAction())) {
            // make a copy of the intent that has the package set to null
            // we do this because the platform sometimes disables instant
            // apps temporarily (triggered by the user) and fallbacks to the
            // web ui. This only works though if the package isn't set
            intent = new Intent(intent);
            intent.setPackage(null);
        }
    }
    if (v != null && launcher.supportsAdaptiveIconAnimation(v)) {
        // Preload the icon to reduce latency b/w swapping the floating view with the original.
        FloatingIconView.fetchIcon(launcher, v, item, true);
    }
    TrustDatabaseHelper db = TrustDatabaseHelper.getInstance(launcher);
    ComponentName cn = item.getTargetComponent();
    boolean isProtected = cn != null && db.isPackageProtected(cn.getPackageName());
    if (isProtected) {
        launcher.startActivitySafelyAuth(v, intent, item);
    } else {
        launcher.startActivitySafely(v, intent, item);
    }
}
Also used : TrustDatabaseHelper(com.android.launcher3.lineage.trust.db.TrustDatabaseHelper) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) ComponentName(android.content.ComponentName) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 19 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by AOSPA.

the class ItemClickHandler method startAppShortcutOrInfoActivity.

private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher) {
    TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: startAppShortcutOrInfoActivity");
    Intent intent;
    if (item instanceof ItemInfoWithIcon && (((ItemInfoWithIcon) item).runtimeStatusFlags & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
        ItemInfoWithIcon appInfo = (ItemInfoWithIcon) item;
        intent = new PackageManagerHelper(launcher).getMarketIntent(appInfo.getTargetComponent().getPackageName());
    } else {
        intent = item.getIntent();
    }
    if (intent == null) {
        throw new IllegalArgumentException("Input must have a valid intent");
    }
    if (item instanceof WorkspaceItemInfo) {
        WorkspaceItemInfo si = (WorkspaceItemInfo) item;
        if (si.hasStatusFlag(WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI) && Intent.ACTION_VIEW.equals(intent.getAction())) {
            // make a copy of the intent that has the package set to null
            // we do this because the platform sometimes disables instant
            // apps temporarily (triggered by the user) and fallbacks to the
            // web ui. This only works though if the package isn't set
            intent = new Intent(intent);
            intent.setPackage(null);
        }
        if ((si.options & WorkspaceItemInfo.FLAG_START_FOR_RESULT) != 0) {
            launcher.startActivityForResult(item.getIntent(), 0);
            InstanceId instanceId = new InstanceIdSequence().newInstanceId();
            launcher.logAppLaunch(launcher.getStatsLogManager(), item, instanceId);
            return;
        }
    }
    if (v != null && launcher.supportsAdaptiveIconAnimation(v)) {
        // Preload the icon to reduce latency b/w swapping the floating view with the original.
        FloatingIconView.fetchIcon(launcher, v, item, true);
    }
    launcher.startActivitySafely(v, intent, item);
}
Also used : InstanceId(com.android.launcher3.logging.InstanceId) InstanceIdSequence(com.android.launcher3.logging.InstanceIdSequence) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 20 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by AOSPA.

the class ItemClickHandler method onClick.

private static void onClick(View v) {
    // view has detached (it's possible for this to happen if the view is removed mid touch).
    if (v.getWindowToken() == null)
        return;
    Launcher launcher = Launcher.getLauncher(v.getContext());
    if (!launcher.getWorkspace().isFinishedSwitchingState())
        return;
    Object tag = v.getTag();
    if (tag instanceof WorkspaceItemInfo) {
        onClickAppShortcut(v, (WorkspaceItemInfo) tag, launcher);
    } else if (tag instanceof FolderInfo) {
        if (v instanceof FolderIcon) {
            onClickFolderIcon(v);
        }
    } else if (tag instanceof AppInfo) {
        startAppShortcutOrInfoActivity(v, (AppInfo) tag, launcher);
    } else if (tag instanceof LauncherAppWidgetInfo) {
        if (v instanceof PendingAppWidgetHostView) {
            onClickPendingWidget((PendingAppWidgetHostView) v, launcher);
        }
    } else if (tag instanceof SearchActionItemInfo) {
        onClickSearchAction(launcher, (SearchActionItemInfo) tag);
    }
}
Also used : FolderIcon(com.android.launcher3.folder.FolderIcon) Launcher(com.android.launcher3.Launcher) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AppInfo(com.android.launcher3.model.data.AppInfo)

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