Search in sources :

Example 1 with Overrides

use of com.android.launcher3.util.ResourceBasedOverride.Overrides 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 2 with Overrides

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

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

use of com.android.launcher3.util.ResourceBasedOverride.Overrides in project android_packages_apps_404Launcher by P-404.

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

use of com.android.launcher3.util.ResourceBasedOverride.Overrides in project android_packages_apps_404Launcher by P-404.

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

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

the class InvariantDeviceProfile method initGrid.

private void initGrid(Context context, Info displayInfo, DisplayOption displayOption, boolean isSplitDisplay) {
    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;
    mExtraAttrs = closestProfile.extraAttrs;
    float iconSizeModifier = (float) Utilities.getPrefs(context).getInt(KEY_ICON_SIZE, 100) / 100F;
    float fontSizeModifier = (float) Utilities.getPrefs(context).getInt(KEY_FONT_SIZE, 100) / 100F;
    iconSize = displayOption.iconSize * iconSizeModifier;
    landscapeIconSize = displayOption.landscapeIconSize * iconSizeModifier;
    iconBitmapSize = ResourceUtils.pxFromDp(iconSize, metrics);
    iconTextSize = displayOption.iconTextSize * fontSizeModifier;
    landscapeIconTextSize = displayOption.landscapeIconTextSize * fontSizeModifier;
    fillResIconDpi = getLauncherIconDensity(iconBitmapSize);
    minCellHeight = displayOption.minCellHeight;
    minCellWidth = displayOption.minCellWidth;
    borderSpacing = displayOption.borderSpacing;
    numShownHotseatIcons = closestProfile.numHotseatIcons;
    numDatabaseHotseatIcons = isSplitDisplay ? closestProfile.numDatabaseHotseatIcons : closestProfile.numHotseatIcons;
    numAllAppsColumns = closestProfile.numAllAppsColumns;
    numDatabaseAllAppsColumns = isSplitDisplay ? closestProfile.numDatabaseAllAppsColumns : closestProfile.numAllAppsColumns;
    if (Utilities.isGridOptionsEnabled(context)) {
        allAppsIconSize = displayOption.allAppsIconSize * iconSizeModifier;
        allAppsIconTextSize = displayOption.allAppsIconTextSize * fontSizeModifier;
    } else {
        allAppsIconSize = iconSize;
        allAppsIconTextSize = iconTextSize;
    }
    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(isSplitDisplay).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)

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