Merge branch 'android14-release' into 14-dev

This commit is contained in:
MrSluffy
2023-12-13 17:08:28 +08:00
parent 5931c9afec
commit 32700b0100
994 changed files with 36405 additions and 15827 deletions
+32 -25
View File
@@ -18,11 +18,10 @@ package com.android.launcher3;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static com.android.launcher3.LauncherState.NORMAL;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.InputType;
@@ -35,6 +34,8 @@ import android.view.accessibility.AccessibilityEvent;
import android.widget.PopupWindow;
import android.widget.TextView;
import androidx.annotation.VisibleForTesting;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragLayer;
@@ -42,10 +43,10 @@ import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.dragndrop.DragView;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.util.Themes;
import app.lawnchair.theme.color.ColorTokens;
import app.lawnchair.theme.drawable.DrawableToken;
import app.lawnchair.theme.drawable.DrawableTokens;
import com.android.launcher3.views.ActivityContext;
/**
* Implements a DropTarget.
@@ -63,10 +64,8 @@ public abstract class ButtonDropTarget extends TextView
public static final int TOOLTIP_LEFT = 1;
public static final int TOOLTIP_RIGHT = 2;
private final Rect mTempRect = new Rect();
protected final Launcher mLauncher;
protected final ActivityContext mActivityContext;
protected final DropTargetHandler mDropTargetHandler;
protected DropTargetBar mDropTargetBar;
/** Whether this drop target is active for the current drag */
@@ -92,13 +91,18 @@ public abstract class ButtonDropTarget extends TextView
private PopupWindow mToolTip;
private int mToolTipLocation;
public ButtonDropTarget(Context context) {
this(context, null, 0);
}
public ButtonDropTarget(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public ButtonDropTarget(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mLauncher = Launcher.getLauncher(context);
mActivityContext = ActivityContext.lookupContext(context);
mDropTargetHandler = mActivityContext.getDropTargetHandler();
Resources resources = getResources();
mDragDistanceThreshold = resources.getDimensionPixelSize(R.dimen.drag_distanceThreshold);
@@ -131,6 +135,12 @@ public abstract class ButtonDropTarget extends TextView
setContentDescription(mText);
}
protected void updateText(CharSequence text) {
setText(text);
mText = getText();
setContentDescription(mText);
}
protected void setDrawable(int resId) {
// We do not set the drawable in the xml as that inflates two drawables
// corresponding to
@@ -231,7 +241,7 @@ public abstract class ButtonDropTarget extends TextView
@Override
public boolean isDropEnabled() {
return mActive && (mAccessibleDrag ||
mLauncher.getDragController().getDistanceDragged() >= mDragDistanceThreshold);
mActivityContext.getDragController().getDistanceDragged() >= mDragDistanceThreshold);
}
@Override
@@ -250,7 +260,8 @@ public abstract class ButtonDropTarget extends TextView
// FlingAnimation handles the animation and then calls completeDrop().
return;
}
final DragLayer dragLayer = mLauncher.getDragLayer();
final DragLayer dragLayer = mDropTargetHandler.getDragLayer();
final DragView dragView = d.dragView;
final Rect to = getIconRect(d);
final float scale = (float) to.width() / dragView.getMeasuredWidth();
@@ -261,7 +272,7 @@ public abstract class ButtonDropTarget extends TextView
Runnable onAnimationEndRunnable = () -> {
completeDrop(d);
mDropTargetBar.onDragEnd();
mLauncher.getStateManager().goToState(NORMAL);
mDropTargetHandler.onDropAnimationComplete();
};
dragLayer.animateView(d.dragView, to, scale, 0.1f, 0.1f,
@@ -283,10 +294,10 @@ public abstract class ButtonDropTarget extends TextView
@Override
public void getHitRectRelativeToDragLayer(android.graphics.Rect outRect) {
super.getHitRect(outRect);
outRect.bottom += mLauncher.getDeviceProfile().dropTargetDragPaddingPx;
outRect.bottom += mActivityContext.getDeviceProfile().dropTargetDragPaddingPx;
sTempCords[0] = sTempCords[1] = 0;
mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, sTempCords);
mActivityContext.getDragLayer().getDescendantCoordRelativeToSelf(this, sTempCords);
outRect.offsetTo(sTempCords[0], sTempCords[1]);
}
@@ -295,7 +306,7 @@ public abstract class ButtonDropTarget extends TextView
int viewHeight = dragObject.dragView.getMeasuredHeight();
int drawableWidth = mDrawable.getIntrinsicWidth();
int drawableHeight = mDrawable.getIntrinsicHeight();
DragLayer dragLayer = mLauncher.getDragLayer();
DragLayer dragLayer = mDropTargetHandler.getDragLayer();
// Find the rect to animate to (the view is center aligned)
Rect to = new Rect();
@@ -336,7 +347,7 @@ public abstract class ButtonDropTarget extends TextView
@Override
public void onClick(View v) {
mLauncher.getAccessibilityDelegate().handleAccessibleDrop(this, null, null);
mDropTargetHandler.onClick(this);
}
public void setTextVisible(boolean isVisible) {
@@ -431,17 +442,13 @@ public abstract class ButtonDropTarget extends TextView
* Returns if the text will be clipped vertically within the provided
* availableHeight.
*/
private boolean isTextClippedVertically(int availableHeight) {
availableHeight -= getPaddingTop() + getPaddingBottom();
if (availableHeight <= 0) {
return true;
}
@VisibleForTesting
protected boolean isTextClippedVertically(int availableHeight) {
Paint.FontMetricsInt fontMetricsInt = getPaint().getFontMetricsInt();
int lineCount = (getLineCount() <= 0) ? 1 : getLineCount();
int textHeight = lineCount * (fontMetricsInt.bottom - fontMetricsInt.top);
getPaint().getTextBounds(mText.toString(), 0, mText.length(), mTempRect);
// Add bounds bottom to height, as text bounds height measures from the text
// baseline and
// above, which characters can descend below
return mTempRect.bottom + mTempRect.height() >= availableHeight;
return textHeight + getPaddingTop() + getPaddingBottom() >= availableHeight;
}
/**