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

Commit 9bfdb76a authored by Adam Cohen's avatar Adam Cohen
Browse files

Polishing the AllApps transition

-> separating HW layers during animation to be siblings
   instead of parent-child (was destroying parent layer
   on each frame)
-> Unifying material transition with pre-L, everything
   is the same, just missing the reveal.

Change-Id: I8f7d5e658c2d9298bea83ce8199cb35e6fc0d44e
parent 6075170b
Loading
Loading
Loading
Loading
+22 −9
Original line number Diff line number Diff line
@@ -24,17 +24,30 @@
        android:clipChildren="false"
        android:orientation="vertical">

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1">
            <FrameLayout
                android:id="@+id/fake_page_container"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >
                <FrameLayout
                android:id="@+id/fake_page"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
            </FrameLayout>
            <com.android.launcher3.AppsCustomizePagedView
                android:id="@+id/apps_customize_pane_content"
                android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
                android:layout_height="match_parent"
                launcher:widgetCountX="@integer/apps_customize_widget_cell_count_x"
                launcher:widgetCountY="@integer/apps_customize_widget_cell_count_y"
                launcher:clingFocusedX="@integer/apps_customize_cling_focused_x"
                launcher:clingFocusedY="@integer/apps_customize_cling_focused_y"
                launcher:maxGap="@dimen/workspace_max_gap"
                launcher:pageIndicator="@+id/apps_customize_page_indicator" />
        </FrameLayout>
        <include
            android:id="@+id/apps_customize_page_indicator"
            layout="@layout/page_indicator"
+2 −1
Original line number Diff line number Diff line
@@ -31,7 +31,8 @@

    <!-- Fade/zoom in/out duration & scale in the AllApps transition.
         Note: This should be less than the workspaceShrinkTime as they happen together. -->
    <integer name="config_appsCustomizeRevealTime">350</integer>
    <integer name="config_appsCustomizeRevealTime">220</integer>
    <integer name="config_appsCustomizeItemsAlphaStagger">60</integer>
    <integer name="config_appsCustomizeZoomInTime">350</integer>
    <integer name="config_appsCustomizeZoomOutTime">600</integer>
    <integer name="config_appsCustomizeZoomScaleFactor">7</integer>
+19 −22
Original line number Diff line number Diff line
@@ -213,6 +213,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
    int mWidgetLoadingId = -1;
    PendingAddWidgetInfo mCreateWidgetInfo = null;
    private boolean mDraggingWidget = false;
    boolean mPageBackgroundsVisible;

    private Toast mWidgetInstructionToast;

@@ -1003,12 +1004,26 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
        int heightSpec = MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.AT_MOST);
        layout.setMinimumWidth(getPageContentWidth());
        layout.measure(widthSpec, heightSpec);
        layout.setPadding(mAllAppsPadding.left, mAllAppsPadding.top, mAllAppsPadding.right,
                mAllAppsPadding.bottom);
        setVisibilityOnChildren(layout, View.VISIBLE);

        Resources res = getContext().getResources();
        layout.setBackground(res.getDrawable(R.drawable.quantum_panel));
        Drawable bg = res.getDrawable(R.drawable.quantum_panel);
        if (bg != null) {
            layout.setBackground(bg);
            bg.setVisible(mPageBackgroundsVisible, false);
        }

        setVisibilityOnChildren(layout, View.VISIBLE);
    }

    public void setPageBackgroundsVisible(boolean visible) {
        mPageBackgroundsVisible = visible;
        int childCount = getChildCount();
        for (int i = 0; i < childCount; ++i) {
            Drawable bg = getChildAt(i).getBackground();
            if (bg != null) {
                bg.setVisible(visible, false);
            }
        }
    }

    public void syncAppsPageItems(int page, boolean immediate) {
@@ -1438,24 +1453,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
                        v.setRotationY(0f);
                    }
                }

                // TODO: clean this up
                alpha = 1;
                translationX = 0;
                scale = 1;

                v.setTranslationX(translationX);
                v.setScaleX(scale);
                v.setScaleY(scale);
                v.setAlpha(alpha);

                // If the view has 0 alpha, we set it to be invisible so as to prevent
                // it from accepting touches
                if (alpha == 0) {
                    v.setVisibility(INVISIBLE);
                } else if (v.getVisibility() != VISIBLE) {
                    v.setVisibility(VISIBLE);
                }
            }
        }

+0 −22
Original line number Diff line number Diff line
@@ -181,9 +181,6 @@ public class AppsCustomizeTabHost extends FrameLayout implements LauncherTransit
    @Override
    public void onLauncherTransitionStart(Launcher l, boolean animated, boolean toWorkspace) {
        mPagedView.onLauncherTransitionStart(l, animated, toWorkspace);
        if (animated && !Utilities.isLmp()) {
            enableAndBuildHardwareLayer();
        }
    }

    @Override
@@ -195,9 +192,6 @@ public class AppsCustomizeTabHost extends FrameLayout implements LauncherTransit
    public void onLauncherTransitionEnd(Launcher l, boolean animated, boolean toWorkspace) {
        mPagedView.onLauncherTransitionEnd(l, animated, toWorkspace);
        mInTransition = false;
        if (animated && !Utilities.isLmp()) {
            setLayerType(LAYER_TYPE_NONE, null);
        }

        if (!toWorkspace) {
            // Make sure adjacent pages are loaded (we wait until after the transition to
@@ -241,20 +235,4 @@ public class AppsCustomizeTabHost extends FrameLayout implements LauncherTransit
            throw new RuntimeException("Failed; can't get z-order of views");
        }
    }

    private void enableAndBuildHardwareLayer() {
        // isHardwareAccelerated() checks if we're attached to a window and if that
        // window is HW accelerated-- we were sometimes not attached to a window
        // and buildLayer was throwing an IllegalStateException
        if (isHardwareAccelerated()) {
            // Turn on hardware layers for performance
            setLayerType(LAYER_TYPE_HARDWARE, null);

            // force building the layer, so you don't get a blip early in an animation
            // when the layer is created layer
            buildLayer();
        }
    }


}
+16 −3
Original line number Diff line number Diff line
@@ -775,6 +775,11 @@ public class DeviceProfile {

            AppsCustomizePagedView pagedView = (AppsCustomizePagedView)
                    host.findViewById(R.id.apps_customize_pane_content);

            FrameLayout fakePageContainer = (FrameLayout)
                    host.findViewById(R.id.fake_page_container);
            FrameLayout fakePage = (FrameLayout) host.findViewById(R.id.fake_page);

            padding = new Rect();
            if (pagedView != null) {
                // Constrain the dimensions of all apps so that it does not span the full width
@@ -790,16 +795,24 @@ public class DeviceProfile {
                if ((isTablet() || isLandscape) && gridPaddingLR > (allAppsCellWidthPx / 4)) {
                    padding.left = padding.right = gridPaddingLR;
                }

                // The icons are centered, so we can't just offset by the page indicator height
                // because the empty space will actually be pageIndicatorHeight + paddingTB
                padding.bottom = Math.max(0, pageIndicatorHeight - paddingTB);
                pagedView.setAllAppsPadding(padding);

                pagedView.setWidgetsPageIndicatorPadding(pageIndicatorHeight);
                fakePage.setBackground(res.getDrawable(R.drawable.quantum_panel));

                // Horizontal padding for the whole paged view
                int pagedViewPadding =
                int pagedFixedViewPadding =
                        res.getDimensionPixelSize(R.dimen.apps_customize_horizontal_padding);
                pagedView.setPadding(pagedViewPadding, 0, pagedViewPadding, 0);

                padding.left += pagedFixedViewPadding;
                padding.right += pagedFixedViewPadding;

                pagedView.setPadding(padding.left, padding.top, padding.right, padding.bottom);
                fakePageContainer.setPadding(padding.left, padding.top, padding.right, padding.bottom);

            }
        }

Loading