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;
}
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);
}
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);
}
}
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;
}
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;
}
Aggregations