Search in sources :

Example 51 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class LoaderCursorTest method newItemInfo.

private ItemInfo newItemInfo(int cellX, int cellY, int spanX, int spanY, int container, int screenId) {
    ItemInfo info = new ItemInfo();
    info.cellX = cellX;
    info.cellY = cellY;
    info.spanX = spanX;
    info.spanY = spanY;
    info.container = container;
    info.screenId = screenId;
    return info;
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 52 with ItemInfo

use of com.android.launcher3.ItemInfo 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 53 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class WidgetUtils method addItemToScreen.

/**
 * Adds {@param item} on the homescreen on the 0th screen
 */
public static void addItemToScreen(ItemInfo item, Context targetContext) {
    ContentResolver resolver = targetContext.getContentResolver();
    int screenId = FIRST_SCREEN_ID;
    // Update the screen id counter for the provider.
    LauncherSettings.Settings.call(resolver, LauncherSettings.Settings.METHOD_NEW_SCREEN_ID);
    if (screenId > FIRST_SCREEN_ID) {
        screenId = FIRST_SCREEN_ID;
    }
    // Insert the item
    ContentWriter writer = new ContentWriter(targetContext);
    item.id = LauncherSettings.Settings.call(resolver, LauncherSettings.Settings.METHOD_NEW_ITEM_ID).getInt(LauncherSettings.Settings.EXTRA_VALUE);
    item.screenId = screenId;
    item.onAddToDatabase(writer);
    writer.put(LauncherSettings.Favorites._ID, item.id);
    resolver.insert(LauncherSettings.Favorites.CONTENT_URI, writer.getValues(targetContext));
}
Also used : ContentWriter(com.android.launcher3.util.ContentWriter) ContentResolver(android.content.ContentResolver)

Example 54 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskView method onInitializeAccessibilityNodeInfo.

@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.string.accessibility_close, getContext().getText(R.string.accessibility_close)));
    final Context context = getContext();
    for (SystemShortcut s : TaskOverlayFactory.getEnabledShortcuts(this, mActivity.getDeviceProfile())) {
        info.addAction(s.createAccessibilityAction(context));
    }
    if (mDigitalWellBeingToast.hasLimit()) {
        info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.string.accessibility_app_usage_settings, getContext().getText(R.string.accessibility_app_usage_settings)));
    }
    final RecentsView recentsView = getRecentsView();
    final AccessibilityNodeInfo.CollectionItemInfo itemInfo = AccessibilityNodeInfo.CollectionItemInfo.obtain(0, 1, recentsView.getTaskViewCount() - recentsView.indexOfChild(this) - 1, 1, false);
    info.setCollectionItemInfo(itemInfo);
}
Also used : Context(android.content.Context) SystemShortcut(com.android.launcher3.popup.SystemShortcut) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo)

Example 55 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class ItemClickHandler method startMarketIntentForPackage.

private static void startMarketIntentForPackage(View v, Launcher launcher, String packageName) {
    ItemInfo item = (ItemInfo) v.getTag();
    if (Utilities.ATLEAST_Q) {
        SessionInfo sessionInfo = InstallSessionHelper.INSTANCE.get(launcher).getActiveSessionInfo(item.user, packageName);
        if (sessionInfo != null) {
            LauncherApps launcherApps = launcher.getSystemService(LauncherApps.class);
            try {
                launcherApps.startPackageInstallerSessionDetailsActivity(sessionInfo, null, launcher.getActivityLaunchOptions(v, item).toBundle());
                return;
            } catch (Exception e) {
                Log.e(TAG, "Unable to launch market intent for package=" + packageName, e);
            }
        }
    }
    // Fallback to using custom market intent.
    Intent intent = new PackageManagerHelper(launcher).getMarketIntent(packageName);
    launcher.startActivitySafely(v, intent, item);
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) LauncherApps(android.content.pm.LauncherApps) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper)

Aggregations

ItemInfo (com.android.launcher3.model.data.ItemInfo)457 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)373 View (android.view.View)199 ArrayList (java.util.ArrayList)169 Point (android.graphics.Point)159 FolderInfo (com.android.launcher3.model.data.FolderInfo)113 SuppressLint (android.annotation.SuppressLint)110 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)100 DragView (com.android.launcher3.dragndrop.DragView)98 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)98 AppWidgetHostView (android.appwidget.AppWidgetHostView)94 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)94 BubbleTextView (com.android.launcher3.BubbleTextView)85 Context (android.content.Context)82 List (java.util.List)80 AppInfo (com.android.launcher3.model.data.AppInfo)79 Intent (android.content.Intent)78 Rect (android.graphics.Rect)76 DraggableView (com.android.launcher3.dragndrop.DraggableView)73 ComponentName (android.content.ComponentName)72