use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_Launcher3 by ProtonAOSP.
the class FloatingWidgetView method getFloatingWidgetView.
/**
* Configures and returns a an instance of {@link FloatingWidgetView} matching the appearance of
* {@param originalView}.
*
* @param widgetBackgroundPosition a {@link RectF} that will be updated with the widget's
* background bounds
* @param windowSize the size of the window when launched
* @param windowCornerRadius the corner radius of the window
*/
public static FloatingWidgetView getFloatingWidgetView(Launcher launcher, LauncherAppWidgetHostView originalView, RectF widgetBackgroundPosition, Size windowSize, float windowCornerRadius, boolean appTargetsAreTranslucent, int fallbackBackgroundColor) {
final DragLayer dragLayer = launcher.getDragLayer();
ViewGroup parent = (ViewGroup) dragLayer.getParent();
FloatingWidgetView floatingView = launcher.getViewCache().getView(R.layout.floating_widget_view, launcher, parent);
floatingView.recycle();
floatingView.init(dragLayer, originalView, widgetBackgroundPosition, windowSize, windowCornerRadius, appTargetsAreTranslucent, fallbackBackgroundColor);
parent.addView(floatingView);
return floatingView;
}
use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_404Launcher by P-404.
the class ButtonDropTarget method getIconRect.
public Rect getIconRect(DragObject dragObject) {
int viewWidth = dragObject.dragView.getMeasuredWidth();
int viewHeight = dragObject.dragView.getMeasuredHeight();
int drawableWidth = mDrawable.getIntrinsicWidth();
int drawableHeight = mDrawable.getIntrinsicHeight();
DragLayer dragLayer = mLauncher.getDragLayer();
// Find the rect to animate to (the view is center aligned)
Rect to = new Rect();
dragLayer.getViewRectRelativeToSelf(this, to);
final int width = drawableWidth;
final int height = drawableHeight;
final int left;
final int right;
if (Utilities.isRtl(getResources())) {
right = to.right - getPaddingRight();
left = right - width;
} else {
left = to.left + getPaddingLeft();
right = left + width;
}
final int top = to.top + (getMeasuredHeight() - height) / 2;
final int bottom = top + height;
to.set(left, top, right, bottom);
// Center the destination rect about the trash icon
final int xOffset = -(viewWidth - width) / 2;
final int yOffset = -(viewHeight - height) / 2;
to.offset(xOffset, yOffset);
return to;
}
use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_404Launcher by P-404.
the class AppWidgetResizeFrame method showForWidget.
public static void showForWidget(LauncherAppWidgetHostView widget, CellLayout cellLayout) {
Launcher launcher = Launcher.getLauncher(cellLayout.getContext());
AbstractFloatingView.closeAllOpenViews(launcher);
DragLayer dl = launcher.getDragLayer();
AppWidgetResizeFrame frame = (AppWidgetResizeFrame) launcher.getLayoutInflater().inflate(R.layout.app_widget_resize_frame, dl, false);
if (widget.hasEnforcedCornerRadius()) {
float enforcedCornerRadius = widget.getEnforcedCornerRadius();
ImageView imageView = frame.findViewById(R.id.widget_resize_frame);
Drawable d = imageView.getDrawable();
if (d instanceof GradientDrawable) {
GradientDrawable gd = (GradientDrawable) d.mutate();
gd.setCornerRadius(enforcedCornerRadius);
}
}
frame.setupForWidget(widget, cellLayout, dl);
((DragLayer.LayoutParams) frame.getLayoutParams()).customPosition = true;
dl.addView(frame);
frame.mIsOpen = true;
frame.post(() -> frame.snapToWidget(false));
}
use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_404Launcher by P-404.
the class AppWidgetResizeFrame method setupForWidget.
private void setupForWidget(LauncherAppWidgetHostView widgetView, CellLayout cellLayout, DragLayer dragLayer) {
mCellLayout = cellLayout;
if (mWidgetView != null) {
mWidgetView.removeOnAttachStateChangeListener(mWidgetViewAttachStateChangeListener);
}
mWidgetView = widgetView;
mWidgetView.addOnAttachStateChangeListener(mWidgetViewAttachStateChangeListener);
LauncherAppWidgetProviderInfo info = (LauncherAppWidgetProviderInfo) widgetView.getAppWidgetInfo();
mDragLayer = dragLayer;
mMinHSpan = info.minSpanX;
mMinVSpan = info.minSpanY;
mMaxHSpan = info.maxSpanX;
mMaxVSpan = info.maxSpanY;
mWidgetPadding = getDefaultPaddingForWidget(getContext(), widgetView.getAppWidgetInfo().provider, null);
// Only show resize handles for the directions in which resizing is possible.
InvariantDeviceProfile idp = LauncherAppState.getIDP(cellLayout.getContext());
mVerticalResizeActive = (info.resizeMode & AppWidgetProviderInfo.RESIZE_VERTICAL) != 0 && mMinVSpan < idp.numRows && mMaxVSpan > 1 && mMinVSpan < mMaxVSpan;
if (!mVerticalResizeActive) {
mDragHandles[INDEX_TOP].setVisibility(GONE);
mDragHandles[INDEX_BOTTOM].setVisibility(GONE);
}
mHorizontalResizeActive = (info.resizeMode & AppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0 && mMinHSpan < idp.numColumns && mMaxHSpan > 1 && mMinHSpan < mMaxHSpan;
if (!mHorizontalResizeActive) {
mDragHandles[INDEX_LEFT].setVisibility(GONE);
mDragHandles[INDEX_RIGHT].setVisibility(GONE);
}
mReconfigureButton = (ImageButton) findViewById(R.id.widget_reconfigure_button);
if (info.isReconfigurable()) {
mReconfigureButton.setVisibility(VISIBLE);
mReconfigureButton.setOnClickListener(view -> {
mLauncher.setWaitingForResult(PendingRequestArgs.forWidgetInfo(mWidgetView.getAppWidgetId(), /* widgetHandler= */
null, (ItemInfo) mWidgetView.getTag()));
mLauncher.getAppWidgetHost().startConfigActivity(mLauncher, mWidgetView.getAppWidgetId(), Launcher.REQUEST_RECONFIGURE_APPWIDGET);
});
if (!hasSeenReconfigurableWidgetEducationTip()) {
post(() -> {
if (showReconfigurableWidgetEducationTip() != null) {
mLauncher.getSharedPrefs().edit().putBoolean(KEY_RECONFIGURABLE_WIDGET_EDUCATION_TIP_SEEN, true).apply();
}
});
}
}
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) mWidgetView.getLayoutParams();
ItemInfo widgetInfo = (ItemInfo) mWidgetView.getTag();
lp.cellX = lp.tmpCellX = widgetInfo.cellX;
lp.cellY = lp.tmpCellY = widgetInfo.cellY;
lp.cellHSpan = widgetInfo.spanX;
lp.cellVSpan = widgetInfo.spanY;
lp.isLockedToGrid = true;
// When we create the resize frame, we first mark all cells as unoccupied. The appropriate
// cells (same if not resized, or different) will be marked as occupied when the resize
// frame is dismissed.
mCellLayout.markCellsAsUnoccupiedForView(mWidgetView);
mLauncher.getStatsLogManager().logger().withInstanceId(logInstanceId).withItemInfo(widgetInfo).log(LAUNCHER_WIDGET_RESIZE_STARTED);
setOnKeyListener(this);
}
use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_404Launcher by P-404.
the class FloatingTaskView method addAnimation.
public void addAnimation(PendingAnimation animation, RectF startingBounds, Rect endBounds, View viewToCover, boolean fadeWithThumbnail) {
final BaseDragLayer dragLayer = mActivity.getDragLayer();
int[] dragLayerBounds = new int[2];
dragLayer.getLocationOnScreen(dragLayerBounds);
SplitOverlayProperties prop = new SplitOverlayProperties(endBounds, startingBounds, viewToCover, dragLayerBounds[0], dragLayerBounds[1]);
ValueAnimator transitionAnimator = ValueAnimator.ofFloat(0, 1);
animation.add(transitionAnimator);
long animDuration = animation.getDuration();
Rect crop = new Rect();
RectF floatingTaskViewBounds = new RectF();
final float initialWindowRadius = supportsRoundedCornersOnWindows(getResources()) ? Math.max(crop.width(), crop.height()) / 2f : 0f;
if (fadeWithThumbnail) {
animation.addFloat(mSplitPlaceholderView, SplitPlaceholderView.ALPHA_FLOAT, 0, 1, ACCEL);
animation.addFloat(mImageView, LauncherAnimUtils.VIEW_ALPHA, 1, 0, DEACCEL_3);
}
MultiValueUpdateListener listener = new MultiValueUpdateListener() {
final FloatProp mWindowRadius = new FloatProp(initialWindowRadius, initialWindowRadius, 0, animDuration, LINEAR);
final FloatProp mDx = new FloatProp(0, prop.dX, 0, animDuration, LINEAR);
final FloatProp mDy = new FloatProp(0, prop.dY, 0, animDuration, LINEAR);
final FloatProp mTaskViewScaleX = new FloatProp(prop.initialTaskViewScaleX, prop.finalTaskViewScaleX, 0, animDuration, LINEAR);
final FloatProp mTaskViewScaleY = new FloatProp(prop.initialTaskViewScaleY, prop.finalTaskViewScaleY, 0, animDuration, LINEAR);
@Override
public void onUpdate(float percent, boolean initOnly) {
// Calculate the icon position.
floatingTaskViewBounds.set(startingBounds);
floatingTaskViewBounds.offset(mDx.value, mDy.value);
Utilities.scaleRectFAboutCenter(floatingTaskViewBounds, mTaskViewScaleX.value, mTaskViewScaleY.value);
update(floatingTaskViewBounds, percent, mWindowRadius.value * 1);
}
};
transitionAnimator.addUpdateListener(listener);
}
Aggregations