use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_Launcher3 by crdroidandroid.
the class ArrowPopup method onLayout.
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
// enforce contained is within screen
BaseDragLayer dragLayer = getPopupContainer();
Rect insets = dragLayer.getInsets();
if (getTranslationX() + l < insets.left || getTranslationX() + r > dragLayer.getWidth() - insets.right) {
// If we are still off screen, center horizontally too.
mGravity |= Gravity.CENTER_HORIZONTAL;
}
if (Gravity.isHorizontal(mGravity)) {
setX(dragLayer.getWidth() / 2 - getMeasuredWidth() / 2);
mArrow.setVisibility(INVISIBLE);
}
if (Gravity.isVertical(mGravity)) {
setY(dragLayer.getHeight() / 2 - getMeasuredHeight() / 2);
}
}
use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_Launcher3 by crdroidandroid.
the class StatefulActivity method onStop.
@Override
protected void onStop() {
BaseDragLayer dragLayer = getDragLayer();
final boolean wasActive = isUserActive();
final STATE_TYPE origState = getStateManager().getState();
final int origDragLayerChildCount = dragLayer.getChildCount();
super.onStop();
if (!isChangingConfigurations()) {
getStateManager().moveToRestState();
}
// Workaround for b/78520668, explicitly trim memory once UI is hidden
onTrimMemory(TRIM_MEMORY_UI_HIDDEN);
if (wasActive) {
// The expected condition is that this activity is stopped because the device goes to
// sleep and the UI may have noticeable changes.
dragLayer.post(() -> {
if ((!getStateManager().isInStableState(origState) || // The drag layer may be animating (e.g. dismissing QSB).
dragLayer.getAlpha() < 1 || // Maybe an ArrowPopup is closed.
dragLayer.getChildCount() != origDragLayerChildCount)) {
onUiChangedWhileSleeping();
}
});
}
}
use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_Launcher3 by crdroidandroid.
the class AbsSwipeUpHandler method onLauncherStart.
private void onLauncherStart() {
final T activity = mActivityInterface.getCreatedActivity();
if (mActivity != activity) {
return;
}
if (mStateCallback.hasStates(STATE_HANDLER_INVALIDATED)) {
return;
}
// RecentsView never updates the display rotation until swipe-up, force update
// RecentsOrientedState before passing to TaskViewSimulator.
mRecentsView.updateRecentsRotation();
mTaskViewSimulator.setOrientationState(mRecentsView.getPagedViewOrientedState());
// as that will set the state as BACKGROUND_APP, overriding the animation to NORMAL.
if (mGestureState.getEndTarget() != HOME) {
Runnable initAnimFactory = () -> {
mAnimationFactory = mActivityInterface.prepareRecentsUI(mDeviceState, mWasLauncherAlreadyVisible, this::onAnimatorPlaybackControllerCreated);
maybeUpdateRecentsAttachedState(false);
};
if (mWasLauncherAlreadyVisible) {
// Launcher is visible, but might be about to stop. Thus, if we prepare recents
// now, it might get overridden by moveToRestState() in onStop(). To avoid this,
// wait until the next gesture (and possibly launcher) starts.
mStateCallback.runOnceAtState(STATE_GESTURE_STARTED, initAnimFactory);
} else {
initAnimFactory.run();
}
}
AbstractFloatingView.closeAllOpenViewsExcept(activity, mWasLauncherAlreadyVisible, AbstractFloatingView.TYPE_LISTENER);
if (mWasLauncherAlreadyVisible) {
mStateCallback.setState(STATE_LAUNCHER_DRAWN);
} else {
Object traceToken = TraceHelper.INSTANCE.beginSection("WTS-init");
View dragLayer = activity.getDragLayer();
dragLayer.getViewTreeObserver().addOnDrawListener(new OnDrawListener() {
boolean mHandled = false;
@Override
public void onDraw() {
if (mHandled) {
return;
}
mHandled = true;
TraceHelper.INSTANCE.endSection(traceToken);
dragLayer.post(() -> dragLayer.getViewTreeObserver().removeOnDrawListener(this));
if (activity != mActivity) {
return;
}
mStateCallback.setState(STATE_LAUNCHER_DRAWN);
}
});
}
activity.getRootView().setOnApplyWindowInsetsListener(this);
mStateCallback.setState(STATE_LAUNCHER_STARTED);
}
use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_Launcher3 by crdroidandroid.
the class LauncherAppWidgetHostView method onLongClick.
@Override
public boolean onLongClick(View view) {
if (!Utilities.isWorkspaceEditAllowed(mLauncher.getApplicationContext()))
return true;
if (mIsScrollable) {
DragLayer dragLayer = mLauncher.getDragLayer();
dragLayer.requestDisallowInterceptTouchEvent(false);
}
view.performLongClick();
return true;
}
use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_Launcher3 by crdroidandroid.
the class ButtonDropTarget method onDrop.
/**
* On drop animate the dropView to the icon.
*/
@Override
public void onDrop(final DragObject d, final DragOptions options) {
if (options.isFlingToDelete) {
// FlingAnimation handles the animation and then calls completeDrop().
return;
}
final DragLayer dragLayer = mLauncher.getDragLayer();
final DragView dragView = d.dragView;
final Rect from = new Rect();
dragLayer.getViewRectRelativeToSelf(d.dragView, from);
final Rect to = getIconRect(d);
final float scale = (float) to.width() / from.width();
dragView.disableColorExtraction();
dragView.detachContentView(/* reattachToPreviousParent= */
true);
mDropTargetBar.deferOnDragEnd();
Runnable onAnimationEndRunnable = () -> {
completeDrop(d);
mDropTargetBar.onDragEnd();
mLauncher.getStateManager().goToState(NORMAL);
// Only re-enable updates once the workspace is back to normal, which will be after the
// current frame.
post(dragView::resumeColorExtraction);
};
dragLayer.animateView(d.dragView, from, to, scale, 1f, 1f, 0.1f, 0.1f, DRAG_VIEW_DROP_DURATION, Interpolators.DEACCEL_2, Interpolators.LINEAR, onAnimationEndRunnable, DragLayer.ANIMATION_END_DISAPPEAR, null);
}
Aggregations