Search in sources :

Example 1 with WindowBounds

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

the class BaseActivityInterface method getTaskDimension.

/**
 * Gets the dimension of the task in the current system state.
 */
public static void getTaskDimension(Context context, DeviceProfile dp, PointF out) {
    if (dp.isMultiWindowMode) {
        WindowBounds bounds = SplitScreenBounds.INSTANCE.getSecondaryWindowBounds(context);
        if (TaskView.CLIP_STATUS_AND_NAV_BARS) {
            out.x = bounds.availableSize.x;
            out.y = bounds.availableSize.y;
        } else {
            out.x = bounds.availableSize.x + bounds.insets.left + bounds.insets.right;
            out.y = bounds.availableSize.y + bounds.insets.top + bounds.insets.bottom;
        }
    } else if (TaskView.CLIP_STATUS_AND_NAV_BARS) {
        out.x = dp.availableWidthPx;
        out.y = dp.availableHeightPx;
    } else {
        out.x = dp.widthPx;
        out.y = dp.heightPx;
    }
}
Also used : WindowBounds(com.android.launcher3.util.WindowBounds)

Example 2 with WindowBounds

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

the class DeviceProfile method toBuilder.

public Builder toBuilder(Context context) {
    WindowBounds bounds = new WindowBounds(widthPx, heightPx, availableWidthPx, availableHeightPx);
    bounds.bounds.offsetTo(windowX, windowY);
    return new Builder(context, inv, mInfo).setWindowBounds(bounds).setUseTwoPanels(isTwoPanels).setMultiWindowMode(isMultiWindowMode);
}
Also used : WindowBounds(com.android.launcher3.util.WindowBounds)

Example 3 with WindowBounds

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

the class AbsSwipeUpHandler method onRecentsAnimationStart.

@Override
public void onRecentsAnimationStart(RecentsAnimationController controller, RecentsAnimationTargets targets) {
    super.onRecentsAnimationStart(controller, targets);
    ActiveGestureLog.INSTANCE.addLog("startRecentsAnimationCallback", targets.apps.length);
    mRemoteTargetHandles = mTargetGluer.assignTargetsForSplitScreen(targets);
    mRecentsAnimationController = controller;
    mRecentsAnimationTargets = targets;
    // configurations targets.homeContentInsets may not be correct.
    if (mActivity == null) {
        RemoteAnimationTargetCompat primaryTaskTarget = targets.apps[0];
        // orientation state is independent of which remote target handle we use since both
        // should be pointing to the same one. Just choose index 0 for now since that works for
        // both split and non-split
        RecentsOrientedState orientationState = mRemoteTargetHandles[0].getTaskViewSimulator().getOrientationState();
        DeviceProfile dp = orientationState.getLauncherDeviceProfile();
        if (targets.minimizedHomeBounds != null && primaryTaskTarget != null) {
            Rect overviewStackBounds = mActivityInterface.getOverviewWindowBounds(targets.minimizedHomeBounds, primaryTaskTarget);
            dp = dp.getMultiWindowProfile(mContext, new WindowBounds(overviewStackBounds, targets.homeContentInsets));
        } else {
            // If we are not in multi-window mode, home insets should be same as system insets.
            dp = dp.copy(mContext);
        }
        dp.updateInsets(targets.homeContentInsets);
        dp.updateIsSeascape(mContext);
        initTransitionEndpoints(dp);
        orientationState.setMultiWindowMode(dp.isMultiWindowMode);
    }
    // Notify when the animation starts
    flushOnRecentsAnimationAndLauncherBound();
    TaskViewUtils.setSplitAuxiliarySurfacesShown(mRecentsAnimationTargets.nonApps, false, /*shown*/
    true);
    // Only add the callback to enable the input consumer after we actually have the controller
    mStateCallback.runOnceAtState(STATE_APP_CONTROLLER_RECEIVED | STATE_GESTURE_STARTED, mRecentsAnimationController::enableInputConsumer);
    mStateCallback.setStateOnUiThread(STATE_APP_CONTROLLER_RECEIVED);
    mPassedOverviewThreshold = false;
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) Rect(android.graphics.Rect) WindowBounds(com.android.launcher3.util.WindowBounds) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) RecentsOrientedState(com.android.quickstep.util.RecentsOrientedState)

Example 4 with WindowBounds

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

the class InvariantDeviceProfile method invDistWeightedInterpolate.

private static DisplayOption invDistWeightedInterpolate(Info displayInfo, ArrayList<DisplayOption> points, @DeviceType int deviceType) {
    int minWidthPx = Integer.MAX_VALUE;
    int minHeightPx = Integer.MAX_VALUE;
    for (WindowBounds bounds : displayInfo.supportedBounds) {
        boolean isTablet = displayInfo.isTablet(bounds);
        if (isTablet && deviceType == TYPE_MULTI_DISPLAY) {
            // For split displays, take half width per page
            minWidthPx = Math.min(minWidthPx, bounds.availableSize.x / 2);
            minHeightPx = Math.min(minHeightPx, bounds.availableSize.y);
        } else if (!isTablet && bounds.isLandscape()) {
            // We will use transposed layout in this case
            minWidthPx = Math.min(minWidthPx, bounds.availableSize.y);
            minHeightPx = Math.min(minHeightPx, bounds.availableSize.x);
        } else {
            minWidthPx = Math.min(minWidthPx, bounds.availableSize.x);
            minHeightPx = Math.min(minHeightPx, bounds.availableSize.y);
        }
    }
    float width = dpiFromPx(minWidthPx, displayInfo.densityDpi);
    float height = dpiFromPx(minHeightPx, displayInfo.densityDpi);
    // Sort the profiles based on the closeness to the device size
    Collections.sort(points, (a, b) -> Float.compare(dist(width, height, a.minWidthDps, a.minHeightDps), dist(width, height, b.minWidthDps, b.minHeightDps)));
    DisplayOption closestPoint = points.get(0);
    GridOption closestOption = closestPoint.grid;
    float weights = 0;
    if (dist(width, height, closestPoint.minWidthDps, closestPoint.minHeightDps) == 0) {
        return closestPoint;
    }
    DisplayOption out = new DisplayOption(closestOption);
    for (int i = 0; i < points.size() && i < KNEARESTNEIGHBOR; ++i) {
        DisplayOption p = points.get(i);
        float w = weight(width, height, p.minWidthDps, p.minHeightDps, WEIGHT_POWER);
        weights += w;
        out.add(new DisplayOption().add(p).multiply(w));
    }
    out.multiply(1.0f / weights);
    // predefined size to avoid cache invalidation
    for (int i = INDEX_DEFAULT; i < COUNT_SIZES; i++) {
        out.iconSizes[i] = Math.min(out.iconSizes[i], closestPoint.iconSizes[i]);
    }
    return out;
}
Also used : WindowBounds(com.android.launcher3.util.WindowBounds) Point(android.graphics.Point)

Example 5 with WindowBounds

use of com.android.launcher3.util.WindowBounds 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)

Aggregations

WindowBounds (com.android.launcher3.util.WindowBounds)41 Point (android.graphics.Point)16 Rect (android.graphics.Rect)15 WindowMetrics (android.view.WindowMetrics)12 Insets (android.graphics.Insets)7 ArrayList (java.util.ArrayList)7 Display (android.view.Display)6 WindowManager (android.view.WindowManager)6 DeviceProfile (com.android.launcher3.DeviceProfile)6 RemoteAnimationTargetCompat (com.android.systemui.shared.system.RemoteAnimationTargetCompat)6 ComponentName (android.content.ComponentName)5 DisplayMetrics (android.util.DisplayMetrics)5 RecentsOrientedState (com.android.quickstep.util.RecentsOrientedState)4 DefaultDisplay (com.android.launcher3.util.DefaultDisplay)1 Info (com.android.launcher3.util.DisplayController.Info)1