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

Commit c02aa6c6 authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Removing some unused PagedView attributes" into ub-launcher3-master

parents 359658b9 cf25b527
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -75,10 +75,6 @@
    <!-- PagedView specific attributes. These attributes are used to customize
         a PagedView view in XML files. -->
    <declare-styleable name="PagedView">
        <!-- A spacing override for the icons within a page -->
        <attr name="pageLayoutWidthGap" format="dimension" />
        <attr name="pageLayoutHeightGap" format="dimension" />

        <!-- The page indicator for this workspace -->
        <attr name="pageIndicator" format="reference" />
    </declare-styleable>
+5 −5
Original line number Diff line number Diff line
@@ -353,13 +353,13 @@ public class DeviceProfile {
    }

    // The rect returned will be extended to below the system ui that covers the workspace
    Rect getHotseatRect() {
    public boolean isInHotseatRect(int x, int y) {
        if (isVerticalBarLayout()) {
            return new Rect(availableWidthPx - hotseatBarHeightPx, 0,
                    Integer.MAX_VALUE, availableHeightPx);
            return (x >= (availableWidthPx - hotseatBarHeightPx))
                    && (y >= 0) && (y <= availableHeightPx);
        } else {
            return new Rect(0, availableHeightPx - hotseatBarHeightPx,
                    availableWidthPx, Integer.MAX_VALUE);
            return (x >= 0) && (x <= availableWidthPx)
                    && (y >= (availableHeightPx - hotseatBarHeightPx));
        }
    }

+19 −48
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.animation.AnimatorSet;
import android.animation.LayoutTransition;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
@@ -47,10 +48,8 @@ import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.Interpolator;

import com.android.launcher3.util.LauncherEdgeEffect;
import com.android.launcher3.util.Thunk;

import java.util.ArrayList;

/**
@@ -67,7 +66,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc

    protected static final int PAGE_SNAP_ANIMATION_DURATION = 750;
    protected static final int SLOW_PAGE_SNAP_ANIMATION_DURATION = 950;
    protected static final float NANOTIME_DIV = 1000000000.0f;

    private static final float RETURN_TO_ORIGINAL_PAGE_THRESHOLD = 0.33f;
    // The page is moved more than halfway, automatically move to the next page on touch up.
@@ -87,25 +85,19 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
    private int mFreeScrollMinScrollX = -1;
    private int mFreeScrollMaxScrollX = -1;

    static final int AUTOMATIC_PAGE_SPACING = -1;

    protected int mFlingThresholdVelocity;
    protected int mMinFlingVelocity;
    protected int mMinSnapVelocity;

    protected float mDensity;
    protected float mSmoothingTime;
    protected float mTouchX;

    protected boolean mFirstLayout = true;
    private int mNormalChildHeight;

    protected int mCurrentPage;
    protected int mRestorePage = INVALID_RESTORE_PAGE;
    protected int mChildCountOnLastLayout;
    private int mChildCountOnLastLayout;

    protected int mNextPage = INVALID_PAGE;
    protected int mMaxScrollX;
    private int mMaxScrollX;
    protected LauncherScroller mScroller;
    private Interpolator mDefaultInterpolator;
    private VelocityTracker mVelocityTracker;
@@ -117,10 +109,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
    private float mDownMotionY;
    private float mDownScrollX;
    private float mDragViewBaselineLeft;
    protected float mLastMotionX;
    protected float mLastMotionXRemainder;
    protected float mLastMotionY;
    protected float mTotalMotionX;
    private float mLastMotionX;
    private float mLastMotionXRemainder;
    private float mLastMotionY;
    private float mTotalMotionX;
    private int mLastScreenCenter = -1;

    private boolean mCancelTap;
@@ -133,23 +125,17 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
    protected final static int TOUCH_STATE_NEXT_PAGE = 3;
    protected final static int TOUCH_STATE_REORDERING = 4;

    protected final static float ALPHA_QUANTIZE_LEVEL = 0.0001f;

    protected int mTouchState = TOUCH_STATE_REST;
    protected boolean mForceScreenScrolled = false;
    private boolean mForceScreenScrolled = false;

    protected OnLongClickListener mLongClickListener;

    protected int mTouchSlop;
    private int mMaximumVelocity;
    protected int mPageLayoutWidthGap;
    protected int mPageLayoutHeightGap;
    protected int mCellCountX = 0;
    protected int mCellCountY = 0;
    protected boolean mCenterPagesVertically;
    protected boolean mAllowOverScroll = true;
    protected int[] mTempVisiblePagesRange = new int[2];
    protected boolean mForceDrawAllChildrenNextFrame;

    protected static final int INVALID_POINTER = -1;

@@ -180,7 +166,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc

    private float mMinScale = 1f;
    private boolean mUseMinScale = false;
    protected View mDragView;
    @Thunk View mDragView;
    private Runnable mSidePageHoverRunnable;
    @Thunk int mSidePageHoverIndex = -1;
    // This variable's scope is only for the duration of startReordering() and endReordering()
@@ -189,12 +175,12 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
    // animation after endReordering()
    private boolean mIsReordering;
    // The runnable that settles the page after snapToPage and animateDragViewToOriginalPosition
    private int NUM_ANIMATIONS_RUNNING_BEFORE_ZOOM_OUT = 2;
    private static final int NUM_ANIMATIONS_RUNNING_BEFORE_ZOOM_OUT = 2;
    private int mPostReorderingPreZoomInRemainingAnimationCount;
    private Runnable mPostReorderingPreZoomInRunnable;

    // Convenience/caching
    private static final Matrix sTmpInvMatrix = new Matrix();
    protected static final Matrix sTmpInvMatrix = new Matrix();
    private static final float[] sTmpPoint = new float[2];
    private static final int[] sTmpIntPoint = new int[2];
    private static final Rect sTmpRect = new Rect();
@@ -223,11 +209,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc

        TypedArray a = context.obtainStyledAttributes(attrs,
                R.styleable.PagedView, defStyle, 0);

        mPageLayoutWidthGap = a.getDimensionPixelSize(
                R.styleable.PagedView_pageLayoutWidthGap, 0);
        mPageLayoutHeightGap = a.getDimensionPixelSize(
                R.styleable.PagedView_pageLayoutHeightGap, 0);
        mPageIndicatorViewId = a.getResourceId(R.styleable.PagedView_pageIndicator, -1);
        a.recycle();

@@ -243,16 +224,15 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
        mScroller = new LauncherScroller(getContext());
        setDefaultInterpolator(new ScrollInterpolator());
        mCurrentPage = 0;
        mCenterPagesVertically = true;

        final ViewConfiguration configuration = ViewConfiguration.get(getContext());
        mTouchSlop = configuration.getScaledPagingTouchSlop();
        mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
        mDensity = getResources().getDisplayMetrics().density;

        mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * mDensity);
        mMinFlingVelocity = (int) (MIN_FLING_VELOCITY * mDensity);
        mMinSnapVelocity = (int) (MIN_SNAP_VELOCITY * mDensity);
        float density = getResources().getDisplayMetrics().density;
        mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * density);
        mMinFlingVelocity = (int) (MIN_FLING_VELOCITY * density);
        mMinSnapVelocity = (int) (MIN_SNAP_VELOCITY * density);
        setOnHierarchyChangeListener(this);
        setWillNotDraw(false);
    }
@@ -606,9 +586,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
            super.scrollTo(x, y);
        }

        mTouchX = x;
        mSmoothingTime = System.nanoTime() / NANOTIME_DIV;

        // Update the last motion events when scrolling
        if (isReordering(true)) {
            float[] p = mapPointFromParentToView(this, mParentDownMotionX, mParentDownMotionY);
@@ -836,6 +813,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
        setMeasuredDimension(scaledWidthSize, scaledHeightSize);
    }

    @SuppressLint("DrawAllocation")
    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        if (getChildCount() == 0) {
@@ -874,10 +852,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
                    childTop = offsetY;
                } else {
                    childTop = offsetY + getPaddingTop() + mInsets.top;
                    if (mCenterPagesVertically) {
                    childTop += (getViewportHeight() - mInsets.top - mInsets.bottom - verticalPadding - child.getMeasuredHeight()) / 2;
                }
                }

                final int childWidth = child.getMeasuredWidth();
                final int childHeight = child.getMeasuredHeight();
@@ -1136,8 +1112,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
                for (int i = pageCount - 1; i >= 0; i--) {
                    final View v = getPageAt(i);
                    if (v == mDragView) continue;
                    if (mForceDrawAllChildrenNextFrame ||
                               (leftScreen <= i && i <= rightScreen && shouldDrawChild(v))) {
                    if (leftScreen <= i && i <= rightScreen && shouldDrawChild(v)) {
                        drawChild(canvas, v, drawingTime);
                    }
                }
@@ -1146,7 +1121,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
                    drawChild(canvas, mDragView, drawingTime);
                }

                mForceDrawAllChildrenNextFrame = false;
                canvas.restore();
            }
        }
@@ -1450,8 +1424,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
            mTotalMotionX += Math.abs(mLastMotionX - x);
            mLastMotionX = x;
            mLastMotionXRemainder = 0;
            mTouchX = getViewportOffsetX() + getScrollX();
            mSmoothingTime = System.nanoTime() / NANOTIME_DIV;
            onScrollInteractionBegin();
            pageBeginMoving();
        }
@@ -1650,8 +1622,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
                // keep the remainder because we are actually testing if we've moved from the last
                // scrolled position (which is discrete).
                if (Math.abs(deltaX) >= 1.0f) {
                    mTouchX += deltaX;
                    mSmoothingTime = System.nanoTime() / NANOTIME_DIV;
                    scrollBy((int) deltaX, 0);
                    mLastMotionX = x;
                    mLastMotionXRemainder = deltaX - (int) deltaX;
@@ -2276,6 +2246,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
    private static final int ANIM_TAG_KEY = 100;

    /* Accessibility */
    @SuppressWarnings("deprecation")
    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    @Override
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
+29 −48
Original line number Diff line number Diff line
@@ -92,13 +92,17 @@ public class Workspace extends PagedView

    private static boolean ENFORCE_DRAG_EVENT_ORDER = false;

    protected static final int SNAP_OFF_EMPTY_SCREEN_DURATION = 400;
    protected static final int FADE_EMPTY_SCREEN_DURATION = 150;
    private static final int SNAP_OFF_EMPTY_SCREEN_DURATION = 400;
    private static final int FADE_EMPTY_SCREEN_DURATION = 150;

    private static final int ADJACENT_SCREEN_DROP_DURATION = 300;

    static final boolean MAP_NO_RECURSE = false;
    static final boolean MAP_RECURSE = true;
    private static final boolean MAP_NO_RECURSE = false;
    private static final boolean MAP_RECURSE = true;

    // The screen id used for the empty screen always present to the right.
    public final static long EXTRA_EMPTY_SCREEN_ID = -201;
    private final static long CUSTOM_CONTENT_SCREEN_ID = -301;

    private static final long CUSTOM_CONTENT_GESTURE_DELAY = 200;
    private long mTouchDownTime = -1;
@@ -113,10 +117,6 @@ public class Workspace extends PagedView

    private ShortcutAndWidgetContainer mDragSourceInternal;

    // The screen id used for the empty screen always present to the right.
    final static long EXTRA_EMPTY_SCREEN_ID = -201;
    private final static long CUSTOM_CONTENT_SCREEN_ID = -301;

    @Thunk LongArrayMap<CellLayout> mWorkspaceScreens = new LongArrayMap<>();
    @Thunk ArrayList<Long> mScreenOrder = new ArrayList<Long>();

@@ -136,8 +136,8 @@ public class Workspace extends PagedView
    private int mDragOverX = -1;
    private int mDragOverY = -1;

    static Rect mLandscapeCellLayoutMetrics = null;
    static Rect mPortraitCellLayoutMetrics = null;
    private static Rect mLandscapeCellLayoutMetrics = null;
    private static Rect mPortraitCellLayoutMetrics = null;

    CustomContentCallbacks mCustomContentCallbacks;
    boolean mCustomContentShowing;
@@ -164,11 +164,11 @@ public class Workspace extends PagedView

    // These are temporary variables to prevent having to allocate a new object just to
    // return an (x, y) value from helper functions. Do NOT use them to maintain other state.
    private int[] mTempCell = new int[2];
    private int[] mTempPt = new int[2];
    private static final Rect sTempRect = new Rect();
    private final int[] mTempXY = new int[2];
    @Thunk float[] mDragViewVisualCenter = new float[2];
    private float[] mTempCellLayoutCenterCoordinates = new float[2];
    private Matrix mTempInverseMatrix = new Matrix();
    private int[] mTempVisiblePagesRange = new int[2];

    private SpringLoadedDragController mSpringLoadedDragController;
    private float mSpringLoadedShrinkFactor;
@@ -182,7 +182,6 @@ public class Workspace extends PagedView
    private boolean mIsSwitchingState = false;

    boolean mAnimatingViewIntoPlace = false;
    boolean mIsDragOccuring = false;
    boolean mChildrenLayersEnabled = true;

    private boolean mStripScreensOnPageStopMoving = false;
@@ -192,9 +191,6 @@ public class Workspace extends PagedView

    private HolographicOutlineHelper mOutlineHelper;
    @Thunk Bitmap mDragOutline = null;
    private static final Rect sTempRect = new Rect();
    private final int[] mTempXY = new int[2];
    private int[] mTempVisiblePagesRange = new int[2];
    public static final int DRAG_BITMAP_PADDING = 2;
    private boolean mWorkspaceFadeInAdjacentScreens;

@@ -205,7 +201,6 @@ public class Workspace extends PagedView

    @Thunk Runnable mDelayedResizeRunnable;
    private Runnable mDelayedSnapToPageRunnable;
    private Point mDisplaySize = new Point();

    // Variables relating to the creation of user folders by hovering shortcuts over shortcuts
    private static final int FOLDER_CREATION_TIMEOUT = 0;
@@ -372,7 +367,6 @@ public class Workspace extends PagedView
            enfoceDragParity("onDragStart", 0, 0);
        }

        mIsDragOccuring = true;
        updateChildrenLayersEnabled(false);
        mLauncher.lockScreenOrientation();
        mLauncher.onInteractionBegin();
@@ -403,7 +397,6 @@ public class Workspace extends PagedView
            removeExtraEmptyScreen(true, mDragSourceInternal != null);
        }

        mIsDragOccuring = false;
        updateChildrenLayersEnabled(false);
        mLauncher.unlockScreenOrientation(false);

@@ -431,8 +424,6 @@ public class Workspace extends PagedView
        setupLayoutTransition();

        mWallpaperOffset = new WallpaperOffsetInterpolator();
        Display display = mLauncher.getWindowManager().getDefaultDisplay();
        display.getSize(mDisplaySize);

        mMaxDistanceForFolderCreation = (0.55f * grid.iconSizePx);

@@ -1835,7 +1826,7 @@ public class Workspace extends PagedView
    }

    protected void onWallpaperTap(MotionEvent ev) {
        final int[] position = mTempCell;
        final int[] position = mTempXY;
        getLocationOnScreen(position);

        int pointerIndex = ev.getActionIndex();
@@ -3005,30 +2996,21 @@ public class Workspace extends PagedView
       xy[1] = xy[1] - v.getTop();
   }

   boolean isPointInSelfOverHotseat(int x, int y, Rect r) {
       if (r == null) {
           r = new Rect();
       }
       mTempPt[0] = x;
       mTempPt[1] = y;
       mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempPt, true);

       DeviceProfile grid = mLauncher.getDeviceProfile();
       r = grid.getHotseatRect();
       if (r.contains(mTempPt[0], mTempPt[1])) {
           return true;
       }
       return false;
   boolean isPointInSelfOverHotseat(int x, int y) {
       mTempXY[0] = x;
       mTempXY[1] = y;
       mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempXY, true);
       return mLauncher.getDeviceProfile().isInHotseatRect(mTempXY[0], mTempXY[1]);
   }

   void mapPointFromSelfToHotseatLayout(Hotseat hotseat, float[] xy) {
       mTempPt[0] = (int) xy[0];
       mTempPt[1] = (int) xy[1];
       mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempPt, true);
       mLauncher.getDragLayer().mapCoordInSelfToDescendent(hotseat.getLayout(), mTempPt);
       mTempXY[0] = (int) xy[0];
       mTempXY[1] = (int) xy[1];
       mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempXY, true);
       mLauncher.getDragLayer().mapCoordInSelfToDescendent(hotseat.getLayout(), mTempXY);

       xy[0] = mTempPt[0];
       xy[1] = mTempPt[1];
       xy[0] = mTempXY[0];
       xy[1] = mTempXY[1];
   }

   /*
@@ -3076,8 +3058,8 @@ public class Workspace extends PagedView
            final float[] touchXy = {originX, originY};
            // Transform the touch coordinates to the CellLayout's local coordinates
            // If the touch point is within the bounds of the cell layout, we can return immediately
            cl.getMatrix().invert(mTempInverseMatrix);
            mapPointFromSelfToChild(cl, touchXy, mTempInverseMatrix);
            cl.getMatrix().invert(sTmpInvMatrix);
            mapPointFromSelfToChild(cl, touchXy, sTmpInvMatrix);

            if (touchXy[0] >= 0 && touchXy[0] <= cl.getWidth() &&
                    touchXy[1] >= 0 && touchXy[1] <= cl.getHeight()) {
@@ -3119,7 +3101,6 @@ public class Workspace extends PagedView
        // Skip drag over events while we are dragging over side pages
        if (mInScrollArea || !transitionStateShouldAllowDrop()) return;

        Rect r = new Rect();
        CellLayout layout = null;
        ItemInfo item = d.dragInfo;
        if (item == null) {
@@ -3137,7 +3118,7 @@ public class Workspace extends PagedView
        // Identify whether we have dragged over a side page
        if (workspaceInModalState()) {
            if (mLauncher.getHotseat() != null && !isExternalDragWidget(d)) {
                if (isPointInSelfOverHotseat(d.x, d.y, r)) {
                if (isPointInSelfOverHotseat(d.x, d.y)) {
                    layout = mLauncher.getHotseat().getLayout();
                }
            }
@@ -3160,7 +3141,7 @@ public class Workspace extends PagedView
        } else {
            // Test to see if we are over the hotseat otherwise just use the current page
            if (mLauncher.getHotseat() != null && !isDragWidget(d)) {
                if (isPointInSelfOverHotseat(d.x, d.y, r)) {
                if (isPointInSelfOverHotseat(d.x, d.y)) {
                    layout = mLauncher.getHotseat().getLayout();
                }
            }