Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b84462a6 authored by Jeremy Sim's avatar Jeremy Sim Committed by Android (Google) Code Review
Browse files

Merge "Fix DWB placement in grouped task view"

parents b82a517f c78ac627
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -144,7 +144,6 @@ public final class DigitalWellBeingToast {

    public void initialize(Task task) {
        mTask = task;

        THREAD_POOL_EXECUTOR.execute(() -> {
            final AppUsageLimit usageLimit = mLauncherApps.getAppUsageLimit(
                    task.getTopComponent().getPackageName(),
@@ -321,7 +320,7 @@ public final class DigitalWellBeingToast {
                mTaskView.getThumbnail().getLayoutParams()).bottomMargin;
        PagedOrientationHandler orientationHandler = mTaskView.getPagedOrientationHandler();
        Pair<Float, Float> translations = orientationHandler
                .setDwbLayoutParamsAndGetTranslations(mTaskView.getMeasuredWidth(),
                .getDwbLayoutTranslations(mTaskView.getMeasuredWidth(),
                        mTaskView.getMeasuredHeight(), mStagedSplitBounds, deviceProfile,
                        mTaskView.getThumbnails(), mTask.key.id, mBanner);
        mSplitOffsetTranslationX = translations.first;
+8 −0
Original line number Diff line number Diff line
@@ -242,6 +242,7 @@ public class GroupedTaskView extends TaskView {
        mIconView2.setDrawableSize(iconDrawableSize, iconDrawableSize);
        mIconView2.setRotation(getPagedOrientationHandler().getDegreesRotated());
        updateIconPlacement();
        updateSecondaryDwbPlacement();
    }

    private void updateIconPlacement() {
@@ -258,6 +259,13 @@ public class GroupedTaskView extends TaskView {
                isRtl, deviceProfile, mSplitBoundsConfig);
    }

    private void updateSecondaryDwbPlacement() {
        if (mSecondaryTask == null) {
            return;
        }
        mDigitalWellBeingToast2.initialize(mSecondaryTask);
    }

    @Override
    protected void updateSnapshotRadius() {
        super.updateSnapshotRadius();
+5 −0
Original line number Diff line number Diff line
@@ -897,6 +897,7 @@ public class TaskView extends FrameLayout implements Reusable {
        LayoutParams iconParams = (LayoutParams) mIconView.getLayoutParams();
        orientationHandler.setIconAndSnapshotParams(mIconView, taskIconMargin, taskIconHeight,
                snapshotParams, isRtl);
        updateDwbPlacement();
        mSnapshotView.setLayoutParams(snapshotParams);
        iconParams.width = iconParams.height = taskIconHeight;
        mIconView.setLayoutParams(iconParams);
@@ -909,6 +910,10 @@ public class TaskView extends FrameLayout implements Reusable {
        mSnapshotView.getTaskOverlay().updateOrientationState(orientationState);
    }

    private void updateDwbPlacement() {
        mDigitalWellBeingToast.initialize(mTask);
    }

    /**
     * Returns whether the task is part of overview grid and not being focused.
     */
+11 −6
Original line number Diff line number Diff line
@@ -310,9 +310,10 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
    }

    @Override
    public Pair<Float, Float> setDwbLayoutParamsAndGetTranslations(int taskViewWidth,
    public Pair<Float, Float> getDwbLayoutTranslations(int taskViewWidth,
            int taskViewHeight, StagedSplitBounds splitBounds, DeviceProfile deviceProfile,
            View[] thumbnailViews, int desiredTaskId, View banner) {
        boolean isRtl = banner.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
        float translationX = 0;
        float translationY = 0;
        FrameLayout.LayoutParams bannerParams = (FrameLayout.LayoutParams) banner.getLayoutParams();
@@ -323,7 +324,7 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
        FrameLayout.LayoutParams snapshotParams =
                (FrameLayout.LayoutParams) thumbnailViews[0]
                        .getLayoutParams();
        bannerParams.gravity = TOP | START;
        bannerParams.gravity = TOP | (isRtl ? END : START);
        if (splitBounds == null) {
            // Single, fullscreen case
            bannerParams.width = taskViewHeight - snapshotParams.topMargin;
@@ -339,9 +340,11 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {

        // Set translations
        if (desiredTaskId == splitBounds.rightBottomTaskId) {
            translationY = (snapshotParams.topMargin + taskViewHeight)
                    * (splitBounds.leftTaskPercent) +
                    (taskViewHeight * splitBounds.dividerWidthPercent);
            float topLeftTaskPlusDividerPercent = splitBounds.appsStackedVertically
                    ? (splitBounds.topTaskPercent + splitBounds.dividerHeightPercent)
                    : (splitBounds.leftTaskPercent + splitBounds.dividerWidthPercent);
            translationY = snapshotParams.topMargin
                    + ((taskViewHeight - snapshotParams.topMargin) * topLeftTaskPlusDividerPercent);
        }
        if (desiredTaskId == splitBounds.leftTopTaskId) {
            translationY = snapshotParams.topMargin;
@@ -440,7 +443,9 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
            StagedSplitBounds splitBoundsConfig, DeviceProfile dp) {
        int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx;
        int totalThumbnailHeight = parentHeight - spaceAboveSnapshot;
        int dividerBar = splitBoundsConfig.visualDividerBounds.width();
        int dividerBar = splitBoundsConfig.appsStackedVertically
                ? splitBoundsConfig.visualDividerBounds.height()
                : splitBoundsConfig.visualDividerBounds.width();
        int primarySnapshotHeight;
        int primarySnapshotWidth;
        int secondarySnapshotHeight;
+6 −1
Original line number Diff line number Diff line
@@ -191,7 +191,12 @@ public interface PagedOrientationHandler {
     */
    PointF getAdditionalInsetForTaskMenu(float margin);

    Pair<Float, Float> setDwbLayoutParamsAndGetTranslations(int taskViewWidth,
    /**
     * Calculates the position where a Digital Wellbeing Banner should be placed on its parent
     * TaskView.
     * @return A Pair of Floats representing the proper x and y translations.
     */
    Pair<Float, Float> getDwbLayoutTranslations(int taskViewWidth,
            int taskViewHeight, StagedSplitBounds splitBounds, DeviceProfile deviceProfile,
            View[] thumbnailViews, int desiredTaskId, View banner);

Loading