Merge branch 'aosp-13' into 13-wip

This commit is contained in:
MrSluffy
2023-09-21 21:54:56 +08:00
1558 changed files with 103738 additions and 36700 deletions
@@ -23,6 +23,7 @@ import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
@@ -30,6 +31,8 @@ import androidx.annotation.Nullable;
import androidx.annotation.Px;
import com.android.launcher3.accessibility.DragViewStateAnnouncer;
import com.android.launcher3.celllayout.CellLayoutLayoutParams;
import com.android.launcher3.celllayout.CellPosMapper.CellPos;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
import com.android.launcher3.logging.InstanceId;
@@ -70,22 +73,6 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
private final View[] mDragHandles = new View[HANDLE_COUNT];
private final List<Rect> mSystemGestureExclusionRects = new ArrayList<>(HANDLE_COUNT);
private final OnAttachStateChangeListener mWidgetViewAttachStateChangeListener =
new OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View view) {
// Do nothing
}
@Override
public void onViewDetachedFromWindow(View view) {
// When the app widget view is detached, we should close the resize frame.
// An example is when the dragging starts, the widget view is detached from
// CellLayout and then reattached to DragLayout.
close(false);
}
};
private LauncherAppWidgetHostView mWidgetView;
private CellLayout mCellLayout;
@@ -229,11 +216,7 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
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;
@@ -258,11 +241,11 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
/* widgetHandler= */ null,
(ItemInfo) mWidgetView.getTag()));
mLauncher
.getAppWidgetHost()
.startConfigActivity(
mLauncher,
mWidgetView.getAppWidgetId(),
Launcher.REQUEST_RECONFIGURE_APPWIDGET);
.getAppWidgetHolder()
.startConfigActivity(
mLauncher,
mWidgetView.getAppWidgetId(),
Launcher.REQUEST_RECONFIGURE_APPWIDGET);
});
if (!hasSeenReconfigurableWidgetEducationTip()) {
post(() -> {
@@ -275,10 +258,13 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
}
}
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) mWidgetView.getLayoutParams();
CellLayoutLayoutParams lp = (CellLayoutLayoutParams) mWidgetView.getLayoutParams();
ItemInfo widgetInfo = (ItemInfo) mWidgetView.getTag();
lp.cellX = lp.tmpCellX = widgetInfo.cellX;
lp.cellY = lp.tmpCellY = widgetInfo.cellY;
CellPos presenterPos = mLauncher.getCellPosMapper().mapModelToPresenter(widgetInfo);
lp.setCellX(presenterPos.cellX);
lp.setTmpCellX(presenterPos.cellX);
lp.setCellY(presenterPos.cellY);
lp.setTmpCellY(presenterPos.cellY);
lp.cellHSpan = widgetInfo.spanX;
lp.cellVSpan = widgetInfo.spanY;
lp.isLockedToGrid = true;
@@ -372,7 +358,7 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
// Handle invalid resize across CellLayouts in the two panel UI.
if (mCellLayout.getParent() instanceof Workspace) {
Workspace workspace = (Workspace) mCellLayout.getParent();
Workspace<?> workspace = (Workspace<?>) mCellLayout.getParent();
CellLayout pairedCellLayout = workspace.getScreenPair(mCellLayout);
if (pairedCellLayout != null) {
Rect focusedCellLayoutBound = sTmpRect;
@@ -412,6 +398,10 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
* Based on the current deltas, we determine if and how to resize the widget.
*/
private void resizeWidgetIfNeeded(boolean onDismiss) {
ViewGroup.LayoutParams wlp = mWidgetView.getLayoutParams();
if (!(wlp instanceof CellLayoutLayoutParams)) {
return;
}
DeviceProfile dp = mLauncher.getDeviceProfile();
float xThreshold = mCellLayout.getCellWidth() + dp.cellLayoutBorderSpacePx.x;
float yThreshold = mCellLayout.getCellHeight() + dp.cellLayoutBorderSpacePx.y;
@@ -424,12 +414,12 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
mDirectionVector[0] = 0;
mDirectionVector[1] = 0;
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) mWidgetView.getLayoutParams();
CellLayoutLayoutParams lp = (CellLayoutLayoutParams) wlp;
int spanX = lp.cellHSpan;
int spanY = lp.cellVSpan;
int cellX = lp.useTmpCoords ? lp.tmpCellX : lp.cellX;
int cellY = lp.useTmpCoords ? lp.tmpCellY : lp.cellY;
int cellX = lp.useTmpCoords ? lp.getTmpCellX() : lp.getCellX();
int cellY = lp.useTmpCoords ? lp.getTmpCellY() : lp.getCellY();
// For each border, we bound the resizing based on the minimum width, and the maximum
// expandability.
@@ -470,8 +460,8 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
mLauncher.getString(R.string.widget_resized, spanX, spanY));
}
lp.tmpCellX = cellX;
lp.tmpCellY = cellY;
lp.setTmpCellX(cellX);
lp.setTmpCellY(cellY);
lp.cellHSpan = spanX;
lp.cellVSpan = spanY;
mRunningVInc += vSpanDelta;
@@ -559,7 +549,7 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
final DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
final CellLayout pairedCellLayout;
if (mCellLayout.getParent() instanceof Workspace) {
Workspace workspace = (Workspace) mCellLayout.getParent();
Workspace<?> workspace = (Workspace<?>) mCellLayout.getParent();
pairedCellLayout = workspace.getScreenPair(mCellLayout);
} else {
pairedCellLayout = null;
@@ -676,9 +666,6 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
@Override
protected void handleClose(boolean animate) {
mDragLayer.removeView(this);
if (mWidgetView != null) {
mWidgetView.removeOnAttachStateChangeListener(mWidgetViewAttachStateChangeListener);
}
}
private void updateInvalidResizeEffect(CellLayout cellLayout, CellLayout pairedCellLayout,
@@ -829,6 +816,6 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
private boolean hasSeenReconfigurableWidgetEducationTip() {
return mLauncher.getSharedPrefs()
.getBoolean(KEY_RECONFIGURABLE_WIDGET_EDUCATION_TIP_SEEN, false)
|| Utilities.IS_RUNNING_IN_TEST_HARNESS;
|| Utilities.isRunningInTestHarness();
}
}