Search in sources :

Example 81 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.

the class Launcher method dump.

/**
 * $ adb shell dumpsys activity com.android.launcher3.Launcher [--all]
 */
@Override
public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
    super.dump(prefix, fd, writer, args);
    if (args.length > 0 && TextUtils.equals(args[0], "--all")) {
        writer.println(prefix + "Workspace Items");
        for (int i = 0; i < mWorkspace.getPageCount(); i++) {
            writer.println(prefix + "  Homescreen " + i);
            ViewGroup layout = ((CellLayout) mWorkspace.getPageAt(i)).getShortcutsAndWidgets();
            for (int j = 0; j < layout.getChildCount(); j++) {
                Object tag = layout.getChildAt(j).getTag();
                if (tag != null) {
                    writer.println(prefix + "    " + tag.toString());
                }
            }
        }
        writer.println(prefix + "  Hotseat");
        ViewGroup layout = mHotseat.getShortcutsAndWidgets();
        for (int j = 0; j < layout.getChildCount(); j++) {
            Object tag = layout.getChildAt(j).getTag();
            if (tag != null) {
                writer.println(prefix + "    " + tag.toString());
            }
        }
    }
    writer.println(prefix + "Misc:");
    dumpMisc(prefix + "\t", writer);
    writer.println(prefix + "\tmWorkspaceLoading=" + mWorkspaceLoading);
    writer.println(prefix + "\tmPendingRequestArgs=" + mPendingRequestArgs + " mPendingActivityResult=" + mPendingActivityResult);
    writer.println(prefix + "\tmRotationHelper: " + mRotationHelper);
    writer.println(prefix + "\tmAppWidgetHost.isListening: " + mAppWidgetHost.isListening());
    // Extra logging for general debugging
    mDragLayer.dump(prefix, writer);
    mStateManager.dump(prefix, writer);
    mPopupDataProvider.dump(prefix, writer);
    mDeviceProfile.dump(prefix, writer);
    try {
        FileLog.flushAll(writer);
    } catch (Exception e) {
    // Ignore
    }
    mModel.dumpState(prefix, fd, writer, args);
    if (mLauncherCallbacks != null) {
        mLauncherCallbacks.dump(prefix, fd, writer, args);
    }
    mOverlayManager.dump(prefix, writer);
}
Also used : ViewGroup(android.view.ViewGroup) DragObject(com.android.launcher3.DropTarget.DragObject) ActivityNotFoundException(android.content.ActivityNotFoundException)

Example 82 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.

the class Launcher method removeItem.

/**
 * Unbinds the view for the specified item, and removes the item and all its children.
 *
 * @param v the view being removed.
 * @param itemInfo the {@link ItemInfo} for this view.
 * @param deleteFromDb whether or not to delete this item from the db.
 */
public boolean removeItem(View v, final ItemInfo itemInfo, boolean deleteFromDb) {
    if (itemInfo instanceof WorkspaceItemInfo) {
        // Remove the shortcut from the folder before removing it from launcher
        View folderIcon = mWorkspace.getHomescreenIconByItemId(itemInfo.container);
        if (folderIcon instanceof FolderIcon) {
            ((FolderInfo) folderIcon.getTag()).remove((WorkspaceItemInfo) itemInfo, true);
        } else {
            mWorkspace.removeWorkspaceItem(v);
        }
        if (deleteFromDb) {
            getModelWriter().deleteItemFromDatabase(itemInfo);
        }
    } else if (itemInfo instanceof FolderInfo) {
        final FolderInfo folderInfo = (FolderInfo) itemInfo;
        if (v instanceof FolderIcon) {
            ((FolderIcon) v).removeListeners();
        }
        mWorkspace.removeWorkspaceItem(v);
        if (deleteFromDb) {
            getModelWriter().deleteFolderAndContentsFromDatabase(folderInfo);
        }
    } else if (itemInfo instanceof LauncherAppWidgetInfo) {
        final LauncherAppWidgetInfo widgetInfo = (LauncherAppWidgetInfo) itemInfo;
        mWorkspace.removeWorkspaceItem(v);
        if (deleteFromDb) {
            getModelWriter().deleteWidgetInfo(widgetInfo, getAppWidgetHost());
        }
    } else {
        return false;
    }
    return true;
}
Also used : FolderIcon(com.android.launcher3.folder.FolderIcon) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) QsbContainerView(com.android.launcher3.qsb.QsbContainerView) OptionsPopupView(com.android.launcher3.views.OptionsPopupView) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) DragView(com.android.launcher3.dragndrop.DragView) ImageView(android.widget.ImageView) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) FloatingSurfaceView(com.android.launcher3.views.FloatingSurfaceView) AppWidgetHostView(android.appwidget.AppWidgetHostView) View(android.view.View) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) ScrimView(com.android.launcher3.views.ScrimView) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 83 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.

the class InvariantDeviceProfile method initGrid.

private void initGrid(Context context, Info displayInfo, DisplayOption displayOption, @DeviceType int deviceType) {
    DisplayMetrics metrics = context.getResources().getDisplayMetrics();
    GridOption closestProfile = displayOption.grid;
    numRows = closestProfile.numRows;
    numColumns = closestProfile.numColumns;
    dbFile = closestProfile.dbFile;
    defaultLayoutId = closestProfile.defaultLayoutId;
    demoModeLayoutId = closestProfile.demoModeLayoutId;
    numFolderRows = closestProfile.numFolderRows;
    numFolderColumns = closestProfile.numFolderColumns;
    isScalable = closestProfile.isScalable;
    devicePaddingId = closestProfile.devicePaddingId;
    this.deviceType = deviceType;
    mExtraAttrs = closestProfile.extraAttrs;
    iconSize = displayOption.iconSizes;
    float maxIconSize = iconSize[0];
    for (int i = 1; i < iconSize.length; i++) {
        maxIconSize = Math.max(maxIconSize, iconSize[i]);
    }
    iconBitmapSize = ResourceUtils.pxFromDp(maxIconSize, metrics);
    fillResIconDpi = getLauncherIconDensity(iconBitmapSize);
    iconTextSize = displayOption.textSizes;
    minCellSize = displayOption.minCellSize;
    borderSpaces = displayOption.borderSpaces;
    folderBorderSpace = displayOption.folderBorderSpace;
    horizontalMargin = displayOption.horizontalMargin;
    numShownHotseatIcons = closestProfile.numHotseatIcons;
    numDatabaseHotseatIcons = deviceType == TYPE_MULTI_DISPLAY ? closestProfile.numDatabaseHotseatIcons : closestProfile.numHotseatIcons;
    numAllAppsColumns = closestProfile.numAllAppsColumns;
    numDatabaseAllAppsColumns = deviceType == TYPE_MULTI_DISPLAY ? closestProfile.numDatabaseAllAppsColumns : closestProfile.numAllAppsColumns;
    if (!Utilities.isGridOptionsEnabled(context)) {
        iconSize[INDEX_ALL_APPS] = iconSize[INDEX_DEFAULT];
        iconTextSize[INDEX_ALL_APPS] = iconTextSize[INDEX_DEFAULT];
    }
    if (devicePaddingId != 0) {
        devicePaddings = new DevicePaddings(context, devicePaddingId);
    }
    // If the partner customization apk contains any grid overrides, apply them
    // Supported overrides: numRows, numColumns, iconSize
    applyPartnerDeviceProfileOverrides(context, metrics);
    final List<DeviceProfile> localSupportedProfiles = new ArrayList<>();
    defaultWallpaperSize = new Point(displayInfo.currentSize);
    for (WindowBounds bounds : displayInfo.supportedBounds) {
        localSupportedProfiles.add(new DeviceProfile.Builder(context, this, displayInfo).setUseTwoPanels(deviceType == TYPE_MULTI_DISPLAY).setWindowBounds(bounds).build());
        // Wallpaper size should be the maximum of the all possible sizes Launcher expects
        int displayWidth = bounds.bounds.width();
        int displayHeight = bounds.bounds.height();
        defaultWallpaperSize.y = Math.max(defaultWallpaperSize.y, displayHeight);
        // We need to ensure that there is enough extra space in the wallpaper
        // for the intended parallax effects
        float parallaxFactor = dpiFromPx(Math.min(displayWidth, displayHeight), displayInfo.densityDpi) < 720 ? 2 : wallpaperTravelToScreenWidthRatio(displayWidth, displayHeight);
        defaultWallpaperSize.x = Math.max(defaultWallpaperSize.x, Math.round(parallaxFactor * displayWidth));
    }
    supportedProfiles = Collections.unmodifiableList(localSupportedProfiles);
    ComponentName cn = new ComponentName(context.getPackageName(), getClass().getName());
    defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null);
}
Also used : WindowBounds(com.android.launcher3.util.WindowBounds) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName) Point(android.graphics.Point) DisplayMetrics(android.util.DisplayMetrics) Point(android.graphics.Point)

Example 84 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.

the class LauncherProvider method loadDefaultFavoritesIfNecessary.

/**
 * Loads the default workspace based on the following priority scheme:
 *   1) From the app restrictions
 *   2) From a package provided by play store
 *   3) From a partner configuration APK, already in the system image
 *   4) The default configuration for the particular device
 */
private synchronized void loadDefaultFavoritesIfNecessary() {
    SharedPreferences sp = Utilities.getPrefs(getContext());
    if (sp.getBoolean(mOpenHelper.getKey(EMPTY_DATABASE_CREATED), false)) {
        Log.d(TAG, "loading default workspace");
        AppWidgetHost widgetHost = mOpenHelper.newLauncherWidgetHost();
        AutoInstallsLayout loader = createWorkspaceLoaderFromAppRestriction(widgetHost);
        if (loader == null) {
            loader = AutoInstallsLayout.get(getContext(), widgetHost, mOpenHelper);
        }
        if (loader == null) {
            final Partner partner = Partner.get(getContext().getPackageManager());
            if (partner != null && partner.hasDefaultLayout()) {
                final Resources partnerRes = partner.getResources();
                int workspaceResId = partnerRes.getIdentifier(Partner.RES_DEFAULT_LAYOUT, "xml", partner.getPackageName());
                if (workspaceResId != 0) {
                    loader = new DefaultLayoutParser(getContext(), widgetHost, mOpenHelper, partnerRes, workspaceResId);
                }
            }
        }
        final boolean usingExternallyProvidedLayout = loader != null;
        if (loader == null) {
            loader = getDefaultLayoutParser(widgetHost);
        }
        // There might be some partially restored DB items, due to buggy restore logic in
        // previous versions of launcher.
        mOpenHelper.createEmptyDB(mOpenHelper.getWritableDatabase());
        // Populate favorites table with initial favorites
        if ((mOpenHelper.loadFavorites(mOpenHelper.getWritableDatabase(), loader) <= 0) && usingExternallyProvidedLayout) {
            // Unable to load external layout. Cleanup and load the internal layout.
            mOpenHelper.createEmptyDB(mOpenHelper.getWritableDatabase());
            mOpenHelper.loadFavorites(mOpenHelper.getWritableDatabase(), getDefaultLayoutParser(widgetHost));
        }
        clearFlagEmptyDbCreated();
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) AppWidgetHost(android.appwidget.AppWidgetHost) LauncherAppWidgetHost(com.android.launcher3.widget.LauncherAppWidgetHost) Resources(android.content.res.Resources)

Example 85 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.

the class AccessibilityActionsView method createAccessibilityNodeInfo.

@Override
public AccessibilityNodeInfo createAccessibilityNodeInfo() {
    AccessibilityNodeInfo info = super.createAccessibilityNodeInfo();
    Launcher l = Launcher.getLauncher(getContext());
    info.addAction(new AccessibilityAction(R.string.all_apps_button_label, l.getText(R.string.all_apps_button_label)));
    for (OptionItem item : OptionsPopupView.getOptions(l)) {
        info.addAction(new AccessibilityAction(item.labelRes, item.label));
    }
    return info;
}
Also used : AccessibilityAction(android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction) OptionItem(com.android.launcher3.views.OptionsPopupView.OptionItem) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) Launcher(com.android.launcher3.Launcher)

Aggregations

Launcher (com.android.launcher3.Launcher)194 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)102 Test (org.junit.Test)102 View (android.view.View)87 LargeTest (androidx.test.filters.LargeTest)83 ItemInfo (com.android.launcher3.model.data.ItemInfo)83 Rect (android.graphics.Rect)80 Point (android.graphics.Point)77 Intent (android.content.Intent)71 ArrayList (java.util.ArrayList)69 DeviceProfile (com.android.launcher3.DeviceProfile)66 BaseQuickstepLauncher (com.android.launcher3.BaseQuickstepLauncher)64 Context (android.content.Context)61 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)49 RecentsView (com.android.quickstep.views.RecentsView)46 DragLayer (com.android.launcher3.dragndrop.DragLayer)45 ComponentName (android.content.ComponentName)43 FolderInfo (com.android.launcher3.model.data.FolderInfo)42 ViewGroup (android.view.ViewGroup)41 AllApps (com.android.launcher3.tapl.AllApps)40