Search in sources :

Example 16 with CellLayout

use of com.android.launcher3.CellLayout in project android_packages_apps_Launcher3 by crdroidandroid.

the class Workspace method onDropCompleted.

/**
 * Called at the end of a drag which originated on the workspace.
 */
public void onDropCompleted(final View target, final DragObject d, final boolean success) {
    if (success) {
        if (target != this && mDragInfo != null) {
            removeWorkspaceItem(mDragInfo.cell);
        }
    } else if (mDragInfo != null) {
        // When drag is cancelled, reattach content view back to its original parent.
        if (mDragInfo.cell instanceof LauncherAppWidgetHostView && d.dragView != null) {
            d.dragView.detachContentView(/* reattachToPreviousParent= */
            true);
        }
        final CellLayout cellLayout = mLauncher.getCellLayout(mDragInfo.container, mDragInfo.screenId);
        if (cellLayout != null) {
            cellLayout.onDropChild(mDragInfo.cell);
        } else if (FeatureFlags.IS_STUDIO_BUILD) {
            throw new RuntimeException("Invalid state: cellLayout == null in " + "Workspace#onDropCompleted. Please file a bug. ");
        }
    }
    View cell = getHomescreenIconByItemId(d.originalDragInfo.id);
    if (d.cancelled && cell != null) {
        cell.setVisibility(VISIBLE);
    }
    mDragInfo = null;
}
Also used : LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) DraggableView(com.android.launcher3.dragndrop.DraggableView) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) AppWidgetHostView(android.appwidget.AppWidgetHostView) View(android.view.View) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) DragView(com.android.launcher3.dragndrop.DragView)

Example 17 with CellLayout

use of com.android.launcher3.CellLayout in project android_packages_apps_Launcher3 by crdroidandroid.

the class WorkspaceStateTransitionAnimation method applyChildState.

private void applyChildState(LauncherState state, CellLayout cl, int childIndex, PageAlphaProvider pageAlphaProvider, PropertySetter propertySetter, StateAnimationConfig config) {
    float pageAlpha = pageAlphaProvider.getPageAlpha(childIndex);
    float springLoadedProgress = (state instanceof SpringLoadedState) ? 1.0f : 0f;
    propertySetter.setFloat(cl, CellLayout.SPRING_LOADED_PROGRESS, springLoadedProgress, ZOOM_OUT);
    Interpolator fadeInterpolator = config.getInterpolator(ANIM_WORKSPACE_FADE, pageAlphaProvider.interpolator);
    propertySetter.setFloat(cl.getShortcutsAndWidgets(), VIEW_ALPHA, pageAlpha, fadeInterpolator);
}
Also used : SpringLoadedState(com.android.launcher3.states.SpringLoadedState) Interpolator(android.view.animation.Interpolator)

Example 18 with CellLayout

use of com.android.launcher3.CellLayout in project android_packages_apps_Launcher3 by crdroidandroid.

the class WorkspaceStateTransitionAnimation method setWorkspaceProperty.

/**
 * Starts a transition animation for the workspace.
 */
private void setWorkspaceProperty(LauncherState state, PropertySetter propertySetter, StateAnimationConfig 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, config);
    }
    int elements = state.getVisibleElements(mLauncher);
    Interpolator fadeInterpolator = config.getInterpolator(ANIM_WORKSPACE_FADE, pageAlphaProvider.interpolator);
    Hotseat hotseat = mWorkspace.getHotseat();
    Interpolator scaleInterpolator = config.getInterpolator(ANIM_WORKSPACE_SCALE, ZOOM_OUT);
    LauncherState fromState = mLauncher.getStateManager().getState();
    boolean shouldSpring = propertySetter instanceof PendingAnimation && fromState == HINT_STATE && state == NORMAL;
    if (shouldSpring) {
        ((PendingAnimation) propertySetter).add(getSpringScaleAnimator(mLauncher, mWorkspace, mNewScale));
    } else {
        propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, scaleInterpolator);
    }
    mWorkspace.setPivotToScaleWithSelf(hotseat);
    float hotseatScale = hotseatScaleAndTranslation.scale;
    if (shouldSpring) {
        PendingAnimation pa = (PendingAnimation) propertySetter;
        pa.add(getSpringScaleAnimator(mLauncher, hotseat, hotseatScale));
    } else {
        Interpolator hotseatScaleInterpolator = config.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);
    float workspacePageIndicatorAlpha = (elements & WORKSPACE_PAGE_INDICATOR) != 0 ? 1 : 0;
    propertySetter.setViewAlpha(mLauncher.getWorkspace().getPageIndicator(), workspacePageIndicatorAlpha, fadeInterpolator);
    Interpolator translationInterpolator = config.getInterpolator(ANIM_WORKSPACE_TRANSLATE, ZOOM_OUT);
    propertySetter.setFloat(mWorkspace, VIEW_TRANSLATE_X, scaleAndTranslation.translationX, translationInterpolator);
    propertySetter.setFloat(mWorkspace, VIEW_TRANSLATE_Y, scaleAndTranslation.translationY, translationInterpolator);
    Interpolator hotseatTranslationInterpolator = config.getInterpolator(ANIM_HOTSEAT_TRANSLATE, translationInterpolator);
    propertySetter.setFloat(hotseat, VIEW_TRANSLATE_Y, hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
    propertySetter.setFloat(mWorkspace.getPageIndicator(), VIEW_TRANSLATE_Y, hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
    if (!config.hasAnimationFlag(SKIP_SCRIM)) {
        setScrim(propertySetter, state, config);
    }
}
Also used : ScaleAndTranslation(com.android.launcher3.LauncherState.ScaleAndTranslation) PendingAnimation(com.android.launcher3.anim.PendingAnimation) PageAlphaProvider(com.android.launcher3.LauncherState.PageAlphaProvider) Interpolator(android.view.animation.Interpolator)

Example 19 with CellLayout

use of com.android.launcher3.CellLayout in project android_packages_apps_Launcher3 by crdroidandroid.

the class LauncherAccessibilityDelegate method getSupportedResizeActions.

private List<OptionItem> getSupportedResizeActions(View host, LauncherAppWidgetInfo info) {
    List<OptionItem> actions = new ArrayList<>();
    AppWidgetProviderInfo providerInfo = ((LauncherAppWidgetHostView) host).getAppWidgetInfo();
    if (providerInfo == null) {
        return actions;
    }
    CellLayout layout;
    if (host.getParent() instanceof DragView) {
        layout = (CellLayout) ((DragView) host.getParent()).getContentViewParent().getParent();
    } else {
        layout = (CellLayout) host.getParent().getParent();
    }
    if ((providerInfo.resizeMode & AppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0) {
        if (layout.isRegionVacant(info.cellX + info.spanX, info.cellY, 1, info.spanY) || layout.isRegionVacant(info.cellX - 1, info.cellY, 1, info.spanY)) {
            actions.add(new OptionItem(mLauncher, R.string.action_increase_width, R.drawable.ic_widget_width_increase, IGNORE, v -> performResizeAction(R.string.action_increase_width, host, info)));
        }
        if (info.spanX > info.minSpanX && info.spanX > 1) {
            actions.add(new OptionItem(mLauncher, R.string.action_decrease_width, R.drawable.ic_widget_width_decrease, IGNORE, v -> performResizeAction(R.string.action_decrease_width, host, info)));
        }
    }
    if ((providerInfo.resizeMode & AppWidgetProviderInfo.RESIZE_VERTICAL) != 0) {
        if (layout.isRegionVacant(info.cellX, info.cellY + info.spanY, info.spanX, 1) || layout.isRegionVacant(info.cellX, info.cellY - 1, info.spanX, 1)) {
            actions.add(new OptionItem(mLauncher, R.string.action_increase_height, R.drawable.ic_widget_height_increase, IGNORE, v -> performResizeAction(R.string.action_increase_height, host, info)));
        }
        if (info.spanY > info.minSpanY && info.spanY > 1) {
            actions.add(new OptionItem(mLauncher, R.string.action_decrease_height, R.drawable.ic_widget_height_decrease, IGNORE, v -> performResizeAction(R.string.action_decrease_height, host, info)));
        }
    }
    return actions;
}
Also used : Rect(android.graphics.Rect) Bundle(android.os.Bundle) AccessibilityDelegate(android.view.View.AccessibilityDelegate) KeyboardDragAndDropView(com.android.launcher3.keyboard.KeyboardDragAndDropView) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) BubbleTextView(com.android.launcher3.BubbleTextView) OptionsPopupView(com.android.launcher3.views.OptionsPopupView) IGNORE(com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE) Handler(android.os.Handler) AccessibilityAction(android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction) FolderInfo(com.android.launcher3.model.data.FolderInfo) View(android.view.View) ButtonDropTarget(com.android.launcher3.ButtonDropTarget) Log(android.util.Log) PendingAddItemInfo(com.android.launcher3.PendingAddItemInfo) RectF(android.graphics.RectF) ACTION_LONG_CLICK(android.view.accessibility.AccessibilityNodeInfo.ACTION_LONG_CLICK) Launcher(com.android.launcher3.Launcher) Favorites(com.android.launcher3.LauncherSettings.Favorites) DragOptions(com.android.launcher3.dragndrop.DragOptions) SparseArray(android.util.SparseArray) WidgetSizes(com.android.launcher3.widget.util.WidgetSizes) List(java.util.List) NotificationListener(com.android.launcher3.notification.NotificationListener) ShortcutUtil(com.android.launcher3.util.ShortcutUtil) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) Workspace(com.android.launcher3.Workspace) NORMAL(com.android.launcher3.LauncherState.NORMAL) Folder(com.android.launcher3.folder.Folder) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) ArrowPopup(com.android.launcher3.popup.ArrowPopup) KeyEvent(android.view.KeyEvent) AppInfo(com.android.launcher3.model.data.AppInfo) ItemInfo(com.android.launcher3.model.data.ItemInfo) ArrayList(java.util.ArrayList) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow) ItemLongClickListener(com.android.launcher3.touch.ItemLongClickListener) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AnimatorListeners.forSuccessCallback(com.android.launcher3.anim.AnimatorListeners.forSuccessCallback) DragObject(com.android.launcher3.DropTarget.DragObject) DragListener(com.android.launcher3.dragndrop.DragController.DragListener) IntArray(com.android.launcher3.util.IntArray) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) Point(android.graphics.Point) TextUtils(android.text.TextUtils) CellLayout(com.android.launcher3.CellLayout) OptionItem(com.android.launcher3.views.OptionsPopupView.OptionItem) R(com.android.launcher3.R) Thunk(com.android.launcher3.util.Thunk) Collections(java.util.Collections) DragView(com.android.launcher3.dragndrop.DragView) OptionItem(com.android.launcher3.views.OptionsPopupView.OptionItem) CellLayout(com.android.launcher3.CellLayout) ArrayList(java.util.ArrayList) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) DragView(com.android.launcher3.dragndrop.DragView) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView)

Example 20 with CellLayout

use of com.android.launcher3.CellLayout in project android_packages_apps_Launcher3 by crdroidandroid.

the class LauncherAccessibilityDelegate method performResizeAction.

private boolean performResizeAction(int action, View host, LauncherAppWidgetInfo info) {
    CellLayout.LayoutParams lp = (CellLayout.LayoutParams) host.getLayoutParams();
    CellLayout layout = (CellLayout) host.getParent().getParent();
    layout.markCellsAsUnoccupiedForView(host);
    if (action == R.string.action_increase_width) {
        if (((host.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) && layout.isRegionVacant(info.cellX - 1, info.cellY, 1, info.spanY)) || !layout.isRegionVacant(info.cellX + info.spanX, info.cellY, 1, info.spanY)) {
            lp.cellX--;
            info.cellX--;
        }
        lp.cellHSpan++;
        info.spanX++;
    } else if (action == R.string.action_decrease_width) {
        lp.cellHSpan--;
        info.spanX--;
    } else if (action == R.string.action_increase_height) {
        if (!layout.isRegionVacant(info.cellX, info.cellY + info.spanY, info.spanX, 1)) {
            lp.cellY--;
            info.cellY--;
        }
        lp.cellVSpan++;
        info.spanY++;
    } else if (action == R.string.action_decrease_height) {
        lp.cellVSpan--;
        info.spanY--;
    }
    layout.markCellsAsOccupiedForView(host);
    WidgetSizes.updateWidgetSizeRanges(((LauncherAppWidgetHostView) host), mLauncher, info.spanX, info.spanY);
    host.requestLayout();
    mLauncher.getModelWriter().updateItemInDatabase(info);
    announceConfirmation(mLauncher.getString(R.string.widget_resized, info.spanX, info.spanY));
    return true;
}
Also used : CellLayout(com.android.launcher3.CellLayout) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView)

Aggregations

CellLayout (com.android.launcher3.CellLayout)178 View (android.view.View)169 SuppressLint (android.annotation.SuppressLint)126 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)124 AppWidgetHostView (android.appwidget.AppWidgetHostView)105 Point (android.graphics.Point)95 DragView (com.android.launcher3.dragndrop.DragView)91 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)87 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)86 ItemInfo (com.android.launcher3.model.data.ItemInfo)73 BubbleTextView (com.android.launcher3.BubbleTextView)62 Rect (android.graphics.Rect)60 FolderIcon (com.android.launcher3.folder.FolderIcon)52 DragLayer (com.android.launcher3.dragndrop.DragLayer)50 ArrayList (java.util.ArrayList)48 FolderInfo (com.android.launcher3.model.data.FolderInfo)45 Workspace (com.android.launcher3.Workspace)43 DraggableView (com.android.launcher3.dragndrop.DraggableView)43 Animator (android.animation.Animator)42 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)40