Search in sources :

Example 1 with OptionsPanel

use of com.saggitt.omega.views.OptionsPanel in project Neo-Launcher by NeoApplications.

the class WorkspaceStateTransitionAnimation method setWorkspaceProperty.

/**
 * Starts a transition animation for the workspace.
 */
private void setWorkspaceProperty(LauncherState state, PropertySetter propertySetter, AnimatorSetBuilder builder, AnimationConfig config) {
    ScaleAndTranslation scaleAndTranslation = state.getWorkspaceScaleAndTranslation(mLauncher);
    ScaleAndTranslation hotseatScaleAndTranslation = state.getHotseatScaleAndTranslation(mLauncher);
    mNewScale = scaleAndTranslation.scale;
    PageAlphaProvider pageAlphaProvider = state.getWorkspacePageAlphaProvider(mLauncher);
    final int childCount = mWorkspace.getChildCount();
    for (int i = 0; i < childCount; i++) {
        applyChildState(state, (CellLayout) mWorkspace.getChildAt(i), i, pageAlphaProvider, propertySetter, builder, config);
    }
    int elements = state.getVisibleElements(mLauncher);
    Interpolator fadeInterpolator = builder.getInterpolator(ANIM_WORKSPACE_FADE, pageAlphaProvider.interpolator);
    boolean playAtomicComponent = config.playAtomicOverviewScaleComponent();
    Hotseat hotseat = mWorkspace.getHotseat();
    if (playAtomicComponent) {
        Interpolator scaleInterpolator = builder.getInterpolator(ANIM_WORKSPACE_SCALE, ZOOM_OUT);
        propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, scaleInterpolator);
        if (!hotseat.getRotationMode().isTransposed) {
            // Set the hotseat's pivot point to match the workspace's, so that it scales
            // together. Since both hotseat and workspace can move, transform the point
            // manually instead of using dragLayer.getDescendantCoordRelativeToSelf and
            // related methods.
            /*hotseat.setPivotY(mWorkspace.getPivotY() + mWorkspace.getTop() - hotseat.getTop());
                hotseat.setPivotX(mWorkspace.getPivotX()
                        + mWorkspace.getLeft() - hotseat.getLeft());*/
            DragLayer dragLayer = mLauncher.getDragLayer();
            float[] workspacePivot = new float[] { mWorkspace.getPivotX(), mWorkspace.getPivotY() };
            dragLayer.getDescendantCoordRelativeToSelf(mWorkspace, workspacePivot);
            dragLayer.mapCoordInSelfToDescendant(hotseat, workspacePivot);
            hotseat.setPivotX(workspacePivot[0]);
            hotseat.setPivotY(workspacePivot[1]);
        }
        float hotseatScale = hotseatScaleAndTranslation.scale;
        Interpolator hotseatScaleInterpolator = builder.getInterpolator(ANIM_HOTSEAT_SCALE, scaleInterpolator);
        propertySetter.setFloat(hotseat, SCALE_PROPERTY, hotseatScale, hotseatScaleInterpolator);
        float hotseatIconsAlpha = (elements & HOTSEAT_ICONS) != 0 ? 1 : 0;
        propertySetter.setViewAlpha(hotseat, hotseatIconsAlpha, fadeInterpolator);
        propertySetter.setViewAlpha(mLauncher.getWorkspace().getPageIndicator(), hotseatIconsAlpha, fadeInterpolator);
    }
    // Set options view
    OptionsPanel optionsPanel = OmegaLauncher.getLauncher(mLauncher).getOptionsView();
    propertySetter.setViewAlpha(optionsPanel, (elements & OPTIONS_VIEW) != 0 ? 1 : 0, fadeInterpolator);
    if (!config.playNonAtomicComponent()) {
        // Only the alpha and scale, handled above, are included in the atomic animation.
        return;
    }
    Interpolator translationInterpolator = !playAtomicComponent ? LINEAR : builder.getInterpolator(ANIM_WORKSPACE_TRANSLATE, ZOOM_OUT);
    propertySetter.setFloat(mWorkspace, View.TRANSLATION_X, scaleAndTranslation.translationX, translationInterpolator);
    propertySetter.setFloat(mWorkspace, View.TRANSLATION_Y, scaleAndTranslation.translationY, translationInterpolator);
    Interpolator hotseatTranslationInterpolator = builder.getInterpolator(ANIM_HOTSEAT_TRANSLATE, translationInterpolator);
    propertySetter.setFloat(hotseat, View.TRANSLATION_Y, hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
    propertySetter.setFloat(mWorkspace.getPageIndicator(), View.TRANSLATION_Y, hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
    setScrim(propertySetter, state);
}
Also used : ScaleAndTranslation(com.android.launcher3.LauncherState.ScaleAndTranslation) DragLayer(com.android.launcher3.dragndrop.DragLayer) PageAlphaProvider(com.android.launcher3.LauncherState.PageAlphaProvider) Interpolator(android.view.animation.Interpolator) OptionsPanel(com.saggitt.omega.views.OptionsPanel)

Aggregations

Interpolator (android.view.animation.Interpolator)1 PageAlphaProvider (com.android.launcher3.LauncherState.PageAlphaProvider)1 ScaleAndTranslation (com.android.launcher3.LauncherState.ScaleAndTranslation)1 DragLayer (com.android.launcher3.dragndrop.DragLayer)1 OptionsPanel (com.saggitt.omega.views.OptionsPanel)1