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

Commit 1a52ef57 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Removing some dependency on Launcher UI

Change-Id: Ic1c84880cfe4daa9398b8eb27c3afc0837c5a8ca
parent 9bb0d726
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.launcher3.uioverrides;
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
import static com.android.launcher3.anim.Interpolators.ACCEL_2;

import android.content.Context;
import android.graphics.Rect;
import android.view.View;

@@ -74,15 +75,7 @@ public class OverviewState extends LauncherState {

    @Override
    public float getVerticalProgress(Launcher launcher) {
        DeviceProfile grid = launcher.getDeviceProfile();
        if (!grid.isVerticalBarLayout()) {
            return 1f;
        }

        float total = grid.heightPx;
        float searchHeight = total - grid.availableHeightPx +
                launcher.getResources().getDimension(R.dimen.all_apps_search_box_full_height);
        return 1 - (searchHeight / total);
        return getVerticalProgress(launcher.getDeviceProfile(), launcher);
    }

    @Override
@@ -125,4 +118,15 @@ public class OverviewState extends LauncherState {

        return new float[] {scale, translationX, translationY};
    }

    public static float getVerticalProgress(DeviceProfile grid, Context context) {
        if (!grid.isVerticalBarLayout()) {
            return 1f;
        }

        float total = grid.heightPx;
        float searchHeight = total - grid.availableHeightPx +
                context.getResources().getDimension(R.dimen.all_apps_search_box_full_height);
        return 1 - (searchHeight / total);
    }
}
+11 −8
Original line number Diff line number Diff line
@@ -33,14 +33,15 @@ import android.view.View;
import android.view.ViewTreeObserver.OnPreDrawListener;

import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Hotseat;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.states.InternalStateHandler;
import com.android.launcher3.uioverrides.RecentsViewStateController;
import com.android.launcher3.util.TraceHelper;
@@ -112,6 +113,15 @@ public class NavBarSwipeInteractionHandler extends InternalStateHandler {
        mContext = context;
        WindowManagerWrapper.getInstance().getStableInsets(mStableInsets);

        DeviceProfile dp = LauncherAppState.getIDP(mContext).getDeviceProfile(mContext);
        // TODO: If in multi window mode, dp = dp.getMultiWindowProfile()
        dp = dp.copy(mContext);
        // TODO: Use different insets for multi-window mode
        dp.updateInsets(mStableInsets);
        RecentsView.getPageRect(dp, mContext, mTargetRect);
        mSourceRect.set(0, 0, dp.widthPx - mStableInsets.left - mStableInsets.right,
                dp.heightPx - mStableInsets.top - mStableInsets.bottom);

        // Build the state callback
        mStateCallback = new MultiStateCallback();
        mStateCallback.addCallback(STATE_LAUNCHER_READY, this::onLauncherReady);
@@ -218,13 +228,6 @@ public class NavBarSwipeInteractionHandler extends InternalStateHandler {
            return;
        }

        if (mTargetRect.isEmpty()) {
            RecentsView.getPageRect(mLauncher, mTargetRect);
            DragLayer dl = mLauncher.getDragLayer();
            mSourceRect.set(0, 0, dl.getWidth() - mStableInsets.left - mStableInsets.right,
                    dl.getHeight() - mStableInsets.top - mStableInsets.bottom);
        }

        float shift = mCurrentShift.value * mActivityMultiplier.value;
        int hotseatSize = getHotseatSize();

+14 −10
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.launcher3.LauncherState;
import com.android.launcher3.PagedView;
import com.android.launcher3.R;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.uioverrides.OverviewState;
import com.android.launcher3.uioverrides.RecentsViewStateController;
import com.android.systemui.shared.recents.model.RecentsTaskLoadPlan;
import com.android.systemui.shared.recents.model.RecentsTaskLoader;
@@ -106,7 +107,8 @@ public class RecentsView extends PagedView {
    protected void onFinishInflate() {
        super.onFinishInflate();

        Rect padding = getPadding(Launcher.getLauncher(getContext()));
        Rect padding =
                getPadding(Launcher.getLauncher(getContext()).getDeviceProfile(), getContext());
        setPadding(padding.left, padding.top, padding.right, padding.bottom);

        mFirstTaskIndex = getPageCount();
@@ -213,8 +215,7 @@ public class RecentsView extends PagedView {
        }
    }

    private static Rect getPadding(Launcher launcher) {
        DeviceProfile profile = launcher.getDeviceProfile();
    private static Rect getPadding(DeviceProfile profile, Context context) {
        Rect stableInsets = new Rect();
        WindowManagerWrapper.getInstance().getStableInsets(stableInsets);
        Rect padding = new Rect(profile.workspacePadding);
@@ -228,7 +229,7 @@ public class RecentsView extends PagedView {
            float availableWidth = taskWidth - 2 * Math.max(padding.left, padding.right);
            float availableHeight = profile.availableHeightPx - padding.top - padding.bottom
                    - stableInsets.top
                    - profile.heightPx * (1 - OVERVIEW.getVerticalProgress(launcher));
                    - profile.heightPx * (1 - OverviewState.getVerticalProgress(profile, context));

            float scaledRatio = Math.min(availableWidth / taskWidth, availableHeight / taskHeight);
            overviewHeight = taskHeight * scaledRatio;
@@ -247,15 +248,18 @@ public class RecentsView extends PagedView {
    }

    public static void getPageRect(Launcher launcher, Rect outRect) {
        DragLayer dl = launcher.getDragLayer();
        Rect targetPadding = getPadding(launcher);
        Rect insets = dl.getInsets();
        getPageRect(launcher.getDeviceProfile(), launcher, outRect);
    }

    public static void getPageRect(DeviceProfile grid, Context context, Rect outRect) {
        Rect targetPadding = getPadding(grid, context);
        Rect insets = grid.getInsets();
        outRect.set(
                targetPadding.left + insets.left,
                targetPadding.top + insets.top,
                dl.getWidth() - targetPadding.right - insets.right,
                dl.getHeight() - targetPadding.bottom - insets.bottom);
        outRect.top += launcher.getResources()
                grid.widthPx - targetPadding.right - insets.right,
                grid.heightPx - targetPadding.bottom - insets.bottom);
        outRect.top += context.getResources()
                .getDimensionPixelSize(R.dimen.task_thumbnail_top_margin);
    }

+9 −1
Original line number Diff line number Diff line
@@ -214,6 +214,11 @@ public class DeviceProfile {
        mBadgeRenderer = new BadgeRenderer(iconSizePx);
    }

    public DeviceProfile copy(Context context) {
        Point size = new Point(availableWidthPx, availableHeightPx);
        return new DeviceProfile(context, inv, size, size, widthPx, heightPx, isLandscape);
    }

    DeviceProfile getMultiWindowProfile(Context context, Point mwSize) {
        // We take the minimum sizes of this profile and it's multi-window variant to ensure that
        // the system decor is always excluded.
@@ -376,6 +381,10 @@ public class DeviceProfile {
        updateWorkspacePadding();
    }

    public Rect getInsets() {
        return mInsets;
    }

    public void updateAppsViewNumCols() {
        allAppsNumCols = allAppsNumPredictiveCols = inv.numColumns;
    }
@@ -509,6 +518,5 @@ public class DeviceProfile {
        Configuration context = new Configuration(c.getResources().getConfiguration());
        context.orientation = orientation;
        return c.createConfigurationContext(context);

    }
}