Search in sources :

Example 6 with Overrides

use of com.android.launcher3.util.ResourceBasedOverride.Overrides in project android_packages_apps_Trebuchet by LineageOS.

the class InvariantDeviceProfile method initGrid.

private void initGrid(Context context, DefaultDisplay.Info displayInfo, DisplayOption displayOption) {
    GridOption closestProfile = displayOption.grid;
    numRows = closestProfile.numRows;
    numColumns = closestProfile.numColumns;
    numHotseatIcons = closestProfile.numHotseatIcons;
    dbFile = closestProfile.dbFile;
    defaultLayoutId = closestProfile.defaultLayoutId;
    demoModeLayoutId = closestProfile.demoModeLayoutId;
    numFolderRows = closestProfile.numFolderRows;
    numFolderColumns = closestProfile.numFolderColumns;
    numAllAppsColumns = closestProfile.numAllAppsColumns;
    mExtraAttrs = closestProfile.extraAttrs;
    iconSize = displayOption.iconSize;
    iconShapePath = getIconShapePath(context);
    iconPack = new IconPackStore(context).getCurrent();
    landscapeIconSize = displayOption.landscapeIconSize;
    iconBitmapSize = ResourceUtils.pxFromDp(iconSize, displayInfo.metrics);
    iconTextSize = displayOption.iconTextSize;
    fillResIconDpi = getLauncherIconDensity(iconBitmapSize);
    if (Utilities.isGridOptionsEnabled(context)) {
        allAppsIconSize = displayOption.allAppsIconSize;
        allAppsIconTextSize = displayOption.allAppsIconTextSize;
    } else {
        allAppsIconSize = iconSize;
        allAppsIconTextSize = iconTextSize;
    }
    // If the partner customization apk contains any grid overrides, apply them
    // Supported overrides: numRows, numColumns, iconSize
    applyPartnerDeviceProfileOverrides(context, displayInfo.metrics);
    Point realSize = new Point(displayInfo.realSize);
    // The real size never changes. smallSide and largeSide will remain the
    // same in any orientation.
    int smallSide = Math.min(realSize.x, realSize.y);
    int largeSide = Math.max(realSize.x, realSize.y);
    DeviceProfile.Builder builder = new DeviceProfile.Builder(context, this, displayInfo).setSizeRange(new Point(displayInfo.smallestSize), new Point(displayInfo.largestSize));
    landscapeProfile = builder.setSize(largeSide, smallSide).build();
    portraitProfile = builder.setSize(smallSide, largeSide).build();
    // for the intended parallax effects
    if (context.getResources().getConfiguration().smallestScreenWidthDp >= 720) {
        defaultWallpaperSize = new Point((int) (largeSide * wallpaperTravelToScreenWidthRatio(largeSide, smallSide)), largeSide);
    } else {
        defaultWallpaperSize = new Point(Math.max(smallSide * 2, largeSide), largeSide);
    }
    ComponentName cn = new ComponentName(context.getPackageName(), getClass().getName());
    defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null);
}
Also used : ComponentName(android.content.ComponentName) IconPackStore(com.android.launcher3.lineage.icon.IconPackStore) Point(android.graphics.Point) Point(android.graphics.Point)

Example 7 with Overrides

use of com.android.launcher3.util.ResourceBasedOverride.Overrides in project android_packages_apps_Launcher3 by ArrowOS.

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 8 with Overrides

use of com.android.launcher3.util.ResourceBasedOverride.Overrides in project android_packages_apps_Launcher3 by ArrowOS.

the class AppWidgetResizeFrame method visualizeResizeForDelta.

/**
 *  Based on the deltas, we resize the frame.
 */
public void visualizeResizeForDelta(int deltaX, int deltaY) {
    mDeltaX = mDeltaXRange.clamp(deltaX);
    mDeltaY = mDeltaYRange.clamp(deltaY);
    DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
    mDeltaX = mDeltaXRange.clamp(deltaX);
    mBaselineX.applyDelta(mLeftBorderActive, mRightBorderActive, mDeltaX, mTempRange1);
    lp.x = mTempRange1.start;
    lp.width = mTempRange1.size();
    mDeltaY = mDeltaYRange.clamp(deltaY);
    mBaselineY.applyDelta(mTopBorderActive, mBottomBorderActive, mDeltaY, mTempRange1);
    lp.y = mTempRange1.start;
    lp.height = mTempRange1.size();
    resizeWidgetIfNeeded(false);
    // When the widget resizes in multi-window mode, the translation value changes to maintain
    // a center fit. These overrides ensure the resize frame always aligns with the widget view.
    getSnappedRectRelativeToDragLayer(sTmpRect);
    if (mLeftBorderActive) {
        lp.width = sTmpRect.width() + sTmpRect.left - lp.x;
    }
    if (mTopBorderActive) {
        lp.height = sTmpRect.height() + sTmpRect.top - lp.y;
    }
    if (mRightBorderActive) {
        lp.x = sTmpRect.left;
    }
    if (mBottomBorderActive) {
        lp.y = sTmpRect.top;
    }
    // Handle invalid resize across CellLayouts in the two panel UI.
    if (mCellLayout.getParent() instanceof Workspace) {
        Workspace workspace = (Workspace) mCellLayout.getParent();
        CellLayout pairedCellLayout = workspace.getScreenPair(mCellLayout);
        if (pairedCellLayout != null) {
            Rect focusedCellLayoutBound = sTmpRect;
            mDragLayerRelativeCoordinateHelper.viewToRect(mCellLayout, focusedCellLayoutBound);
            Rect resizeFrameBound = sTmpRect2;
            findViewById(R.id.widget_resize_frame).getGlobalVisibleRect(resizeFrameBound);
            float progress = 1f;
            if (workspace.indexOfChild(pairedCellLayout) < workspace.indexOfChild(mCellLayout) && mDeltaX < 0 && resizeFrameBound.left < focusedCellLayoutBound.left) {
                // Resize from right to left.
                progress = (mDragAcrossTwoPanelOpacityMargin + mDeltaX) / mDragAcrossTwoPanelOpacityMargin;
            } else if (workspace.indexOfChild(pairedCellLayout) > workspace.indexOfChild(mCellLayout) && mDeltaX > 0 && resizeFrameBound.right > focusedCellLayoutBound.right) {
                // Resize from left to right.
                progress = (mDragAcrossTwoPanelOpacityMargin - mDeltaX) / mDragAcrossTwoPanelOpacityMargin;
            }
            float alpha = Math.max(MIN_OPACITY_FOR_CELL_LAYOUT_DURING_INVALID_RESIZE, progress);
            float springLoadedProgress = Math.min(1f, 1f - progress);
            updateInvalidResizeEffect(mCellLayout, pairedCellLayout, alpha, springLoadedProgress);
        }
    }
    requestLayout();
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer) Rect(android.graphics.Rect)

Example 9 with Overrides

use of com.android.launcher3.util.ResourceBasedOverride.Overrides in project android_packages_apps_Launcher3 by ProtonAOSP.

the class AppWidgetResizeFrame method visualizeResizeForDelta.

/**
 *  Based on the deltas, we resize the frame.
 */
public void visualizeResizeForDelta(int deltaX, int deltaY) {
    mDeltaX = mDeltaXRange.clamp(deltaX);
    mDeltaY = mDeltaYRange.clamp(deltaY);
    DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
    mDeltaX = mDeltaXRange.clamp(deltaX);
    mBaselineX.applyDelta(mLeftBorderActive, mRightBorderActive, mDeltaX, mTempRange1);
    lp.x = mTempRange1.start;
    lp.width = mTempRange1.size();
    mDeltaY = mDeltaYRange.clamp(deltaY);
    mBaselineY.applyDelta(mTopBorderActive, mBottomBorderActive, mDeltaY, mTempRange1);
    lp.y = mTempRange1.start;
    lp.height = mTempRange1.size();
    resizeWidgetIfNeeded(false);
    // When the widget resizes in multi-window mode, the translation value changes to maintain
    // a center fit. These overrides ensure the resize frame always aligns with the widget view.
    getSnappedRectRelativeToDragLayer(sTmpRect);
    if (mLeftBorderActive) {
        lp.width = sTmpRect.width() + sTmpRect.left - lp.x;
    }
    if (mTopBorderActive) {
        lp.height = sTmpRect.height() + sTmpRect.top - lp.y;
    }
    if (mRightBorderActive) {
        lp.x = sTmpRect.left;
    }
    if (mBottomBorderActive) {
        lp.y = sTmpRect.top;
    }
    // Handle invalid resize across CellLayouts in the two panel UI.
    if (mCellLayout.getParent() instanceof Workspace) {
        Workspace workspace = (Workspace) mCellLayout.getParent();
        CellLayout pairedCellLayout = workspace.getScreenPair(mCellLayout);
        if (pairedCellLayout != null) {
            Rect focusedCellLayoutBound = sTmpRect;
            mDragLayerRelativeCoordinateHelper.viewToRect(mCellLayout, focusedCellLayoutBound);
            Rect resizeFrameBound = sTmpRect2;
            findViewById(R.id.widget_resize_frame).getGlobalVisibleRect(resizeFrameBound);
            float progress = 1f;
            if (workspace.indexOfChild(pairedCellLayout) < workspace.indexOfChild(mCellLayout) && mDeltaX < 0 && resizeFrameBound.left < focusedCellLayoutBound.left) {
                // Resize from right to left.
                progress = (mDragAcrossTwoPanelOpacityMargin + mDeltaX) / mDragAcrossTwoPanelOpacityMargin;
            } else if (workspace.indexOfChild(pairedCellLayout) > workspace.indexOfChild(mCellLayout) && mDeltaX > 0 && resizeFrameBound.right > focusedCellLayoutBound.right) {
                // Resize from left to right.
                progress = (mDragAcrossTwoPanelOpacityMargin - mDeltaX) / mDragAcrossTwoPanelOpacityMargin;
            }
            float alpha = Math.max(MIN_OPACITY_FOR_CELL_LAYOUT_DURING_INVALID_RESIZE, progress);
            float springLoadedProgress = Math.min(1f, 1f - progress);
            updateInvalidResizeEffect(mCellLayout, pairedCellLayout, alpha, springLoadedProgress);
        }
    }
    requestLayout();
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer) Rect(android.graphics.Rect)

Example 10 with Overrides

use of com.android.launcher3.util.ResourceBasedOverride.Overrides in project android_packages_apps_Launcher3 by AOSPA.

the class AppWidgetResizeFrame method visualizeResizeForDelta.

/**
 *  Based on the deltas, we resize the frame.
 */
public void visualizeResizeForDelta(int deltaX, int deltaY) {
    mDeltaX = mDeltaXRange.clamp(deltaX);
    mDeltaY = mDeltaYRange.clamp(deltaY);
    DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
    mDeltaX = mDeltaXRange.clamp(deltaX);
    mBaselineX.applyDelta(mLeftBorderActive, mRightBorderActive, mDeltaX, mTempRange1);
    lp.x = mTempRange1.start;
    lp.width = mTempRange1.size();
    mDeltaY = mDeltaYRange.clamp(deltaY);
    mBaselineY.applyDelta(mTopBorderActive, mBottomBorderActive, mDeltaY, mTempRange1);
    lp.y = mTempRange1.start;
    lp.height = mTempRange1.size();
    resizeWidgetIfNeeded(false);
    // When the widget resizes in multi-window mode, the translation value changes to maintain
    // a center fit. These overrides ensure the resize frame always aligns with the widget view.
    getSnappedRectRelativeToDragLayer(sTmpRect);
    if (mLeftBorderActive) {
        lp.width = sTmpRect.width() + sTmpRect.left - lp.x;
    }
    if (mTopBorderActive) {
        lp.height = sTmpRect.height() + sTmpRect.top - lp.y;
    }
    if (mRightBorderActive) {
        lp.x = sTmpRect.left;
    }
    if (mBottomBorderActive) {
        lp.y = sTmpRect.top;
    }
    // Handle invalid resize across CellLayouts in the two panel UI.
    if (mCellLayout.getParent() instanceof Workspace) {
        Workspace workspace = (Workspace) mCellLayout.getParent();
        CellLayout pairedCellLayout = workspace.getScreenPair(mCellLayout);
        if (pairedCellLayout != null) {
            Rect focusedCellLayoutBound = sTmpRect;
            mDragLayerRelativeCoordinateHelper.viewToRect(mCellLayout, focusedCellLayoutBound);
            Rect resizeFrameBound = sTmpRect2;
            findViewById(R.id.widget_resize_frame).getGlobalVisibleRect(resizeFrameBound);
            float progress = 1f;
            if (workspace.indexOfChild(pairedCellLayout) < workspace.indexOfChild(mCellLayout) && mDeltaX < 0 && resizeFrameBound.left < focusedCellLayoutBound.left) {
                // Resize from right to left.
                progress = (mDragAcrossTwoPanelOpacityMargin + mDeltaX) / mDragAcrossTwoPanelOpacityMargin;
            } else if (workspace.indexOfChild(pairedCellLayout) > workspace.indexOfChild(mCellLayout) && mDeltaX > 0 && resizeFrameBound.right > focusedCellLayoutBound.right) {
                // Resize from left to right.
                progress = (mDragAcrossTwoPanelOpacityMargin - mDeltaX) / mDragAcrossTwoPanelOpacityMargin;
            }
            float alpha = Math.max(MIN_OPACITY_FOR_CELL_LAYOUT_DURING_INVALID_RESIZE, progress);
            float springLoadedProgress = Math.min(1f, 1f - progress);
            updateInvalidResizeEffect(mCellLayout, pairedCellLayout, alpha, springLoadedProgress);
        }
    }
    requestLayout();
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer) Rect(android.graphics.Rect)

Aggregations

ComponentName (android.content.ComponentName)6 Point (android.graphics.Point)6 DisplayMetrics (android.util.DisplayMetrics)5 WindowBounds (com.android.launcher3.util.WindowBounds)5 ArrayList (java.util.ArrayList)5 Rect (android.graphics.Rect)4 DragLayer (com.android.launcher3.dragndrop.DragLayer)4 IconPackStore (com.android.launcher3.lineage.icon.IconPackStore)1